Browse Source

CLDC-3420 Check tshortfall for care homes (#2659)

* Check tshortfall for care homes

* Fix BU tests
pull/2666/head^2
kosiakkatrina 3 months ago committed by GitHub
parent
commit
54d15d95ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      app/models/validations/financial_validations.rb
  2. 2
      config/locales/en.yml
  3. 16
      spec/models/validations/financial_validations_spec.rb
  4. 2
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  5. 2
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

5
app/models/validations/financial_validations.rb

@ -121,6 +121,11 @@ module Validations::FinancialValidations
def validate_rent_amount(record)
if record.wtshortfall
if record.is_supported_housing? && record.wchchrg && (record.wtshortfall > record.wchchrg)
record.errors.add :tshortfall, message: I18n.t("validations.financial.tshortfall.more_than_carehome_charge")
record.errors.add :chcharge, I18n.t("validations.financial.carehome.less_than_shortfall")
end
if record.wtcharge && (record.wtshortfall > record.wtcharge)
record.errors.add :tshortfall, :more_than_rent, message: I18n.t("validations.financial.tshortfall.more_than_total_charge")
record.errors.add :tcharge, I18n.t("validations.financial.tcharge.less_than_shortfall")

2
config/locales/en.yml

@ -384,6 +384,7 @@ en:
tshortfall:
outstanding_amount_not_expected: "You cannot answer the outstanding amount question if you don’t have outstanding rent or charges."
more_than_total_charge: "Enter a value less than the total charge."
more_than_carehome_charge: "Enter a value less than the care home charge."
must_be_positive: "Enter a value over £0.01 as you told us there is an outstanding amount."
hbrentshortfall:
outstanding_amount_not_expected: "Answer must be ‘yes’ as you have answered the outstanding amount question."
@ -456,6 +457,7 @@ en:
carehome:
out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}."
not_provided: "Enter how much rent and other charges the household pays %{period}."
less_than_shortfall: "The care home charge must be more than the outstanding amount."
cash_discount_invalid: "Cash discount must be £0 - £999,999."
staircasing:
percentage_bought_must_be_greater_than_percentage_owned: "Total percentage %{buyer_now_owns} must be more than percentage bought in this transaction."

16
spec/models/validations/financial_validations_spec.rb

@ -123,6 +123,22 @@ RSpec.describe Validations::FinancialValidations do
.to include(match I18n.t("validations.financial.tshortfall.more_than_total_charge"))
end
it "validates that carehome charge is no less than the shortfall" do
record.hb = 6
record.hbrentshortfall = 1
record.tshortfall_known = 0
record.tshortfall = 299.50
record.chcharge = 198
record.needstype = 2
record.period = 2
record.set_derived_fields!
financial_validator.validate_rent_amount(record)
expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.carehome.less_than_shortfall"))
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.more_than_carehome_charge"))
end
it "expects that rent can be less than the shortfall if total charge is higher" do
record.hb = 6
record.hbrentshortfall = 1

2
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -215,7 +215,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
field_131: "101.11",
field_132: "1500.19",
field_133: "1",
field_134: "234.56",
field_134: "34.56",
field_27: "15",
field_28: "0",

2
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -235,7 +235,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
field_127: "13.14",
field_128: "101.11",
field_129: "1",
field_130: "234.56",
field_130: "34.56",
field_24: "15",
field_30: now.day.to_s,

Loading…
Cancel
Save