<%= t(".heading") %>
diff --git a/app/views/shared/partials/_revealing_checkbox.html.erb b/app/views/shared/partials/_revealing_checkbox.html.erb
index 807c2fb822..31c5662f06 100644
--- a/app/views/shared/partials/_revealing_checkbox.html.erb
+++ b/app/views/shared/partials/_revealing_checkbox.html.erb
@@ -13,7 +13,7 @@
<% end %>
<%= form.govuk_text_field "#{name}#{number}",
label: { text: model.period(number) },
- value: gds_number_to_currency(model.__send__(:"#{name}#{number}"), unit: ""),
+ value: model.__send__(:"#{name}#{number}"),
prefix_text: defined?(input_prefix) ? input_prefix : nil,
form_group: { classes: error_class },
width: "one-third" %>
diff --git a/features/providers/bank_statement_upload/check_your_means_answers.feature b/features/providers/bank_statement_upload/check_your_means_answers.feature
index 926b25666a..99cf9618a5 100644
--- a/features/providers/bank_statement_upload/check_your_means_answers.feature
+++ b/features/providers/bank_statement_upload/check_your_means_answers.feature
@@ -88,7 +88,7 @@ Feature: Bank statement upload check your answers
And I click "Save and continue"
Then I should be on the "check_income_answers" page showing "Check your answers"
- When I click Check Your Answers Change link for "applicant student finance"
+ When I click Check Your Answers Change link for applicant 'student_finance'
And I choose "Yes"
And I enter amount "5000"
diff --git a/features/providers/partner_means_assessment/bank_statement_upload/check_your_means_answers.feature b/features/providers/partner_means_assessment/bank_statement_upload/check_your_means_answers.feature
index a97a52642b..f4a6a1002f 100644
--- a/features/providers/partner_means_assessment/bank_statement_upload/check_your_means_answers.feature
+++ b/features/providers/partner_means_assessment/bank_statement_upload/check_your_means_answers.feature
@@ -88,7 +88,7 @@ Feature: Bank statement upload check your answers
And I click "Save and continue"
Then I should be on the "check_income_answers" page showing "Check your answers"
- When I click Check Your Answers Change link for "partner student finance"
+ When I click Check Your Answers Change link for partner 'student_finance'
And I choose "Yes"
And I enter amount "5000"
diff --git a/features/providers/regressions/enter_humanized_currency_amounts.feature b/features/providers/regressions/enter_humanized_currency_amounts.feature
new file mode 100644
index 0000000000..bb4588c146
--- /dev/null
+++ b/features/providers/regressions/enter_humanized_currency_amounts.feature
@@ -0,0 +1,141 @@
+@javascript
+Feature: Entering humanized monetary amounts on various forms
+ Scenario: I can enter humanized monetary amounts like 1,000 for cash income
+ Given csrf is enabled
+ And I have completed a non-passported employed application for "client" with bank statements as far as the end of the means income section
+ Then I should be on the "check_income_answers" page showing "Check your answers"
+
+ When I click Check Your Answers Change link for applicant 'cash_income'
+ And I select "Maintenance payments from a former partner"
+ And I fill "aggregated-cash-income-maintenance-in1-field" with "£2,654.33"
+ And I fill "aggregated-cash-income-maintenance-in2-field" with "£3,654.33"
+ And I fill "aggregated-cash-income-maintenance-in3-field" with "£4,654.33"
+
+ When I click 'Save and continue'
+ Then I should be on the 'check_income_answers' page showing 'Check your answers'
+ And I should see "£2,654.33"
+ And I should see "£3,654.33"
+ And I should see "£4,654.33"
+
+ Scenario: I can enter humanized monetary amounts like 1,000 for cash outgoings and housing benefit
+ Given csrf is enabled
+ And I have completed a non-passported employed application for "client" with bank statements as far as the end of the means income section
+ Then I should be on the "check_income_answers" page showing "Check your answers"
+
+ When I click Check Your Answers Change link for applicant 'cash_outgoings'
+ And I select "Housing payments"
+ And I fill "aggregated-cash-outgoings-rent-or-mortgage1-field" with "£2,275.43"
+ And I fill "aggregated-cash-outgoings-rent-or-mortgage2-field" with "£3,275.43"
+ And I fill "aggregated-cash-outgoings-rent-or-mortgage3-field" with "£4,275.43"
+
+ When I click 'Save and continue'
+ Then I should be on the 'housing_benefits' page showing "Does your client get Housing Benefit?"
+
+ When I choose "Yes"
+ And I fill "providers-means-housing-benefit-form-housing-benefit-amount-field" with "£1,322.55"
+ And I choose "Monthly"
+
+ When I click 'Save and continue'
+ Then I should be on the 'check_income_answers' page showing 'Check your answers'
+ And I should see "£2,275.43"
+ And I should see "£3,275.43"
+ And I should see "£4,275.43"
+ And I should see "£1,322.55"
+
+ Scenario: I can enter humanized monetary amounts like 1,000 for state benefits
+ Given csrf is enabled
+ And I have completed a non-passported employed application for "client" with bank statements as far as the end of the means income section
+ Then I should be on the "check_income_answers" page showing "Check your answers"
+
+ When I click Check Your Answers Change link for applicant 'state_benefits'
+ And I choose "Yes"
+ And I click 'Save and continue'
+
+ Then I should be on a page with title "Add benefit, charitable or government payment details"
+ And I fill 'regular-transaction-description-field' with "my government handout"
+ And I fill 'regular-transaction-amount-field' with "£1,222,333.44"
+ And I choose "Every week"
+
+ When I click 'Save and continue'
+ Then I should be on the 'add_other_state_benefits' page showing 'You added 1 benefit, charitable or government payment'
+ And I should see "£1,222,333.44"
+
+ Scenario: I can enter humanized monetary amounts like 1,000 for student finance
+ Given csrf is enabled
+ And I have completed a non-passported employed application for "client" with bank statements as far as the end of the means income section
+ Then I should be on the 'check_income_answers' page showing 'Check your answers'
+
+ When I click Check Your Answers Change link for applicant 'student_finance'
+ Then I should be on a page with title "Does your client get student finance?"
+ And I choose "Yes"
+ And I fill 'applicant-student-finance-amount-field' with "£5,432.11"
+
+ When I click 'Save and continue'
+ Then I should be on the 'check_income_answers' page showing 'Check your answers'
+ And I should see "£5,432.11"
+
+ Scenario: I can enter humanized monetary amounts like 1,000 for regular income
+ Given csrf is enabled
+ And I have completed a non-passported employed application for "client" with bank statements as far as the end of the means income section
+ Then I should be on the 'check_income_answers' page showing 'Check your answers'
+
+ When I click Check Your Answers Change link for "Payments your client receives"
+ Then I should be on a page with title "Which of these payments does your client get?"
+ And I select "Financial help from friends or family"
+ And I fill "Friends or family" with "£1,112.33"
+ And I choose the "Monthly" frequency for "Friends or family"
+
+ When I click 'Save and continue'
+ Then I should be on a page with title "Select payments your client receives in cash"
+ And I select "My client receives none of these payments in cash"
+ And I click 'Save and continue'
+ Then I should be on the 'check_income_answers' page showing 'Check your answers'
+ And I should see "£1,112.33"
+
+ Scenario: I can enter humanized monetary amounts like 1,000 for regular outgoings and housing benefit
+ Given csrf is enabled
+ And I have completed a non-passported employed application for "client" with bank statements as far as the end of the means income section
+ Then I should be on the 'check_income_answers' page showing 'Check your answers'
+
+ When I click Check Your Answers Change link for "Payments your client makes"
+ Then I should be on a page with title "Which of these payments does your client pay?"
+ And I select "Maintenance payments to a former partner"
+ And I fill "Maintenance out" with "£2,322.22"
+ And I choose the "Monthly" frequency for "Maintenance out"
+
+ When I click 'Save and continue'
+ Then I should be on a page with title "Select payments your client pays in cash"
+
+ When I select "None of the above"
+ And I click 'Save and continue'
+ Then I should be on a page with title "Does your client get Housing Benefit?"
+
+ When I click 'Save and continue'
+ Then I should be on the 'check_income_answers' page showing 'Check your answers'
+ And I should see "£2,322.22"
+
+ Scenario: I can enter humanized monetary amounts like 1,000 for mandatory capital disregards
+ Given the feature flag for means_test_review_a is enabled
+ And the MTR-A start date is in the past
+ And I have completed the income and capital sections of a non-passported application with bank statement uploads post-MTRA
+ When I am viewing the means capital check your answers page
+
+ When I click link "Change Budgeting Advances"
+ And I fill "capital-disregard-amount-field" with "£1,654.33"
+
+ When I click 'Save and continue'
+ Then I should be on the 'check_capital_answers' page showing 'Check your answers'
+ And I should see "£1,654.33"
+
+ Scenario: I can enter humanized monetary amounts like 1,000 for discretionary capital disregards
+ Given the feature flag for means_test_review_a is enabled
+ And the MTR-A start date is in the past
+ And I have completed the income and capital sections of a non-passported application with bank statement uploads post-MTRA
+ When I am viewing the means capital check your answers page
+
+ When I click link "Change Compensation, damages or ex-gratia payments for personal harm"
+ And I fill "capital-disregard-amount-field" with "£2,321.11"
+
+ When I click 'Save and continue'
+ Then I should be on the 'check_capital_answers' page showing 'Check your answers'
+ And I should see "£2,321.11"
diff --git a/features/step_definitions/bank_statement_upload_steps.rb b/features/step_definitions/bank_statement_upload_steps.rb
index 35813b7938..255f91e56b 100644
--- a/features/step_definitions/bank_statement_upload_steps.rb
+++ b/features/step_definitions/bank_statement_upload_steps.rb
@@ -33,6 +33,7 @@
:legal_aid_application,
:with_proceedings,
:with_employed_applicant,
+ :with_maintenance_in_category,
:with_rent_or_mortgage_regular_transaction,
:with_housing_benefit_regular_transaction,
:with_savings_amount,
diff --git a/features/step_definitions/civil_journey_steps.rb b/features/step_definitions/civil_journey_steps.rb
index c3f81f7eec..ce9c48fa7a 100644
--- a/features/step_definitions/civil_journey_steps.rb
+++ b/features/step_definitions/civil_journey_steps.rb
@@ -1139,6 +1139,14 @@
end
end
+Given("I click Check Your Answers Change link for partner {string}") do |question|
+ question_id = question.parameterize(separator: "_")
+
+ within "#app-check-your-answers__partner__#{question_id}" do
+ click_on("Change")
+ end
+end
+
Given("I click Check Your Answers Change link for {string}") do |question|
question_id = question.parameterize(separator: "_")
diff --git a/spec/forms/providers/means/capital_disregards/add_details_form_spec.rb b/spec/forms/providers/means/capital_disregards/add_details_form_spec.rb
index a98a51c09c..047d81a546 100644
--- a/spec/forms/providers/means/capital_disregards/add_details_form_spec.rb
+++ b/spec/forms/providers/means/capital_disregards/add_details_form_spec.rb
@@ -32,9 +32,24 @@
end
it "updates the capital_disregard" do
- expect(application.capital_disregards.first.amount).to eq 123
- expect(application.capital_disregards.first.account_name).to eq "Barclays"
- expect(application.capital_disregards.first.date_received).to eq Date.new(2024, 2, 1)
+ expect(application.capital_disregards.first)
+ .to have_attributes(
+ amount: 123,
+ account_name: "Barclays",
+ date_received: Date.new(2024, 2, 1),
+ )
+ end
+
+ context "with humanized monetary value" do
+ let(:amount) { "£1,244.55" }
+
+ it "is valid" do
+ expect(form).to be_valid
+ end
+
+ it "saves the monetary result" do
+ expect(application.capital_disregards.first.amount).to eq(1_244.55)
+ end
end
context "when amount is missing" do
diff --git a/spec/forms/providers/means/housing_benefit_form_spec.rb b/spec/forms/providers/means/housing_benefit_form_spec.rb
index 8d84abd0b1..31e90563dc 100644
--- a/spec/forms/providers/means/housing_benefit_form_spec.rb
+++ b/spec/forms/providers/means/housing_benefit_form_spec.rb
@@ -454,6 +454,21 @@
)
end
+ it "cleans the housing benefit regular transactions amount of humanized characters" do
+ legal_aid_application = create(:legal_aid_application, :with_applicant)
+ transaction_type = create(:transaction_type, :housing_benefit)
+ params = {
+ "transaction_type_ids" => transaction_type.id,
+ "housing_benefit_amount" => "£1,543.66",
+ "housing_benefit_frequency" => "weekly",
+ legal_aid_application:,
+ }
+ form = described_class.new(params)
+ form.save
+
+ expect(legal_aid_application.regular_transactions.first).to have_attributes(amount: 1_543.66)
+ end
+
context "when a housing benefit regular transaction already exists" do
it "does not create another legal aid application transaction type" do
legal_aid_application = create(:legal_aid_application, :with_applicant)
diff --git a/spec/forms/providers/means/regular_income_form_spec.rb b/spec/forms/providers/means/regular_income_form_spec.rb
index 1ef05a68a0..de2098915e 100644
--- a/spec/forms/providers/means/regular_income_form_spec.rb
+++ b/spec/forms/providers/means/regular_income_form_spec.rb
@@ -597,6 +597,21 @@
outgoing_cash_transaction,
)
end
+
+ it "cleans the regular transaction amount of humanized characters" do
+ legal_aid_application = create(:legal_aid_application, :with_applicant)
+ pension = create(:transaction_type, :pension)
+ params = {
+ "transaction_type_ids" => ["", pension.id],
+ "pension_amount" => "£2,333.66",
+ "pension_frequency" => "monthly",
+ }.merge(legal_aid_application:)
+
+ form = described_class.new(params)
+ form.save
+
+ expect(legal_aid_application.regular_transactions.first).to have_attributes(amount: 2_333.66)
+ end
end
end
end
diff --git a/spec/forms/providers/means/regular_outgoings_form_spec.rb b/spec/forms/providers/means/regular_outgoings_form_spec.rb
index 9a4ff28492..d690e1263e 100644
--- a/spec/forms/providers/means/regular_outgoings_form_spec.rb
+++ b/spec/forms/providers/means/regular_outgoings_form_spec.rb
@@ -470,6 +470,21 @@
.to contain_exactly([rent_or_mortgage.id, 250.50, "weekly"], [child_care.id, 100, "monthly"])
end
+ it "cleans the regular transaction amount of humanized characters" do
+ legal_aid_application = create(:legal_aid_application, :with_applicant)
+ rent_or_mortgage = create(:transaction_type, :rent_or_mortgage)
+ params = {
+ "transaction_type_ids" => ["", rent_or_mortgage.id],
+ "rent_or_mortgage_amount" => "£2,333.55",
+ "rent_or_mortgage_frequency" => "monthly",
+ }.merge(legal_aid_application:)
+
+ form = described_class.new(params)
+ form.save
+
+ expect(legal_aid_application.regular_transactions.first).to have_attributes(amount: 2_333.55)
+ end
+
it "destroys any existing housing benefit transactions if housing " \
"payments are not selected" do
legal_aid_application = create(:legal_aid_application, :with_applicant)
diff --git a/spec/forms/providers/means/state_benefit_form_spec.rb b/spec/forms/providers/means/state_benefit_form_spec.rb
index 762c44f703..ac0b70fe19 100644
--- a/spec/forms/providers/means/state_benefit_form_spec.rb
+++ b/spec/forms/providers/means/state_benefit_form_spec.rb
@@ -62,6 +62,12 @@
it { expect(validation).to be false }
end
+ context "when the amount is humanized monetary value" do
+ let(:amount) { "£1,000" }
+
+ it { expect(validation).to be true }
+ end
+
context "when the frequency is not valid" do
let(:frequency) { "NOT-A-FREQUENCY" }
@@ -93,6 +99,18 @@
expect(legal_aid_application.regular_transactions.first.description).to eq "New State Benefit"
end
end
+
+ context "with humanized monetary value" do
+ let(:model) { RegularTransaction.new(legal_aid_application:, transaction_type_id: transaction_type.id) }
+ let(:amount) { "£1,244.55" }
+
+ it "saves the new transaction" do
+ params[:model] = model
+ save_form
+
+ expect(legal_aid_application.regular_transactions.first.amount).to eq(1_244.55)
+ end
+ end
end
end
end
diff --git a/spec/models/aggregated_cash_income_spec.rb b/spec/models/aggregated_cash_income_spec.rb
index 89a8e15b21..8bed17c69c 100644
--- a/spec/models/aggregated_cash_income_spec.rb
+++ b/spec/models/aggregated_cash_income_spec.rb
@@ -300,6 +300,15 @@
end
end
+ context "with valid comma separate monetary params" do
+ let(:params) { valid_params.merge(benefits1: "1,222,222.33") }
+
+ it "creates the expected cash income records" do
+ expect { call_update }.to change(CashTransaction, :count).by(6)
+ expect(CashTransaction.pluck(:amount)).to include(1_222_222.33)
+ end
+ end
+
context "with invalid params" do
context "and non-numeric values" do
let(:params) { non_numeric_params }
diff --git a/spec/models/aggregated_cash_outgoings_spec.rb b/spec/models/aggregated_cash_outgoings_spec.rb
index a4a2251215..c424f086c1 100644
--- a/spec/models/aggregated_cash_outgoings_spec.rb
+++ b/spec/models/aggregated_cash_outgoings_spec.rb
@@ -250,6 +250,15 @@ def error_msg(name, month)
end
end
+ context "with valid comma separate monetary params" do
+ let(:params) { valid_params.merge(rent_or_mortgage1: "1,222,222.33") }
+
+ it "creates the expected cash income records" do
+ expect { call_update }.to change(CashTransaction, :count).by(6)
+ expect(CashTransaction.pluck(:amount)).to include(1_222_222.33)
+ end
+ end
+
context "with invalid params" do
context "and non-numeric values" do
let(:params) { non_numeric_params }