Browse Source

Extract discounted ownership validations

pull/2712/head
Kat 2 years ago
parent
commit
491ff76347
  1. 5
      app/models/form/sales/pages/deposit_and_mortgage_value_check.rb
  2. 5
      app/models/form/sales/pages/discounted_sale_value_check.rb
  3. 5
      app/models/form/sales/pages/extra_borrowing_value_check.rb
  4. 5
      app/models/form/sales/pages/grant_value_check.rb
  5. 5
      app/models/form/sales/pages/percentage_discount_value_check.rb
  6. 3
      app/models/form/sales/questions/deposit_and_mortgage_value_check.rb
  7. 3
      app/models/form/sales/questions/discounted_sale_value_check.rb
  8. 3
      app/models/form/sales/questions/extra_borrowing_value_check.rb
  9. 3
      app/models/form/sales/questions/grant_value_check.rb
  10. 3
      app/models/form/sales/questions/percentage_discount_value_check.rb
  11. 15
      config/locales/en.yml
  12. 38
      config/locales/forms/2023/sales/soft_validations.en.yml
  13. 39
      config/locales/forms/2024/sales/soft_validations.en.yml
  14. 7
      spec/models/form/sales/pages/discounted_sale_value_check_spec.rb
  15. 7
      spec/models/form/sales/pages/percentage_discount_value_check_spec.rb

5
app/models/form/sales/pages/deposit_and_mortgage_value_check.rb

@ -6,8 +6,9 @@ class Form::Sales::Pages::DepositAndMortgageValueCheck < ::Form::Page
"mortgage_plus_deposit_less_than_discounted_value?" => true, "mortgage_plus_deposit_less_than_discounted_value?" => true,
}, },
] ]
@copy_key = "sales.sale_information.deposit_and_mortgage_value_check"
@title_text = { @title_text = {
"translation" => "soft_validations.deposit_and_mortgage.title_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "mortgage", "key" => "mortgage",
@ -27,7 +28,7 @@ class Form::Sales::Pages::DepositAndMortgageValueCheck < ::Form::Page
], ],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.deposit_and_mortgage.hint_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [], "arguments" => [],
} }
end end

5
app/models/form/sales/pages/discounted_sale_value_check.rb

@ -2,8 +2,9 @@ class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page
def initialize(id, hsh, subsection, person_index = nil) def initialize(id, hsh, subsection, person_index = nil)
super(id, hsh, subsection) super(id, hsh, subsection)
@depends_on = depends_on @depends_on = depends_on
@copy_key = "sales.sale_information.discounted_sale_value_check"
@title_text = { @title_text = {
"translation" => "soft_validations.discounted_sale_value.title_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "field_formatted_as_currency", "key" => "field_formatted_as_currency",
@ -13,7 +14,7 @@ class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page
], ],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.discounted_sale_value.informative_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [ "arguments" => [
{ {
"key" => "field_formatted_as_currency", "key" => "field_formatted_as_currency",

5
app/models/form/sales/pages/extra_borrowing_value_check.rb

@ -6,8 +6,9 @@ class Form::Sales::Pages::ExtraBorrowingValueCheck < Form::Page
"extra_borrowing_expected_but_not_reported?" => true, "extra_borrowing_expected_but_not_reported?" => true,
}, },
] ]
@copy_key = "sales.sale_information.extra_borrowing_value_check"
@title_text = { @title_text = {
"translation" => "soft_validations.extra_borrowing.title_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "field_formatted_as_currency", "key" => "field_formatted_as_currency",
@ -17,7 +18,7 @@ class Form::Sales::Pages::ExtraBorrowingValueCheck < Form::Page
], ],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.extra_borrowing.hint_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [], "arguments" => [],
} }
end end

5
app/models/form/sales/pages/grant_value_check.rb

