Browse Source

Update validation message: mortgage, discount and deposit

pull/1584/head
Kat 3 years ago
parent
commit
b6896b2b3f
  1. 4
      app/models/form/sales/pages/shared_ownership_deposit_value_check.rb
  2. 8
      app/models/sales_log.rb
  3. 2
      config/locales/en.yml
  4. 2
      spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb

4
app/models/form/sales/pages/shared_ownership_deposit_value_check.rb

@ -12,8 +12,8 @@ class Form::Sales::Pages::SharedOwnershipDepositValueCheck < ::Form::Page
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "expected_shared_ownership_deposit_value",
"i18n_template" => "expected_shared_ownership_deposit_value",
"arguments_for_key" => "mortgage_deposit_and_discount_total",
"i18n_template" => "mortgage_deposit_and_discount_total",
},
],
}

8
app/models/sales_log.rb

@ -219,6 +219,14 @@ class SalesLog < Log
value * equity / 100
end
def mortgage_deposit_and_discount_total
mortgage_amount = mortgage || 0
deposit_amount = deposit || 0
cashdis_amount = cashdis || 0
mortgage_amount + deposit_amount + cashdis_amount
end
def mortgage_and_deposit_total
return unless mortgage && deposit

2
config/locales/en.yml

@ -556,7 +556,7 @@ en:
title_text: "You told us that the property has been vacant for more than 2 years."
hint_text: "This is higher than we would expect."
shared_ownership_deposit:
title_text: "Mortgage, deposit and cash discount total should equal %{expected_shared_ownership_deposit_value}"
title_text: "You told us that the mortgage, deposit and discount add up to %{mortgage_deposit_and_discount_total}"
old_persons_shared_ownership:
title_text: "You told us the buyer is using the Older Persons Shared Ownership scheme."
hint_text: "At least one buyer must be aged 65 years and over to use this scheme."

2
spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb

@ -34,7 +34,7 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipDepositValueCheck, type: :mode
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.shared_ownership_deposit.title_text",
"arguments" => [{ "arguments_for_key" => "expected_shared_ownership_deposit_value", "i18n_template" => "expected_shared_ownership_deposit_value", "key" => "field_formatted_as_currency" }],
"arguments" => [{ "arguments_for_key" => "mortgage_deposit_and_discount_total", "i18n_template" => "mortgage_deposit_and_discount_total", "key" => "field_formatted_as_currency" }],
})
end

Loading…
Cancel
Save