diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index 3fade5b99..32ed2f1bd 100644 --- a/app/models/validations/financial_validations.rb +++ b/app/models/validations/financial_validations.rb @@ -69,11 +69,11 @@ module Validations::FinancialValidations record.errors.add :tcharge, I18n.t("validations.financial.tcharge.under_10") end - answered_questions = [record.tcharge, record.chcharge].concat(!(record.household_charge && record.household_charge.zero?).nil? ? [record.household_charge] : []) + answered_questions = [record.tcharge, record.chcharge].concat(record.household_charge && record.household_charge.zero? ? [record.household_charge] : []) if answered_questions.count(&:present?) > 1 - record.errors.add :tcharge, I18n.t("validations.financial.tcharge.complete_1_of_3") if record.tcharge.present? - record.errors.add :chcharge, I18n.t("validations.financial.chcharge.complete_1_of_3") if record.chcharge.present? - record.errors.add :household_charge, I18n.t("validations.financial.household_charge.complete_1_of_3") if record.household_charge.present? + record.errors.add :tcharge, I18n.t("validations.financial.charges.complete_1_of_3") if record.tcharge.present? + record.errors.add :chcharge, I18n.t("validations.financial.charges.complete_1_of_3") if record.chcharge.present? + record.errors.add :household_charge, I18n.t("validations.financial.charges.complete_1_of_3") if record.household_charge.present? end validate_charges(record) diff --git a/config/locales/en.yml b/config/locales/en.yml index 1e1eb5e29..9236471b8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -94,11 +94,29 @@ en: less_than_double_shortfall: "Answer must be more than double the shortfall in basic rent" scharge: this_landlord: - general_needs: "Service charge must be between 0 and 55 per week if the landlord is this landlord and it is a general needs letting" - supported_housing: "Service charge must be between 0 and 280 per week if the landlord is this landlord and it is a suported housing letting" + general_needs: "Service charge must be between £0 and £55 per week if the landlord is this landlord and it is a general needs letting" + supported_housing: "Service charge must be between £0 and £280 per week if the landlord is this landlord and it is a suported housing letting" other_landlord: - general_needs: "Service charge must be between 0 and 45 per week if the landlord is another RP and it is a general needs letting" - supported_housing: "Service charge must be between 0 and 165 per week if the landlord is another RP and it is a suported housing letting" + general_needs: "Service charge must be between £0 and £45 per week if the landlord is another RP and it is a general needs letting" + supported_housing: "Service charge must be between £0 and £165 per week if the landlord is another RP and it is a suported housing letting" + pscharge: + this_landlord: + general_needs: "Personal service charge must be between £0 and £30 per week if the landlord is this landlord and it is a general needs letting" + supported_housing: "Personal service charge must be between £0 and £200 per week if the landlord is this landlord and it is a suported housing letting" + other_landlord: + general_needs: "Personal service charge must be between £0 and £35 per week if the landlord is another RP and it is a general needs letting" + supported_housing: "Personal service charge must be between £0 and £75 per week if the landlord is another RP and it is a suported housing letting" + supcharg: + this_landlord: + general_needs: "Support charge must be between £0 and £40 per week if the landlord is this landlord and it is a general needs letting" + supported_housing: "Support charge must be between £0 and £465 per week if the landlord is this landlord and it is a suported housing letting" + other_landlord: + general_needs: "Support charge must be between £0 and £60 per week if the landlord is another RP and it is a general needs letting" + supported_housing: "Support charge must be between £0 and £120 per week if the landlord is another RP and it is a suported housing letting" + charges: + complete_1_of_3: 'Only one question out of "Total charge", "Charges for carehomes" and "Does the household pay rent or charges?" needs to be selected and completed' + tcharge: + under_10: "Total charge must be at least £10 per week" household: reasonpref: diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index 83ad13419..15abf7b77 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -139,10 +139,8 @@ FactoryBot.define do armedforces { 0 } builtype { 1 } unitletas { 2 } - household_charge { 1 } has_benefits { 1 } is_carehome { 0 } - chcharge { 7 } letting_in_sheltered_accommodation { 0 } la_known { 1 } declaration { 1 } diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index e086408ae..a5f116f79 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -141,7 +141,6 @@ "has_benefits": 1, "household_charge": 1, "is_carehome": 1, - "chcharge": 6, "letting_in_sheltered_accommodation": 0, "declaration": 1, "referral": 1 diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml index b5917356c..3220b1cd5 100644 --- a/spec/fixtures/exports/case_logs.xml +++ b/spec/fixtures/exports/case_logs.xml @@ -135,7 +135,7 @@ 0 0 0 - 1 + 200.0 50.0 @@ -143,7 +143,7 @@ 35.0 325.0 12.0 - 7.0 + 1 1 diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb index 7e3247533..bc7128087 100644 --- a/spec/models/validations/financial_validations_spec.rb +++ b/spec/models/validations/financial_validations_spec.rb @@ -635,11 +635,11 @@ RSpec.describe Validations::FinancialValidations do record.household_charge = 0 financial_validator.validate_rent_amount(record) expect(record.errors["tcharge"]) - .to include(match I18n.t("validations.financial.tcharge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) expect(record.errors["chcharge"]) - .to include(match I18n.t("validations.financial.chcharge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) expect(record.errors["household_charge"]) - .to include(match I18n.t("validations.financial.household_charge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) end it "returns an error for tcharge and chcharge types selected" do @@ -649,9 +649,9 @@ RSpec.describe Validations::FinancialValidations do expect(record.errors["household_charge"]) .to be_empty expect(record.errors["tcharge"]) - .to include(match I18n.t("validations.financial.tcharge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) expect(record.errors["chcharge"]) - .to include(match I18n.t("validations.financial.chcharge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) end it "returns an error for tcharge and household_charge types selected" do @@ -661,9 +661,9 @@ RSpec.describe Validations::FinancialValidations do expect(record.errors["chcharge"]) .to be_empty expect(record.errors["tcharge"]) - .to include(match I18n.t("validations.financial.tcharge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) expect(record.errors["household_charge"]) - .to include(match I18n.t("validations.financial.household_charge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) end it "returns an error for chcharge and household_charge types selected" do @@ -673,9 +673,9 @@ RSpec.describe Validations::FinancialValidations do expect(record.errors["tcharge"]) .to be_empty expect(record.errors["chcharge"]) - .to include(match I18n.t("validations.financial.chcharge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) expect(record.errors["household_charge"]) - .to include(match I18n.t("validations.financial.household_charge.complete_1_of_3")) + .to include(match I18n.t("validations.financial.charges.complete_1_of_3")) end end