Skip to content

Commit

Permalink
AP-5368 cash income and outgoings bug (#7458) (#7473)
Browse files Browse the repository at this point in the history
Ensure none_selected value is retained when there is an error

Co-authored-by: RoseSAK <[email protected]>
  • Loading branch information
RoseSAK and RoseSAK authored Nov 26, 2024
1 parent 10f3d6a commit 2d315a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/controllers/providers/means/cash_incomes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/providers/means/cash_outgoings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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: 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(
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: 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(
Expand Down

0 comments on commit 2d315a7

Please sign in to comment.