@ -2,13 +2,14 @@ class Form::Sales::Pages::GrantValueCheck < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "grant_value_check" @id = "grant_value_check"
@copy_key = "sales.sale_information.grant_value_check"
@depends_on = [ @depends_on = [
{ {
"grant_outside_common_range?" => true, "grant_outside_common_range?" => true,
}, },
] ]
@title_text = { @title_text = {
"translation" => "soft_validations.grant.title_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "field_formatted_as_currency", "key" => "field_formatted_as_currency",
@ -18,7 +19,7 @@ class Form::Sales::Pages::GrantValueCheck < ::Form::Page
], ],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.grant.hint_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [], "arguments" => [],
} }
end end

5
app/models/form/sales/pages/percentage_discount_value_check.rb

@ -1,12 +1,13 @@
class Form::Sales::Pages::PercentageDiscountValueCheck < ::Form::Page class Form::Sales::Pages::PercentageDiscountValueCheck < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@copy_key = "sales.sale_information.percentage_discount_value_check"
@title_text = { @title_text = {
"translation" => "soft_validations.percentage_discount_value.title_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [{ "key" => "discount", "label" => true, "i18n_template" => "discount" }], "arguments" => [{ "key" => "discount", "label" => true, "i18n_template" => "discount" }],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.percentage_discount_value.hint_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [], "arguments" => [],
} }
@depends_on = [{ "percentage_discount_invalid?" => true }] @depends_on = [{ "percentage_discount_invalid?" => true }]

3
app/models/form/sales/questions/deposit_and_mortgage_value_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::DepositAndMortgageValueCheck < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "deposit_and_mortgage_value_check" @id = "deposit_and_mortgage_value_check"
@check_answer_label = "Deposit and mortgage against discount confirmation" @copy_key = "sales.sale_information.deposit_and_mortgage_value_check"
@header = "Are you sure? Mortgage and deposit usually equal or are more than (value - discount)"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },

3
app/models/form/sales/questions/discounted_sale_value_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::DiscountedSaleValueCheck < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "discounted_sale_value_check" @id = "discounted_sale_value_check"
@check_answer_label = "Discounted sale value confirmation" @copy_key = "sales.sale_information.discounted_sale_value_check"
@header = "Are you sure this is correct?"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },

3
app/models/form/sales/questions/extra_borrowing_value_check.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::ExtraBorrowingValueCheck < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super(id, hsh, page) super(id, hsh, page)
@id = "extrabor_value_check" @id = "extrabor_value_check"
@check_answer_label = "Extra borrowing confirmation" @copy_key = "sales.sale_information.extra_borrowing_value_check"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },
@ -18,6 +18,5 @@ class Form::Sales::Questions::ExtraBorrowingValueCheck < ::Form::Question
}, },
], ],
} }
@header = "Are you sure there is no extra borrowing?"
end end
end end

3
app/models/form/sales/questions/grant_value_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::GrantValueCheck < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "grant_value_check" @id = "grant_value_check"
@check_answer_label = "Grant value confirmation" @copy_key = "sales.sale_information.grant_value_check"
@header = "Are you sure? Grants are usually £9,000 - £16,000"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },

3
app/models/form/sales/questions/percentage_discount_value_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::PercentageDiscountValueCheck < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "percentage_discount_value_check" @id = "percentage_discount_value_check"
@check_answer_label = "Percentage discount confirmation" @copy_key = "sales.sale_information.percentage_discount_value_check"
@header = "Are you sure this is correct?"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },

15
config/locales/en.yml

@ -657,9 +657,6 @@ en:
max: max:
title: "You told us this person is over 66 and not retired." title: "You told us this person is over 66 and not retired."
hint_text: "The minimum expected retirement age in England is 66." hint_text: "The minimum expected retirement age in England is 66."
extra_borrowing:
title_text: "You told us that the mortgage and deposit total is %{mortgage_and_deposit_total}."
hint_text: "This is higher than the purchase price minus the discount."
pregnancy: pregnancy:
title: "You told us somebody in the household is pregnant." title: "You told us somebody in the household is pregnant."
all_male_tenants: "You also told us that all the tenants living at the property are male." all_male_tenants: "You also told us that all the tenants living at the property are male."
@ -670,17 +667,8 @@ en:
void_date: void_date:
title_text: "You told us that the property has been vacant for more than 2 years." 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." hint_text: "This is higher than we would expect."
discounted_sale_value:
title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}."
informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}."
care_home_charges: care_home_charges:
title_text: "Care home charges should be provided if this is a care home accommodation." title_text: "Care home charges should be provided if this is a care home accommodation."
percentage_discount_value:
title_text: "You told us that the percentage discount is %{discount}."
hint_text: "This is higher than we would expect."
grant:
title_text: "You told us that the grant amount is %{grant}."
hint_text: "Loans, grants and subsidies are usually between £9,000 and £16,000."
referral: referral:
title_text: "Are you sure?" title_text: "Are you sure?"
hint_text: "This is a general needs log, and this referral type is for supported housing." hint_text: "This is a general needs log, and this referral type is for supported housing."
@ -693,9 +681,6 @@ en:
charges: charges:
informative_text: "This is higher than we would expect." informative_text: "This is higher than we would expect."
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>" hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
deposit_and_mortgage:
title_text: "You told us the mortgage amount was %{mortgage}, the cash deposit was %{deposit} and the discount was %{discount}."
hint_text: "We would expect the mortgage amount and the deposit added together to be the same as the purchase price minus the discount."
reasonother: reasonother:
title_text: "You told us that the tenant’s main reason for leaving their last settled home was %{reasonother}." title_text: "You told us that the tenant’s main reason for leaving their last settled home was %{reasonother}."
informative_text: "The reason you have entered looks very similar to one of the existing response categories. informative_text: "The reason you have entered looks very similar to one of the existing response categories.

38
config/locales/forms/2023/sales/soft_validations.en.yml

@ -195,4 +195,42 @@ en:
title_text: "You told us that the monthly charges were %{mscharge}." title_text: "You told us that the monthly charges were %{mscharge}."
informative_text: "This is higher than we would expect." informative_text: "This is higher than we would expect."
extra_borrowing_value_check:
page_header: ""
check_answer_label: "Extra borrowing confirmation"
hint_text: ""
question_text: "Are you sure there is no extra borrowing?"
title_text: "You told us that the mortgage and deposit total is %{mortgage_and_deposit_total}."
informative_text: "This is higher than the purchase price minus the discount."
percentage_discount_value_check:
page_header: ""
check_answer_label: "Percentage discount confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the percentage discount is %{discount}."
informative_text: "This is higher than we would expect."
grant_value_check:
page_header: ""
check_answer_label: "Grant value confirmation"
hint_text: ""
question_text: "Are you sure? Grants are usually £9,000 - £16,000"
title_text: "You told us that the grant amount is %{grant}."
informative_text: "Loans, grants and subsidies are usually between £9,000 and £16,000."
discounted_sale_value_check:
page_header: ""
check_answer_label: "Discounted sale value confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}."
informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}."
deposit_and_mortgage_value_check:
page_header: ""
check_answer_label: "Deposit and mortgage against discount confirmation"
hint_text: ""
question_text: "Are you sure? Mortgage and deposit usually equal or are more than (value - discount)"
title_text: "You told us the mortgage amount was %{mortgage}, the cash deposit was %{deposit} and the discount was %{discount}."
informative_text: "We would expect the mortgage amount and the deposit added together to be the same as the purchase price minus the discount."

39
config/locales/forms/2024/sales/soft_validations.en.yml

