Browse Source

CLDC-1975 format money amounts with currency and 2 decimals (#1525)

* Allow interruption screens to format money values

* Remove formatting from saleslog method

* Use money flag

* Use pre exhisting method to format values

* Update config/locales/en.yml

Co-authored-by: Arthur Campbell <51094020+arfacamble@users.noreply.github.com>

---------

Co-authored-by: Arthur Campbell <51094020+arfacamble@users.noreply.github.com>
pull/1542/head
Jack 2 years ago committed by GitHub
parent
commit
12aa3ccfaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/models/form/lettings/pages/max_rent_value_check.rb
  2. 10
      app/models/form/lettings/pages/min_rent_value_check.rb
  3. 12
      app/models/form/lettings/pages/net_income_value_check.rb
  4. 16
      app/models/form/sales/pages/discounted_sale_value_check.rb
  5. 4
      app/models/form/sales/pages/shared_ownership_deposit_value_check.rb
  6. 5
      app/models/log.rb
  7. 7
      app/models/sales_log.rb
  8. 14
      config/locales/en.yml
  9. 73
      spec/helpers/interruption_screen_helper_spec.rb
  10. 37
      spec/models/form/lettings/pages/max_rent_value_check_spec.rb
  11. 48
      spec/models/form/lettings/pages/min_rent_value_check_spec.rb
  12. 40
      spec/models/form/lettings/pages/net_income_value_check_spec.rb
  13. 54
      spec/models/form/sales/pages/about_price_value_check_spec.rb
  14. 4
      spec/models/form/sales/pages/discounted_sale_value_check_spec.rb
  15. 8
      spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb
  16. 2
      spec/models/sales_log_spec.rb
  17. 10
      spec/services/imports/lettings_logs_import_service_spec.rb

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

@ -5,14 +5,20 @@ 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",
},
],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.rent.max_hint_text", "translation" => "soft_validations.rent.max_hint_text",
"arguments" => [ "arguments" => [
{ {
"key" => "soft_max_for_period", "key" => "field_formatted_as_currency",
"label" => false, "arguments_for_key" => "soft_max_for_period",
"i18n_template" => "soft_max_for_period", "i18n_template" => "soft_max_for_period",
}, },
], ],

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

@ -5,14 +5,18 @@ 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",
}],
} }
@informative_text = { @informative_text = {
"translation" => "soft_validations.rent.min_hint_text", "translation" => "soft_validations.rent.min_hint_text",
"arguments" => [ "arguments" => [
{ {
"key" => "soft_min_for_period", "key" => "field_formatted_as_currency",
"label" => false, "arguments_for_key" => "soft_min_for_period",
"i18n_template" => "soft_min_for_period", "i18n_template" => "soft_min_for_period",
}, },
], ],

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

@ -7,8 +7,16 @@ 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" => "earnings", "label" => true, "i18n_template" => "earnings" }, "key" => "field_formatted_as_currency",
"arguments_for_key" => "ecstat1",
"i18n_template" => "ecstat1",
},
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "earnings",
"i18n_template" => "earnings",
},
], ],
} }
end end

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

