From 9cb8d89ef7a51d5ed69c218b05fdefa54074e712 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 25 Jan 2023 15:00:45 +0000 Subject: [PATCH] feat: add 22/23 year validation --- app/models/sales_log.rb | 1 + .../validations/sales/setup_validations.rb | 9 +++++++++ config/locales/en.yml | 16 +++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 app/models/validations/sales/setup_validations.rb diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 45bd9f729..826ae4860 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -1,4 +1,5 @@ class SalesLogValidator < ActiveModel::Validator + include Validations::Sales::SetupValidations include Validations::Sales::HouseholdValidations include Validations::Sales::PropertyValidations include Validations::SharedValidations diff --git a/app/models/validations/sales/setup_validations.rb b/app/models/validations/sales/setup_validations.rb new file mode 100644 index 000000000..1f5602fd0 --- /dev/null +++ b/app/models/validations/sales/setup_validations.rb @@ -0,0 +1,9 @@ +module Validations::Sales::SetupValidations + def validate_saledate(record) + return unless record.saledate + + if record.saledate < Time.zone.local(2022, 4, 1) + record.errors.add :saledate, I18n.t("validations.setup.saledate.financial_year") + end + end +end diff --git a/config/locales/en.yml b/config/locales/en.yml index 68c7199de..f44004d77 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -147,6 +147,8 @@ en: setup: intermediate_rent_product_name: blank: "Enter name of other intermediate rent product" + saledate: + financial_year: "Date must be from 22/23 financial year" startdate: later_than_14_days_after: "The tenancy start date must not be later than 14 days from today’s date" before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme" @@ -301,7 +303,7 @@ en: child_over_20: "Answer cannot be 20 or over as the relationship is ‘child’" not_student_16_19: "Answer cannot be between 16 and 19 as person %{person_num} is a child of the lead tenant but is not a full-time student" student_16_19: - cannot_be_16_19: + cannot_be_16_19: student_not_child: "Person cannot be aged 16-19 if they are a student but don't have relationship ‘child’" child_not_student: "Person cannot be aged 16-19 if they have relationship ‘child’ but are not a student" must_be_16_19: "Person must be aged 16-19 if they are a student and have relationship ‘child’" @@ -313,8 +315,8 @@ en: child_under_16: "Person’s %{person_num} working situation must be ’child under 16‘ as you told us they’re under 16" child_over_16: "Answer cannot be ‘child under 16’ as you told us the person %{person_num} is older than 16" not_student_16_19: "Person’s %{person_num} working situation must be full-time student or prefers not to say as you told us they’re between 16 and 19." - student_16_19: - cannot_be_student: + student_16_19: + cannot_be_student: child_not_16_19: "Person cannot be a student if they are not aged 16-19 but have relationship ‘child’" 16_19_not_child: "Person cannot be a student if they are aged 16-19 but don‘t have relationship ‘child’" must_be_student: "Person must be a student if they are aged 16-19 and have relationship ‘child’" @@ -326,8 +328,8 @@ en: child_over_20: "Answer cannot be ‘child’ if the person's age is 20 or over" one_partner: "Number of partners cannot be greater than 1" not_student_16_19: "Answer cannot be ‘child’ as you told us the person %{person_num} is between 16 and 19 and is not a full-time student" - student_16_19: - cannot_be_child: + student_16_19: + cannot_be_child: student_not_16_19: "Answer cannot be ‘child’ if the person is a student but not aged 16-19" 16_19_not_student: "Answer cannot be ‘child’ if the person is aged 16-19 but not a student" must_be_child: "Answer must be ‘child’ if the person is aged 16-19 and a student" @@ -413,9 +415,9 @@ en: deactivation: during_deactivated_period: "The location is already deactivated during this date, please enter a different date" sale_information: - previous_property_beds: + previous_property_beds: property_type_bedsit: "Bedsit bedroom maximum 1" - previous_property_type: + previous_property_type: property_type_bedsit: "A bedsit can not have more than 1 bedroom" soft_validations: