Browse Source

Use money flag

pull/1525/head
Jack S 3 years ago
parent
commit
99e2e04b2e
  1. 3
      app/models/form/lettings/pages/max_rent_value_check.rb
  2. 8
      app/models/form/lettings/pages/min_rent_value_check.rb
  3. 4
      app/models/form/lettings/pages/net_income_value_check.rb
  4. 1
      app/models/form/sales/pages/about_price_value_check.rb
  5. 4
      app/models/form/sales/pages/discounted_sale_value_check.rb
  6. 1
      app/models/form/sales/pages/shared_ownership_deposit_value_check.rb
  7. 14
      config/locales/en.yml
  8. 37
      spec/models/form/lettings/pages/max_rent_value_check_spec.rb
  9. 48
      spec/models/form/lettings/pages/min_rent_value_check_spec.rb
  10. 40
      spec/models/form/lettings/pages/net_income_value_check_spec.rb
  11. 54
      spec/models/form/sales/pages/about_price_value_check_spec.rb
  12. 4
      spec/models/form/sales/pages/discounted_sale_value_check_spec.rb
  13. 8
      spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb
  14. 10
      spec/services/imports/lettings_logs_import_service_spec.rb

3
app/models/form/lettings/pages/max_rent_value_check.rb

@ -5,7 +5,7 @@ class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page
@depends_on = [{ "rent_in_soft_max_range?" => true }] @depends_on = [{ "rent_in_soft_max_range?" => true }]
@title_text = { @title_text = {
"translation" => "soft_validations.rent.outside_range_title", "translation" => "soft_validations.rent.outside_range_title",
"arguments" => [{ "key" => "brent", "label" => true, "i18n_template" => "brent" }], "arguments" => [{ "key" => "brent", "label" => true, "i18n_template" => "brent", "money" => true }],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.rent.max_hint_text", "translation" => "soft_validations.rent.max_hint_text",
@ -14,6 +14,7 @@ class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page
"key" => "soft_max_for_period", "key" => "soft_max_for_period",
"label" => false, "label" => false,
"i18n_template" => "soft_max_for_period", "i18n_template" => "soft_max_for_period",
"money" => true,
}, },
], ],
} }

8
app/models/form/lettings/pages/min_rent_value_check.rb

@ -5,7 +5,12 @@ class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page
@depends_on = [{ "rent_in_soft_min_range?" => true }] @depends_on = [{ "rent_in_soft_min_range?" => true }]
@title_text = { @title_text = {
"translation" => "soft_validations.rent.outside_range_title", "translation" => "soft_validations.rent.outside_range_title",
"arguments" => [{ "key" => "brent", "label" => true, "i18n_template" => "brent" }], "arguments" => [{
"key" => "brent",
"label" => true,
"i18n_template" => "brent",
"money" => true,
}],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.rent.min_hint_text", "translation" => "soft_validations.rent.min_hint_text",
@ -14,6 +19,7 @@ class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page
"key" => "soft_min_for_period", "key" => "soft_min_for_period",
"label" => false, "label" => false,
"i18n_template" => "soft_min_for_period", "i18n_template" => "soft_min_for_period",
"money" => true,
}, },
], ],
} }

4
app/models/form/lettings/pages/net_income_value_check.rb

@ -7,8 +7,8 @@ class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page
@informative_text = { @informative_text = {
"translation" => "soft_validations.net_income.hint_text", "translation" => "soft_validations.net_income.hint_text",
"arguments" => [ "arguments" => [
{ "key" => "ecstat1", "label" => true, "i18n_template" => "ecstat1" }, { "key" => "ecstat1", "label" => true, "i18n_template" => "ecstat1", "money" => true },
{ "key" => "earnings", "label" => true, "i18n_template" => "earnings" }, { "key" => "earnings", "label" => true, "i18n_template" => "earnings", "money" => true },
], ],
} }
end end

1
app/models/form/sales/pages/about_price_value_check.rb

@ -13,6 +13,7 @@ class Form::Sales::Pages::AboutPriceValueCheck < ::Form::Page
"key" => "value", "key" => "value",
"label" => true, "label" => true,
"i18n_template" => "value", "i18n_template" => "value",
"money" => true,
}, },
], ],
} }

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

