From 2d315a79f79b6e3d9cef292c23bc5719eddc02aa Mon Sep 17 00:00:00 2001 From: Rose Date: Tue, 26 Nov 2024 16:10:00 +0000 Subject: [PATCH] AP-5368 cash income and outgoings bug (#7458) (#7473) Ensure none_selected value is retained when there is an error Co-authored-by: RoseSAK --- app/controllers/providers/means/cash_incomes_controller.rb | 5 ++++- app/controllers/providers/means/cash_outgoings_controller.rb | 5 ++++- app/views/shared/means/_cash_income.html.erb | 2 +- app/views/shared/means/_cash_outgoing.html.erb | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/providers/means/cash_incomes_controller.rb b/app/controllers/providers/means/cash_incomes_controller.rb index dca701144a..47728251e4 100644 --- a/app/controllers/providers/means/cash_incomes_controller.rb +++ b/app/controllers/providers/means/cash_incomes_controller.rb @@ -3,13 +3,16 @@ module Means class CashIncomesController < ProviderBaseController before_action :setup_variables, only: %i[show update] - def show; end + def show + @none_selected = legal_aid_application.no_cash_income? + end def update if aggregated_cash_income.update(form_params) update_no_cash_income(form_params) go_forward else + @none_selected = form_params[:none_selected] == "true" render :show end end diff --git a/app/controllers/providers/means/cash_outgoings_controller.rb b/app/controllers/providers/means/cash_outgoings_controller.rb index 209b57e371..9cebf51a8c 100644 --- a/app/controllers/providers/means/cash_outgoings_controller.rb +++ b/app/controllers/providers/means/cash_outgoings_controller.rb @@ -3,13 +3,16 @@ module Means class CashOutgoingsController < ProviderBaseController before_action :setup_cash_outgoings, only: %i[show update] - def show; end + def show + @none_selected = legal_aid_application.no_cash_outgoings? + end def update if aggregated_cash_outgoings.update(form_params) update_no_cash_outgoings(form_params) go_forward else + @none_selected = form_params[:none_selected] == "true" render :show end end diff --git a/app/views/shared/means/_cash_income.html.erb b/app/views/shared/means/_cash_income.html.erb index b07c674db2..38f9a0c897 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.no_cash_income? %> + <%= form.govuk_check_box :none_selected, true, "", multiple: false, label: { text: none_of_the_above }, checked: @none_selected %> <% 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 05bd709e9a..d437dda3ed 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.no_cash_outgoings? %> + <%= form.govuk_check_box :none_selected, true, "", multiple: false, label: { text: t("generic.none_of_the_above") }, checked: @none_selected %> <% end %> <%= next_action_buttons(