@ -4,11 +4,23 @@ 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" => "field_formatted_as_currency",
"arguments_for_key" => "value_with_discount",
"i18n_template" => "value_with_discount",
},
],
} }
@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" => "field_formatted_as_currency",
"arguments_for_key" => "mortgage_deposit_and_grant_total",
"i18n_template" => "mortgage_deposit_and_grant_total",
},
],
} }
@person_index = person_index @person_index = person_index
@depends_on = [ @depends_on = [

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

@ -11,8 +11,8 @@ class Form::Sales::Pages::SharedOwnershipDepositValueCheck < ::Form::Page
"translation" => "soft_validations.shared_ownership_deposit.title_text", "translation" => "soft_validations.shared_ownership_deposit.title_text",
"arguments" => [ "arguments" => [
{ {
"key" => "expected_shared_ownership_deposit_value", "key" => "field_formatted_as_currency",
"label" => false, "arguments_for_key" => "expected_shared_ownership_deposit_value",
"i18n_template" => "expected_shared_ownership_deposit_value", "i18n_template" => "expected_shared_ownership_deposit_value",
}, },
], ],

5
app/models/log.rb

@ -126,6 +126,11 @@ class Log < ApplicationRecord
end end
end end
def field_formatted_as_currency(field_name)
field_value = public_send(field_name)
format_as_currency(field_value)
end
private private
def plural_gender_for_person(person_num) def plural_gender_for_person(person_num)

7
app/models/sales_log.rb

@ -216,7 +216,7 @@ class SalesLog < Log
def expected_shared_ownership_deposit_value def expected_shared_ownership_deposit_value
return unless value && equity return unless value && equity
format_as_currency(value * equity / 100) value * equity / 100
end end
def process_postcode(postcode, postcode_known_key, la_inferred_key, la_key) def process_postcode(postcode, postcode_known_key, la_inferred_key, la_key)
@ -323,11 +323,6 @@ class SalesLog < Log
format_as_currency(soft_min) format_as_currency(soft_min)
end end
def field_formatted_as_currency(field_name)
field_value = public_send(field_name)
format_as_currency(field_value)
end
def should_process_uprn_change? def should_process_uprn_change?
uprn_changed? && saledate && saledate.year >= 2023 uprn_changed? && saledate && saledate.year >= 2023
end end

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 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"

73
spec/helpers/interruption_screen_helper_spec.rb

@ -4,9 +4,9 @@ RSpec.describe InterruptionScreenHelper do
form_handler = FormHandler.instance form_handler = FormHandler.instance
let(:form) { form_handler.get_form("test_form") } let(:form) { form_handler.get_form("test_form") }
let(:subsection) { form.get_subsection("household_characteristics") } let(:subsection) { form.get_subsection("household_characteristics") }
let(:user) { FactoryBot.create(:user) } let(:user) { create(:user) }
let(:lettings_log) do let(:lettings_log) do
FactoryBot.create( create(
:lettings_log, :lettings_log,
:in_progress, :in_progress,
ecstat1: 1, ecstat1: 1,
@ -14,6 +14,7 @@ RSpec.describe InterruptionScreenHelper do
incfreq: 1, incfreq: 1,
created_by: user, created_by: user,
sex1: "F", sex1: "F",
brent: 12_345,
) )
end end
@ -45,7 +46,13 @@ RSpec.describe InterruptionScreenHelper do
], ],
} }
expect(display_informative_text(informative_text, lettings_log)) expect(display_informative_text(informative_text, lettings_log))
.to eq(I18n.t("soft_validations.net_income.hint_text", ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase, earnings: lettings_log.form.get_question("earnings", lettings_log).answer_label(lettings_log))) .to eq(
I18n.t(
"soft_validations.net_income.hint_text",
ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase,
earnings: lettings_log.form.get_question("earnings", lettings_log).answer_label(lettings_log),
),
)
end end
end end
@ -62,7 +69,12 @@ RSpec.describe InterruptionScreenHelper do
], ],
} }
expect(display_informative_text(informative_text, lettings_log)) expect(display_informative_text(informative_text, lettings_log))
.to eq(I18n.t("test.one_argument", ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase)) .to eq(
I18n.t(
"test.one_argument",
ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase,
),
)
end end
end end
@ -84,7 +96,12 @@ RSpec.describe InterruptionScreenHelper do
], ],
} }
expect(display_informative_text(informative_text, lettings_log)) expect(display_informative_text(informative_text, lettings_log))
.to eq(I18n.t("test.one_argument", ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase)) .to eq(
I18n.t(
"test.one_argument",
ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase,
),
)
end end
end end
@ -126,15 +143,15 @@ RSpec.describe InterruptionScreenHelper do
informative_text_hash = { informative_text_hash = {
"arguments" => [ "arguments" => [
{ {
"key" => "retirement_age_for_person", "key" => "field_formatted_as_currency",
"arguments_for_key" => 1, "arguments_for_key" => "brent",
"i18n_template" => "argument", "i18n_template" => "argument",
}, },
], ],
} }
allow(lettings_log).to receive(:retirement_age_for_person) allow(lettings_log).to receive(:field_formatted_as_currency)
display_informative_text(informative_text_hash, lettings_log) display_informative_text(informative_text_hash, lettings_log)
expect(lettings_log).to have_received(:retirement_age_for_person).with(1) expect(lettings_log).to have_received(:field_formatted_as_currency).with("brent")
end end
it "returns the correct text" do it "returns the correct text" do
@ -143,13 +160,13 @@ RSpec.describe InterruptionScreenHelper do
"translation" => translation, "translation" => translation,
"arguments" => [ "arguments" => [
{ {
"key" => "retirement_age_for_person", "key" => "field_formatted_as_currency",
"arguments_for_key" => 1, "arguments_for_key" => "brent",
"i18n_template" => "argument", "i18n_template" => "argument",
}, },
], ],
} }
expect(display_informative_text(informative_text_hash, lettings_log)).to eq(I18n.t(translation, argument: lettings_log.retirement_age_for_person(1))) expect(display_informative_text(informative_text_hash, lettings_log)).to eq("You said this: £12,345.00")
end end
end end
end end
@ -178,6 +195,38 @@ RSpec.describe InterruptionScreenHelper do
expect(display_title_text(title_text, lettings_log)) expect(display_title_text(title_text, lettings_log))
.to eq(I18n.t("test.title_text.one_argument", argument: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase)) .to eq(I18n.t("test.title_text.one_argument", argument: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase))
end end
context "when and argument is given with a key and arguments for the key" do
it "makes the correct method call" do
title_text = {
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "brent",
"i18n_template" => "argument",
},
],
}
allow(lettings_log).to receive(:field_formatted_as_currency)
display_title_text(title_text, lettings_log)
expect(lettings_log).to have_received(:field_formatted_as_currency).with("brent")
end
it "returns the correct text" do
translation = "test.title_text.one_argument"
title_text = {
"translation" => translation,
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "brent",
"i18n_template" => "argument",
},
],
}
expect(display_title_text(title_text, lettings_log)).to eq("You said this: £12,345.00")
end
end
end end
context "when title text is not defined" do context "when title text is not defined" do

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 }], "translation" => "soft_validations.rent.outside_range_title" })
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({ "arguments" => [{ "arguments_for_key" => "soft_max_for_period", "i18n_template" => "soft_max_for_period", "key" => "field_formatted_as_currency" }], "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 }],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"arguments" => [{ "arguments_for_key" => "soft_min_for_period", "i18n_template" => "soft_min_for_period", "key" => "field_formatted_as_currency" }],
"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" => [{ "arguments_for_key" => "ecstat1", "i18n_template" => "ecstat1", "key" => "field_formatted_as_currency" }, { "arguments_for_key" => "earnings", "i18n_template" => "earnings", "key" => "field_formatted_as_currency" }],
"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 }], "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" => [{ "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" => "soft_validations.discounted_sale_value.informative_text",
"arguments" => [{ "key" => "mortgage_deposit_and_grant_total", "label" => false, "i18n_template" => "mortgage_deposit_and_grant_total" }], "arguments" => [{ "arguments_for_key" => "mortgage_deposit_and_grant_total", "i18n_template" => "mortgage_deposit_and_grant_total", "key" => "field_formatted_as_currency" }],
}) })
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" => [{ "arguments_for_key" => "expected_shared_ownership_deposit_value", "i18n_template" => "expected_shared_ownership_deposit_value", "key" => "field_formatted_as_currency" }],
{
"key" => "expected_shared_ownership_deposit_value",
"label" => false,
"i18n_template" => "expected_shared_ownership_deposit_value",
},
],
}) })
end end

2
spec/models/sales_log_spec.rb

@ -498,7 +498,7 @@ RSpec.describe SalesLog, type: :model do
let!(:completed_sales_log) { create(:sales_log, :completed, ownershipsch: 1, type: 2, value: 1000, equity: 50) } let!(:completed_sales_log) { create(:sales_log, :completed, ownershipsch: 1, type: 2, value: 1000, equity: 50) }
it "is set to completed for a completed sales log" do it "is set to completed for a completed sales log" do
expect(completed_sales_log.expected_shared_ownership_deposit_value).to eq("£500.00") expect(completed_sales_log.expected_shared_ownership_deposit_value).to eq(500)
end end
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