Browse Source

CLDC-3546: Add error to managing org when it does not have relevant rent period

pull/2538/head
Rachael Booth 2 years ago
parent
commit
d750e9ee7b
  1. 7
      app/models/validations/financial_validations.rb
  2. 1
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  3. 4
      config/locales/en.yml
  4. 8
      spec/models/validations/financial_validations_spec.rb

7
app/models/validations/financial_validations.rb

@ -149,7 +149,12 @@ module Validations::FinancialValidations
unless record.managing_organisation.rent_periods.include? record.period
record.errors.add :period, :wrong_rent_period, message: I18n.t(
"validations.financial.rent_period.invalid_for_org",
"validations.financial.rent_period.invalid_for_org.period",
org_name: record.managing_organisation.name,
rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase,
)
record.errors.add :managing_organisation, :skip_bu_error, message: I18n.t(
"validations.financial.rent_period.invalid_for_org.managing_org",
org_name: record.managing_organisation.name,
rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase,
)

1
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -467,6 +467,7 @@ class BulkUpload::Lettings::Year2024::RowParser
fields.each do |field|
next if errors.include?(field)
next if error.type == :skip_bu_error
question = log.form.get_question(error.attribute, log)

4
config/locales/en.yml

@ -436,7 +436,9 @@ en:
under_10: "Enter a total charge that is at least £10.00 per week"
less_than_shortfall: "The total charge must be more than the outstanding amount"
rent_period:
invalid_for_org: "%{org_name} does not use %{rent_period} as a rent period. Choose another rent period, or a data coordinator can add rent periods to your organisation"
invalid_for_org:
period: "%{org_name} does not use %{rent_period} as a rent period. Choose another rent period, or a data coordinator can add rent periods to your organisation"
managing_org: "%{org_name} does not use %{rent_period} as a rent period. Set another rent period on this log, or a data coordinator can add rent periods to this organisation"
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}"

8
spec/models/validations/financial_validations_spec.rb

@ -165,7 +165,13 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_period(record)
expect(record.errors["period"])
.to include(match I18n.t(
"validations.financial.rent_period.invalid_for_org",
"validations.financial.rent_period.invalid_for_org.period",
org_name: user.organisation.name,
rent_period: "every 4 weeks",
))
expect(record.errors["managing_organisation"])
.to include(match I18n.t(
"validations.financial.rent_period.invalid_for_org.managing_org",
org_name: user.organisation.name,
rent_period: "every 4 weeks",
))

Loading…
Cancel
Save