diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index a0b528bde..dcb534efb 100644 --- a/app/models/validations/financial_validations.rb +++ b/app/models/validations/financial_validations.rb @@ -133,8 +133,8 @@ module Validations::FinancialValidations if record.chcharge.blank? # record.errors.add :is_carehome, I18n.t("validations.financial.carehome.not_provided", period:) # record.errors.add :chcharge, I18n.t("validations.financial.carehome.not_provided", period:) - elsif !weekly_value_in_range(record, "chcharge", 10, 1000) - max_chcharge = record.weekly_to_value_per_period(1000) + elsif !weekly_value_in_range(record, "chcharge", 10, 5000) + max_chcharge = record.weekly_to_value_per_period(5000) min_chcharge = record.weekly_to_value_per_period(10) message = I18n.t("validations.financial.carehome.out_of_range", period:, min_chcharge:, max_chcharge:) diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb index 02a2f752f..a325f24d9 100644 --- a/spec/models/validations/financial_validations_spec.rb +++ b/spec/models/validations/financial_validations_spec.rb @@ -916,42 +916,42 @@ RSpec.describe Validations::FinancialValidations do context "and charges are over the valid limit (£1,000 per week)" do it "validates charge when period is weekly for 52 weeks" do record.period = 1 - record.chcharge = 1001 + record.chcharge = 5001 financial_validator.validate_care_home_charges(record) expect(record.errors["chcharge"]) - .to include("Household rent and other charges must be between £10.00 and £1,000.00 if paying weekly for 52 weeks") + .to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks") expect(record.errors["period"]) - .to include("Household rent and other charges must be between £10.00 and £1,000.00 if paying weekly for 52 weeks") + .to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks") end it "validates charge when period is monthly" do record.period = 4 - record.chcharge = 4334 + record.chcharge = 21_667 financial_validator.validate_care_home_charges(record) expect(record.errors["chcharge"]) - .to include("Household rent and other charges must be between £43.00 and £4,333.00 if paying every calendar month") + .to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month") expect(record.errors["period"]) - .to include("Household rent and other charges must be between £43.00 and £4,333.00 if paying every calendar month") + .to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month") end it "validates charge when period is every 2 weeks" do record.period = 2 - record.chcharge = 2001 + record.chcharge = 12_001 financial_validator.validate_care_home_charges(record) expect(record.errors["chcharge"]) - .to include("Household rent and other charges must be between £20.00 and £2,000.00 if paying every 2 weeks") + .to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks") expect(record.errors["period"]) - .to include("Household rent and other charges must be between £20.00 and £2,000.00 if paying every 2 weeks") + .to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks") end it "validates charge when period is every 4 weeks" do record.period = 3 - record.chcharge = 4001 + record.chcharge = 24_001 financial_validator.validate_care_home_charges(record) expect(record.errors["chcharge"]) - .to include("Household rent and other charges must be between £40.00 and £4,000.00 if paying every 4 weeks") + .to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks") expect(record.errors["period"]) - .to include("Household rent and other charges must be between £40.00 and £4,000.00 if paying every 4 weeks") + .to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks") end end @@ -1007,9 +1007,9 @@ RSpec.describe Validations::FinancialValidations do record.chcharge = 9 financial_validator.validate_care_home_charges(record) expect(record.errors["chcharge"]) - .to include("Household rent and other charges must be between £10.00 and £1,000.00 if paying weekly for 52 weeks") + .to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks") expect(record.errors["period"]) - .to include("Household rent and other charges must be between £10.00 and £1,000.00 if paying weekly for 52 weeks") + .to include("Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks") end it "validates charge when period is monthly" do @@ -1017,9 +1017,9 @@ RSpec.describe Validations::FinancialValidations do record.chcharge = 42 financial_validator.validate_care_home_charges(record) expect(record.errors["chcharge"]) - .to include("Household rent and other charges must be between £43.00 and £4,333.00 if paying every calendar month") + .to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month") expect(record.errors["period"]) - .to include("Household rent and other charges must be between £43.00 and £4,333.00 if paying every calendar month") + .to include("Household rent and other charges must be between £43.00 and £21,666.00 if paying every calendar month") end it "validates charge when period is every 2 weeks" do @@ -1027,9 +1027,9 @@ RSpec.describe Validations::FinancialValidations do record.chcharge = 19 financial_validator.validate_care_home_charges(record) expect(record.errors["chcharge"]) - .to include("Household rent and other charges must be between £20.00 and £2,000.00 if paying every 2 weeks") + .to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks") expect(record.errors["period"]) - .to include("Household rent and other charges must be between £20.00 and £2,000.00 if paying every 2 weeks") + .to include("Household rent and other charges must be between £20.00 and £10,000.00 if paying every 2 weeks") end it "validates charge when period is every 4 weeks" do @@ -1037,9 +1037,9 @@ RSpec.describe Validations::FinancialValidations do record.chcharge = 39 financial_validator.validate_care_home_charges(record) expect(record.errors["chcharge"]) - .to include("Household rent and other charges must be between £40.00 and £4,000.00 if paying every 4 weeks") + .to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks") expect(record.errors["period"]) - .to include("Household rent and other charges must be between £40.00 and £4,000.00 if paying every 4 weeks") + .to include("Household rent and other charges must be between £40.00 and £20,000.00 if paying every 4 weeks") end end end diff --git a/spec/services/imports/lettings_logs_import_service_spec.rb b/spec/services/imports/lettings_logs_import_service_spec.rb index 40c92c5ce..d8d1ab401 100644 --- a/spec/services/imports/lettings_logs_import_service_spec.rb +++ b/spec/services/imports/lettings_logs_import_service_spec.rb @@ -908,7 +908,7 @@ RSpec.describe Imports::LettingsLogsImportService do before do scheme1.update!(registered_under_care_act: 2) - lettings_log_xml.at_xpath("//xmlns:Q18b").content = "2000" + lettings_log_xml.at_xpath("//xmlns:Q18b").content = "6000" lettings_log_xml.at_xpath("//xmlns:Q17").content = "1" lettings_log_xml.at_xpath("//xmlns:Q18ai").content = "" lettings_log_xml.at_xpath("//xmlns:Q18aii").content = "" @@ -918,7 +918,7 @@ RSpec.describe Imports::LettingsLogsImportService do end it "intercepts the relevant validation error" do - expect(logger).to receive(:warn).with(/Removing chcharge with error: Household rent and other charges must be between £10.00 and £1,000.00 if paying weekly for 52 weeks/) + expect(logger).to receive(:warn).with(/Removing chcharge with error: Household rent and other charges must be between £10.00 and £5,000.00 if paying weekly for 52 weeks/) expect { lettings_log_service.send(:create_log, lettings_log_xml) } .not_to raise_error end