@ -4,11 +4,11 @@ class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page
@depends_on = depends_on @depends_on = depends_on
@title_text = { @title_text = {
"translation" => "soft_validations.discounted_sale_value.title_text", "translation" => "soft_validations.discounted_sale_value.title_text",
"arguments" => [{ "key" => "value_with_discount", "label" => false, "i18n_template" => "value_with_discount" }], "arguments" => [{ "key" => "value_with_discount", "label" => false, "i18n_template" => "value_with_discount", "money" => true }],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.discounted_sale_value.informative_text", "translation" => "soft_validations.discounted_sale_value.informative_text",
"arguments" => [{ "key" => "mortgage_deposit_and_grant_total", "label" => false, "i18n_template" => "mortgage_deposit_and_grant_total" }], "arguments" => [{ "key" => "mortgage_deposit_and_grant_total", "label" => false, "i18n_template" => "mortgage_deposit_and_grant_total", "money" => true }],
} }
@person_index = person_index @person_index = person_index
@depends_on = [ @depends_on = [

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

@ -14,6 +14,7 @@ class Form::Sales::Pages::SharedOwnershipDepositValueCheck < ::Form::Page
"key" => "expected_shared_ownership_deposit_value", "key" => "expected_shared_ownership_deposit_value",
"label" => false, "label" => false,
"i18n_template" => "expected_shared_ownership_deposit_value", "i18n_template" => "expected_shared_ownership_deposit_value",
"money" => true,
}, },
], ],
} }

14
config/locales/en.yml

@ -283,7 +283,7 @@ en:
general_needs: "Enter a value for the support charge between £0 and £60 per week if the landlord is a local authority and it is a general needs letting" general_needs: "Enter a value for the support charge between £0 and £60 per week if the landlord is a local authority and it is a general needs letting"
supported_housing: "Enter a value for the support charge between £0 and £120 per week if the landlord is a local authority and it is a supported housing letting" supported_housing: "Enter a value for the support charge between £0 and £120 per week if the landlord is a local authority and it is a supported housing letting"
ecstat: ecstat:
over_hard_max: "Net income of £%{hard_max} per week is too high for given the tenant’s working situation" over_hard_max: "Net income of %{hard_max} per week is too high for given the tenant’s working situation"
brent: brent:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms" below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms"
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms" above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms"
@ -314,7 +314,7 @@ en:
charges: charges:
complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’" complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’"
tcharge: tcharge:
under_10: "Enter a total charge that is at least £10 per week" under_10: "Enter a total charge that is at least £10.00 per week"
rent_period: rent_period:
invalid_for_org: "%{org_name} does not charge rent %{rent_period}" invalid_for_org: "%{org_name} does not charge rent %{rent_period}"
carehome: carehome:
@ -516,8 +516,8 @@ en:
under_soft_min_for_economic_status: "You said income was %{income}, which is below this working situation's minimum (%{minimum})" under_soft_min_for_economic_status: "You said income was %{income}, which is below this working situation's minimum (%{minimum})"
rent: rent:
outside_range_title: "You told us the rent is %{brent}" outside_range_title: "You told us the rent is %{brent}"
min_hint_text: "The minimum rent expected for this type of property in this local authority is £%{soft_min_for_period}." min_hint_text: "The minimum rent expected for this type of property in this local authority is %{soft_min_for_period}."
max_hint_text: "The maximum rent expected for this type of property in this local authority is £%{soft_max_for_period}." max_hint_text: "The maximum rent expected for this type of property in this local authority is %{soft_max_for_period}."
purchase_price: purchase_price:
title_text: "You told us the purchase price is %{value}" title_text: "You told us the purchase price is %{value}"
hint_text: "The %{min_or_max} purchase price expected for this type of property in this local authority is %{soft_min_or_soft_max}" hint_text: "The %{min_or_max} purchase price expected for this type of property in this local authority is %{soft_min_or_soft_max}"
@ -539,7 +539,7 @@ en:
void_date: void_date:
title_text: "You told us the time between the start of the tenancy and the void date is more than 2 years" title_text: "You told us the time between the start of the tenancy and the void date is more than 2 years"
shared_ownership_deposit: shared_ownership_deposit:
title_text: "Mortgage, deposit and cash discount total should equal £%{expected_shared_ownership_deposit_value}" title_text: "Mortgage, deposit and cash discount total should equal %{expected_shared_ownership_deposit_value}"
old_persons_shared_ownership: "At least one buyer should be aged over 64 for Older persons’ shared ownership scheme" old_persons_shared_ownership: "At least one buyer should be aged over 64 for Older persons’ shared ownership scheme"
staircase_bought_seems_high: "You said %{percentage}% was bought in this staircasing transaction, which seems high. Are you sure?" staircase_bought_seems_high: "You said %{percentage}% was bought in this staircasing transaction, which seems high. Are you sure?"
monthly_charges_over_soft_max: monthly_charges_over_soft_max:
@ -547,8 +547,8 @@ en:
student_not_child: student_not_child:
title_text: "You told us this person is a student aged beween 16 and 19" title_text: "You told us this person is a student aged beween 16 and 19"
discounted_sale_value: discounted_sale_value:
title_text: "Mortgage, deposit, and grant total must equal £%{value_with_discount}" 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}" 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"

37
spec/models/form/lettings/pages/max_rent_value_check_spec.rb

@ -0,0 +1,37 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::MaxRentValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "shared_ownership_deposit_value_check" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[rent_value_check])
end
it "has the correct id" do
expect(page.id).to eq("max_rent_value_check")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "rent_in_soft_max_range?" => true }])
end
it "has the correct title_text" do
expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true, "money" => true }], "translation" => "soft_validations.rent.outside_range_title" })
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({ "arguments" => [{ "i18n_template" => "soft_max_for_period", "key" => "soft_max_for_period", "label" => false, "money" => true }], "translation" => "soft_validations.rent.max_hint_text" })
end
end

48
spec/models/form/lettings/pages/min_rent_value_check_spec.rb

@ -0,0 +1,48 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::MinRentValueCheck, type: :model do
subject(:page) { described_class.new(nil, page_definition, subsection) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do
expect(page.description).to be nil
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[rent_value_check])
end
it "has the correct id" do
expect(page.id).to eq("min_rent_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "rent_in_soft_min_range?" => true }],
)
end
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.rent.outside_range_title",
"arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true, "money" => true }],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"arguments" => [{ "i18n_template" => "soft_min_for_period", "key" => "soft_min_for_period", "label" => false, "money" => true }],
"translation" => "soft_validations.rent.min_hint_text",
})
end
end

40
spec/models/form/lettings/pages/net_income_value_check_spec.rb

@ -0,0 +1,40 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::NetIncomeValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "shared_ownership_deposit_value_check" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[net_income_value_check])
end
it "has the correct id" do
expect(page.id).to eq("net_income_value_check")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "net_income_soft_validation_triggered?" => true }])
end
it "has the correct title_text" do
expect(page.title_text).to eq({ "translation" => "soft_validations.net_income.title_text" })
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"arguments" => [{ "i18n_template" => "ecstat1", "key" => "ecstat1", "label" => true, "money" => true }, { "i18n_template" => "earnings", "key" => "earnings", "label" => true, "money" => true }],
"translation" => "soft_validations.net_income.hint_text",
})
end
end

54
spec/models/form/sales/pages/about_price_value_check_spec.rb

@ -0,0 +1,54 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::AboutPriceValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "savings_value_check" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[value_value_check])
end
it "has the correct id" do
expect(page.id).to eq("savings_value_check")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "purchase_price_out_of_soft_range?" => true }])
end
it "is interruption screen page" do
expect(page.interruption_screen?).to eq(true)
end
it "has the correct title_text" do
expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "value", "key" => "value", "label" => true, "money" => true }], "translation" => "soft_validations.purchase_price.title_text" })
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.purchase_price.hint_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "purchase_price_soft_min_or_soft_max",
"i18n_template" => "soft_min_or_soft_max",
},
{
"key" => "purchase_price_min_or_max_text",
"i18n_template" => "min_or_max",
},
],
})
end
end

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

@ -27,14 +27,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" => "soft_validations.discounted_sale_value.title_text",
"arguments" => [{ "key" => "value_with_discount", "label" => false, "i18n_template" => "value_with_discount" }], "arguments" => [{ "key" => "value_with_discount", "label" => false, "i18n_template" => "value_with_discount", "money" => true }],
}) })
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" => "soft_validations.discounted_sale_value.informative_text",
"arguments" => [{ "key" => "mortgage_deposit_and_grant_total", "label" => false, "i18n_template" => "mortgage_deposit_and_grant_total" }], "arguments" => [{ "key" => "mortgage_deposit_and_grant_total", "label" => false, "i18n_template" => "mortgage_deposit_and_grant_total", "money" => true }],
}) })
end end

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

@ -34,13 +34,7 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipDepositValueCheck, type: :mode
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.shared_ownership_deposit.title_text", "translation" => "soft_validations.shared_ownership_deposit.title_text",
"arguments" => [ "arguments" => [{ "i18n_template" => "expected_shared_ownership_deposit_value", "key" => "expected_shared_ownership_deposit_value", "label" => false, "money" => true }],
{
"key" => "expected_shared_ownership_deposit_value",
"label" => false,
"i18n_template" => "expected_shared_ownership_deposit_value",
},
],
}) })
end end

10
spec/services/imports/lettings_logs_import_service_spec.rb

@ -532,11 +532,11 @@ RSpec.describe Imports::LettingsLogsImportService do
end end
it "intercepts the relevant validation error" do it "intercepts the relevant validation error" do
expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing brent with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing brent with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week")
expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing scharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing scharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week")
expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing pscharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing pscharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week")
expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing supcharg with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing supcharg with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week")
expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing tcharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing tcharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week")
expect { lettings_log_service.send(:create_log, lettings_log_xml) } expect { lettings_log_service.send(:create_log, lettings_log_xml) }
.not_to raise_error .not_to raise_error
end end

Loading…
Cancel
Save