diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index 5e7d92d2c..9b6236029 100644 --- a/app/models/validations/financial_validations.rb +++ b/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, ) diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index b912c167b..2e54f5c3f 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/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) diff --git a/config/locales/en.yml b/config/locales/en.yml index a70e7082b..b6ba761f2 100644 --- a/config/locales/en.yml +++ b/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}" diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb index c743381f7..a96f895f3 100644 --- a/spec/models/validations/financial_validations_spec.rb +++ b/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", ))