From 00f95e483f67e1f0c8ca619f03399bc075d6c8c6 Mon Sep 17 00:00:00 2001 From: skdejong Date: Tue, 5 Dec 2023 12:38:53 +0000 Subject: [PATCH 1/4] AP-4630:Add partner_no_cash_income --- .../providers/partners/cash_incomes_controller.rb | 2 +- app/views/providers/partners/cash_incomes/show.html.erb | 3 ++- app/views/shared/means/_cash_income.html.erb | 2 +- db/migrate/20231205092447_add_no_cash_income_to_partners.rb | 5 +++++ db/schema.rb | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20231205092447_add_no_cash_income_to_partners.rb diff --git a/app/controllers/providers/partners/cash_incomes_controller.rb b/app/controllers/providers/partners/cash_incomes_controller.rb index be68873187..24f7993ce1 100644 --- a/app/controllers/providers/partners/cash_incomes_controller.rb +++ b/app/controllers/providers/partners/cash_incomes_controller.rb @@ -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 diff --git a/app/views/providers/partners/cash_incomes/show.html.erb b/app/views/providers/partners/cash_incomes/show.html.erb index 2c77ab7b61..d22cc1c56d 100644 --- a/app/views/providers/partners/cash_incomes/show.html.erb +++ b/app/views/providers/partners/cash_incomes/show.html.erb @@ -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 %> diff --git a/app/views/shared/means/_cash_income.html.erb b/app/views/shared/means/_cash_income.html.erb index dfae752e52..909d5be2a0 100644 --- a/app/views/shared/means/_cash_income.html.erb +++ b/app/views/shared/means/_cash_income.html.erb @@ -26,7 +26,7 @@ <%= 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.present? ? type.no_cash_income? : @legal_aid_application.no_cash_income? %> <% end %> <%= next_action_buttons( diff --git a/db/migrate/20231205092447_add_no_cash_income_to_partners.rb b/db/migrate/20231205092447_add_no_cash_income_to_partners.rb new file mode 100644 index 0000000000..1f3779c887 --- /dev/null +++ b/db/migrate/20231205092447_add_no_cash_income_to_partners.rb @@ -0,0 +1,5 @@ +class AddNoCashIncomeToPartners < ActiveRecord::Migration[7.1] + def change + add_column :partners, :no_cash_income, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 4122404c36..12114aaabe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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_092447) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -764,6 +764,7 @@ t.decimal "student_finance_amount" t.boolean "extra_employment_information" t.string "extra_employment_information_details" + t.boolean "no_cash_income" t.index ["legal_aid_application_id"], name: "index_partners_on_legal_aid_application_id" end From 7b9e1833c49a877b58a8aac4aa8a87417a62e22e Mon Sep 17 00:00:00 2001 From: skdejong Date: Tue, 5 Dec 2023 18:33:35 +0000 Subject: [PATCH 2/4] AP-4630:Add partner_no_cash_outgoings --- .../providers/partners/cash_outgoings_controller.rb | 2 +- app/views/providers/means/cash_incomes/show.html.erb | 3 ++- app/views/providers/means/cash_outgoings/show.html.erb | 3 ++- app/views/providers/partners/cash_outgoings/show.html.erb | 3 ++- app/views/shared/means/_cash_outgoing.html.erb | 2 +- .../20231205180352_add_no_cash_outgoings_to_partners.rb | 5 +++++ db/schema.rb | 3 ++- 7 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20231205180352_add_no_cash_outgoings_to_partners.rb diff --git a/app/controllers/providers/partners/cash_outgoings_controller.rb b/app/controllers/providers/partners/cash_outgoings_controller.rb index 289af43d3d..05ec7d4bcb 100644 --- a/app/controllers/providers/partners/cash_outgoings_controller.rb +++ b/app/controllers/providers/partners/cash_outgoings_controller.rb @@ -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 diff --git a/app/views/providers/means/cash_incomes/show.html.erb b/app/views/providers/means/cash_incomes/show.html.erb index 571ca513f3..c3122d05e0 100644 --- a/app/views/providers/means/cash_incomes/show.html.erb +++ b/app/views/providers/means/cash_incomes/show.html.erb @@ -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 %> diff --git a/app/views/providers/means/cash_outgoings/show.html.erb b/app/views/providers/means/cash_outgoings/show.html.erb index 8a5408e48c..21508d3645 100644 --- a/app/views/providers/means/cash_outgoings/show.html.erb +++ b/app/views/providers/means/cash_outgoings/show.html.erb @@ -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 %> diff --git a/app/views/providers/partners/cash_outgoings/show.html.erb b/app/views/providers/partners/cash_outgoings/show.html.erb index ea7ca26d67..4c820b94ae 100644 --- a/app/views/providers/partners/cash_outgoings/show.html.erb +++ b/app/views/providers/partners/cash_outgoings/show.html.erb @@ -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 %> diff --git a/app/views/shared/means/_cash_outgoing.html.erb b/app/views/shared/means/_cash_outgoing.html.erb index 049ee06679..8c5b8cb786 100644 --- a/app/views/shared/means/_cash_outgoing.html.erb +++ b/app/views/shared/means/_cash_outgoing.html.erb @@ -27,7 +27,7 @@ <%= 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.present? ? type.no_cash_outgoings? : @legal_aid_application.no_cash_outgoings? %> <% end %> <%= next_action_buttons( diff --git a/db/migrate/20231205180352_add_no_cash_outgoings_to_partners.rb b/db/migrate/20231205180352_add_no_cash_outgoings_to_partners.rb new file mode 100644 index 0000000000..4024912db6 --- /dev/null +++ b/db/migrate/20231205180352_add_no_cash_outgoings_to_partners.rb @@ -0,0 +1,5 @@ +class AddNoCashOutgoingsToPartners < ActiveRecord::Migration[7.1] + def change + add_column :partners, :no_cash_outgoings, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 12114aaabe..aa89fff6b4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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_12_05_092447) 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" @@ -765,6 +765,7 @@ 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 From d7a792eb7b0c706236da4874e3c22cdda25cb08e Mon Sep 17 00:00:00 2001 From: skdejong Date: Wed, 6 Dec 2023 12:24:41 +0000 Subject: [PATCH 3/4] AP-4630: Update unit tests for cash incomes and outgoings --- .../providers/partners/cash_incomes_controller_spec.rb | 4 ++-- .../providers/partners/cash_outgoings_controller_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/requests/providers/partners/cash_incomes_controller_spec.rb b/spec/requests/providers/partners/cash_incomes_controller_spec.rb index 79dfa49052..a537441c25 100644 --- a/spec/requests/providers/partners/cash_incomes_controller_spec.rb +++ b/spec/requests/providers/partners/cash_incomes_controller_spec.rb @@ -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 @@ -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 diff --git a/spec/requests/providers/partners/cash_outgoings_controller_spec.rb b/spec/requests/providers/partners/cash_outgoings_controller_spec.rb index 61b4bf3657..dfe6360c10 100644 --- a/spec/requests/providers/partners/cash_outgoings_controller_spec.rb +++ b/spec/requests/providers/partners/cash_outgoings_controller_spec.rb @@ -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 @@ -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 From f63b4131b6a2daba447b97bd635f507e20c6f289 Mon Sep 17 00:00:00 2001 From: skdejong Date: Wed, 6 Dec 2023 13:01:34 +0000 Subject: [PATCH 4/4] AP-4630: Remove unneeded code --- app/views/shared/means/_cash_income.html.erb | 2 +- app/views/shared/means/_cash_outgoing.html.erb | 2 +- db/schema.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/shared/means/_cash_income.html.erb b/app/views/shared/means/_cash_income.html.erb index 909d5be2a0..b07c674db2 100644 --- a/app/views/shared/means/_cash_income.html.erb +++ b/app/views/shared/means/_cash_income.html.erb @@ -26,7 +26,7 @@ <%= form.govuk_radio_divider %> - <%= form.govuk_check_box :none_selected, true, "", multiple: false, label: { text: none_of_the_above }, checked: type.present? ? type.no_cash_income? : @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( diff --git a/app/views/shared/means/_cash_outgoing.html.erb b/app/views/shared/means/_cash_outgoing.html.erb index 8c5b8cb786..05bd709e9a 100644 --- a/app/views/shared/means/_cash_outgoing.html.erb +++ b/app/views/shared/means/_cash_outgoing.html.erb @@ -27,7 +27,7 @@ <%= form.govuk_radio_divider %> - <%= form.govuk_check_box :none_selected, true, "", multiple: false, label: { text: t("generic.none_of_the_above") }, checked: type.present? ? type.no_cash_outgoings? : @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( diff --git a/db/schema.rb b/db/schema.rb index aa89fff6b4..0c4a773b8e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1076,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"