Skip to content

Commit

Permalink
Merge pull request #6083 from ministryofjustice/AP-4630-partner/cash_…
Browse files Browse the repository at this point in the history
…income

Ap 4630 partner/cash income and outgoings - remembers positive answers provided for client
  • Loading branch information
skdejong authored Dec 12, 2023
2 parents 0d952fd + f63b413 commit 0c12d34
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def form_params

def update_no_cash_income(params)
val = params.permit(:none_selected)[:none_selected] == "true"
legal_aid_application.update!(no_cash_income: val)
legal_aid_application.partner.update!(no_cash_income: val)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def form_params

def update_no_cash_outgoings(params)
val = params.permit(:none_selected)[:none_selected] == "true"
legal_aid_application.update!(no_cash_outgoings: val)
legal_aid_application.partner.update!(no_cash_outgoings: val)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/views/providers/means/cash_incomes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
url: providers_legal_aid_application_means_cash_income_path(@legal_aid_application),
page_title: t(".page_title"),
caption: t("generic.client_means_caption"),
none_of_the_above: t(".none_of_the_above") %>
none_of_the_above: t(".none_of_the_above"),
type: @legal_aid_application %>
3 changes: 2 additions & 1 deletion app/views/providers/means/cash_outgoings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
form: @form,
url: providers_legal_aid_application_means_cash_outgoing_path(@legal_aid_application),
page_title: t(".page_heading"),
caption: t("generic.client_means_caption") %>
caption: t("generic.client_means_caption"),
type: @legal_aid_application %>
3 changes: 2 additions & 1 deletion app/views/providers/partners/cash_incomes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
url: providers_legal_aid_application_partners_cash_income_path(@legal_aid_application),
page_title: t(".page_title"),
caption: t("generic.partner_means_caption"),
none_of_the_above: t(".none_of_the_above") %>
none_of_the_above: t(".none_of_the_above"),
type: @legal_aid_application.partner %>
3 changes: 2 additions & 1 deletion app/views/providers/partners/cash_outgoings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
form: @form,
url: providers_legal_aid_application_partners_cash_outgoing_path(@legal_aid_application),
page_title: t(".page_heading"),
caption: t("generic.partner_means_caption") %>
caption: t("generic.partner_means_caption"),
type: @legal_aid_application.partner %>
2 changes: 1 addition & 1 deletion app/views/shared/means/_cash_income.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>

<%= form.govuk_radio_divider %>
<%= form.govuk_check_box :none_selected, true, "", multiple: false, label: { text: none_of_the_above }, checked: @legal_aid_application.no_cash_income? %>
<%= form.govuk_check_box :none_selected, true, "", multiple: false, label: { text: none_of_the_above }, checked: type.no_cash_income? %>
<% end %>

<%= next_action_buttons(
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/means/_cash_outgoing.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>

<%= form.govuk_radio_divider %>
<%= form.govuk_check_box :none_selected, true, "", multiple: false, label: { text: t("generic.none_of_the_above") }, checked: @legal_aid_application.no_cash_outgoings? %>
<%= form.govuk_check_box :none_selected, true, "", multiple: false, label: { text: t("generic.none_of_the_above") }, checked: type.no_cash_outgoings? %>
<% end %>

<%= next_action_buttons(
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20231205092447_add_no_cash_income_to_partners.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddNoCashIncomeToPartners < ActiveRecord::Migration[7.1]
def change
add_column :partners, :no_cash_income, :boolean
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddNoCashOutgoingsToPartners < ActiveRecord::Migration[7.1]
def change
add_column :partners, :no_cash_outgoings, :boolean
end
end
8 changes: 5 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2023_11_08_110820) do
ActiveRecord::Schema[7.1].define(version: 2023_12_05_180352) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -764,6 +764,8 @@
t.decimal "student_finance_amount"
t.boolean "extra_employment_information"
t.string "extra_employment_information_details"
t.boolean "no_cash_income"
t.boolean "no_cash_outgoings"
t.index ["legal_aid_application_id"], name: "index_partners_on_legal_aid_application_id"
end

Expand Down Expand Up @@ -1074,8 +1076,8 @@
add_foreign_key "legal_aid_applications", "providers"
add_foreign_key "legal_framework_merits_task_lists", "legal_aid_applications", on_delete: :cascade
add_foreign_key "legal_framework_submissions", "legal_aid_applications"
add_foreign_key "linked_applications", "legal_aid_applications", column: "associated_application_id", validate: false
add_foreign_key "linked_applications", "legal_aid_applications", column: "lead_application_id", validate: false
add_foreign_key "linked_applications", "legal_aid_applications", column: "associated_application_id"
add_foreign_key "linked_applications", "legal_aid_applications", column: "lead_application_id"
add_foreign_key "matter_oppositions", "legal_aid_applications", on_delete: :cascade
add_foreign_key "offices", "firms"
add_foreign_key "offices_providers", "offices"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
end

it "updates the model attribute for no cash income to false" do
expect { request }.to change { legal_aid_application.reload.no_cash_income }.from(nil).to(false)
expect { request }.to change { legal_aid_application.partner.reload.no_cash_income }.from(nil).to(false)
end

it "sets the applicant as owner" do
Expand All @@ -94,7 +94,7 @@
end

it "updates the model attribute for no cash income to true" do
expect { request }.to change { legal_aid_application.reload.no_cash_income }.from(nil).to(true)
expect { request }.to change { legal_aid_application.partner.reload.no_cash_income }.from(nil).to(true)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
let(:params) { valid_params }

it "updates the model attribute for no cash outgoings to false" do
expect { request }.to change { legal_aid_application.reload.no_cash_outgoings }.from(nil).to(false)
expect { request }.to change { legal_aid_application.partner.reload.no_cash_outgoings }.from(nil).to(false)
end

context "with no housing payments selected for either applicant or partner" do
Expand Down Expand Up @@ -122,7 +122,7 @@
let(:params) { nothing_selected_params }

it "updates the model attribute for no cash outgoings to true" do
expect { request }.to change { legal_aid_application.reload.no_cash_outgoings }.from(nil).to(true)
expect { request }.to change { legal_aid_application.partner.reload.no_cash_outgoings }.from(nil).to(true)
end
end

Expand Down

0 comments on commit 0c12d34

Please sign in to comment.