@ -195,3 +195,42 @@ en:
title_text: "You told us that the monthly charges were %{mscharge}." title_text: "You told us that the monthly charges were %{mscharge}."
informative_text: "This is higher than we would expect." informative_text: "This is higher than we would expect."
extra_borrowing_value_check:
page_header: ""
check_answer_label: "Extra borrowing confirmation"
hint_text: ""
question_text: "Are you sure there is no extra borrowing?"
title_text: "You told us that the mortgage and deposit total is %{mortgage_and_deposit_total}."
informative_text: "This is higher than the purchase price minus the discount."
percentage_discount_value_check:
page_header: ""
check_answer_label: "Percentage discount confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the percentage discount is %{discount}."
informative_text: "This is higher than we would expect."
grant_value_check:
page_header: ""
check_answer_label: "Grant value confirmation"
hint_text: ""
question_text: "Are you sure? Grants are usually £9,000 - £16,000"
title_text: "You told us that the grant amount is %{grant}."
informative_text: "Loans, grants and subsidies are usually between £9,000 and £16,000."
discounted_sale_value_check:
page_header: ""
check_answer_label: "Discounted sale value confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}."
informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}."
deposit_and_mortgage_value_check:
page_header: ""
check_answer_label: "Deposit and mortgage against discount confirmation"
hint_text: ""
question_text: "Are you sure? Mortgage and deposit usually equal or are more than (value - discount)"
title_text: "You told us the mortgage amount was %{mortgage}, the cash deposit was %{deposit} and the discount was %{discount}."
informative_text: "We would expect the mortgage amount and the deposit added together to be the same as the purchase price minus the discount."

7
spec/models/form/sales/pages/discounted_sale_value_check_spec.rb

@ -6,7 +6,8 @@ RSpec.describe Form::Sales::Pages::DiscountedSaleValueCheck, type: :model do
let(:page_id) { "discounted_sale_value_check" } let(:page_id) { "discounted_sale_value_check" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:index) { 1 } let(:index) { 1 }
let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -22,14 +23,14 @@ RSpec.describe Form::Sales::Pages::DiscountedSaleValueCheck, type: :model do
it "has the correct title_text" do it "has the correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.discounted_sale_value.title_text", "translation" => "forms.2024.sales.sale_information.discounted_sale_value_check.title_text",
"arguments" => [{ "arguments_for_key" => "value_with_discount", "i18n_template" => "value_with_discount", "key" => "field_formatted_as_currency" }], "arguments" => [{ "arguments_for_key" => "value_with_discount", "i18n_template" => "value_with_discount", "key" => "field_formatted_as_currency" }],
}) })
end end
it "has the correct informative_text" do it "has the correct informative_text" do
expect(page.informative_text).to eq({ expect(page.informative_text).to eq({
"translation" => "soft_validations.discounted_sale_value.informative_text", "translation" => "forms.2024.sales.sale_information.discounted_sale_value_check.informative_text",
"arguments" => [{ "arguments_for_key" => "mortgage_deposit_and_grant_total", "i18n_template" => "mortgage_deposit_and_grant_total", "key" => "field_formatted_as_currency" }], "arguments" => [{ "arguments_for_key" => "mortgage_deposit_and_grant_total", "i18n_template" => "mortgage_deposit_and_grant_total", "key" => "field_formatted_as_currency" }],
}) })
end end

7
spec/models/form/sales/pages/percentage_discount_value_check_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::PercentageDiscountValueCheck, type: :model do
let(:page_id) { "percentage_discount_value_check" } let(:page_id) { "percentage_discount_value_check" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -21,14 +22,14 @@ RSpec.describe Form::Sales::Pages::PercentageDiscountValueCheck, type: :model do
it "has the correct title_text" do it "has the correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.percentage_discount_value.title_text", "translation" => "forms.2024.sales.sale_information.percentage_discount_value_check.title_text",
"arguments" => [{ "key" => "discount", "label" => true, "i18n_template" => "discount" }], "arguments" => [{ "key" => "discount", "label" => true, "i18n_template" => "discount" }],
}) })
end end
it "has the correct informative_text" do it "has the correct informative_text" do
expect(page.informative_text).to eq({ expect(page.informative_text).to eq({
"translation" => "soft_validations.percentage_discount_value.hint_text", "translation" => "forms.2024.sales.sale_information.percentage_discount_value_check.informative_text",
"arguments" => [], "arguments" => [],
}) })
end end

Loading…
Cancel
Save