From 51bc0cffeb55d1f0c8f4734e4b0cabad241be5e0 Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Thu, 31 Oct 2024 19:04:18 +0000
Subject: [PATCH 01/27] CLDC-3665 Extract sale information copy (#2711)
* Extract shared ownership copy
* Extract discounted ownership copy
* rename files
* CLDC-3665 Extract sale information soft validations (#2712)
* Extract shared ownership copy
* Extract shared ownership soft validations
* Extract discounted ownership validations
* Fix mappings
* Update some translations
* Remove full stops
---
app/helpers/interruption_screen_helper.rb | 1 +
.../form/sales/pages/about_staircase.rb | 2 +-
app/models/form/sales/pages/buyer_previous.rb | 1 +
app/models/form/sales/pages/deposit.rb | 2 +-
.../pages/deposit_and_mortgage_value_check.rb | 5 +-
.../form/sales/pages/deposit_discount.rb | 2 +-
.../form/sales/pages/deposit_value_check.rb | 2 +-
app/models/form/sales/pages/discount.rb | 2 +-
.../pages/discounted_sale_value_check.rb | 5 +-
app/models/form/sales/pages/equity.rb | 2 +-
app/models/form/sales/pages/exchange_date.rb | 1 +
.../form/sales/pages/extra_borrowing.rb | 2 +-
.../pages/extra_borrowing_value_check.rb | 5 +-
app/models/form/sales/pages/grant.rb | 2 +-
.../form/sales/pages/grant_value_check.rb | 5 +-
app/models/form/sales/pages/handover_date.rb | 1 +
.../form/sales/pages/handover_date_check.rb | 3 +-
app/models/form/sales/pages/la_nominations.rb | 1 +
.../form/sales/pages/leasehold_charges.rb | 1 +
.../sales/pages/living_before_purchase.rb | 3 +-
app/models/form/sales/pages/monthly_rent.rb | 1 +
.../form/sales/pages/mortgage_amount.rb | 2 +-
.../form/sales/pages/mortgage_lender.rb | 2 +-
.../form/sales/pages/mortgage_lender_other.rb | 2 +-
.../form/sales/pages/mortgage_length.rb | 1 +
app/models/form/sales/pages/mortgageused.rb | 2 +-
.../form/sales/pages/previous_bedrooms.rb | 2 +-
.../sales/pages/previous_property_type.rb | 2 +-
.../form/sales/pages/previous_tenure.rb | 1 +
app/models/form/sales/pages/purchase_price.rb | 2 +-
.../purchase_price_outright_ownership.rb | 12 +-
app/models/form/sales/pages/resale.rb | 1 +
.../shared_ownership_deposit_value_check.rb | 4 +-
app/models/form/sales/pages/staircase.rb | 1 +
.../pages/staircase_bought_value_check.rb | 5 +-
.../pages/staircase_owned_value_check.rb | 7 +-
.../sales/pages/value_shared_ownership.rb | 2 +-
.../form/sales/questions/buyer_previous.rb | 3 +-
.../form/sales/questions/deposit_amount.rb | 11 +-
.../deposit_and_mortgage_value_check.rb | 3 +-
.../form/sales/questions/deposit_discount.rb | 4 +-
.../sales/questions/deposit_value_check.rb | 6 +-
app/models/form/sales/questions/discount.rb | 6 +-
.../questions/discounted_sale_value_check.rb | 3 +-
app/models/form/sales/questions/equity.rb | 4 +-
.../form/sales/questions/exchange_date.rb | 3 +-
.../form/sales/questions/extra_borrowing.rb | 4 +-
.../questions/extra_borrowing_value_check.rb | 3 +-
app/models/form/sales/questions/fromprop.rb | 4 +-
app/models/form/sales/questions/grant.rb | 4 +-
.../form/sales/questions/grant_value_check.rb | 3 +-
.../form/sales/questions/handover_date.rb | 4 +-
.../sales/questions/handover_date_check.rb | 3 +-
.../sales/questions/has_leasehold_charges.rb | 4 +-
.../form/sales/questions/la_nominations.rb | 4 +-
.../form/sales/questions/leasehold_charges.rb | 3 +-
.../sales/questions/living_before_purchase.rb | 4 +-
.../questions/living_before_purchase_years.rb | 22 +-
.../form/sales/questions/monthly_rent.rb | 4 +-
.../form/sales/questions/mortgage_amount.rb | 4 +-
.../form/sales/questions/mortgage_lender.rb | 4 +-
.../sales/questions/mortgage_lender_other.rb | 3 +-
.../form/sales/questions/mortgage_length.rb | 4 +-
.../form/sales/questions/mortgageused.rb | 3 +-
.../form/sales/questions/previous_bedrooms.rb | 4 +-
.../form/sales/questions/previous_tenure.rb | 4 +-
.../form/sales/questions/purchase_price.rb | 14 +-
app/models/form/sales/questions/resale.rb | 4 +-
.../shared_ownership_deposit_value_check.rb | 3 +-
app/models/form/sales/questions/staircase.rb | 4 +-
.../form/sales/questions/staircase_bought.rb | 3 +-
.../questions/staircase_bought_value_check.rb | 3 +-
.../form/sales/questions/staircase_owned.rb | 3 +-
.../questions/staircase_owned_value_check.rb | 7 +-
.../form/sales/questions/staircase_sale.rb | 3 +-
app/models/form/sales/questions/value.rb | 4 +-
config/locales/en.yml | 41 ----
.../forms/2023/sales/sale_information.en.yml | 208 ++++++++++++++++++
.../forms/2023/sales/soft_validations.en.yml | 130 ++++++++---
.../forms/2024/sales/sale_information.en.yml | 207 +++++++++++++++++
.../forms/2024/sales/soft_validations.en.yml | 133 ++++++++---
.../subsections/tenancy_information_spec.rb | 2 +-
.../pages/discounted_sale_value_check_spec.rb | 7 +-
.../sales/pages/handover_date_check_spec.rb | 5 +-
...ared_ownership_deposit_value_check_spec.rb | 9 +-
.../pages/staircase_owned_value_check_spec.rb | 9 +-
.../questions/deposit_value_check_spec.rb | 2 +-
.../living_before_purchase_years_spec.rb | 2 +-
.../staircase_owned_value_check_spec.rb | 2 +-
89 files changed, 754 insertions(+), 283 deletions(-)
create mode 100644 config/locales/forms/2023/sales/sale_information.en.yml
create mode 100644 config/locales/forms/2024/sales/sale_information.en.yml
diff --git a/app/helpers/interruption_screen_helper.rb b/app/helpers/interruption_screen_helper.rb
index b28c7eaa9..7d9a38ddf 100644
--- a/app/helpers/interruption_screen_helper.rb
+++ b/app/helpers/interruption_screen_helper.rb
@@ -1,6 +1,7 @@
module InterruptionScreenHelper
def display_informative_text(informative_text, log)
return informative_text if informative_text.is_a? String
+ return "" if informative_text.nil?
return "" unless informative_text["arguments"]
translation_params = {}
diff --git a/app/models/form/sales/pages/about_staircase.rb b/app/models/form/sales/pages/about_staircase.rb
index 4d5882916..d736bae15 100644
--- a/app/models/form/sales/pages/about_staircase.rb
+++ b/app/models/form/sales/pages/about_staircase.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::AboutStaircase < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
- @header = "About the staircasing transaction"
+ @copy_key = "sales.sale_information.about_staircasing"
@depends_on = [{
"staircase" => 1,
"joint_purchase?" => joint_purchase,
diff --git a/app/models/form/sales/pages/buyer_previous.rb b/app/models/form/sales/pages/buyer_previous.rb
index 87f87b66b..0d20207a3 100644
--- a/app/models/form/sales/pages/buyer_previous.rb
+++ b/app/models/form/sales/pages/buyer_previous.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::BuyerPrevious < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
+ @copy_key = "sales.sale_information.soctenant.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@depends_on = [{ "joint_purchase?" => joint_purchase, "soctenant_is_inferred?" => false }]
end
diff --git a/app/models/form/sales/pages/deposit.rb b/app/models/form/sales/pages/deposit.rb
index 3e298e4f6..f0bbda05c 100644
--- a/app/models/form/sales/pages/deposit.rb
+++ b/app/models/form/sales/pages/deposit.rb
@@ -3,7 +3,7 @@ class Form::Sales::Pages::Deposit < ::Form::Page
super(id, hsh, subsection)
@ownershipsch = ownershipsch
@optional = optional
- @header = "About the deposit"
+ @copy_key = "sales.sale_information.deposit"
end
def questions
diff --git a/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb b/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb
index fe5ad4acb..142c79cb5 100644
--- a/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb
+++ b/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb
@@ -6,8 +6,9 @@ class Form::Sales::Pages::DepositAndMortgageValueCheck < ::Form::Page
"mortgage_plus_deposit_less_than_discounted_value?" => true,
},
]
+ @copy_key = "sales.soft_validations.deposit_and_mortgage_value_check"
@title_text = {
- "translation" => "soft_validations.deposit_and_mortgage.title_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "mortgage",
@@ -27,7 +28,7 @@ class Form::Sales::Pages::DepositAndMortgageValueCheck < ::Form::Page
],
}
@informative_text = {
- "translation" => "soft_validations.deposit_and_mortgage.hint_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
diff --git a/app/models/form/sales/pages/deposit_discount.rb b/app/models/form/sales/pages/deposit_discount.rb
index 6931a7510..caf726460 100644
--- a/app/models/form/sales/pages/deposit_discount.rb
+++ b/app/models/form/sales/pages/deposit_discount.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::DepositDiscount < ::Form::Page
def initialize(id, hsh, subsection, optional:)
super(id, hsh, subsection)
@optional = optional
- @header = "About the deposit"
+ @copy_key = "sales.sale_information.cashdis"
end
def questions
diff --git a/app/models/form/sales/pages/deposit_value_check.rb b/app/models/form/sales/pages/deposit_value_check.rb
index cbec4b031..fea99b28b 100644
--- a/app/models/form/sales/pages/deposit_value_check.rb
+++ b/app/models/form/sales/pages/deposit_value_check.rb
@@ -26,7 +26,7 @@ class Form::Sales::Pages::DepositValueCheck < ::Form::Page
def questions
@questions ||= [
- Form::Sales::Questions::DepositValueCheck.new(nil, nil, self),
+ Form::Sales::Questions::DepositValueCheck.new(nil, nil, self, joint_purchase: @joint_purchase),
]
end
diff --git a/app/models/form/sales/pages/discount.rb b/app/models/form/sales/pages/discount.rb
index 56670075b..2d632985e 100644
--- a/app/models/form/sales/pages/discount.rb
+++ b/app/models/form/sales/pages/discount.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::Discount < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "discount"
- @header = "About the price of the property"
+ @copy_key = "sales.sale_information.discount"
@depends_on = [{
"right_to_buy?" => true,
}]
diff --git a/app/models/form/sales/pages/discounted_sale_value_check.rb b/app/models/form/sales/pages/discounted_sale_value_check.rb
index dcb820e49..4fbff90c6 100644
--- a/app/models/form/sales/pages/discounted_sale_value_check.rb
+++ b/app/models/form/sales/pages/discounted_sale_value_check.rb
@@ -2,8 +2,9 @@ class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page
def initialize(id, hsh, subsection, person_index = nil)
super(id, hsh, subsection)
@depends_on = depends_on
+ @copy_key = "sales.soft_validations.discounted_sale_value_check"
@title_text = {
- "translation" => "soft_validations.discounted_sale_value.title_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@@ -13,7 +14,7 @@ class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page
],
}
@informative_text = {
- "translation" => "soft_validations.discounted_sale_value.informative_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
diff --git a/app/models/form/sales/pages/equity.rb b/app/models/form/sales/pages/equity.rb
index 018ba6f79..9bf3050a0 100644
--- a/app/models/form/sales/pages/equity.rb
+++ b/app/models/form/sales/pages/equity.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::Equity < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "equity"
- @header = "About the price of the property"
+ @copy_key = "sales.sale_information.equity"
end
def questions
diff --git a/app/models/form/sales/pages/exchange_date.rb b/app/models/form/sales/pages/exchange_date.rb
index ec71b0647..4317c39e0 100644
--- a/app/models/form/sales/pages/exchange_date.rb
+++ b/app/models/form/sales/pages/exchange_date.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::ExchangeDate < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "exchange_contracts"
+ @copy_key = "sales.sale_information.exchange_date"
@depends_on = [{
"resale" => 2,
}]
diff --git a/app/models/form/sales/pages/extra_borrowing.rb b/app/models/form/sales/pages/extra_borrowing.rb
index 4bb8d0530..c6ddb705a 100644
--- a/app/models/form/sales/pages/extra_borrowing.rb
+++ b/app/models/form/sales/pages/extra_borrowing.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::ExtraBorrowing < ::Form::Page
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@ownershipsch = ownershipsch
- @header = ""
+ @copy_key = "sales.sale_information.extrabor"
@description = ""
@subsection = subsection
@depends_on = [{
diff --git a/app/models/form/sales/pages/extra_borrowing_value_check.rb b/app/models/form/sales/pages/extra_borrowing_value_check.rb
index b3cf0b2db..9fc621611 100644
--- a/app/models/form/sales/pages/extra_borrowing_value_check.rb
+++ b/app/models/form/sales/pages/extra_borrowing_value_check.rb
@@ -6,8 +6,9 @@ class Form::Sales::Pages::ExtraBorrowingValueCheck < Form::Page
"extra_borrowing_expected_but_not_reported?" => true,
},
]
+ @copy_key = "sales.soft_validations.extra_borrowing_value_check"
@title_text = {
- "translation" => "soft_validations.extra_borrowing.title_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@@ -17,7 +18,7 @@ class Form::Sales::Pages::ExtraBorrowingValueCheck < Form::Page
],
}
@informative_text = {
- "translation" => "soft_validations.extra_borrowing.hint_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
diff --git a/app/models/form/sales/pages/grant.rb b/app/models/form/sales/pages/grant.rb
index 7c7d2a625..2f96701c5 100644
--- a/app/models/form/sales/pages/grant.rb
+++ b/app/models/form/sales/pages/grant.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::Grant < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "grant"
- @header = "About the price of the property"
+ @copy_key = "sales.sale_information.grant"
@depends_on = [{
"right_to_buy?" => false,
"rent_to_buy_full_ownership?" => false,
diff --git a/app/models/form/sales/pages/grant_value_check.rb b/app/models/form/sales/pages/grant_value_check.rb
index 6b53d74ee..0c5d50901 100644
--- a/app/models/form/sales/pages/grant_value_check.rb
+++ b/app/models/form/sales/pages/grant_value_check.rb
@@ -2,13 +2,14 @@ class Form::Sales::Pages::GrantValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "grant_value_check"
+ @copy_key = "sales.soft_validations.grant_value_check"
@depends_on = [
{
"grant_outside_common_range?" => true,
},
]
@title_text = {
- "translation" => "soft_validations.grant.title_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@@ -18,7 +19,7 @@ class Form::Sales::Pages::GrantValueCheck < ::Form::Page
],
}
@informative_text = {
- "translation" => "soft_validations.grant.hint_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
diff --git a/app/models/form/sales/pages/handover_date.rb b/app/models/form/sales/pages/handover_date.rb
index 35fbe7822..c40effc8e 100644
--- a/app/models/form/sales/pages/handover_date.rb
+++ b/app/models/form/sales/pages/handover_date.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::HandoverDate < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "handover_date"
+ @copy_key = "sales.sale_information.handover_date"
@depends_on = [
{ "ownershipsch" => 1, "resale" => 2 },
]
diff --git a/app/models/form/sales/pages/handover_date_check.rb b/app/models/form/sales/pages/handover_date_check.rb
index e8d666f60..690c3dde7 100644
--- a/app/models/form/sales/pages/handover_date_check.rb
+++ b/app/models/form/sales/pages/handover_date_check.rb
@@ -2,11 +2,12 @@ class Form::Sales::Pages::HandoverDateCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "handover_date_check"
+ @copy_key = "sales.soft_validations.hodate_check"
@depends_on = [{ "saledate_check" => nil, "hodate_3_years_or_more_saledate?" => true },
{ "saledate_check" => 1, "hodate_3_years_or_more_saledate?" => true }]
@informative_text = {}
@title_text = {
- "translation" => "soft_validations.hodate.must_be_less_than_3_years_from_saledate",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
end
diff --git a/app/models/form/sales/pages/la_nominations.rb b/app/models/form/sales/pages/la_nominations.rb
index fc3f39f6a..6adda533d 100644
--- a/app/models/form/sales/pages/la_nominations.rb
+++ b/app/models/form/sales/pages/la_nominations.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::LaNominations < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "la_nominations"
+ @copy_key = "sales.sale_information.la_nominations"
end
def questions
diff --git a/app/models/form/sales/pages/leasehold_charges.rb b/app/models/form/sales/pages/leasehold_charges.rb
index a8ce52805..72b2eeea3 100644
--- a/app/models/form/sales/pages/leasehold_charges.rb
+++ b/app/models/form/sales/pages/leasehold_charges.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::LeaseholdCharges < ::Form::Page
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@ownershipsch = ownershipsch
+ @copy_key = "sales.sale_information.leaseholdcharges"
end
def questions
diff --git a/app/models/form/sales/pages/living_before_purchase.rb b/app/models/form/sales/pages/living_before_purchase.rb
index c5dd64330..3bb5510ce 100644
--- a/app/models/form/sales/pages/living_before_purchase.rb
+++ b/app/models/form/sales/pages/living_before_purchase.rb
@@ -3,12 +3,13 @@ class Form::Sales::Pages::LivingBeforePurchase < ::Form::Page
super(id, hsh, subsection)
@ownershipsch = ownershipsch
@joint_purchase = joint_purchase
+ @copy_key = "sales.sale_information.living_before_purchase.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
def questions
@questions ||= [
living_before_purchase,
- Form::Sales::Questions::LivingBeforePurchaseYears.new(nil, nil, self, ownershipsch: @ownershipsch),
+ Form::Sales::Questions::LivingBeforePurchaseYears.new(nil, nil, self, ownershipsch: @ownershipsch, joint_purchase: @joint_purchase),
].compact
end
diff --git a/app/models/form/sales/pages/monthly_rent.rb b/app/models/form/sales/pages/monthly_rent.rb
index 29f0d895f..943e47cff 100644
--- a/app/models/form/sales/pages/monthly_rent.rb
+++ b/app/models/form/sales/pages/monthly_rent.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::MonthlyRent < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "monthly_rent"
+ @copy_key = "sales.sale_information.mrent"
end
def questions
diff --git a/app/models/form/sales/pages/mortgage_amount.rb b/app/models/form/sales/pages/mortgage_amount.rb
index 73e306c2a..41fba167c 100644
--- a/app/models/form/sales/pages/mortgage_amount.rb
+++ b/app/models/form/sales/pages/mortgage_amount.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::MortgageAmount < ::Form::Page
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@ownershipsch = ownershipsch
- @header = "Mortgage Amount"
+ @copy_key = "sales.sale_information.mortgage"
@depends_on = [{ "mortgage_used?" => true }]
end
diff --git a/app/models/form/sales/pages/mortgage_lender.rb b/app/models/form/sales/pages/mortgage_lender.rb
index f187815b1..87646a514 100644
--- a/app/models/form/sales/pages/mortgage_lender.rb
+++ b/app/models/form/sales/pages/mortgage_lender.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::MortgageLender < ::Form::Page
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@ownershipsch = ownershipsch
- @header = ""
+ @copy_key = "sales.sale_information.mortgagelender"
@description = ""
@subsection = subsection
@depends_on = [{
diff --git a/app/models/form/sales/pages/mortgage_lender_other.rb b/app/models/form/sales/pages/mortgage_lender_other.rb
index 903a7dba8..903d6518f 100644
--- a/app/models/form/sales/pages/mortgage_lender_other.rb
+++ b/app/models/form/sales/pages/mortgage_lender_other.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::MortgageLenderOther < ::Form::Page
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@ownershipsch = ownershipsch
- @header = ""
+ @copy_key = "sales.sale_information.mortgagelenderother"
@description = ""
@subsection = subsection
@depends_on = [{
diff --git a/app/models/form/sales/pages/mortgage_length.rb b/app/models/form/sales/pages/mortgage_length.rb
index dbc01a695..76c46694a 100644
--- a/app/models/form/sales/pages/mortgage_length.rb
+++ b/app/models/form/sales/pages/mortgage_length.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::MortgageLength < ::Form::Page
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@ownershipsch = ownershipsch
+ @copy_key = "sales.sale_information.mortlen"
@depends_on = [{
"mortgageused" => 1,
}]
diff --git a/app/models/form/sales/pages/mortgageused.rb b/app/models/form/sales/pages/mortgageused.rb
index a4912b12d..ab48b0c2d 100644
--- a/app/models/form/sales/pages/mortgageused.rb
+++ b/app/models/form/sales/pages/mortgageused.rb
@@ -1,7 +1,7 @@
class Form::Sales::Pages::Mortgageused < ::Form::Page
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
- @header = "Mortgage Amount"
+ @copy_key = "sales.sale_information.mortgageused"
@ownershipsch = ownershipsch
end
diff --git a/app/models/form/sales/pages/previous_bedrooms.rb b/app/models/form/sales/pages/previous_bedrooms.rb
index 722822c2d..26b3ef050 100644
--- a/app/models/form/sales/pages/previous_bedrooms.rb
+++ b/app/models/form/sales/pages/previous_bedrooms.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::PreviousBedrooms < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "previous_bedrooms"
- @header = "About the buyers’ previous property"
+ @copy_key = "sales.sale_information.frombeds"
@depends_on = [
{
"soctenant" => 1,
diff --git a/app/models/form/sales/pages/previous_property_type.rb b/app/models/form/sales/pages/previous_property_type.rb
index 8c46963d0..c5dd4f66a 100644
--- a/app/models/form/sales/pages/previous_property_type.rb
+++ b/app/models/form/sales/pages/previous_property_type.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::PreviousPropertyType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "previous_property_type"
- @header = ""
+ @copy_key = "sales.sale_information.fromprop"
@description = ""
@subsection = subsection
@depends_on = [
diff --git a/app/models/form/sales/pages/previous_tenure.rb b/app/models/form/sales/pages/previous_tenure.rb
index 0f4a4b250..c35b6bd67 100644
--- a/app/models/form/sales/pages/previous_tenure.rb
+++ b/app/models/form/sales/pages/previous_tenure.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::PreviousTenure < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "shared_ownership_previous_tenure"
+ @copy_key = "sales.sale_information.socprevten"
@header = ""
@description = ""
@subsection = subsection
diff --git a/app/models/form/sales/pages/purchase_price.rb b/app/models/form/sales/pages/purchase_price.rb
index 2203375ef..0bb1da53e 100644
--- a/app/models/form/sales/pages/purchase_price.rb
+++ b/app/models/form/sales/pages/purchase_price.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::PurchasePrice < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "purchase_price"
- @header = "About the price of the property"
+ @copy_key = "sales.sale_information.purchase_price.discounted_ownership"
@depends_on = [{ "right_to_buy?" => true },
{
"right_to_buy?" => false,
diff --git a/app/models/form/sales/pages/purchase_price_outright_ownership.rb b/app/models/form/sales/pages/purchase_price_outright_ownership.rb
index 897a19c2e..ea42a7001 100644
--- a/app/models/form/sales/pages/purchase_price_outright_ownership.rb
+++ b/app/models/form/sales/pages/purchase_price_outright_ownership.rb
@@ -4,11 +4,21 @@ class Form::Sales::Pages::PurchasePriceOutrightOwnership < ::Form::Page
@depends_on = [
{ "outright_sale_or_discounted_with_full_ownership?" => true },
]
- @header = "About the price of the property"
@top_guidance_partial = "financial_calculations_outright_sale"
@ownershipsch = ownershipsch
end
+ def copy_key
+ case @ownershipsch
+ when 1
+ "sales.sale_information.purchase_price.shared_ownership"
+ when 2
+ "sales.sale_information.purchase_price.discounted_ownership"
+ when 3
+ "sales.sale_information.purchase_price.outright_sale"
+ end
+ end
+
def questions
@questions ||= [
Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: @ownershipsch),
diff --git a/app/models/form/sales/pages/resale.rb b/app/models/form/sales/pages/resale.rb
index ffdbbc046..6f4cd24e2 100644
--- a/app/models/form/sales/pages/resale.rb
+++ b/app/models/form/sales/pages/resale.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::Resale < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "resale"
+ @copy_key = "sales.sale_information.resale"
@depends_on = [
{
"staircase" => 2,
diff --git a/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb b/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb
index bc8df6743..e56db3e38 100644
--- a/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb
+++ b/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb
@@ -6,9 +6,9 @@ class Form::Sales::Pages::SharedOwnershipDepositValueCheck < ::Form::Page
"shared_ownership_deposit_invalid?" => true,
},
]
- @informative_text = {}
+ @copy_key = "sales.soft_validations.shared_ownership_deposit_value_check"
@title_text = {
- "translation" => "soft_validations.shared_ownership_deposit.title_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "mortgage_deposit_and_discount_error_fields",
diff --git a/app/models/form/sales/pages/staircase.rb b/app/models/form/sales/pages/staircase.rb
index 6ab76e2bf..28b0d6b38 100644
--- a/app/models/form/sales/pages/staircase.rb
+++ b/app/models/form/sales/pages/staircase.rb
@@ -2,6 +2,7 @@ class Form::Sales::Pages::Staircase < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "staircasing"
+ @copy_key = "sales.sale_information.staircasing"
end
def questions
diff --git a/app/models/form/sales/pages/staircase_bought_value_check.rb b/app/models/form/sales/pages/staircase_bought_value_check.rb
index 283261a53..3b505f3cc 100644
--- a/app/models/form/sales/pages/staircase_bought_value_check.rb
+++ b/app/models/form/sales/pages/staircase_bought_value_check.rb
@@ -7,8 +7,9 @@ class Form::Sales::Pages::StaircaseBoughtValueCheck < ::Form::Page
"staircase_bought_above_fifty?" => true,
},
]
+ @copy_key = "sales.soft_validations.staircase_bought_value_check"
@title_text = {
- "translation" => "soft_validations.staircase_bought_seems_high.title_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "stairbought",
@@ -17,7 +18,7 @@ class Form::Sales::Pages::StaircaseBoughtValueCheck < ::Form::Page
],
}
@informative_text = {
- "translation" => "soft_validations.staircase_bought_seems_high.hint_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
diff --git a/app/models/form/sales/pages/staircase_owned_value_check.rb b/app/models/form/sales/pages/staircase_owned_value_check.rb
index d83bf7d5d..1a26215e3 100644
--- a/app/models/form/sales/pages/staircase_owned_value_check.rb
+++ b/app/models/form/sales/pages/staircase_owned_value_check.rb
@@ -8,8 +8,9 @@ class Form::Sales::Pages::StaircaseOwnedValueCheck < ::Form::Page
"joint_purchase?" => joint_purchase,
},
]
+ @copy_key = "sales.soft_validations.stairowned_value_check.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@title_text = {
- "translation" => joint_purchase ? "soft_validations.staircase_owned.title_text.two" : "soft_validations.staircase_owned.title_text.one",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "stairowned",
@@ -19,14 +20,14 @@ class Form::Sales::Pages::StaircaseOwnedValueCheck < ::Form::Page
],
}
@informative_text = {
- "translation" => "soft_validations.staircase_owned.hint_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions
@questions ||= [
- Form::Sales::Questions::StaircaseOwnedValueCheck.new(nil, nil, self),
+ Form::Sales::Questions::StaircaseOwnedValueCheck.new(nil, nil, self, joint_purchase: @joint_purchase),
]
end
diff --git a/app/models/form/sales/pages/value_shared_ownership.rb b/app/models/form/sales/pages/value_shared_ownership.rb
index a4f6dbe1c..c2212c787 100644
--- a/app/models/form/sales/pages/value_shared_ownership.rb
+++ b/app/models/form/sales/pages/value_shared_ownership.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::ValueSharedOwnership < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "value_shared_ownership"
- @header = "About the price of the property"
+ @copy_key = "sales.sale_information.value"
end
def questions
diff --git a/app/models/form/sales/questions/buyer_previous.rb b/app/models/form/sales/questions/buyer_previous.rb
index b35a67c5e..dfc0c2fd2 100644
--- a/app/models/form/sales/questions/buyer_previous.rb
+++ b/app/models/form/sales/questions/buyer_previous.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::BuyerPrevious < ::Form::Question
def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page)
@id = "soctenant"
- @check_answer_label = I18n.t("check_answer_labels.soctenant", count: joint_purchase ? 2 : 1)
- @header = I18n.t("questions.soctenant", count: joint_purchase ? 2 : 1)
+ @copy_key = "sales.sale_information.soctenant.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb
index c1d91cc12..41586cd94 100644
--- a/app/models/form/sales/questions/deposit_amount.rb
+++ b/app/models/form/sales/questions/deposit_amount.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:, optional:)
super(id, hsh, subsection)
@id = "deposit"
- @check_answer_label = "Cash deposit"
- @header = "How much cash deposit was paid on the property?"
+ @copy_key = "sales.sale_information.deposit"
@type = "numeric"
@min = 0
@max = 999_999
@@ -25,14 +24,6 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question
2024 => { 1 => 96, 2 => 109, 3 => 116 },
}.freeze
- def hint_text
- if @optional
- "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan. As this is a fully staircased sale this question is optional. If you do not have the information available click save and continue"
- else
- "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan"
- end
- end
-
def top_guidance_partial
return "financial_calculations_shared_ownership" if @ownershipsch == 1
return "financial_calculations_discounted_ownership" if @ownershipsch == 2
diff --git a/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb b/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb
index 263cf4342..3a60e2afa 100644
--- a/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb
+++ b/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::DepositAndMortgageValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "deposit_and_mortgage_value_check"
- @check_answer_label = "Deposit and mortgage against discount confirmation"
- @header = "Are you sure? Mortgage and deposit usually equal or are more than (value - discount)"
+ @copy_key = "sales.soft_validations.deposit_and_mortgage_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
diff --git a/app/models/form/sales/questions/deposit_discount.rb b/app/models/form/sales/questions/deposit_discount.rb
index faf8d76f7..289e3962c 100644
--- a/app/models/form/sales/questions/deposit_discount.rb
+++ b/app/models/form/sales/questions/deposit_discount.rb
@@ -2,15 +2,13 @@ class Form::Sales::Questions::DepositDiscount < ::Form::Question
def initialize(id, hsh, page)
super
@id = "cashdis"
- @check_answer_label = "Cash discount through SocialHomeBuy"
- @header = "How much cash discount was given through Social HomeBuy?"
+ @copy_key = "sales.sale_information.cashdis"
@type = "numeric"
@min = 0
@max = 999_999
@step = 1
@width = 5
@prefix = "£"
- @hint_text = "Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@top_guidance_partial = "financial_calculations_shared_ownership"
end
diff --git a/app/models/form/sales/questions/deposit_value_check.rb b/app/models/form/sales/questions/deposit_value_check.rb
index f8d403d9c..71560fa84 100644
--- a/app/models/form/sales/questions/deposit_value_check.rb
+++ b/app/models/form/sales/questions/deposit_value_check.rb
@@ -1,8 +1,8 @@
class Form::Sales::Questions::DepositValueCheck < ::Form::Question
- def initialize(id, hsh, page)
- super
+ def initialize(id, hsh, page, joint_purchase:)
+ super(id, hsh, page)
@id = "deposit_value_check"
- @copy_key = "sales.soft_validations.deposit_value_check"
+ @copy_key = "sales.soft_validations.deposit_value_check.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb
index f99203ebe..1d8c5a46b 100644
--- a/app/models/form/sales/questions/discount.rb
+++ b/app/models/form/sales/questions/discount.rb
@@ -2,17 +2,13 @@ class Form::Sales::Questions::Discount < ::Form::Question
def initialize(id, hsh, page)
super
@id = "discount"
- @check_answer_label = "Percentage discount"
- @header = "What was the percentage discount?"
@type = "numeric"
+ @copy_key = "sales.sale_information.discount"
@min = 0
@max = form.start_year_after_2024? ? 70 : 100
@step = 0.1
@width = 5
@suffix = "%"
- @hint_text = "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB)
- If discount capped, enter capped %
- If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given."
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@top_guidance_partial = "financial_calculations_discounted_ownership"
end
diff --git a/app/models/form/sales/questions/discounted_sale_value_check.rb b/app/models/form/sales/questions/discounted_sale_value_check.rb
index 1d86b2f32..a02aaac72 100644
--- a/app/models/form/sales/questions/discounted_sale_value_check.rb
+++ b/app/models/form/sales/questions/discounted_sale_value_check.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::DiscountedSaleValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "discounted_sale_value_check"
- @check_answer_label = "Discounted sale value confirmation"
- @header = "Are you sure this is correct?"
+ @copy_key = "sales.soft_validations.discounted_sale_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
diff --git a/app/models/form/sales/questions/equity.rb b/app/models/form/sales/questions/equity.rb
index 2e1ad4dee..dd1a14227 100644
--- a/app/models/form/sales/questions/equity.rb
+++ b/app/models/form/sales/questions/equity.rb
@@ -2,15 +2,13 @@ class Form::Sales::Questions::Equity < ::Form::Question
def initialize(id, hsh, page)
super
@id = "equity"
- @check_answer_label = "Initial percentage equity stake"
- @header = "What was the initial percentage equity stake purchased?"
+ @copy_key = "sales.sale_information.equity"
@type = "numeric"
@min = 0
@max = 100
@step = 1
@width = 5
@suffix = "%"
- @hint_text = "Enter the amount of initial equity held by the purchaser (for example, 25% or 50%)"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@top_guidance_partial = "financial_calculations_shared_ownership"
end
diff --git a/app/models/form/sales/questions/exchange_date.rb b/app/models/form/sales/questions/exchange_date.rb
index 8e9dd4691..a29a7a6c7 100644
--- a/app/models/form/sales/questions/exchange_date.rb
+++ b/app/models/form/sales/questions/exchange_date.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::ExchangeDate < ::Form::Question
def initialize(id, hsh, page)
super
@id = "exdate"
- @check_answer_label = "Exchange of contracts date"
- @header = "What is the exchange of contracts date?"
+ @copy_key = "sales.sale_information.exchange_date"
@type = "date"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/sales/questions/extra_borrowing.rb b/app/models/form/sales/questions/extra_borrowing.rb
index 2b4303423..e3cd0ff7e 100644
--- a/app/models/form/sales/questions/extra_borrowing.rb
+++ b/app/models/form/sales/questions/extra_borrowing.rb
@@ -2,12 +2,10 @@ class Form::Sales::Questions::ExtraBorrowing < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@id = "extrabor"
- @check_answer_label = "Any other borrowing?"
- @header = "Does this include any extra borrowing?"
+ @copy_key = "sales.sale_information.extrabor"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@page = page
- @hint_text = ""
@ownershipsch = ownershipsch
@question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch]
end
diff --git a/app/models/form/sales/questions/extra_borrowing_value_check.rb b/app/models/form/sales/questions/extra_borrowing_value_check.rb
index 0f12ce110..7a251fab8 100644
--- a/app/models/form/sales/questions/extra_borrowing_value_check.rb
+++ b/app/models/form/sales/questions/extra_borrowing_value_check.rb
@@ -2,7 +2,7 @@ class Form::Sales::Questions::ExtraBorrowingValueCheck < ::Form::Question
def initialize(id, hsh, page)
super(id, hsh, page)
@id = "extrabor_value_check"
- @check_answer_label = "Extra borrowing confirmation"
+ @copy_key = "sales.soft_validations.extra_borrowing_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
@@ -18,6 +18,5 @@ class Form::Sales::Questions::ExtraBorrowingValueCheck < ::Form::Question
},
],
}
- @header = "Are you sure there is no extra borrowing?"
end
end
diff --git a/app/models/form/sales/questions/fromprop.rb b/app/models/form/sales/questions/fromprop.rb
index ec17e5939..1a3393b7a 100644
--- a/app/models/form/sales/questions/fromprop.rb
+++ b/app/models/form/sales/questions/fromprop.rb
@@ -2,10 +2,8 @@ class Form::Sales::Questions::Fromprop < ::Form::Question
def initialize(id, hsh, page)
super
@id = "fromprop"
- @check_answer_label = "Previous property type"
- @header = "What was the previous property type?"
+ @copy_key = "sales.sale_information.fromprop"
@type = "radio"
- @hint_text = ""
@page = page
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
diff --git a/app/models/form/sales/questions/grant.rb b/app/models/form/sales/questions/grant.rb
index 45b70d61f..17361fe9c 100644
--- a/app/models/form/sales/questions/grant.rb
+++ b/app/models/form/sales/questions/grant.rb
@@ -2,15 +2,13 @@ class Form::Sales::Questions::Grant < ::Form::Question
def initialize(id, hsh, page)
super
@id = "grant"
- @check_answer_label = "Amount of any loan, grant or subsidy"
- @header = "What was the amount of any loan, grant, discount or subsidy given?"
+ @copy_key = "sales.sale_information.grant"
@type = "numeric"
@min = 0
@max = 999_999
@step = 1
@width = 5
@prefix = "£"
- @hint_text = "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@top_guidance_partial = "financial_calculations_discounted_ownership"
end
diff --git a/app/models/form/sales/questions/grant_value_check.rb b/app/models/form/sales/questions/grant_value_check.rb
index a7efdbaee..63dbb7bac 100644
--- a/app/models/form/sales/questions/grant_value_check.rb
+++ b/app/models/form/sales/questions/grant_value_check.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::GrantValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "grant_value_check"
- @check_answer_label = "Grant value confirmation"
- @header = "Are you sure? Grants are usually £9,000 - £16,000"
+ @copy_key = "sales.soft_validations.grant_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
diff --git a/app/models/form/sales/questions/handover_date.rb b/app/models/form/sales/questions/handover_date.rb
index 5fb55e5c8..8994ecc40 100644
--- a/app/models/form/sales/questions/handover_date.rb
+++ b/app/models/form/sales/questions/handover_date.rb
@@ -2,10 +2,8 @@ class Form::Sales::Questions::HandoverDate < ::Form::Question
def initialize(id, hsh, page)
super
@id = "hodate"
- @check_answer_label = "Practical completion or handover date"
- @header = "What is the practical completion or handover date?"
+ @copy_key = "sales.sale_information.handover_date"
@type = "date"
- @hint_text = "This is the date on which the building contractor hands over responsibility for the completed property to the private registered provider (PRP)"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/sales/questions/handover_date_check.rb b/app/models/form/sales/questions/handover_date_check.rb
index f19ee0196..233c449bb 100644
--- a/app/models/form/sales/questions/handover_date_check.rb
+++ b/app/models/form/sales/questions/handover_date_check.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::HandoverDateCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "hodate_check"
- @check_answer_label = "Practical completion or handover date check"
- @header = "Are you sure?"
+ @copy_key = "sales.soft_validations.hodate_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
diff --git a/app/models/form/sales/questions/has_leasehold_charges.rb b/app/models/form/sales/questions/has_leasehold_charges.rb
index 3e021daa0..fced1d3da 100644
--- a/app/models/form/sales/questions/has_leasehold_charges.rb
+++ b/app/models/form/sales/questions/has_leasehold_charges.rb
@@ -2,9 +2,7 @@ class Form::Sales::Questions::HasLeaseholdCharges < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@id = "has_mscharge"
- @check_answer_label = "Does the property have any monthly leasehold charges?"
- @header = "Does the property have any monthly leasehold charges?"
- @hint_text = "For example, service and management charges"
+ @copy_key = "sales.sale_information.leaseholdcharges.has_mscharge"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = {
diff --git a/app/models/form/sales/questions/la_nominations.rb b/app/models/form/sales/questions/la_nominations.rb
index 0d6e9e249..34540677f 100644
--- a/app/models/form/sales/questions/la_nominations.rb
+++ b/app/models/form/sales/questions/la_nominations.rb
@@ -2,11 +2,9 @@ class Form::Sales::Questions::LaNominations < ::Form::Question
def initialize(id, hsh, page)
super
@id = "lanomagr"
- @check_answer_label = "Household rehoused under a local authority nominations agreement?"
- @header = "Was the household rehoused under a 'local authority nominations agreement'?"
+ @copy_key = "sales.sale_information.la_nominations"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @hint_text = "A local authority nominations agreement is a written agreement between a local authority and private registered provider (PRP) that some or all of its sales vacancies are offered to local authorities for rehousing"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/sales/questions/leasehold_charges.rb b/app/models/form/sales/questions/leasehold_charges.rb
index 2561ccc1d..73d57b1e4 100644
--- a/app/models/form/sales/questions/leasehold_charges.rb
+++ b/app/models/form/sales/questions/leasehold_charges.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::LeaseholdCharges < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@id = "mscharge"
- @check_answer_label = "Monthly leasehold charges"
- @header = "Enter the total monthly charge"
+ @copy_key = "sales.sale_information.leaseholdcharges.mscharge"
@type = "numeric"
@min = 1
@step = 0.01
diff --git a/app/models/form/sales/questions/living_before_purchase.rb b/app/models/form/sales/questions/living_before_purchase.rb
index 9f28d61ee..c4337e38d 100644
--- a/app/models/form/sales/questions/living_before_purchase.rb
+++ b/app/models/form/sales/questions/living_before_purchase.rb
@@ -2,9 +2,7 @@ class Form::Sales::Questions::LivingBeforePurchase < ::Form::Question
def initialize(id, hsh, page, ownershipsch:, joint_purchase:)
super(id, hsh, page)
@id = "proplen_asked"
- @check_answer_label = "#{joint_purchase ? 'Buyers' : 'Buyer'} lived in the property before purchasing"
- @header = "Did the #{joint_purchase ? 'buyers' : 'buyer'} live in the property before purchasing it?"
- @hint_text = nil
+ @copy_key = "sales.sale_information.living_before_purchase.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}.proplen_asked"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = {
diff --git a/app/models/form/sales/questions/living_before_purchase_years.rb b/app/models/form/sales/questions/living_before_purchase_years.rb
index 4ef92a46c..465ba9877 100644
--- a/app/models/form/sales/questions/living_before_purchase_years.rb
+++ b/app/models/form/sales/questions/living_before_purchase_years.rb
@@ -1,10 +1,8 @@
class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question
- def initialize(id, hsh, page, ownershipsch:)
+ def initialize(id, hsh, page, ownershipsch:, joint_purchase:)
super(id, hsh, page)
@id = "proplen"
- @check_answer_label = "Number of years living in the property before purchase"
- @header = header_text
- @hint_text = hint_text
+ @copy_key = "sales.sale_information.living_before_purchase.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}.proplen"
@type = "numeric"
@min = 0
@max = 80
@@ -14,22 +12,6 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question
@question_number = question_number
end
- def header_text
- if form.start_date.year >= 2023
- "How long did they live there?"
- else
- "How long did the buyer(s) live in the property before purchase?"
- end
- end
-
- def hint_text
- if form.start_date.year >= 2023
- "You should round up to the nearest year"
- else
- "You should round this up to the nearest year. If the buyers haven't been living in the property, enter '0'"
- end
- end
-
def suffix_label(log)
" #{'year'.pluralize(log[id])}"
end
diff --git a/app/models/form/sales/questions/monthly_rent.rb b/app/models/form/sales/questions/monthly_rent.rb
index c53f1b7e6..7e64d8571 100644
--- a/app/models/form/sales/questions/monthly_rent.rb
+++ b/app/models/form/sales/questions/monthly_rent.rb
@@ -2,14 +2,12 @@ class Form::Sales::Questions::MonthlyRent < ::Form::Question
def initialize(id, hsh, page)
super
@id = "mrent"
- @check_answer_label = "Monthly rent"
- @header = "What is the basic monthly rent?"
+ @copy_key = "sales.sale_information.mrent"
@type = "numeric"
@min = 0
@step = 0.01
@width = 5
@prefix = "£"
- @hint_text = "Amount paid before any charges"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb
index cfd031f27..a6ffcf26a 100644
--- a/app/models/form/sales/questions/mortgage_amount.rb
+++ b/app/models/form/sales/questions/mortgage_amount.rb
@@ -2,14 +2,12 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@id = "mortgage"
- @check_answer_label = "Mortgage amount"
- @header = "What is the mortgage amount?"
+ @copy_key = "sales.sale_information.mortgage"
@type = "numeric"
@min = 1
@step = 1
@width = 5
@prefix = "£"
- @hint_text = "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound."
@ownershipsch = ownershipsch
@question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch]
@top_guidance_partial = top_guidance_partial
diff --git a/app/models/form/sales/questions/mortgage_lender.rb b/app/models/form/sales/questions/mortgage_lender.rb
index bf4c93b55..c5a10efb4 100644
--- a/app/models/form/sales/questions/mortgage_lender.rb
+++ b/app/models/form/sales/questions/mortgage_lender.rb
@@ -2,10 +2,8 @@ class Form::Sales::Questions::MortgageLender < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@id = "mortgagelender"
- @check_answer_label = "Mortgage Lender"
- @header = "What is the name of the mortgage lender?"
+ @copy_key = "sales.sale_information.mortgagelender"
@type = "select"
- @hint_text = ""
@page = page
@bottom_guidance_partial = "mortgage_lender"
@ownershipsch = ownershipsch
diff --git a/app/models/form/sales/questions/mortgage_lender_other.rb b/app/models/form/sales/questions/mortgage_lender_other.rb
index 677b1c117..49876efb0 100644
--- a/app/models/form/sales/questions/mortgage_lender_other.rb
+++ b/app/models/form/sales/questions/mortgage_lender_other.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::MortgageLenderOther < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@id = "mortgagelenderother"
- @check_answer_label = "Other Mortgage Lender"
- @header = "What is the other mortgage lender?"
+ @copy_key = "sales.sale_information.mortgagelenderother"
@type = "text"
@page = page
@ownershipsch = ownershipsch
diff --git a/app/models/form/sales/questions/mortgage_length.rb b/app/models/form/sales/questions/mortgage_length.rb
index e1bda4ea0..877818b98 100644
--- a/app/models/form/sales/questions/mortgage_length.rb
+++ b/app/models/form/sales/questions/mortgage_length.rb
@@ -2,14 +2,12 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@id = "mortlen"
- @check_answer_label = "Length of mortgage"
- @header = "What is the length of the mortgage?"
+ @copy_key = "sales.sale_information.mortlen"
@type = "numeric"
@min = 0
@max = 60
@step = 1
@width = 5
- @hint_text = "You should round up to the nearest year. Value should not exceed 60 years."
@ownershipsch = ownershipsch
@question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch]
end
diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb
index 4ece2544e..341d3ff60 100644
--- a/app/models/form/sales/questions/mortgageused.rb
+++ b/app/models/form/sales/questions/mortgageused.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection)
@id = "mortgageused"
- @check_answer_label = "Mortgage used"
- @header = "Was a mortgage used for the purchase of this property?"
+ @copy_key = "sales.sale_information.mortgageused"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@ownershipsch = ownershipsch
diff --git a/app/models/form/sales/questions/previous_bedrooms.rb b/app/models/form/sales/questions/previous_bedrooms.rb
index 50970bc89..d29da208a 100644
--- a/app/models/form/sales/questions/previous_bedrooms.rb
+++ b/app/models/form/sales/questions/previous_bedrooms.rb
@@ -2,14 +2,12 @@ class Form::Sales::Questions::PreviousBedrooms < ::Form::Question
def initialize(id, hsh, page)
super
@id = "frombeds"
- @check_answer_label = "Number of bedrooms in previous property"
- @header = "How many bedrooms did the property have?"
+ @copy_key = "sales.sale_information.frombeds"
@type = "numeric"
@width = 5
@min = 1
@max = 6
@step = 1
- @hint_text = "For bedsits enter 1"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/sales/questions/previous_tenure.rb b/app/models/form/sales/questions/previous_tenure.rb
index 7227fa00e..55b103f0d 100644
--- a/app/models/form/sales/questions/previous_tenure.rb
+++ b/app/models/form/sales/questions/previous_tenure.rb
@@ -2,10 +2,8 @@ class Form::Sales::Questions::PreviousTenure < ::Form::Question
def initialize(id, hsh, page)
super
@id = "socprevten"
- @check_answer_label = "Previous property tenure"
- @header = "What was the previous tenure of the buyer?"
+ @copy_key = "sales.sale_information.socprevten"
@type = "radio"
- @hint_text = ""
@page = page
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb
index 3a9bd4ee7..44497b727 100644
--- a/app/models/form/sales/questions/purchase_price.rb
+++ b/app/models/form/sales/questions/purchase_price.rb
@@ -2,14 +2,11 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
def initialize(id, hsh, page, ownershipsch:)
super(id, hsh, page)
@id = "value"
- @check_answer_label = "Purchase price"
- @header = "What is the full purchase price?"
@type = "numeric"
@min = 0
@step = 0.01
@width = 5
@prefix = "£"
- @hint_text = hint_text
@ownership_sch = ownershipsch
@question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch]
@top_guidance_partial = top_guidance_partial
@@ -20,10 +17,13 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
2024 => { 2 => 101, 3 => 111 },
}.freeze
- def hint_text
- return if @ownership_sch == 3 # outright sale
-
- "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount"
+ def copy_key
+ case @ownership_sch
+ when 2
+ "sales.sale_information.purchase_price.discounted_ownership"
+ when 3
+ "sales.sale_information.purchase_price.outright_sale"
+ end
end
def top_guidance_partial
diff --git a/app/models/form/sales/questions/resale.rb b/app/models/form/sales/questions/resale.rb
index be4e5535d..0026adb48 100644
--- a/app/models/form/sales/questions/resale.rb
+++ b/app/models/form/sales/questions/resale.rb
@@ -2,11 +2,9 @@ class Form::Sales::Questions::Resale < ::Form::Question
def initialize(id, hsh, page)
super
@id = "resale"
- @check_answer_label = "Is this a resale?"
- @header = "Is this a resale?"
+ @copy_key = "sales.sale_information.resale"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @hint_text = "If the social landlord has previously sold the property to another buyer and is now reselling the property, select 'yes'. If this is the first time the property has been sold, select 'no'."
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/sales/questions/shared_ownership_deposit_value_check.rb b/app/models/form/sales/questions/shared_ownership_deposit_value_check.rb
index 3f8111881..e7f520b43 100644
--- a/app/models/form/sales/questions/shared_ownership_deposit_value_check.rb
+++ b/app/models/form/sales/questions/shared_ownership_deposit_value_check.rb
@@ -2,9 +2,8 @@ class Form::Sales::Questions::SharedOwnershipDepositValueCheck < ::Form::Questio
def initialize(id, hsh, page)
super
@id = "shared_ownership_deposit_value_check"
- @check_answer_label = "Shared ownership deposit confirmation"
+ @copy_key = "sales.soft_validations.shared_ownership_deposit_value_check"
@type = "interruption_screen"
- @header = "Are you sure this is correct?"
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
diff --git a/app/models/form/sales/questions/staircase.rb b/app/models/form/sales/questions/staircase.rb
index 1eb84bfb5..9fc969735 100644
--- a/app/models/form/sales/questions/staircase.rb
+++ b/app/models/form/sales/questions/staircase.rb
@@ -2,11 +2,9 @@ class Form::Sales::Questions::Staircase < ::Form::Question
def initialize(id, hsh, page)
super
@id = "staircase"
- @check_answer_label = "Staircasing transaction"
- @header = "Is this a staircasing transaction?"
+ @copy_key = "sales.sale_information.staircasing"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @hint_text = "A staircasing transaction is when the household purchases more shares in their property, increasing the proportion they own and decreasing the proportion the housing association owns. Once the household purchases 100% of the shares, they own the property"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/sales/questions/staircase_bought.rb b/app/models/form/sales/questions/staircase_bought.rb
index 0a6343db4..8a3e88347 100644
--- a/app/models/form/sales/questions/staircase_bought.rb
+++ b/app/models/form/sales/questions/staircase_bought.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::StaircaseBought < ::Form::Question
def initialize(id, hsh, page)
super
@id = "stairbought"
- @check_answer_label = "Percentage bought in this staircasing transaction"
- @header = "What percentage of the property has been bought in this staircasing transaction?"
+ @copy_key = "sales.sale_information.about_staircasing.stairbought"
@type = "numeric"
@width = 5
@min = 0
diff --git a/app/models/form/sales/questions/staircase_bought_value_check.rb b/app/models/form/sales/questions/staircase_bought_value_check.rb
index 65fe02e66..146e89dfd 100644
--- a/app/models/form/sales/questions/staircase_bought_value_check.rb
+++ b/app/models/form/sales/questions/staircase_bought_value_check.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::StaircaseBoughtValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "staircase_bought_value_check"
- @check_answer_label = "Percentage bought confirmation"
- @header = "Are you sure this is correct?"
+ @copy_key = "sales.soft_validations.staircase_bought_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
diff --git a/app/models/form/sales/questions/staircase_owned.rb b/app/models/form/sales/questions/staircase_owned.rb
index 64614e608..dc8daaf20 100644
--- a/app/models/form/sales/questions/staircase_owned.rb
+++ b/app/models/form/sales/questions/staircase_owned.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::StaircaseOwned < ::Form::Question
def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page)
@id = "stairowned"
- @check_answer_label = I18n.t("check_answer_labels.stairowned", count: joint_purchase ? 2 : 1)
- @header = I18n.t("questions.stairowned", count: joint_purchase ? 2 : 1)
+ @copy_key = "sales.sale_information.about_staircasing.stairowned.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@type = "numeric"
@width = 5
@min = 0
diff --git a/app/models/form/sales/questions/staircase_owned_value_check.rb b/app/models/form/sales/questions/staircase_owned_value_check.rb
index eb742b196..3457d60fe 100644
--- a/app/models/form/sales/questions/staircase_owned_value_check.rb
+++ b/app/models/form/sales/questions/staircase_owned_value_check.rb
@@ -1,9 +1,8 @@
class Form::Sales::Questions::StaircaseOwnedValueCheck < ::Form::Question
- def initialize(id, hsh, page)
- super
+ def initialize(id, hsh, page, joint_purchase:)
+ super(id, hsh, page)
@id = "stairowned_value_check"
- @check_answer_label = "Percentage owned confirmation"
- @header = "Are you sure?"
+ @copy_key = "sales.soft_validations.stairowned_value_check.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
diff --git a/app/models/form/sales/questions/staircase_sale.rb b/app/models/form/sales/questions/staircase_sale.rb
index de1c8305a..ac54084f5 100644
--- a/app/models/form/sales/questions/staircase_sale.rb
+++ b/app/models/form/sales/questions/staircase_sale.rb
@@ -2,8 +2,7 @@ class Form::Sales::Questions::StaircaseSale < ::Form::Question
def initialize(id, hsh, page)
super
@id = "staircasesale"
- @check_answer_label = "Part of a back-to-back staircasing transaction"
- @header = "Is this transaction part of a back-to-back staircasing transaction to facilitate sale of the home on the open market?"
+ @copy_key = "sales.sale_information.about_staircasing.staircasesale"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
diff --git a/app/models/form/sales/questions/value.rb b/app/models/form/sales/questions/value.rb
index 3ec96e76e..257344fa2 100644
--- a/app/models/form/sales/questions/value.rb
+++ b/app/models/form/sales/questions/value.rb
@@ -2,14 +2,12 @@ class Form::Sales::Questions::Value < ::Form::Question
def initialize(id, hsh, page)
super
@id = "value"
- @check_answer_label = "Full purchase price"
- @header = "What was the full purchase price?"
+ @copy_key = "sales.sale_information.value"
@type = "numeric"
@min = 0
@step = 1
@width = 5
@prefix = "£"
- @hint_text = "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@top_guidance_partial = "financial_calculations_shared_ownership"
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 4ef35d19e..52e2c18e9 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -605,12 +605,6 @@ en:
outside_range_title: "You told us the rent is %{brent}."
informative_text: "This is %{higher_or_lower} than we would expect."
hint_text: "Check the following:
- the decimal point
- the frequency, for example every week or every calendar month
- the rent type is correct, for example affordable or social rent
"
- staircase_owned:
- title_text:
- one: "You told us that the buyer now owns %{stairowned} of the property."
- two: "You told us that the buyers now own %{stairowned} of the property."
- hint_text: "The maximum percentage that can be owned under the Older Persons Shared Ownership scheme is 75%, unless the property was funded outside the Affordable Homes Programme.
-Make sure these answers are correct."
retirement:
min:
title: "You told us this person is aged %{age} years and retired."
@@ -618,9 +612,6 @@ Make sure these answers are correct."
max:
title: "You told us this person is over 66 and not retired."
hint_text: "The minimum expected retirement age in England is 66."
- extra_borrowing:
- title_text: "You told us that the mortgage and deposit total is %{mortgage_and_deposit_total}."
- hint_text: "This is higher than the purchase price minus the discount."
pregnancy:
title: "You told us somebody in the household is pregnant."
all_male_tenants: "You also told us that all the tenants living at the property are male."
@@ -631,19 +622,6 @@ Make sure these answers are correct."
void_date:
title_text: "You told us that the property has been vacant for more than 2 years."
hint_text: "This is higher than we would expect."
- shared_ownership_deposit:
- title_text: "You told us that the %{mortgage_deposit_and_discount_error_fields} add up to %{mortgage_deposit_and_discount_total}."
- staircase_bought_seems_high:
- title_text: "You told us that %{percentage}% was bought in this staircasing transaction."
- hint_text: "Most staircasing transactions are less than 50%"
- discounted_sale_value:
- title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}."
- informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}."
- care_home_charges:
- title_text: "Care home charges should be provided if this is a care home accommodation."
- grant:
- title_text: "You told us that the grant amount is %{grant}."
- hint_text: "Loans, grants and subsidies are usually between £9,000 and £16,000."
referral:
title_text: "Are you sure?"
hint_text: "This is a general needs log, and this referral type is for supported housing."
@@ -656,16 +634,11 @@ Make sure these answers are correct."
charges:
informative_text: "This is higher than we would expect."
hint_text: "Check the following:- the decimal point
- the frequency, for example every week or every calendar month
- the needs type
"
- deposit_and_mortgage:
- title_text: "You told us the mortgage amount was %{mortgage}, the cash deposit was %{deposit} and the discount was %{discount}."
- hint_text: "We would expect the mortgage amount and the deposit added together to be the same as the purchase price minus the discount."
reasonother:
title_text: "You told us that the tenant’s main reason for leaving their last settled home was %{reasonother}."
informative_text: "The reason you have entered looks very similar to one of the existing response categories.
Please check the categories and select the appropriate one.
If the existing categories are not suitable, please confirm here to move onto the next question."
- hodate:
- must_be_less_than_3_years_from_saledate: "You told us practical completion or handover date is more than 3 years before sale completion date."
saledate:
must_be_less_than_3_years_from_hodate: "You told us sale completion date is more than 3 years after practical completion or handover date."
partner_under_16_lettings:
@@ -703,12 +676,6 @@ Make sure these answers are correct."
W: "Suitable for someone who uses a wheelchair and offers the full use of all rooms and facilities."
A: "Fitted with stairlifts, ramps, level access showers or grab rails."
N: "Not designed to wheelchair-user standards or fitted with any equipment or adaptations."
- soctenant:
- one: "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?"
- other: "Were any of the buyers private registered providers, housing association or local authority tenants immediately before this sale?"
- stairowned:
- one: "What percentage of the property does the buyer now own in total?"
- other: "What percentage of the property do the buyers now own in total?"
hints:
location:
@@ -722,14 +689,6 @@ Make sure these answers are correct."
bulk_upload:
needstype: "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes."
- check_answer_labels:
- soctenant:
- one: "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?"
- other: "Any buyers were registered providers, housing association or local authority tenants immediately before this sale?"
- stairowned:
- one: "Percentage the buyer now owns in total."
- other: "Percentage the buyers now own in total."
-
warnings:
organisation:
deactivate: "All schemes and users at this organisation will be deactivated. All the organisation's relationships will be removed. It will no longer be possible to create logs for this organisation."
diff --git a/config/locales/forms/2023/sales/sale_information.en.yml b/config/locales/forms/2023/sales/sale_information.en.yml
new file mode 100644
index 000000000..318d7c7db
--- /dev/null
+++ b/config/locales/forms/2023/sales/sale_information.en.yml
@@ -0,0 +1,208 @@
+en:
+ forms:
+ 2023:
+ sales:
+ sale_information:
+ living_before_purchase:
+ joint_purchase:
+ page_header: ""
+ proplen:
+ check_answer_label: "Number of years living in the property before purchase"
+ hint_text: "You should round up to the nearest year"
+ question_text: "How long did they live there?"
+ proplen_asked:
+ check_answer_label: "Buyers lived in the property before purchasing"
+ hint_text: ""
+ question_text: "Did the buyers live in the property before purchasing it?"
+ not_joint_purchase:
+ page_header: ""
+ proplen:
+ check_answer_label: "Number of years living in the property before purchase"
+ hint_text: "You should round up to the nearest year"
+ question_text: "How long did they live there?"
+ proplen_asked:
+ check_answer_label: "Buyer lived in the property before purchasing"
+ hint_text: ""
+ question_text: "Did the buyer live in the property before purchasing it?"
+
+ staircasing:
+ page_header: ""
+ check_answer_label: "Staircasing transaction"
+ hint_text: "A staircasing transaction is when the household purchases more shares in their property, increasing the proportion they own and decreasing the proportion the housing association owns. Once the household purchases 100% of the shares, they own the property"
+ question_text: "Is this a staircasing transaction?"
+ about_staircasing:
+ page_header: "About the staircasing transaction"
+ stairbought:
+ check_answer_label: "Percentage bought in this staircasing transaction"
+ hint_text: ""
+ question_text: "What percentage of the property has been bought in this staircasing transaction?"
+ stairowned:
+ joint_purchase:
+ check_answer_label: "Percentage the buyers now own in total"
+ hint_text: ""
+ question_text: "What percentage of the property do the buyers now own in total?"
+ not_joint_purchase:
+ check_answer_label: "Percentage the buyer now owns in total"
+ hint_text: ""
+ question_text: "What percentage of the property does the buyer now own in total?"
+
+ resale:
+ page_header: ""
+ check_answer_label: "Is this a resale?"
+ hint_text: "If the social landlord has previously sold the property to another buyer and is now reselling the property, select 'yes'. If this is the first time the property has been sold, select 'no'."
+ question_text: "Is this a resale?"
+
+ exchange_date:
+ page_header: ""
+ check_answer_label: "Exchange of contracts date"
+ hint_text: ""
+ question_text: "What is the exchange of contracts date?"
+
+ handover_date:
+ page_header: ""
+ check_answer_label: "Practical completion or handover date"
+ hint_text: "This is the date on which the building contractor hands over responsibility for the completed property to the private registered provider (PRP)"
+ question_text: "What is the practical completion or handover date?"
+
+ la_nominations:
+ page_header: ""
+ check_answer_label: "Household rehoused under a local authority nominations agreement?"
+ hint_text: "A local authority nominations agreement is a written agreement between a local authority and private registered provider (PRP) that some or all of its sales vacancies are offered to local authorities for rehousing"
+ question_text: "Was the household rehoused under a 'local authority nominations agreement'?"
+
+ soctenant:
+ joint_purchase:
+ page_header: ""
+ check_answer_label: "Any buyers were registered providers, housing association or local authority tenants immediately before this sale?"
+ hint_text: ""
+ question_text: "Were any of the buyers private registered providers, housing association or local authority tenants immediately before this sale?"
+ not_joint_purchase:
+ page_header: ""
+ check_answer_label: "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?"
+ hint_text: ""
+ question_text: "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?"
+
+ frombeds:
+ page_header: "About the buyers’ previous property"
+ check_answer_label: "Number of bedrooms in previous property"
+ hint_text: "For bedsits enter 1"
+ question_text: "How many bedrooms did the property have?"
+
+ fromprop:
+ page_header: ""
+ check_answer_label: "Previous property type"
+ hint_text: ""
+ question_text: "What was the previous property type?"
+
+ socprevten:
+ page_header: ""
+ check_answer_label: "Previous property tenure"
+ hint_text: ""
+ question_text: "What was the previous tenure of the buyer?"
+
+ value:
+ page_header: "About the price of the property"
+ check_answer_label: "Full purchase price"
+ hint_text: "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)"
+ question_text: "What was the full purchase price?"
+
+ equity:
+ page_header: "About the price of the property"
+ check_answer_label: "Initial percentage equity stake"
+ hint_text: "Enter the amount of initial equity held by the purchaser (for example, 25% or 50%)"
+ question_text: "What was the initial percentage equity stake purchased?"
+
+ mortgageused:
+ page_header: "Mortgage Amount"
+ check_answer_label: "Mortgage used"
+ hint_text: ""
+ question_text: "Was a mortgage used for the purchase of this property?"
+
+ mortgage:
+ page_header: "Mortgage Amount"
+ check_answer_label: "Mortgage amount"
+ hint_text: "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound."
+ question_text: "What is the mortgage amount?"
+
+ mortgagelender:
+ page_header: ""
+ check_answer_label: "Mortgage lender"
+ hint_text: ""
+ question_text: "What is the name of the mortgage lender?"
+
+ mortgagelenderother:
+ page_header: ""
+ check_answer_label: "Other Mortgage Lender"
+ hint_text: ""
+ question_text: "What is the other mortgage lender?"
+
+ mortlen:
+ page_header: ""
+ check_answer_label: "Length of mortgage"
+ hint_text: "You should round up to the nearest year. Value should not exceed 60 years."
+ question_text: "What is the length of the mortgage?"
+
+ extrabor:
+ page_header: ""
+ check_answer_label: "Any other borrowing?"
+ hint_text: ""
+ question_text: "Does this include any extra borrowing?"
+
+ deposit:
+ page_header: "About the deposit"
+ check_answer_label: "Deposit amount"
+ hint_text: "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan"
+ question_text: "How much cash deposit was paid on the property?"
+
+ cashdis:
+ page_header: "About the deposit"
+ check_answer_label: "Cash discount through SocialHomeBuy"
+ hint_text: "Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme"
+ question_text: "How much cash discount was given through Social HomeBuy?"
+
+ mrent:
+ page_header: ""
+ check_answer_label: "Monthly rent"
+ hint_text: "Amount paid before any charges"
+ question_text: "What is the basic monthly rent?"
+
+ leaseholdcharges:
+ page_header: ""
+ has_mscharge:
+ check_answer_label: "Does the property have any monthly leasehold charges?"
+ hint_text: "For example, service and management charges"
+ question_text: "Does the property have any monthly leasehold charges?"
+ mscharge:
+ check_answer_label: "Monthly leasehold charges"
+ hint_text: ""
+ question_text: "Enter the total monthly charge"
+
+ purchase_price:
+ shared_ownership:
+ page_header: "About the price of the property"
+ check_answer_label: "Purchase price"
+ hint_text: "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount"
+ question_text: "What is the full purchase price?"
+ discounted_ownership:
+ page_header: "About the price of the property"
+ check_answer_label: "Purchase price"
+ hint_text: "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount"
+ question_text: "What is the full purchase price?"
+ outright_sale:
+ page_header: "About the price of the property"
+ check_answer_label: "Purchase price"
+ hint_text: ""
+ question_text: "What is the full purchase price?"
+
+ discount:
+ page_header: "About the price of the property"
+ check_answer_label: "Percentage discount"
+ hint_text: "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB)If discount capped, enter capped %If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given."
+ question_text: "What was the percentage discount?"
+
+ grant:
+ page_header: "About the price of the property"
+ check_answer_label: "Amount of any loan, grant or subsidy"
+ hint_text: "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy"
+ question_text: "What was the amount of any loan, grant, discount or subsidy given?"
+
\ No newline at end of file
diff --git a/config/locales/forms/2023/sales/soft_validations.en.yml b/config/locales/forms/2023/sales/soft_validations.en.yml
index 1c3cd4955..20f131e90 100644
--- a/config/locales/forms/2023/sales/soft_validations.en.yml
+++ b/config/locales/forms/2023/sales/soft_validations.en.yml
@@ -40,7 +40,7 @@ en:
max:
page_header: ""
title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?"
-
+
income2_value_check:
check_answer_label: "Buyer 2 income confirmation"
hint_text: ""
@@ -60,14 +60,6 @@ en:
question_text: "Are you sure this is correct?"
title_text: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?"
- value_value_check:
- page_header: ""
- check_answer_label: "Purchase price confirmation"
- hint_text: ""
- question_text: "Are you sure?"
- title_text: "You told us the purchase price is %{value}."
- informative_text: "This is %{higher_or_lower} than we would expect."
-
mortgage_value_check:
page_header: ""
check_answer_label: "Mortgage confirmation"
@@ -76,22 +68,6 @@ en:
title_text: "You told us that the mortgage amount is %{mortgage}."
informative_text: "This is more than 5 times the income, which is higher than we would expect."
- monthly_charges_value_check:
- page_header: ""
- check_answer_label: "Monthly charges confirmation"
- hint_text: ""
- question_text: "Are you sure this is correct?"
- title_text: "You told us that the monthly charges were %{mscharge}."
- informative_text: "This is higher than we would expect."
-
- percentage_discount_value_check:
- page_header: ""
- check_answer_label: "Percentage discount confirmation"
- hint_text: ""
- question_text: "Are you sure this is correct?"
- title_text: "You told us that the percentage discount is %{discount}."
- informative_text: "This is higher than we would expect."
-
savings_value_check:
page_header: ""
check_answer_label: "Savings confirmation"
@@ -104,15 +80,65 @@ en:
title_text: "You told us the buyer’s savings were %{savings}."
informative_text: "This is higher than we would expect."
- deposit_value_check:
+ staircase_bought_value_check:
page_header: ""
- check_answer_label: "Deposit confirmation"
+ check_answer_label: "Percentage bought confirmation"
hint_text: ""
- question_text: "Are you sure that the deposit is this much higher than the buyer's savings?"
+ question_text: "Are you sure this is correct?"
+ title_text: "You told us that %{percentage}% was bought in this staircasing transaction."
+ informative_text: "Most staircasing transactions are less than 50%"
+
+ stairowned_value_check:
joint_purchase:
+ page_header: ""
+ check_answer_label: "Percentage owned confirmation"
+ hint_text: ""
+ question_text: "Are you sure?"
+ title_text: "You told us that the buyers now own %{stairowned} of the property."
+ informative_text: "The maximum percentage that can be owned under the Older Persons Shared Ownership scheme is 75%, unless the property was funded outside the Affordable Homes Programme. Make sure these answers are correct."
+ not_joint_purchase:
+ page_header: ""
+ check_answer_label: "Percentage owned confirmation"
+ hint_text: ""
+ question_text: "Are you sure?"
+ title_text: "You told us that the buyer now owns %{stairowned} of the property."
+ informative_text: "The maximum percentage that can be owned under the Older Persons Shared Ownership scheme is 75%, unless the property was funded outside the Affordable Homes Programme. Make sure these answers are correct."
+
+ hodate_check:
+ page_header: ""
+ check_answer_label: "Practical completion or handover date check"
+ hint_text: ""
+ question_text: "Are you sure?"
+ title_text: "You told us practical completion or handover date is more than 3 years before sale completion date."
+
+ value_value_check:
+ page_header: ""
+ check_answer_label: "Purchase price confirmation"
+ hint_text: ""
+ question_text: "Are you sure?"
+ title_text: "You told us the purchase price is %{value}."
+ informative_text: "This is %{higher_or_lower} than we would expect."
+
+ shared_ownership_deposit_value_check:
+ page_header: ""
+ check_answer_label: "Shared ownership deposit confirmation"
+ hint_text: ""
+ question_text: "Are you sure this is correct?"
+ title_text: "You told us that the %{mortgage_deposit_and_discount_error_fields} add up to %{mortgage_deposit_and_discount_total}."
+
+ deposit_value_check:
+ joint_purchase:
+ page_header: ""
+ check_answer_label: "Deposit confirmation"
+ hint_text: ""
+ question_text: "Are you sure that the deposit is this much higher than the buyer's savings?"
title_text: "You told us the buyers’ deposit was %{deposit} and their savings were %{savings}."
informative_text: "The deposit amount is higher than we would expect for the amount of savings they have."
not_joint_purchase:
+ page_header: ""
+ check_answer_label: "Deposit confirmation"
+ hint_text: ""
+ question_text: "Are you sure that the deposit is this much higher than the buyer's savings?"
title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}."
informative_text: "The deposit amount is higher than we would expect for the amount of savings they have."
@@ -162,3 +188,51 @@ en:
question_text: "Are you sure this is correct?"
title_text: "You told us there are more than 1 persons with 'Partner' relationship to buyer 1."
informative_text: "Are you sure this is correct?"
+
+ monthly_charges_value_check:
+ page_header: ""
+ check_answer_label: "Monthly charges confirmation"
+ hint_text: ""
+ question_text: "Are you sure this is correct?"
+ title_text: "You told us that the monthly charges were %{mscharge}."
+ informative_text: "This is higher than we would expect."
+
+ extra_borrowing_value_check:
+ page_header: ""
+ check_answer_label: "Extra borrowing confirmation"
+ hint_text: ""
+ question_text: "Are you sure there is no extra borrowing?"
+ title_text: "You told us that the mortgage and deposit total is %{mortgage_and_deposit_total}."
+ informative_text: "This is higher than the purchase price minus the discount."
+
+ percentage_discount_value_check:
+ page_header: ""
+ check_answer_label: "Percentage discount confirmation"
+ hint_text: ""
+ question_text: "Are you sure this is correct?"
+ title_text: "You told us that the percentage discount is %{discount}."
+ informative_text: "This is higher than we would expect."
+
+ grant_value_check:
+ page_header: ""
+ check_answer_label: "Grant value confirmation"
+ hint_text: ""
+ question_text: "Are you sure? Grants are usually £9,000 - £16,000"
+ title_text: "You told us that the grant amount is %{grant}."
+ informative_text: "Loans, grants and subsidies are usually between £9,000 and £16,000."
+
+ discounted_sale_value_check:
+ page_header: ""
+ check_answer_label: "Discounted sale value confirmation"
+ hint_text: ""
+ question_text: "Are you sure this is correct?"
+ title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}."
+ informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}."
+
+ deposit_and_mortgage_value_check:
+ page_header: ""
+ check_answer_label: "Deposit and mortgage against discount confirmation"
+ hint_text: ""
+ question_text: "Are you sure? Mortgage and deposit usually equal or are more than (value - discount)"
+ title_text: "You told us the mortgage amount was %{mortgage}, the cash deposit was %{deposit} and the discount was %{discount}."
+ informative_text: "We would expect the mortgage amount and the deposit added together to be the same as the purchase price minus the discount."
diff --git a/config/locales/forms/2024/sales/sale_information.en.yml b/config/locales/forms/2024/sales/sale_information.en.yml
new file mode 100644
index 000000000..d0031416e
--- /dev/null
+++ b/config/locales/forms/2024/sales/sale_information.en.yml
@@ -0,0 +1,207 @@
+en:
+ forms:
+ 2024:
+ sales:
+ sale_information:
+ living_before_purchase:
+ joint_purchase:
+ page_header: ""
+ proplen:
+ check_answer_label: "Number of years living in the property before purchase"
+ hint_text: "You should round up to the nearest year"
+ question_text: "How long did they live there?"
+ proplen_asked:
+ check_answer_label: "Buyers lived in the property before purchasing"
+ hint_text: ""
+ question_text: "Did the buyers live in the property before purchasing it?"
+ not_joint_purchase:
+ page_header: ""
+ proplen:
+ check_answer_label: "Number of years living in the property before purchase"
+ hint_text: "You should round up to the nearest year"
+ question_text: "How long did they live there?"
+ proplen_asked:
+ check_answer_label: "Buyer lived in the property before purchasing"
+ hint_text: ""
+ question_text: "Did the buyer live in the property before purchasing it?"
+
+ staircasing:
+ page_header: ""
+ check_answer_label: "Staircasing transaction"
+ hint_text: "A staircasing transaction is when the household purchases more shares in their property, increasing the proportion they own and decreasing the proportion the housing association owns. Once the household purchases 100% of the shares, they own the property"
+ question_text: "Is this a staircasing transaction?"
+ about_staircasing:
+ page_header: "About the staircasing transaction"
+ stairbought:
+ check_answer_label: "Percentage bought in this staircasing transaction"
+ hint_text: ""
+ question_text: "What percentage of the property has been bought in this staircasing transaction?"
+ stairowned:
+ joint_purchase:
+ check_answer_label: "Percentage the buyers now own in total"
+ hint_text: ""
+ question_text: "What percentage of the property do the buyers now own in total?"
+ not_joint_purchase:
+ check_answer_label: "Percentage the buyer now owns in total"
+ hint_text: ""
+ question_text: "What percentage of the property does the buyer now own in total?"
+ staircasesale:
+ check_answer_label: "Part of a back-to-back staircasing transaction"
+ hint_text: ""
+ question_text: "Is this transaction part of a back-to-back staircasing transaction to facilitate sale of the home on the open market?"
+
+ resale:
+ page_header: ""
+ check_answer_label: "Is this a resale?"
+ hint_text: "If the social landlord has previously sold the property to another buyer and is now reselling the property, select 'yes'. If this is the first time the property has been sold, select 'no'."
+ question_text: "Is this a resale?"
+
+ exchange_date:
+ page_header: ""
+ check_answer_label: "Exchange of contracts date"
+ hint_text: ""
+ question_text: "What is the exchange of contracts date?"
+
+ handover_date:
+ page_header: ""
+ check_answer_label: "Practical completion or handover date"
+ hint_text: "This is the date on which the building contractor hands over responsibility for the completed property to the private registered provider (PRP)"
+ question_text: "What is the practical completion or handover date?"
+
+ la_nominations:
+ page_header: ""
+ check_answer_label: "Household rehoused under a local authority nominations agreement?"
+ hint_text: "A local authority nominations agreement is a written agreement between a local authority and private registered provider (PRP) that some or all of its sales vacancies are offered to local authorities for rehousing"
+ question_text: "Was the household rehoused under a 'local authority nominations agreement'?"
+
+ soctenant:
+ joint_purchase:
+ page_header: ""
+ check_answer_label: "Any buyers were registered providers, housing association or local authority tenants immediately before this sale?"
+ hint_text: ""
+ question_text: "Were any of the buyers private registered providers, housing association or local authority tenants immediately before this sale?"
+ not_joint_purchase:
+ page_header: ""
+ check_answer_label: "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?"
+ hint_text: ""
+ question_text: "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?"
+
+ frombeds:
+ page_header: "About the buyers’ previous property"
+ check_answer_label: "Number of bedrooms in previous property"
+ hint_text: "For bedsits enter 1"
+ question_text: "How many bedrooms did the property have?"
+
+ fromprop:
+ page_header: ""
+ check_answer_label: "Previous property type"
+ hint_text: ""
+ question_text: "What was the previous property type?"
+
+ socprevten:
+ page_header: ""
+ check_answer_label: "Previous property tenure"
+ hint_text: ""
+ question_text: "What was the previous tenure of the buyer?"
+
+ value:
+ page_header: "About the price of the property"
+ check_answer_label: "Full purchase price"
+ hint_text: "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)"
+ question_text: "What was the full purchase price?"
+
+ equity:
+ page_header: "About the price of the property"
+ check_answer_label: "Initial percentage equity stake"
+ hint_text: "Enter the amount of initial equity held by the purchaser (for example, 25% or 50%)"
+ question_text: "What was the initial percentage equity stake purchased?"
+
+ mortgageused:
+ page_header: "Mortgage Amount"
+ check_answer_label: "Mortgage used"
+ hint_text: ""
+ question_text: "Was a mortgage used for the purchase of this property?"
+
+ mortgage:
+ page_header: "Mortgage Amount"
+ check_answer_label: "Mortgage amount"
+ hint_text: "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound."
+ question_text: "What is the mortgage amount?"
+
+ mortgagelender:
+ page_header: ""
+ check_answer_label: "Mortgage lender"
+ hint_text: ""
+ question_text: "What is the name of the mortgage lender?"
+
+ mortgagelenderother:
+ page_header: ""
+ check_answer_label: "Other Mortgage Lender"
+ hint_text: ""
+ question_text: "What is the other mortgage lender?"
+
+ mortlen:
+ page_header: ""
+ check_answer_label: "Length of mortgage"
+ hint_text: "You should round up to the nearest year. Value should not exceed 60 years."
+ question_text: "What is the length of the mortgage?"
+
+ extrabor:
+ page_header: ""
+ check_answer_label: "Any other borrowing?"
+ hint_text: ""
+ question_text: "Does this include any extra borrowing?"
+
+ deposit:
+ page_header: "About the deposit"
+ check_answer_label: "Deposit amount"
+ hint_text: "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan. As this is a fully staircased sale this question is optional. If you do not have the information available click save and continue"
+ question_text: "How much cash deposit was paid on the property?"
+
+ cashdis:
+ page_header: "About the deposit"
+ check_answer_label: "Cash discount through SocialHomeBuy"
+ hint_text: "Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme"
+ question_text: "How much cash discount was given through Social HomeBuy?"
+
+ mrent:
+ page_header: ""
+ check_answer_label: "Monthly rent"
+ hint_text: "Amount paid before any charges"
+ question_text: "What is the basic monthly rent?"
+
+ leaseholdcharges:
+ page_header: ""
+ has_mscharge:
+ check_answer_label: "Does the property have any monthly leasehold charges?"
+ hint_text: "For example, service and management charges"
+ question_text: "Does the property have any monthly leasehold charges?"
+ mscharge:
+ check_answer_label: "Monthly leasehold charges"
+ hint_text: ""
+ question_text: "Enter the total monthly charge"
+
+ purchase_price:
+ discounted_ownership:
+ page_header: "About the price of the property"
+ check_answer_label: "Purchase price"
+ hint_text: "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount"
+ question_text: "What is the full purchase price?"
+ outright_sale:
+ page_header: "About the price of the property"
+ check_answer_label: "Purchase price"
+ hint_text: ""
+ question_text: "What is the full purchase price?"
+
+ discount:
+ page_header: "About the price of the property"
+ check_answer_label: "Percentage discount"
+ hint_text: "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB)If discount capped, enter capped %If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given."
+ question_text: "What was the percentage discount?"
+
+ grant:
+ page_header: "About the price of the property"
+ check_answer_label: "Amount of any loan, grant or subsidy"
+ hint_text: "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy"
+ question_text: "What was the amount of any loan, grant, discount or subsidy given?"
+
\ No newline at end of file
diff --git a/config/locales/forms/2024/sales/soft_validations.en.yml b/config/locales/forms/2024/sales/soft_validations.en.yml
index 872db4679..b9b1ad479 100644
--- a/config/locales/forms/2024/sales/soft_validations.en.yml
+++ b/config/locales/forms/2024/sales/soft_validations.en.yml
@@ -57,15 +57,6 @@ en:
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?"
- informative_text: ""
-
- value_value_check:
- page_header: ""
- check_answer_label: "Purchase price confirmation"
- hint_text: ""
- question_text: "Are you sure?"
- title_text: "You told us the purchase price is %{value}."
- informative_text: "This is %{higher_or_lower} than we would expect."
mortgage_value_check:
page_header: ""
@@ -75,22 +66,6 @@ en:
title_text: "You told us that the mortgage amount is %{mortgage}."
informative_text: "This is more than 5 times the income, which is higher than we would expect."
- monthly_charges_value_check:
- page_header: ""
- check_answer_label: "Monthly charges confirmation"
- hint_text: ""
- question_text: "Are you sure this is correct?"
- title_text: "You told us that the monthly charges were %{mscharge}."
- informative_text: "This is higher than we would expect."
-
- percentage_discount_value_check:
- page_header: ""
- check_answer_label: "Percentage discount confirmation"
- hint_text: ""
- question_text: "Are you sure this is correct?"
- title_text: "You told us that the percentage discount is %{discount}."
- informative_text: "This is higher than we would expect."
-
savings_value_check:
page_header: ""
check_answer_label: "Savings confirmation"
@@ -103,15 +78,65 @@ en:
title_text: "You told us the buyer’s savings were %{savings}."
informative_text: "This is higher than we would expect."
- deposit_value_check:
+ staircase_bought_value_check:
page_header: ""
- check_answer_label: "Deposit confirmation"
+ check_answer_label: "Percentage bought confirmation"
hint_text: ""
- question_text: "Are you sure that the deposit is this much higher than the buyer's savings?"
+ question_text: "Are you sure this is correct?"
+ title_text: "You told us that %{percentage}% was bought in this staircasing transaction."
+ informative_text: "Most staircasing transactions are less than 50%"
+
+ stairowned_value_check:
joint_purchase:
+ page_header: ""
+ check_answer_label: "Percentage owned confirmation"
+ hint_text: ""
+ question_text: "Are you sure?"
+ title_text: "You told us that the buyers now own %{stairowned} of the property."
+ informative_text: "The maximum percentage that can be owned under the Older Persons Shared Ownership scheme is 75%, unless the property was funded outside the Affordable Homes Programme. Make sure these answers are correct."
+ not_joint_purchase:
+ page_header: ""
+ check_answer_label: "Percentage owned confirmation"
+ hint_text: ""
+ question_text: "Are you sure?"
+ title_text: "You told us that the buyer now owns %{stairowned} of the property."
+ informative_text: "The maximum percentage that can be owned under the Older Persons Shared Ownership scheme is 75%, unless the property was funded outside the Affordable Homes Programme. Make sure these answers are correct."
+
+ hodate_check:
+ page_header: ""
+ check_answer_label: "Practical completion or handover date check"
+ hint_text: ""
+ question_text: "Are you sure?"
+ title_text: "You told us practical completion or handover date is more than 3 years before sale completion date."
+
+ value_value_check:
+ page_header: ""
+ check_answer_label: "Purchase price confirmation"
+ hint_text: ""
+ question_text: "Are you sure?"
+ title_text: "You told us the purchase price is %{value}."
+ informative_text: "This is %{higher_or_lower} than we would expect."
+
+ shared_ownership_deposit_value_check:
+ page_header: ""
+ check_answer_label: "Shared ownership deposit confirmation"
+ hint_text: ""
+ question_text: "Are you sure this is correct?"
+ title_text: "You told us that the %{mortgage_deposit_and_discount_error_fields} add up to %{mortgage_deposit_and_discount_total}."
+
+ deposit_value_check:
+ joint_purchase:
+ page_header: ""
+ check_answer_label: "Deposit confirmation"
+ hint_text: ""
+ question_text: "Are you sure that the deposit is this much higher than the buyer's savings?"
title_text: "You told us the buyers’ deposit was %{deposit} and their savings were %{savings}."
informative_text: "The deposit amount is higher than we would expect for the amount of savings they have."
not_joint_purchase:
+ page_header: ""
+ check_answer_label: "Deposit confirmation"
+ hint_text: ""
+ question_text: "Are you sure that the deposit is this much higher than the buyer's savings?"
title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}."
informative_text: "The deposit amount is higher than we would expect for the amount of savings they have."
@@ -129,6 +154,7 @@ en:
hint_text: ""
question_text: "You told us that someone in the household uses a wheelchair."
title_text: "You told us that someone in the household uses a wheelchair."
+
buyer_livein_value_check:
buyer1:
page_header: ""
@@ -144,6 +170,7 @@ en:
question_text: "Are you sure this is correct?"
title_text: "You told us that buyer 2 will not live in the property."
informative_text: "For %{ownership_scheme} types, the buyer usually lives in the property."
+
student_not_child_value_check:
page_header: ""
check_answer_label: "Student not a child confirmation"
@@ -151,6 +178,7 @@ en:
question_text: "Are you sure this person is not a child?"
title_text: "You told us this person is a student aged between 16 and 19."
informative_text: "Are you sure this person is not a child?"
+
partner_under_16_value_check:
page_header: ""
check_answer_label: "Partner under 16 confirmation"
@@ -158,6 +186,7 @@ en:
question_text: "Are you sure this is correct?"
title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1."
informative_text: "Are you sure this is correct?"
+
multiple_partners_value_check:
page_header: ""
check_answer_label: "Multiple partners confirmation"
@@ -165,3 +194,51 @@ en:
question_text: "Are you sure this is correct?"
title_text: "You told us there are more than 1 persons with 'Partner' relationship to buyer 1."
informative_text: "Are you sure this is correct?"
+
+ monthly_charges_value_check:
+ page_header: ""
+ check_answer_label: "Monthly charges confirmation"
+ hint_text: ""
+ question_text: "Are you sure this is correct?"
+ title_text: "You told us that the monthly charges were %{mscharge}."
+ informative_text: "This is higher than we would expect."
+
+ extra_borrowing_value_check:
+ page_header: ""
+ check_answer_label: "Extra borrowing confirmation"
+ hint_text: ""
+ question_text: "Are you sure there is no extra borrowing?"
+ title_text: "You told us that the mortgage and deposit total is %{mortgage_and_deposit_total}."
+ informative_text: "This is higher than the purchase price minus the discount."
+
+ percentage_discount_value_check:
+ page_header: ""
+ check_answer_label: "Percentage discount confirmation"
+ hint_text: ""
+ question_text: "Are you sure this is correct?"
+ title_text: "You told us that the percentage discount is %{discount}."
+ informative_text: "This is higher than we would expect."
+
+ grant_value_check:
+ page_header: ""
+ check_answer_label: "Grant value confirmation"
+ hint_text: ""
+ question_text: "Are you sure? Grants are usually £9,000 - £16,000"
+ title_text: "You told us that the grant amount is %{grant}."
+ informative_text: "Loans, grants and subsidies are usually between £9,000 and £16,000."
+
+ discounted_sale_value_check:
+ page_header: ""
+ check_answer_label: "Discounted sale value confirmation"
+ hint_text: ""
+ question_text: "Are you sure this is correct?"
+ title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}."
+ informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}."
+
+ deposit_and_mortgage_value_check:
+ page_header: ""
+ check_answer_label: "Deposit and mortgage against discount confirmation"
+ hint_text: ""
+ question_text: "Are you sure? Mortgage and deposit usually equal or are more than (value - discount)"
+ title_text: "You told us the mortgage amount was %{mortgage}, the cash deposit was %{deposit} and the discount was %{discount}."
+ informative_text: "We would expect the mortgage amount and the deposit added together to be the same as the purchase price minus the discount."
diff --git a/spec/models/form/lettings/subsections/tenancy_information_spec.rb b/spec/models/form/lettings/subsections/tenancy_information_spec.rb
index 96770ea78..0c69f89ab 100644
--- a/spec/models/form/lettings/subsections/tenancy_information_spec.rb
+++ b/spec/models/form/lettings/subsections/tenancy_information_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do
end
describe "pages" do
- let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
+ let(:section) { instance_double(Form::Lettings::Sections::TenancyAndProperty, form:) }
let(:form) { instance_double(Form, start_date:) }
before do
diff --git a/spec/models/form/sales/pages/discounted_sale_value_check_spec.rb b/spec/models/form/sales/pages/discounted_sale_value_check_spec.rb
index 38a5f69ae..3b51ec744 100644
--- a/spec/models/form/sales/pages/discounted_sale_value_check_spec.rb
+++ b/spec/models/form/sales/pages/discounted_sale_value_check_spec.rb
@@ -6,7 +6,8 @@ RSpec.describe Form::Sales::Pages::DiscountedSaleValueCheck, type: :model do
let(:page_id) { "discounted_sale_value_check" }
let(:page_definition) { nil }
let(:index) { 1 }
- let(:subsection) { instance_double(Form::Subsection) }
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
+ let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@@ -22,14 +23,14 @@ RSpec.describe Form::Sales::Pages::DiscountedSaleValueCheck, type: :model do
it "has the correct title_text" do
expect(page.title_text).to eq({
- "translation" => "soft_validations.discounted_sale_value.title_text",
+ "translation" => "forms.2024.sales.soft_validations.discounted_sale_value_check.title_text",
"arguments" => [{ "arguments_for_key" => "value_with_discount", "i18n_template" => "value_with_discount", "key" => "field_formatted_as_currency" }],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
- "translation" => "soft_validations.discounted_sale_value.informative_text",
+ "translation" => "forms.2024.sales.soft_validations.discounted_sale_value_check.informative_text",
"arguments" => [{ "arguments_for_key" => "mortgage_deposit_and_grant_total", "i18n_template" => "mortgage_deposit_and_grant_total", "key" => "field_formatted_as_currency" }],
})
end
diff --git a/spec/models/form/sales/pages/handover_date_check_spec.rb b/spec/models/form/sales/pages/handover_date_check_spec.rb
index f245675d5..ae465da16 100644
--- a/spec/models/form/sales/pages/handover_date_check_spec.rb
+++ b/spec/models/form/sales/pages/handover_date_check_spec.rb
@@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::HandoverDateCheck, type: :model do
let(:page_id) { "" }
let(:page_definition) { nil }
- let(:subsection) { instance_double(Form::Subsection) }
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
+ let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@@ -21,7 +22,7 @@ RSpec.describe Form::Sales::Pages::HandoverDateCheck, type: :model do
it "has the correct title_text" do
expect(page.title_text).to eq({
- "translation" => "soft_validations.hodate.must_be_less_than_3_years_from_saledate",
+ "translation" => "forms.2024.sales.soft_validations.hodate_check.title_text",
"arguments" => [],
})
end
diff --git a/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb b/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb
index 3a1c22f24..bca971fe5 100644
--- a/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb
+++ b/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb
@@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipDepositValueCheck, type: :mode
let(:page_id) { "shared_ownership_deposit_value_check" }
let(:page_definition) { nil }
- let(:subsection) { instance_double(Form::Subsection) }
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
+ let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@@ -29,7 +30,7 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipDepositValueCheck, type: :mode
it "has the correct title_text" do
expect(page.title_text).to eq({
- "translation" => "soft_validations.shared_ownership_deposit.title_text",
+ "translation" => "forms.2024.sales.soft_validations.shared_ownership_deposit_value_check.title_text",
"arguments" => [
{ "i18n_template" => "mortgage_deposit_and_discount_error_fields", "key" => "mortgage_deposit_and_discount_error_fields" },
{ "arguments_for_key" => "mortgage_deposit_and_discount_total", "i18n_template" => "mortgage_deposit_and_discount_total", "key" => "field_formatted_as_currency" },
@@ -37,10 +38,6 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipDepositValueCheck, type: :mode
})
end
- it "has the correct informative_text" do
- expect(page.informative_text).to eq({})
- end
-
it "has the correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[mortgage mortgageused cashdis type deposit value equity])
end
diff --git a/spec/models/form/sales/pages/staircase_owned_value_check_spec.rb b/spec/models/form/sales/pages/staircase_owned_value_check_spec.rb
index 95e59ea4e..5fa65fd8d 100644
--- a/spec/models/form/sales/pages/staircase_owned_value_check_spec.rb
+++ b/spec/models/form/sales/pages/staircase_owned_value_check_spec.rb
@@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::StaircaseOwnedValueCheck, type: :model do
let(:page_id) { "an_id" }
let(:page_definition) { nil }
- let(:subsection) { instance_double(Form::Subsection) }
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
+ let(:subsection) { instance_double(Form::Subsection, form:) }
let(:joint_purchase) { false }
it "has correct subsection" do
@@ -33,7 +34,7 @@ RSpec.describe Form::Sales::Pages::StaircaseOwnedValueCheck, type: :model do
it "has the correct informative_text" do
expect(page.informative_text).to eq({
- "translation" => "soft_validations.staircase_owned.hint_text",
+ "translation" => "forms.2024.sales.soft_validations.stairowned_value_check.not_joint_purchase.informative_text",
"arguments" => [],
})
end
@@ -45,7 +46,7 @@ RSpec.describe Form::Sales::Pages::StaircaseOwnedValueCheck, type: :model do
context "when not a joint purchase" do
it "has the correct title_text" do
expect(page.title_text).to eq({
- "translation" => "soft_validations.staircase_owned.title_text.one",
+ "translation" => "forms.2024.sales.soft_validations.stairowned_value_check.not_joint_purchase.title_text",
"arguments" => [
{
"key" => "stairowned",
@@ -62,7 +63,7 @@ RSpec.describe Form::Sales::Pages::StaircaseOwnedValueCheck, type: :model do
it "has the correct title_text" do
expect(page.title_text).to eq({
- "translation" => "soft_validations.staircase_owned.title_text.two",
+ "translation" => "forms.2024.sales.soft_validations.stairowned_value_check.joint_purchase.title_text",
"arguments" => [
{
"key" => "stairowned",
diff --git a/spec/models/form/sales/questions/deposit_value_check_spec.rb b/spec/models/form/sales/questions/deposit_value_check_spec.rb
index 2e861110a..077c2e6a6 100644
--- a/spec/models/form/sales/questions/deposit_value_check_spec.rb
+++ b/spec/models/form/sales/questions/deposit_value_check_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::DepositValueCheck, type: :model do
- subject(:question) { described_class.new(question_id, question_definition, page) }
+ subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
let(:question_id) { nil }
let(:question_definition) { nil }
diff --git a/spec/models/form/sales/questions/living_before_purchase_years_spec.rb b/spec/models/form/sales/questions/living_before_purchase_years_spec.rb
index c9893dece..ddf5abd8f 100644
--- a/spec/models/form/sales/questions/living_before_purchase_years_spec.rb
+++ b/spec/models/form/sales/questions/living_before_purchase_years_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model do
- subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 1) }
+ subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 1, joint_purchase: true) }
let(:question_id) { nil }
let(:question_definition) { nil }
diff --git a/spec/models/form/sales/questions/staircase_owned_value_check_spec.rb b/spec/models/form/sales/questions/staircase_owned_value_check_spec.rb
index 4298e40b8..cbff9cec1 100644
--- a/spec/models/form/sales/questions/staircase_owned_value_check_spec.rb
+++ b/spec/models/form/sales/questions/staircase_owned_value_check_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::StaircaseOwnedValueCheck, type: :model do
- subject(:question) { described_class.new(question_id, question_definition, page) }
+ subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
let(:question_id) { nil }
let(:question_definition) { nil }
From f3d709f6c84660f8396752c69da66ad7e9e9ed4d Mon Sep 17 00:00:00 2001
From: Rachael Booth
Date: Fri, 1 Nov 2024 09:49:44 +0000
Subject: [PATCH 02/27] Add paper_trail to bulk upload objects (#2745)
---
app/models/bulk_upload.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb
index 93f661225..a0ed265c9 100644
--- a/app/models/bulk_upload.rb
+++ b/app/models/bulk_upload.rb
@@ -32,6 +32,8 @@ class BulkUpload < ApplicationRecord
scope :filter_by_user, ->(user_id, _user = nil) { user_id.present? ? where(user_id:) : all }
scope :filter_by_uploading_organisation, ->(organisation_id, _user = nil) { where(organisation_id:) }
+ has_paper_trail
+
def completed?
incomplete_logs = logs.where.not(status: "completed")
!incomplete_logs.exists?
From fa83f3abc2c8ed49d4022d8ac565feaf2274b892 Mon Sep 17 00:00:00 2001
From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
Date: Fri, 1 Nov 2024 12:18:24 +0000
Subject: [PATCH 03/27] CLDC-3685: Copy changes lettings income and benefits
(#2732)
---
.../form/lettings/pages/care_home_weekly.rb | 1 +
.../form/lettings/pages/income_amount.rb | 2 +-
.../form/lettings/pages/income_known.rb | 1 -
.../form/lettings/pages/rent_4_weekly.rb | 2 +-
.../form/lettings/pages/rent_bi_weekly.rb | 2 +-
.../form/lettings/pages/rent_monthly.rb | 2 +-
app/models/form/lettings/pages/rent_weekly.rb | 2 +-
.../form/lettings/questions/benefits.rb | 3 -
.../form/lettings/questions/brent_4_weekly.rb | 4 +-
.../lettings/questions/brent_bi_weekly.rb | 4 +-
.../form/lettings/questions/brent_monthly.rb | 4 +-
.../form/lettings/questions/brent_weekly.rb | 4 +-
.../lettings/questions/chcharge_4_weekly.rb | 4 +-
.../lettings/questions/chcharge_bi_weekly.rb | 4 +-
.../lettings/questions/chcharge_monthly.rb | 4 +-
.../lettings/questions/chcharge_weekly.rb | 4 +-
.../form/lettings/questions/earnings.rb | 4 +-
app/models/form/lettings/questions/hb.rb | 3 -
.../lettings/questions/hbrentshortfall.rb | 3 -
.../lettings/questions/household_charge.rb | 3 -
app/models/form/lettings/questions/incfreq.rb | 4 +-
.../form/lettings/questions/is_carehome.rb | 4 +-
.../lettings/questions/net_income_known.rb | 3 -
app/models/form/lettings/questions/period.rb | 3 -
.../lettings/questions/pscharge_4_weekly.rb | 4 +-
.../lettings/questions/pscharge_bi_weekly.rb | 4 +-
.../lettings/questions/pscharge_monthly.rb | 4 +-
.../lettings/questions/pscharge_weekly.rb | 4 +-
.../lettings/questions/scharge_4_weekly.rb | 4 +-
.../lettings/questions/scharge_bi_weekly.rb | 4 +-
.../lettings/questions/scharge_monthly.rb | 4 +-
.../form/lettings/questions/scharge_weekly.rb | 4 +-
.../lettings/questions/supcharg_4_weekly.rb | 4 +-
.../lettings/questions/supcharg_bi_weekly.rb | 4 +-
.../lettings/questions/supcharg_monthly.rb | 4 +-
.../lettings/questions/supcharg_weekly.rb | 4 +-
.../lettings/questions/tcharge_4_weekly.rb | 4 +-
.../lettings/questions/tcharge_bi_weekly.rb | 4 +-
.../lettings/questions/tcharge_monthly.rb | 4 +-
.../form/lettings/questions/tcharge_weekly.rb | 4 +-
.../form/lettings/questions/tshortfall.rb | 3 +-
.../lettings/questions/tshortfall_known.rb | 4 +-
.../2023/lettings/income_and_benefits.en.yml | 108 ++++++++++++++++++
.../2024/lettings/income_and_benefits.en.yml | 108 ++++++++++++++++++
44 files changed, 251 insertions(+), 110 deletions(-)
create mode 100644 config/locales/forms/2023/lettings/income_and_benefits.en.yml
create mode 100644 config/locales/forms/2024/lettings/income_and_benefits.en.yml
diff --git a/app/models/form/lettings/pages/care_home_weekly.rb b/app/models/form/lettings/pages/care_home_weekly.rb
index 56165ce62..ef0ca01c3 100644
--- a/app/models/form/lettings/pages/care_home_weekly.rb
+++ b/app/models/form/lettings/pages/care_home_weekly.rb
@@ -2,6 +2,7 @@ class Form::Lettings::Pages::CareHomeWeekly < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "care_home_weekly"
+ @copy_key = "lettings.income_and_benefits.care_home"
@depends_on = [
{ "rent_and_charges_paid_weekly?" => true, "is_supported_housing?" => true, "household_charge" => 0 },
{ "rent_and_charges_paid_weekly?" => true, "is_supported_housing?" => true, "household_charge" => nil },
diff --git a/app/models/form/lettings/pages/income_amount.rb b/app/models/form/lettings/pages/income_amount.rb
index 589ae463a..71151e695 100644
--- a/app/models/form/lettings/pages/income_amount.rb
+++ b/app/models/form/lettings/pages/income_amount.rb
@@ -2,7 +2,7 @@ class Form::Lettings::Pages::IncomeAmount < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "income_amount"
- @header = "Total household income"
+ @copy_key = "lettings.income_and_benefits.income_amount"
@depends_on = [{ "net_income_known" => 0 }]
end
diff --git a/app/models/form/lettings/pages/income_known.rb b/app/models/form/lettings/pages/income_known.rb
index c031b1521..ba026d93f 100644
--- a/app/models/form/lettings/pages/income_known.rb
+++ b/app/models/form/lettings/pages/income_known.rb
@@ -2,7 +2,6 @@ class Form::Lettings::Pages::IncomeKnown < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "income_known"
- @header = "Household’s combined income after tax"
end
def questions
diff --git a/app/models/form/lettings/pages/rent_4_weekly.rb b/app/models/form/lettings/pages/rent_4_weekly.rb
index e71cd7ffa..aa6441f6e 100644
--- a/app/models/form/lettings/pages/rent_4_weekly.rb
+++ b/app/models/form/lettings/pages/rent_4_weekly.rb
@@ -2,7 +2,7 @@ class Form::Lettings::Pages::Rent4Weekly < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "rent_4_weekly"
- @header = "Household rent and charges"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges"
@depends_on = [
{ "household_charge" => 0, "rent_and_charges_paid_every_4_weeks?" => true, "is_carehome?" => false },
{ "household_charge" => nil, "rent_and_charges_paid_every_4_weeks?" => true, "is_carehome?" => false },
diff --git a/app/models/form/lettings/pages/rent_bi_weekly.rb b/app/models/form/lettings/pages/rent_bi_weekly.rb
index 0b1b9c884..7eab8daf4 100644
--- a/app/models/form/lettings/pages/rent_bi_weekly.rb
+++ b/app/models/form/lettings/pages/rent_bi_weekly.rb
@@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentBiWeekly < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "rent_bi_weekly"
- @header = "Household rent and charges"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges"
@depends_on = [
{ "household_charge" => nil, "rent_and_charges_paid_every_2_weeks?" => true, "is_carehome?" => false },
{ "household_charge" => 0, "rent_and_charges_paid_every_2_weeks?" => true, "is_carehome?" => false },
diff --git a/app/models/form/lettings/pages/rent_monthly.rb b/app/models/form/lettings/pages/rent_monthly.rb
index d6af7a08c..9a3cd6a7e 100644
--- a/app/models/form/lettings/pages/rent_monthly.rb
+++ b/app/models/form/lettings/pages/rent_monthly.rb
@@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentMonthly < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "rent_monthly"
- @header = "Household rent and charges"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges"
@depends_on = [
{ "household_charge" => nil, "rent_and_charges_paid_monthly?" => true, "is_carehome?" => false },
{ "household_charge" => 0, "rent_and_charges_paid_monthly?" => true, "is_carehome?" => false },
diff --git a/app/models/form/lettings/pages/rent_weekly.rb b/app/models/form/lettings/pages/rent_weekly.rb
index 4f1709820..86106cfe3 100644
--- a/app/models/form/lettings/pages/rent_weekly.rb
+++ b/app/models/form/lettings/pages/rent_weekly.rb
@@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentWeekly < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "rent_weekly"
- @header = "Household rent and charges"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges"
@depends_on = [
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => 0, "is_carehome?" => false },
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => nil, "is_carehome?" => false },
diff --git a/app/models/form/lettings/questions/benefits.rb b/app/models/form/lettings/questions/benefits.rb
index bc17396fb..f5f2a3ee1 100644
--- a/app/models/form/lettings/questions/benefits.rb
+++ b/app/models/form/lettings/questions/benefits.rb
@@ -2,11 +2,8 @@ class Form::Lettings::Questions::Benefits < ::Form::Question
def initialize(id, hsh, page)
super
@id = "benefits"
- @check_answer_label = "Household income from Universal Credit, state pension or benefits"
- @header = "How much of the household’s income is from Universal Credit, state pensions or benefits?"
@type = "radio"
@check_answers_card_number = 0
- @hint_text = "This excludes child and housing benefit, council tax support and tax credits."
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/lettings/questions/brent_4_weekly.rb b/app/models/form/lettings/questions/brent_4_weekly.rb
index 436b628ad..2dc18ba56 100644
--- a/app/models/form/lettings/questions/brent_4_weekly.rb
+++ b/app/models/form/lettings/questions/brent_4_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::Brent4Weekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "brent"
- @check_answer_label = "Basic rent"
- @header = "What is the basic rent?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.brent"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/brent_bi_weekly.rb b/app/models/form/lettings/questions/brent_bi_weekly.rb
index 8dc27b610..d8bcfa136 100644
--- a/app/models/form/lettings/questions/brent_bi_weekly.rb
+++ b/app/models/form/lettings/questions/brent_bi_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::BrentBiWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "brent"
- @check_answer_label = "Basic rent"
- @header = "What is the basic rent?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.brent"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/brent_monthly.rb b/app/models/form/lettings/questions/brent_monthly.rb
index 7b567736b..a96239d7a 100644
--- a/app/models/form/lettings/questions/brent_monthly.rb
+++ b/app/models/form/lettings/questions/brent_monthly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::BrentMonthly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "brent"
- @check_answer_label = "Basic rent"
- @header = "What is the basic rent?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.brent"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/brent_weekly.rb b/app/models/form/lettings/questions/brent_weekly.rb
index e604e5f34..155addfec 100644
--- a/app/models/form/lettings/questions/brent_weekly.rb
+++ b/app/models/form/lettings/questions/brent_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::BrentWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "brent"
- @check_answer_label = "Basic rent"
- @header = "What is the basic rent?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.brent"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/chcharge_4_weekly.rb b/app/models/form/lettings/questions/chcharge_4_weekly.rb
index b42bbe052..1cf3adae4 100644
--- a/app/models/form/lettings/questions/chcharge_4_weekly.rb
+++ b/app/models/form/lettings/questions/chcharge_4_weekly.rb
@@ -2,12 +2,10 @@ class Form::Lettings::Questions::Chcharge4Weekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "chcharge"
- @check_answer_label = "Care home charges"
- @header = "How much does the household pay every 4 weeks?"
+ @copy_key = "lettings.income_and_benefits.care_home.chcharge_4_weekly"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
- @hint_text = ""
@step = 0.01
@prefix = "£"
@suffix = " every 4 weeks"
diff --git a/app/models/form/lettings/questions/chcharge_bi_weekly.rb b/app/models/form/lettings/questions/chcharge_bi_weekly.rb
index 72de6d32b..c2abc4bdd 100644
--- a/app/models/form/lettings/questions/chcharge_bi_weekly.rb
+++ b/app/models/form/lettings/questions/chcharge_bi_weekly.rb
@@ -2,12 +2,10 @@ class Form::Lettings::Questions::ChchargeBiWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "chcharge"
- @check_answer_label = "Care home charges"
- @header = "How much does the household pay every 2 weeks?"
+ @copy_key = "lettings.income_and_benefits.care_home.chcharge_bi_weekly"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
- @hint_text = ""
@step = 0.01
@prefix = "£"
@suffix = " every 2 weeks"
diff --git a/app/models/form/lettings/questions/chcharge_monthly.rb b/app/models/form/lettings/questions/chcharge_monthly.rb
index c640085d2..d76a4ae1f 100644
--- a/app/models/form/lettings/questions/chcharge_monthly.rb
+++ b/app/models/form/lettings/questions/chcharge_monthly.rb
@@ -2,12 +2,10 @@ class Form::Lettings::Questions::ChchargeMonthly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "chcharge"
- @check_answer_label = "Care home charges"
- @header = "How much does the household pay every month?"
+ @copy_key = "lettings.income_and_benefits.care_home.chcharge_monthly"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
- @hint_text = ""
@step = 0.01
@prefix = "£"
@suffix = " every month"
diff --git a/app/models/form/lettings/questions/chcharge_weekly.rb b/app/models/form/lettings/questions/chcharge_weekly.rb
index 484da8b5b..ab7f64622 100644
--- a/app/models/form/lettings/questions/chcharge_weekly.rb
+++ b/app/models/form/lettings/questions/chcharge_weekly.rb
@@ -2,12 +2,10 @@ class Form::Lettings::Questions::ChchargeWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "chcharge"
- @check_answer_label = "Care home charges"
- @header = "How much does the household pay every week?"
+ @copy_key = "lettings.income_and_benefits.care_home.chcharge_weekly"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
- @hint_text = ""
@step = 0.01
@prefix = "£"
@suffix = " every week"
diff --git a/app/models/form/lettings/questions/earnings.rb b/app/models/form/lettings/questions/earnings.rb
index 2ebb3e30b..9dc070e6a 100644
--- a/app/models/form/lettings/questions/earnings.rb
+++ b/app/models/form/lettings/questions/earnings.rb
@@ -2,14 +2,12 @@ class Form::Lettings::Questions::Earnings < ::Form::Question
def initialize(id, hsh, page)
super
@id = "earnings"
- @check_answer_label = "Total household income"
- @header = "How much income does the household have in total?"
+ @copy_key = "lettings.income_and_benefits.income_amount.earnings"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
@top_guidance_partial = "what_counts_as_income"
- @hint_text = ""
@step = 0.01
@prefix = "£"
@suffix = [
diff --git a/app/models/form/lettings/questions/hb.rb b/app/models/form/lettings/questions/hb.rb
index a3feba77a..4f4703993 100644
--- a/app/models/form/lettings/questions/hb.rb
+++ b/app/models/form/lettings/questions/hb.rb
@@ -2,11 +2,8 @@ class Form::Lettings::Questions::Hb < ::Form::Question
def initialize(id, hsh, page)
super
@id = "hb"
- @check_answer_label = "Housing-related benefits received"
- @header = "Is the household likely to be receiving any of these housing-related benefits?"
@type = "radio"
@check_answers_card_number = 0
- @hint_text = form.start_year_after_2024? ? "This is about when the tenant is in their new let. If they are unsure about the situation for their new let and their financial and working situation hasn’t changed significantly, answer based on what housing-related benefits they currently receive." : ""
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/lettings/questions/hbrentshortfall.rb b/app/models/form/lettings/questions/hbrentshortfall.rb
index ee9546e73..a34df70e0 100644
--- a/app/models/form/lettings/questions/hbrentshortfall.rb
+++ b/app/models/form/lettings/questions/hbrentshortfall.rb
@@ -2,11 +2,8 @@ class Form::Lettings::Questions::Hbrentshortfall < ::Form::Question
def initialize(id, hsh, page)
super
@id = "hbrentshortfall"
- @check_answer_label = "Any outstanding amount for basic rent and charges"
- @header = "After the household has received any housing-related benefits, will they still need to pay for rent and charges?"
@type = "radio"
@check_answers_card_number = 0
- @hint_text = "Also known as the ‘outstanding amount’."
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/lettings/questions/household_charge.rb b/app/models/form/lettings/questions/household_charge.rb
index 7f89aa548..60fee977d 100644
--- a/app/models/form/lettings/questions/household_charge.rb
+++ b/app/models/form/lettings/questions/household_charge.rb
@@ -2,11 +2,8 @@ class Form::Lettings::Questions::HouseholdCharge < ::Form::Question
def initialize(id, hsh, page)
super
@id = "household_charge"
- @check_answer_label = "Does the household pay rent or charges?"
- @header = "Does the household pay rent or other charges for the accommodation?"
@type = "radio"
@check_answers_card_number = 0
- @hint_text = "If rent is charged on the property then answer Yes to this question, even if the tenants do not pay it themselves."
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/lettings/questions/incfreq.rb b/app/models/form/lettings/questions/incfreq.rb
index 3067c5c98..d4384218e 100644
--- a/app/models/form/lettings/questions/incfreq.rb
+++ b/app/models/form/lettings/questions/incfreq.rb
@@ -2,11 +2,9 @@ class Form::Lettings::Questions::Incfreq < ::Form::Question
def initialize(id, hsh, page)
super
@id = "incfreq"
- @check_answer_label = "How often does the household receive this amount?"
- @header = "How often does the household receive this amount?"
+ @copy_key = "lettings.income_and_benefits.income_amount.incfreq"
@type = "radio"
@check_answers_card_number = 0
- @hint_text = ""
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = true
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
diff --git a/app/models/form/lettings/questions/is_carehome.rb b/app/models/form/lettings/questions/is_carehome.rb
index 41996b4f0..efb29a817 100644
--- a/app/models/form/lettings/questions/is_carehome.rb
+++ b/app/models/form/lettings/questions/is_carehome.rb
@@ -2,11 +2,9 @@ class Form::Lettings::Questions::IsCarehome < ::Form::Question
def initialize(id, hsh, page)
super
@id = "is_carehome"
- @check_answer_label = "Care home accommodation"
- @header = "Is this accommodation a care home?"
+ @copy_key = "lettings.income_and_benefits.care_home.is_carehome"
@type = "radio"
@check_answers_card_number = 0
- @hint_text = ""
@conditional_for = { "chcharge" => [1] }
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/lettings/questions/net_income_known.rb b/app/models/form/lettings/questions/net_income_known.rb
index 5858d4d26..01c3bcaa3 100644
--- a/app/models/form/lettings/questions/net_income_known.rb
+++ b/app/models/form/lettings/questions/net_income_known.rb
@@ -2,12 +2,9 @@ class Form::Lettings::Questions::NetIncomeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "net_income_known"
- @check_answer_label = "Do you know the household’s combined total income after tax?"
- @header = "Do you know the household’s combined income after tax?"
@type = "radio"
@check_answers_card_number = 0
@top_guidance_partial = "what_counts_as_income"
- @hint_text = ""
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/lettings/questions/period.rb b/app/models/form/lettings/questions/period.rb
index aefe8be84..6f98bd2a8 100644
--- a/app/models/form/lettings/questions/period.rb
+++ b/app/models/form/lettings/questions/period.rb
@@ -2,11 +2,8 @@ class Form::Lettings::Questions::Period < ::Form::Question
def initialize(id, hsh, page)
super
@id = "period"
- @check_answer_label = "Frequency of household rent and charges"
- @header = "How often does the household pay rent and other charges?"
@type = "radio"
@check_answers_card_number = 0
- @hint_text = "Select how often the household is charged. This may be different to how often they pay."
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
diff --git a/app/models/form/lettings/questions/pscharge_4_weekly.rb b/app/models/form/lettings/questions/pscharge_4_weekly.rb
index 0340e55b8..56d2e60b8 100644
--- a/app/models/form/lettings/questions/pscharge_4_weekly.rb
+++ b/app/models/form/lettings/questions/pscharge_4_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::Pscharge4Weekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "pscharge"
- @check_answer_label = "Personal service charge"
- @header = "What is the personal service charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.pscharge"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/pscharge_bi_weekly.rb b/app/models/form/lettings/questions/pscharge_bi_weekly.rb
index db4e040f0..6022f6019 100644
--- a/app/models/form/lettings/questions/pscharge_bi_weekly.rb
+++ b/app/models/form/lettings/questions/pscharge_bi_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::PschargeBiWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "pscharge"
- @check_answer_label = "Personal service charge"
- @header = "What is the personal service charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.pscharge"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/pscharge_monthly.rb b/app/models/form/lettings/questions/pscharge_monthly.rb
index e96cd32d4..225db53d3 100644
--- a/app/models/form/lettings/questions/pscharge_monthly.rb
+++ b/app/models/form/lettings/questions/pscharge_monthly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::PschargeMonthly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "pscharge"
- @check_answer_label = "Personal service charge"
- @header = "What is the personal service charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.pscharge"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/pscharge_weekly.rb b/app/models/form/lettings/questions/pscharge_weekly.rb
index 6b5fa9889..2ff06301c 100644
--- a/app/models/form/lettings/questions/pscharge_weekly.rb
+++ b/app/models/form/lettings/questions/pscharge_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::PschargeWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "pscharge"
- @check_answer_label = "Personal service charge"
- @header = "What is the personal service charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.pscharge"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/scharge_4_weekly.rb b/app/models/form/lettings/questions/scharge_4_weekly.rb
index a2f81c6ef..e91dadab3 100644
--- a/app/models/form/lettings/questions/scharge_4_weekly.rb
+++ b/app/models/form/lettings/questions/scharge_4_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::Scharge4Weekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "scharge"
- @check_answer_label = "Service charge"
- @header = "What is the service charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.scharge"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/scharge_bi_weekly.rb b/app/models/form/lettings/questions/scharge_bi_weekly.rb
index a19acbab5..59138835d 100644
--- a/app/models/form/lettings/questions/scharge_bi_weekly.rb
+++ b/app/models/form/lettings/questions/scharge_bi_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::SchargeBiWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "scharge"
- @check_answer_label = "Service charge"
- @header = "What is the service charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.scharge"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/scharge_monthly.rb b/app/models/form/lettings/questions/scharge_monthly.rb
index eb399b0de..33404a8ce 100644
--- a/app/models/form/lettings/questions/scharge_monthly.rb
+++ b/app/models/form/lettings/questions/scharge_monthly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::SchargeMonthly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "scharge"
- @check_answer_label = "Service charge"
- @header = "What is the service charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.scharge"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/scharge_weekly.rb b/app/models/form/lettings/questions/scharge_weekly.rb
index faf854b82..d8e16986e 100644
--- a/app/models/form/lettings/questions/scharge_weekly.rb
+++ b/app/models/form/lettings/questions/scharge_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::SchargeWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "scharge"
- @check_answer_label = "Service charge"
- @header = "What is the service charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.scharge"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/supcharg_4_weekly.rb b/app/models/form/lettings/questions/supcharg_4_weekly.rb
index 292578d56..cd3b7beed 100644
--- a/app/models/form/lettings/questions/supcharg_4_weekly.rb
+++ b/app/models/form/lettings/questions/supcharg_4_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::Supcharg4Weekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "supcharg"
- @check_answer_label = "Support charge"
- @header = "What is the support charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.supcharg"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "Any charges made to fund support services included in tenancy agreement."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/supcharg_bi_weekly.rb b/app/models/form/lettings/questions/supcharg_bi_weekly.rb
index 4f6daf141..dba861ebe 100644
--- a/app/models/form/lettings/questions/supcharg_bi_weekly.rb
+++ b/app/models/form/lettings/questions/supcharg_bi_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::SupchargBiWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "supcharg"
- @check_answer_label = "Support charge"
- @header = "What is the support charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.supcharg"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "Any charges made to fund support services included in tenancy agreement."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/supcharg_monthly.rb b/app/models/form/lettings/questions/supcharg_monthly.rb
index 9dd1c669b..3b5b3e41c 100644
--- a/app/models/form/lettings/questions/supcharg_monthly.rb
+++ b/app/models/form/lettings/questions/supcharg_monthly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::SupchargMonthly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "supcharg"
- @check_answer_label = "Support charge"
- @header = "What is the support charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.supcharg"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "Any charges made to fund support services included in tenancy agreement."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/supcharg_weekly.rb b/app/models/form/lettings/questions/supcharg_weekly.rb
index 54a9743b6..f48a8ccfe 100644
--- a/app/models/form/lettings/questions/supcharg_weekly.rb
+++ b/app/models/form/lettings/questions/supcharg_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::SupchargWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "supcharg"
- @check_answer_label = "Support charge"
- @header = "What is the support charge?"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.supcharg"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "Any charges made to fund support services included in tenancy agreement."
@step = 0.01
@fields_to_add = %w[brent scharge pscharge supcharg]
@result_field = "tcharge"
diff --git a/app/models/form/lettings/questions/tcharge_4_weekly.rb b/app/models/form/lettings/questions/tcharge_4_weekly.rb
index 3a353efe8..6475adab0 100644
--- a/app/models/form/lettings/questions/tcharge_4_weekly.rb
+++ b/app/models/form/lettings/questions/tcharge_4_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::Tcharge4Weekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tcharge"
- @check_answer_label = "Household rent and charges"
- @header = "Total charge"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.tcharge"
@type = "numeric_output"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "This is the total for rent and all charges."
@step = 0.01
@readonly = true
@prefix = "£"
diff --git a/app/models/form/lettings/questions/tcharge_bi_weekly.rb b/app/models/form/lettings/questions/tcharge_bi_weekly.rb
index 42fd9398b..446886d9d 100644
--- a/app/models/form/lettings/questions/tcharge_bi_weekly.rb
+++ b/app/models/form/lettings/questions/tcharge_bi_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::TchargeBiWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tcharge"
- @check_answer_label = "Household rent and charges"
- @header = "Total charge"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.tcharge"
@type = "numeric_output"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "This is the total for rent and all charges."
@step = 0.01
@readonly = true
@prefix = "£"
diff --git a/app/models/form/lettings/questions/tcharge_monthly.rb b/app/models/form/lettings/questions/tcharge_monthly.rb
index 3fcabdace..2c52f4c92 100644
--- a/app/models/form/lettings/questions/tcharge_monthly.rb
+++ b/app/models/form/lettings/questions/tcharge_monthly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::TchargeMonthly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tcharge"
- @check_answer_label = "Household rent and charges"
- @header = "Total charge"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.tcharge"
@type = "numeric_output"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "This is the total for rent and all charges."
@step = 0.01
@readonly = true
@prefix = "£"
diff --git a/app/models/form/lettings/questions/tcharge_weekly.rb b/app/models/form/lettings/questions/tcharge_weekly.rb
index d1ac7cb34..0c0ee5d8e 100644
--- a/app/models/form/lettings/questions/tcharge_weekly.rb
+++ b/app/models/form/lettings/questions/tcharge_weekly.rb
@@ -2,13 +2,11 @@ class Form::Lettings::Questions::TchargeWeekly < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tcharge"
- @check_answer_label = "Household rent and charges"
- @header = "Total charge"
+ @copy_key = "lettings.income_and_benefits.rent_and_charges.tcharge"
@type = "numeric_output"
@width = 5
@check_answers_card_number = 0
@min = 0
- @hint_text = "This is the total for rent and all charges."
@step = 0.01
@readonly = true
@prefix = "£"
diff --git a/app/models/form/lettings/questions/tshortfall.rb b/app/models/form/lettings/questions/tshortfall.rb
index 75583008c..3219c7689 100644
--- a/app/models/form/lettings/questions/tshortfall.rb
+++ b/app/models/form/lettings/questions/tshortfall.rb
@@ -2,8 +2,7 @@ class Form::Lettings::Questions::Tshortfall < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tshortfall"
- @check_answer_label = "Estimated outstanding amount"
- @header = "Estimated outstanding amount"
+ @copy_key = "lettings.income_and_benefits.outstanding_amount.tshortfall"
@type = "numeric"
@width = 5
@check_answers_card_number = 0
diff --git a/app/models/form/lettings/questions/tshortfall_known.rb b/app/models/form/lettings/questions/tshortfall_known.rb
index 600736077..7a5da7127 100644
--- a/app/models/form/lettings/questions/tshortfall_known.rb
+++ b/app/models/form/lettings/questions/tshortfall_known.rb
@@ -2,11 +2,9 @@ class Form::Lettings::Questions::TshortfallKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tshortfall_known"
- @check_answer_label = "Do you know the outstanding amount?"
- @header = "Can you estimate the outstanding amount?"
+ @copy_key = "lettings.income_and_benefits.outstanding_amount.tshortfall_known"
@type = "radio"
@check_answers_card_number = 0
- @hint_text = "You only need to give an approximate figure."
@answer_options = ANSWER_OPTIONS
@conditional_for = { "tshortfall" => [0] }
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
diff --git a/config/locales/forms/2023/lettings/income_and_benefits.en.yml b/config/locales/forms/2023/lettings/income_and_benefits.en.yml
new file mode 100644
index 000000000..bc19c7954
--- /dev/null
+++ b/config/locales/forms/2023/lettings/income_and_benefits.en.yml
@@ -0,0 +1,108 @@
+en:
+ forms:
+ 2023:
+ lettings:
+ income_and_benefits:
+ net_income_known:
+ page_header: "Household’s combined income after tax"
+ check_answer_label: "Do you know the household’s combined total income after tax?"
+ hint_text: ""
+ question_text: "Do you know the household’s combined income after tax?"
+
+ income_amount:
+ page_header: "Total household income"
+ incfreq:
+ check_answer_label: "How often does the household receive this amount?"
+ hint_text: ""
+ question_text: "How often does the household receive this amount?"
+ earnings:
+ check_answer_label: "Total household income"
+ hint_text: ""
+ question_text: "How much income does the household have in total?"
+
+ hb:
+ page_header: ""
+ check_answer_label: "Housing-related benefits received"
+ hint_text: ""
+ question_text: "Is the household likely to be receiving any of these housing-related benefits?"
+
+ benefits:
+ page_header: ""
+ check_answer_label: "Household income from Universal Credit, state pension or benefit"
+ hint_text: "This excludes child and housing benefit, council tax support and tax credits."
+ question_text: "How much of the household’s income is from Universal Credit, state pensions or benefits?"
+
+ household_charge:
+ page_header: ""
+ check_answer_label: "Does the household pay rent or charges"
+ hint_text: "If rent is charged on the property then answer Yes to this question, even if the tenants do not pay it themselves."
+ question_text: "Does the household pay rent or other charges for the accommodation?"
+
+ period:
+ page_header: ""
+ check_answer_label: "Frequency of household rent and charges"
+ hint_text: "Select how often the household is charged. This may be different to how often they pay."
+ question_text: "How often does the household pay rent and other charges?"
+
+ care_home:
+ page_header: ""
+ is_carehome:
+ check_answer_label: "Care home accommodation"
+ hint_text: ""
+ question_text: "Is this accommodation a care home?"
+ chcharge_weekly:
+ check_answer_label: "Care home charges"
+ hint_text: ""
+ question_text: "How much does the household pay every week?"
+ chcharge_bi_weekly:
+ check_answer_label: "Care home charges"
+ hint_text: ""
+ question_text: "How much does the household pay every 2 weeks?"
+ chcharge_4_weekly:
+ check_answer_label: "Care home charges"
+ hint_text: ""
+ question_text: "How much does the household pay every 4 weeks?"
+ chcharge_monthly:
+ check_answer_label: "Care home charges"
+ hint_text: ""
+ question_text: "How much does the household pay every month?"
+
+ rent_and_charges:
+ page_header: "Household rent and charges"
+ brent:
+ check_answer_label: "Basic rent"
+ hint_text: "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent."
+ question_text: "What is the basic rent?"
+ scharge:
+ check_answer_label: "Service charge"
+ hint_text: "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge."
+ question_text: "What is the service charge?"
+ pscharge:
+ check_answer_label: "Personal service charge"
+ hint_text: "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit."
+ question_text: "What is the personal service charge?"
+ supcharg:
+ check_answer_label: "Support charge"
+ hint_text: "Any charges made to fund support services included in tenancy agreement."
+ question_text: "What is the support charge?"
+ tcharge:
+ check_answer_label: "Household rent and charges"
+ hint_text: "This is the total for rent and all charges."
+ question_text: "Total charge"
+
+ hbrentshortfall:
+ page_header: ""
+ check_answer_label: "Any outstanding amount for basic rent and charges"
+ hint_text: "Also known as the ‘outstanding amount’."
+ question_text: "After the household has received any housing-related benefits, will they still need to pay for rent and charges?"
+
+ outstanding_amount:
+ page_header: ""
+ tshortfall_known:
+ check_answer_label: "Do you know the outstanding amount?"
+ hint_text: "You only need to give an approximate figure."
+ question_text: "Can you estimate the outstanding amount?"
+ tshortfall:
+ check_answer_label: "Estimated outstanding amountt"
+ hint_text: "Also known as the ‘outstanding amount’."
+ question_text: "Estimated outstanding amount"
diff --git a/config/locales/forms/2024/lettings/income_and_benefits.en.yml b/config/locales/forms/2024/lettings/income_and_benefits.en.yml
new file mode 100644
index 000000000..bb3cc320e
--- /dev/null
+++ b/config/locales/forms/2024/lettings/income_and_benefits.en.yml
@@ -0,0 +1,108 @@
+en:
+ forms:
+ 2024:
+ lettings:
+ income_and_benefits:
+ net_income_known:
+ page_header: "Household’s combined income after tax"
+ check_answer_label: "Do you know the household’s combined total income after tax?"
+ hint_text: ""
+ question_text: "Do you know the household’s combined income after tax?"
+
+ income_amount:
+ page_header: "Total household income"
+ incfreq:
+ check_answer_label: "How often does the household receive this amount?"
+ hint_text: ""
+ question_text: "How often does the household receive this amount?"
+ earnings:
+ check_answer_label: "Total household income"
+ hint_text: ""
+ question_text: "How much income does the household have in total?"
+
+ hb:
+ page_header: ""
+ check_answer_label: "Housing-related benefits received"
+ hint_text: "This is about when the tenant is in their new let. If they are unsure about the situation for their new let and their financial and working situation hasn’t changed significantly, answer based on what housing-related benefits they currently receive."
+ question_text: "Is the household likely to be receiving any of these housing-related benefits?"
+
+ benefits:
+ page_header: ""
+ check_answer_label: "Household income from Universal Credit, state pension or benefit"
+ hint_text: "This excludes child and housing benefit, council tax support and tax credits."
+ question_text: "How much of the household’s income is from Universal Credit, state pensions or benefits?"
+
+ household_charge:
+ page_header: ""
+ check_answer_label: "Does the household pay rent or charges"
+ hint_text: "If rent is charged on the property then answer Yes to this question, even if the tenants do not pay it themselves."
+ question_text: "Does the household pay rent or other charges for the accommodation?"
+
+ period:
+ page_header: ""
+ check_answer_label: "Frequency of household rent and charges"
+ hint_text: "Select how often the household is charged. This may be different to how often they pay."
+ question_text: "How often does the household pay rent and other charges?"
+
+ care_home:
+ page_header: ""
+ is_carehome:
+ check_answer_label: "Care home accommodation"
+ hint_text: ""
+ question_text: "Is this accommodation a care home?"
+ chcharge_weekly:
+ check_answer_label: "Care home charges"
+ hint_text: ""
+ question_text: "How much does the household pay every week?"
+ chcharge_bi_weekly:
+ check_answer_label: "Care home charges"
+ hint_text: ""
+ question_text: "How much does the household pay every 2 weeks?"
+ chcharge_4_weekly:
+ check_answer_label: "Care home charges"
+ hint_text: ""
+ question_text: "How much does the household pay every 4 weeks?"
+ chcharge_monthly:
+ check_answer_label: "Care home charges"
+ hint_text: ""
+ question_text: "How much does the household pay every month?"
+
+ rent_and_charges:
+ page_header: "Household rent and charges"
+ brent:
+ check_answer_label: "Basic rent"
+ hint_text: "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent."
+ question_text: "What is the basic rent?"
+ scharge:
+ check_answer_label: "Service charge"
+ hint_text: "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge."
+ question_text: "What is the service charge?"
+ pscharge:
+ check_answer_label: "Personal service charge"
+ hint_text: "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit."
+ question_text: "What is the personal service charge?"
+ supcharg:
+ check_answer_label: "Support charge"
+ hint_text: "Any charges made to fund support services included in tenancy agreement."
+ question_text: "What is the support charge?"
+ tcharge:
+ check_answer_label: "Household rent and charges"
+ hint_text: "This is the total for rent and all charges."
+ question_text: "Total charge"
+
+ hbrentshortfall:
+ page_header: ""
+ check_answer_label: "Any outstanding amount for basic rent and charges"
+ hint_text: "Also known as the ‘outstanding amount’."
+ question_text: "After the household has received any housing-related benefits, will they still need to pay for rent and charges?"
+
+ outstanding_amount:
+ page_header: ""
+ tshortfall_known:
+ check_answer_label: "Do you know the outstanding amount?"
+ hint_text: "You only need to give an approximate figure."
+ question_text: "Can you estimate the outstanding amount?"
+ tshortfall:
+ check_answer_label: "Estimated outstanding amountt"
+ hint_text: "Also known as the ‘outstanding amount’."
+ question_text: "Estimated outstanding amount"
From 83e3ddccdd70f04685b67d9216a3c01dce826645 Mon Sep 17 00:00:00 2001
From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
Date: Mon, 4 Nov 2024 15:12:22 +0000
Subject: [PATCH 04/27] CLDC-3692: Extract lettings tenancy validations (#2743)
* Extract lettings tenancy validations
---
app/models/validations/tenancy_validations.rb | 39 ++++++++-----------
config/locales/en.yml | 6 ---
.../validations/lettings/tenancy.en.yml | 25 ++++++++++++
.../validations/tenancy_validations_spec.rb | 15 ++++---
4 files changed, 49 insertions(+), 36 deletions(-)
create mode 100644 config/locales/validations/lettings/tenancy.en.yml
diff --git a/app/models/validations/tenancy_validations.rb b/app/models/validations/tenancy_validations.rb
index bd55203fb..d08f8a071 100644
--- a/app/models/validations/tenancy_validations.rb
+++ b/app/models/validations/tenancy_validations.rb
@@ -10,10 +10,9 @@ module Validations::TenancyValidations
min_tenancy_length = 1
return if record.tenancylength.to_i.between?(min_tenancy_length, 99)
- message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:)
- record.errors.add :needstype, message
- record.errors.add :tenancylength, :tenancylength_invalid, message: message
- record.errors.add :tenancy, message
+ record.errors.add :needstype, I18n.t("validations.lettings.tenancy.needstype.invalid_fixed_tenancylength", min_tenancy_length:)
+ record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.invalid_fixed_tenancylength", min_tenancy_length:)
+ record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.invalid_fixed_tenancylength", min_tenancy_length:)
end
def validate_general_needs_fixed_tenancy_length_affordable_social_rent(record)
@@ -23,11 +22,10 @@ module Validations::TenancyValidations
min_tenancy_length = 2
return if record.tenancylength.to_i.between?(min_tenancy_length, 99)
- message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:)
- record.errors.add :needstype, message
- record.errors.add :rent_type, message
- record.errors.add :tenancylength, :tenancylength_invalid, message: message
- record.errors.add :tenancy, message
+ record.errors.add :needstype, I18n.t("validations.lettings.tenancy.needstype.invalid_fixed_tenancylength", min_tenancy_length:)
+ record.errors.add :rent_type, I18n.t("validations.lettings.tenancy.rent_type.invalid_fixed_tenancylength", min_tenancy_length:)
+ record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.invalid_fixed_tenancylength", min_tenancy_length:)
+ record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.invalid_fixed_tenancylength", min_tenancy_length:)
end
def validate_general_needs_fixed_tenancy_length_intermediate_rent(record)
@@ -37,11 +35,10 @@ module Validations::TenancyValidations
min_tenancy_length = 1
return if record.tenancylength.to_i.between?(min_tenancy_length, 99)
- message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:)
- record.errors.add :needstype, message
- record.errors.add :rent_type, message
- record.errors.add :tenancylength, :tenancylength_invalid, message: message
- record.errors.add :tenancy, message
+ record.errors.add :needstype, I18n.t("validations.lettings.tenancy.needstype.invalid_fixed_tenancylength", min_tenancy_length:)
+ record.errors.add :rent_type, I18n.t("validations.lettings.tenancy.rent_type.invalid_fixed_tenancylength", min_tenancy_length:)
+ record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.invalid_fixed_tenancylength", min_tenancy_length:)
+ record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.invalid_fixed_tenancylength", min_tenancy_length:)
end
def validate_periodic_tenancy_length(record)
@@ -50,18 +47,16 @@ module Validations::TenancyValidations
min_tenancy_length = 1
return if record.tenancylength.to_i.between?(min_tenancy_length, 99)
- message = I18n.t("validations.tenancy.length.invalid_periodic", min_tenancy_length:)
- record.errors.add :tenancylength, :tenancylength_invalid, message: message
- record.errors.add :tenancy, message
+ record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.invalid_periodic_tenancylength", min_tenancy_length:)
+ record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.invalid_periodic_tenancylength", min_tenancy_length:)
end
def validate_tenancy_length_blank_when_not_required(record)
return if record.tenancylength.blank?
return if record.tenancy_type_fixed_term? || record.is_periodic_tenancy?
- message = I18n.t("validations.tenancy.length.fixed_term_not_required")
- record.errors.add :tenancylength, :tenancylength_invalid, message: message
- record.errors.add :tenancy, message
+ record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.fixed_term_not_required")
+ record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.fixed_term_not_required")
end
def validate_other_tenancy_type(record)
@@ -72,8 +67,8 @@ module Validations::TenancyValidations
return unless record.collection_start_year && record.joint
if record.hhmemb == 1 && record.joint == 1 && record.collection_start_year >= 2022
- record.errors.add :joint, :not_joint_tenancy, message: I18n.t("validations.tenancy.not_joint")
- record.errors.add :hhmemb, I18n.t("validations.tenancy.joint_more_than_one_member")
+ record.errors.add :joint, :not_joint_tenancy, message: I18n.t("validations.lettings.tenancy.joint.sole_tenancy")
+ record.errors.add :hhmemb, I18n.t("validations.lettings.tenancy.joint.multiple_members_required")
end
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 52e2c18e9..3b1cbf872 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -541,14 +541,8 @@ en:
nationality: "Select a valid nationality."
tenancy:
- length:
- fixed_term_not_required: "You must only answer the length of the tenancy if it's fixed-term."
- invalid_fixed: "Enter a tenancy length between %{min_tenancy_length} and 99 years for a tenancy of this type."
- invalid_periodic: "Enter a tenancy length between %{min_tenancy_length} and 99 years (or don't specify the length) for a tenancy of this type."
internal_transfer: "Answer must be secure tenancy as this tenancy is an internal transfer."
cannot_be_internal_transfer: "Answer cannot be internal transfer as this is not a secure tenancy."
- not_joint: "This cannot be a joint tenancy as you've told us there's only one person in the household."
- joint_more_than_one_member: "There must be more than one person in the household as you've told us this is a joint tenancy."
declaration:
missing:
diff --git a/config/locales/validations/lettings/tenancy.en.yml b/config/locales/validations/lettings/tenancy.en.yml
new file mode 100644
index 000000000..4c053e9ae
--- /dev/null
+++ b/config/locales/validations/lettings/tenancy.en.yml
@@ -0,0 +1,25 @@
+en:
+ validations:
+ lettings:
+ tenancy:
+ needstype:
+ invalid_fixed_tenancylength: "Enter a tenancy length between %{min_tenancy_length} and 99 years for a tenancy of this type."
+ invalid_periodic_tenancylength: "Enter a tenancy length between %{min_tenancy_length} and 99 years (or don't specify the length) for a tenancy of this type."
+
+ tenancylength:
+ invalid_fixed_tenancylength: "Enter a tenancy length between %{min_tenancy_length} and 99 years for a tenancy of this type."
+ invalid_periodic_tenancylength: "Enter a tenancy length between %{min_tenancy_length} and 99 years (or don't specify the length) for a tenancy of this type."
+ fixed_term_not_required: "You must only answer the length of the tenancy if it's fixed-term."
+
+ tenancy:
+ invalid_fixed_tenancylength: "Enter a tenancy length between %{min_tenancy_length} and 99 years for a tenancy of this type."
+ invalid_periodic_tenancylength: "Enter a tenancy length between %{min_tenancy_length} and 99 years (or don't specify the length) for a tenancy of this type."
+ fixed_term_not_required: "You must only answer the length of the tenancy if it's fixed-term."
+
+ rent_type:
+ invalid_fixed_tenancylength: "Enter a tenancy length between %{min_tenancy_length} and 99 years for a tenancy of this type."
+ invalid_periodic_tenancylength: "Enter a tenancy length between %{min_tenancy_length} and 99 years (or don't specify the length) for a tenancy of this type."
+
+ joint:
+ sole_tenancy: "This cannot be a joint tenancy as you've told us there's only one person in the household."
+ multiple_members_required: "There must be more than one person in the household as you've told us this is a joint tenancy."
diff --git a/spec/models/validations/tenancy_validations_spec.rb b/spec/models/validations/tenancy_validations_spec.rb
index a41752616..751506c07 100644
--- a/spec/models/validations/tenancy_validations_spec.rb
+++ b/spec/models/validations/tenancy_validations_spec.rb
@@ -76,12 +76,12 @@ RSpec.describe Validations::TenancyValidations do
{
name: "assured shorthold",
code: 4,
- expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) },
+ expected_error: ->(min_tenancy_length) { I18n.t("validations.lettings.tenancy.tenancylength.invalid_fixed_tenancylength", min_tenancy_length:) },
},
{
name: "secure fixed term",
code: 6,
- expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) },
+ expected_error: ->(min_tenancy_length) { I18n.t("validations.lettings.tenancy.tenancylength.invalid_fixed_tenancylength", min_tenancy_length:) },
},
]
@@ -211,7 +211,7 @@ RSpec.describe Validations::TenancyValidations do
periodic_tenancy_case = {
name: "periodic",
code: 8,
- expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.invalid_periodic", min_tenancy_length:) },
+ expected_error: ->(min_tenancy_length) { I18n.t("validations.lettings.tenancy.tenancylength.invalid_periodic_tenancylength", min_tenancy_length:) },
}
error_fields = %w[tenancylength tenancy]
include_examples "adds expected errors based on the tenancy length", periodic_tenancy_case, error_fields, 1
@@ -237,9 +237,8 @@ RSpec.describe Validations::TenancyValidations do
it "adds errors to tenancylength and tenancy" do
tenancy_validator.validate_tenancy_length_blank_when_not_required(record)
- expected_error = I18n.t("validations.tenancy.length.fixed_term_not_required")
- expect(record.errors["tenancylength"]).to include(expected_error)
- expect(record.errors["tenancy"]).to include(expected_error)
+ expect(record.errors["tenancylength"]).to include(I18n.t("validations.lettings.tenancy.tenancylength.fixed_term_not_required"))
+ expect(record.errors["tenancy"]).to include(I18n.t("validations.lettings.tenancy.tenancy.fixed_term_not_required"))
end
end
@@ -321,8 +320,8 @@ RSpec.describe Validations::TenancyValidations do
describe "joint tenancy validation" do
context "when the data inputter has said that there is only one member in the household" do
let(:record) { FactoryBot.build(:lettings_log, :setup_completed, hhmemb: 1) }
- let(:expected_error) { I18n.t("validations.tenancy.not_joint") }
- let(:hhmemb_expected_error) { I18n.t("validations.tenancy.joint_more_than_one_member") }
+ let(:expected_error) { I18n.t("validations.lettings.tenancy.joint.sole_tenancy") }
+ let(:hhmemb_expected_error) { I18n.t("validations.lettings.tenancy.joint.multiple_members_required") }
it "displays an error if the data inputter says the letting is a joint tenancy" do
record.joint = 1
From 1e968e50a6af5b205d6e8977056adc6ad8b98b9d Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Tue, 5 Nov 2024 10:06:28 +0000
Subject: [PATCH 05/27] CLDC-3694 Extract lettings BU validations
---
.../bulk_upload/lettings/validator.rb | 10 +-
.../lettings/year2023/row_parser.rb | 138 ++++++++---------
.../lettings/year2024/row_parser.rb | 144 +++++++++---------
app/services/bulk_upload/processor.rb | 27 ++--
config/locales/en.yml | 27 ----
.../lettings/2023/bulk_upload.en.yml | 56 +++++++
.../lettings/2024/bulk_upload.en.yml | 56 +++++++
.../lettings/year2023/row_parser_spec.rb | 126 +++++++--------
.../lettings/year2024/row_parser_spec.rb | 142 ++++++++---------
9 files changed, 411 insertions(+), 315 deletions(-)
create mode 100644 config/locales/validations/lettings/2023/bulk_upload.en.yml
create mode 100644 config/locales/validations/lettings/2024/bulk_upload.en.yml
diff --git a/app/services/bulk_upload/lettings/validator.rb b/app/services/bulk_upload/lettings/validator.rb
index 4da5b2c40..116c3b745 100644
--- a/app/services/bulk_upload/lettings/validator.rb
+++ b/app/services/bulk_upload/lettings/validator.rb
@@ -158,7 +158,7 @@ private
def validate_file_not_empty
if File.size(path).zero? || csv_parser.body_rows.flatten.compact.empty?
- errors.add(:base, :blank_file)
+ errors.add(:base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.blank_file"))
halt_validations!
end
@@ -168,7 +168,7 @@ private
return if halt_validations?
unless csv_parser.correct_field_count?
- errors.add(:base, :wrong_field_numbers_count)
+ errors.add(:base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.wrong_template.wrong_field_numbers_count"))
halt_validations!
end
end
@@ -177,7 +177,7 @@ private
return if halt_validations?
if csv_parser.too_many_columns?
- errors.add(:base, :over_max_column_count)
+ errors.add(:base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.wrong_template.over_max_column_count"))
halt_validations!
end
end
@@ -185,14 +185,14 @@ private
def validate_correct_template
return if halt_validations?
- errors.add(:base, :wrong_template) if csv_parser.wrong_template_for_year?
+ errors.add(:base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.wrong_template.wrong_template")) if csv_parser.wrong_template_for_year?
end
def validate_missing_required_headers
return if halt_validations?
if csv_parser.missing_required_headers?
- errors.add :base, I18n.t("activemodel.errors.models.bulk_upload/lettings/validator.attributes.base.no_headers", guidance_link: bulk_upload_lettings_log_url(id: "guidance", form: { year: bulk_upload.year }, host: ENV["APP_HOST"], anchor: "using-the-bulk-upload-template"))
+ errors.add :base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.wrong_template.no_headers", guidance_link: bulk_upload_lettings_log_url(id: "guidance", form: { year: bulk_upload.year }, host: ENV["APP_HOST"], anchor: "using-the-bulk-upload-template"))
halt_validations!
end
end
diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb
index 59cf7ea34..3424e0608 100644
--- a/app/services/bulk_upload/lettings/year2023/row_parser.rb
+++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb
@@ -141,6 +141,8 @@ class BulkUpload::Lettings::Year2023::RowParser
field_134: "What do you expect the outstanding amount to be?",
}.freeze
+ ERROR_BASE_KEY = "validations.lettings.2023.bulk_upload".freeze
+
attribute :bulk_upload
attribute :block_log_creation, :boolean, default: -> { false }
@@ -285,12 +287,12 @@ class BulkUpload::Lettings::Year2023::RowParser
validates :field_5,
presence: {
- message: I18n.t("validations.not_answered", question: "letting type."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "letting type."),
category: :setup,
},
inclusion: {
in: (1..12).to_a,
- message: I18n.t("validations.invalid_option", question: "letting type."),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "letting type."),
unless: -> { field_5.blank? },
category: :setup,
},
@@ -298,33 +300,33 @@ class BulkUpload::Lettings::Year2023::RowParser
validates :field_6,
presence: {
- message: I18n.t("validations.not_answered", question: "property renewal."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "property renewal."),
category: :setup,
},
on: :after_log
validates :field_7,
presence: {
- message: I18n.t("validations.not_answered", question: "tenancy start date (day)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (day)."),
category: :setup,
},
on: :after_log
validates :field_8,
presence: {
- message: I18n.t("validations.not_answered", question: "tenancy start date (month)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (month)."),
category: :setup,
},
on: :after_log
validates :field_9,
presence: {
- message: I18n.t("validations.not_answered", question: "tenancy start date (year)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (year)."),
category: :setup,
},
format: {
with: /\A(\d{2}|\d{4})\z/,
- message: I18n.t("validations.setup.startdate.year_not_two_or_four_digits"),
+ message: I18n.t("#{ERROR_BASE_KEY}.startdate.year_not_two_or_four_digits"),
category: :setup,
unless: -> { field_9.blank? },
},
@@ -333,55 +335,55 @@ class BulkUpload::Lettings::Year2023::RowParser
validates :field_16,
presence: {
if: proc { supported_housing? },
- message: I18n.t("validations.not_answered", question: "scheme code."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "scheme code."),
category: :setup,
},
on: :after_log
validates :field_116,
presence: {
- message: I18n.t("validations.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"),
category: :not_answered,
},
inclusion: {
in: [1, 2],
- message: I18n.t("validations.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"),
if: -> { field_116.present? },
},
on: :after_log
validates :field_117,
presence: {
- message: I18n.t("validations.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"),
category: :not_answered,
},
inclusion: {
in: [1, 2],
- message: I18n.t("validations.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"),
if: -> { field_117.present? },
},
on: :after_log
validates :field_118,
presence: {
- message: I18n.t("validations.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"),
category: :not_answered,
},
inclusion: {
in: [1, 2],
- message: I18n.t("validations.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"),
if: -> { field_118.present? },
},
on: :after_log
- validates :field_46, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 1 must be a number or the letter R" }, on: :after_log
- validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 2 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(2).zero? }
- validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 3 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(3).zero? }
- validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 4 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(4).zero? }
- validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 5 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(5).zero? }
- validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 6 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(6).zero? }
- validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 7 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(7).zero? }
- validates :field_76, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 8 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(8).zero? }
+ validates :field_46, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 1) }, on: :after_log
+ validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 2) }, on: :after_log, if: proc { details_known?(2).zero? }
+ validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 3) }, on: :after_log, if: proc { details_known?(3).zero? }
+ validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 4) }, on: :after_log, if: proc { details_known?(4).zero? }
+ validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 5) }, on: :after_log, if: proc { details_known?(5).zero? }
+ validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 6) }, on: :after_log, if: proc { details_known?(6).zero? }
+ validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 7) }, on: :after_log, if: proc { details_known?(7).zero? }
+ validates :field_76, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 8) }, on: :after_log, if: proc { details_known?(8).zero? }
validate :validate_needs_type_present, on: :after_log
validate :validate_data_types, on: :after_log
@@ -521,7 +523,7 @@ class BulkUpload::Lettings::Year2023::RowParser
def add_duplicate_found_in_spreadsheet_errors
spreadsheet_duplicate_hash.each_key do |field|
- errors.add(field, :spreadsheet_dupe, category: :setup)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup)
end
end
@@ -529,7 +531,7 @@ private
def validate_declaration_acceptance
unless field_45 == 1
- errors.add(:field_45, I18n.t("validations.declaration.missing.pre_2024"), category: :setup)
+ errors.add(:field_45, I18n.t("#{ERROR_BASE_KEY}.declaration.missing"), category: :setup)
end
end
@@ -544,9 +546,9 @@ private
fields.each do |field|
if setup_question?(question)
- errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup)
else
- errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])))
end
end
end
@@ -556,7 +558,7 @@ private
return if field_3.blank?
unless assigned_to
- errors.add(:field_3, "User with the specified email could not be found.")
+ errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.not_found"))
end
end
@@ -566,7 +568,7 @@ private
return if assigned_to.organisation == owning_organisation&.absorbing_organisation || assigned_to.organisation == managing_organisation&.absorbing_organisation
block_log_creation!
- errors.add(:field_3, "User must be related to owning organisation or managing organisation.")
+ errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.organisation_not_related"))
end
def assigned_to
@@ -575,7 +577,7 @@ private
def validate_uprn_exists_if_any_key_address_fields_are_blank
if field_18.blank? && (field_19.blank? || field_21.blank?)
- errors.add(:field_18, I18n.t("validations.not_answered", question: "UPRN."), category: :not_answered)
+ errors.add(:field_18, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "UPRN."), category: :not_answered)
end
end
@@ -614,21 +616,21 @@ private
def validate_needs_type_present
if field_4.blank?
- errors.add(:field_4, I18n.t("validations.not_answered", question: "needs type."), category: :setup)
+ errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "needs type."), category: :setup)
end
end
def validate_no_and_dont_know_disabled_needs_conjunction
if field_87 == 1 && field_88 == 1
- errors.add(:field_87, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction"))
- errors.add(:field_88, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction"))
+ errors.add(:field_87, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction"))
+ errors.add(:field_88, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction"))
end
end
def validate_dont_know_disabled_needs_conjunction
if field_88 == 1 && [field_83, field_84, field_85, field_86].count(1).positive?
%i[field_88 field_83 field_84 field_85 field_86].each do |field|
- errors.add(field, I18n.t("validations.household.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1
end
end
end
@@ -636,7 +638,7 @@ private
def validate_no_disabled_needs_conjunction
if field_87 == 1 && [field_83, field_84, field_85, field_86].count(1).positive?
%i[field_87 field_83 field_84 field_85 field_86].each do |field|
- errors.add(field, I18n.t("validations.household.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1
end
end
end
@@ -644,17 +646,17 @@ private
def validate_only_one_housing_needs_type
if [field_83, field_84, field_85].count(1) > 1
%i[field_83 field_84 field_85].each do |field|
- errors.add(field, I18n.t("validations.household.housingneeds_type.only_one_option_permitted")) if send(field) == 1
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds_type.only_one_option_permitted")) if send(field) == 1
end
end
end
def validate_no_housing_needs_questions_answered
if [field_83, field_84, field_85, field_86, field_87, field_88].all?(&:blank?)
- errors.add(:field_87, I18n.t("validations.not_answered", question: "anybody with disabled access needs."), category: :not_answered)
- errors.add(:field_86, I18n.t("validations.not_answered", question: "other access needs."), category: :not_answered)
+ errors.add(:field_87, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "anybody with disabled access needs."), category: :not_answered)
+ errors.add(:field_86, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "other access needs."), category: :not_answered)
%i[field_83 field_84 field_85].each do |field|
- errors.add(field, I18n.t("validations.not_answered", question: "disabled access needs type."), category: :not_answered)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "disabled access needs type."), category: :not_answered)
end
end
end
@@ -663,7 +665,7 @@ private
reason_fields = %i[field_111 field_112 field_113 field_114 field_115]
if field_110 == 1 && reason_fields.all? { |field| attributes[field.to_s].blank? }
reason_fields.each do |field|
- errors.add(field, I18n.t("validations.not_answered", question: "reason for reasonable preference."), category: :not_answered)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "reason for reasonable preference."), category: :not_answered)
end
end
end
@@ -673,12 +675,12 @@ private
if household_no_illness?
illness_option_fields.each do |field|
if attributes[field.to_s] == 1
- errors.add(field, I18n.t("validations.household.condition_effects.no_choices"))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.condition_effects.no_choices"))
end
end
elsif illness_option_fields.all? { |field| attributes[field.to_s].blank? }
illness_option_fields.each do |field|
- errors.add(field, I18n.t("validations.not_answered", question: "how is person affected by condition or illness."), category: :not_answered)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "how is person affected by condition or illness."), category: :not_answered)
end
end
end
@@ -690,20 +692,20 @@ private
def validate_lettings_type_matches_bulk_upload
if [1, 3, 5, 7, 9, 11].include?(field_5) && !general_needs?
block_log_creation!
- errors.add(:field_4, I18n.t("validations.setup.needstype.lettype_not_supported_housing"), category: :setup)
- errors.add(:field_5, I18n.t("validations.setup.lettype.needstype_supported_housing"), category: :setup)
+ errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.needstype.lettype_not_supported_housing"), category: :setup)
+ errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.lettype.needstype_supported_housing"), category: :setup)
end
if [2, 4, 6, 8, 10, 12].include?(field_5) && !supported_housing?
block_log_creation!
- errors.add(:field_4, I18n.t("validations.setup.needstype.lettype_not_general_needs"), category: :setup)
- errors.add(:field_5, I18n.t("validations.setup.lettype.needstype_general_needs"), category: :setup)
+ errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.needstype.lettype_not_general_needs"), category: :setup)
+ errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.lettype.needstype_general_needs"), category: :setup)
end
end
def validate_leaving_reason_for_renewal
if field_6 == 1 && ![40, 42].include?(field_102)
- errors.add(:field_102, I18n.t("validations.household.reason.renewal_reason_needed"))
+ errors.add(:field_102, I18n.t("#{ERROR_BASE_KEY}.reason.renewal_reason_needed"))
end
end
@@ -717,13 +719,13 @@ private
def validate_cannot_be_la_referral_if_general_needs_and_la
if field_119 == 4 && general_needs? && owning_organisation && owning_organisation.la?
- errors.add :field_119, I18n.t("validations.household.referral.la_general_needs.prp_referred_by_la")
+ errors.add :field_119, I18n.t("#{ERROR_BASE_KEY}.referral.general_needs_prp_referred_by_la")
end
end
def validate_la_with_local_housing_referral
if field_119 == 3 && owning_organisation && owning_organisation.la?
- errors.add(:field_119, I18n.t("validations.household.referral.nominated_by_local_ha_but_la"))
+ errors.add(:field_119, I18n.t("#{ERROR_BASE_KEY}.referral.nominated_by_local_ha_but_la"))
end
end
@@ -731,15 +733,15 @@ private
return if startdate.blank? || bulk_upload.form.blank?
unless bulk_upload.form.valid_start_date_for_form?(startdate)
- errors.add(:field_7, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
- errors.add(:field_8, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
- errors.add(:field_9, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_7, I18n.t("#{ERROR_BASE_KEY}.startdate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_8, I18n.t("#{ERROR_BASE_KEY}.startdate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_9, I18n.t("#{ERROR_BASE_KEY}.startdate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
end
end
def validate_data_types
unless attribute_set["field_5"].value_before_type_cast&.match?(/^\d+\.?0*$/)
- errors.add(:field_5, I18n.t("validations.invalid_number", question: "letting type."))
+ errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.invalid_number", question: "letting type."))
end
end
@@ -756,14 +758,14 @@ private
fields.each do |field|
if errors.select { |e| fields.include?(e.attribute) }.none?
question_text = question.error_display_label.presence || "this question."
- errors.add(field, I18n.t("validations.not_answered", question: format_ending(question_text)), category: :setup) if field.present?
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: format_ending(question_text)), category: :setup) if field.present?
end
end
else
fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) }
question_text = question.error_display_label.presence || "this question."
- errors.add(field, I18n.t("validations.not_answered", question: format_ending(question_text)), category: :not_answered)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: format_ending(question_text)), category: :not_answered)
end
end
end
@@ -773,28 +775,28 @@ private
def validate_related_location_exists
if scheme && location_id.present? && location.nil? && location_field.present?
block_log_creation!
- errors.add(location_field, "#{location_or_scheme.capitalize} code must relate to a #{location_or_scheme} that is owned by the owning organisation or managing organisation.", category: :setup)
+ errors.add(location_field, I18n.t("#{ERROR_BASE_KEY}.scheme.must_relate_to_org", capitalised_location_or_scheme: location_or_scheme.capitalize, location_or_scheme:), category: :setup)
end
end
def validate_location_data_given
if supported_housing? && location_id.blank? && location_field.present?
block_log_creation!
- errors.add(location_field, I18n.t("validations.not_answered", question: "#{location_or_scheme} code."), category: :setup)
+ errors.add(location_field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "#{location_or_scheme} code."), category: :setup)
end
end
def validate_related_scheme_exists
if scheme_id.present? && scheme_field.present? && owning_organisation.present? && managing_organisation.present? && scheme.nil?
block_log_creation!
- errors.add(scheme_field, "This #{scheme_or_management_group} code does not belong to the owning organisation or managing organisation.", category: :setup)
+ errors.add(scheme_field, I18n.t("#{ERROR_BASE_KEY}.scheme.does_not_belong_to_org", scheme_or_management_group:), category: :setup)
end
end
def validate_scheme_data_given
if supported_housing? && scheme_field.present? && scheme_id.blank?
block_log_creation!
- errors.add(scheme_field, I18n.t("validations.not_answered", question: "#{scheme_or_management_group} code."), category: :setup)
+ errors.add(scheme_field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "#{scheme_or_management_group} code."), category: :setup)
end
end
@@ -803,7 +805,7 @@ private
block_log_creation!
if errors[:field_2].blank?
- errors.add(:field_2, "This managing organisation does not have a relationship with the owning organisation.", category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.no_relationship"), category: :setup)
end
end
end
@@ -813,7 +815,7 @@ private
block_log_creation!
if errors[:field_2].blank?
- errors.add(:field_2, "The managing organisation code is incorrect.", category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.not_found"), category: :setup)
end
end
end
@@ -821,7 +823,7 @@ private
def validate_managing_org_data_given
if field_2.blank?
block_log_creation!
- errors.add(:field_2, "The managing organisation code is incorrect.", category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.not_answered"), category: :setup)
end
end
@@ -830,7 +832,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_stock_owner"), category: :setup)
end
end
end
@@ -840,7 +842,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_found"), category: :setup)
end
end
end
@@ -848,7 +850,7 @@ private
def validate_owning_org_data_given
if field_1.blank?
block_log_creation!
- errors.add(:field_1, I18n.t("validations.not_answered", question: "owning organisation."), category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "owning organisation."), category: :setup)
end
end
@@ -857,20 +859,20 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "You do not have permission to add logs for this owning organisation.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted"), category: :setup)
end
end
end
def validate_correct_intermediate_rent_type
if field_11.blank? || ![1, 2, 3].include?(field_11.to_i)
- errors.add(:field_11, I18n.t("validations.not_answered", question: "intermediate rent type."), category: :setup)
+ errors.add(:field_11, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "intermediate rent type."), category: :setup)
end
end
def validate_correct_affordable_rent_type
if field_10.blank? || ![1, 2, 3].include?(field_10.to_i)
- errors.add(:field_10, I18n.t("validations.not_answered", question: "is this a London Affordable Rent letting."), category: :setup)
+ errors.add(:field_10, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "is this a London Affordable Rent letting."), category: :setup)
end
end
@@ -880,7 +882,7 @@ private
def validate_if_log_already_exists
if log_already_exists?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("#{ERROR_BASE_KEY}.duplicate")
errors.add(:field_1, error_message) # owning_organisation
errors.add(:field_7, error_message) # startdate
diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb
index 312a5472a..ef7433614 100644
--- a/app/services/bulk_upload/lettings/year2024/row_parser.rb
+++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb
@@ -146,6 +146,8 @@ class BulkUpload::Lettings::Year2024::RowParser
6 => 5,
}.freeze
+ ERROR_BASE_KEY = "validations.lettings.2024.bulk_upload".freeze
+
attribute :bulk_upload
attribute :block_log_creation, :boolean, default: -> { false }
@@ -286,12 +288,12 @@ class BulkUpload::Lettings::Year2024::RowParser
validates :field_11,
presence: {
- message: I18n.t("validations.not_answered", question: "rent type."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "rent type."),
category: :setup,
},
inclusion: {
in: (1..6).to_a,
- message: I18n.t("validations.invalid_option", question: "rent type."),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "rent type."),
unless: -> { field_11.blank? },
category: :setup,
},
@@ -299,33 +301,33 @@ class BulkUpload::Lettings::Year2024::RowParser
validates :field_7,
presence: {
- message: I18n.t("validations.not_answered", question: "property renewal."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "property renewal."),
category: :setup,
},
on: :after_log
validates :field_8,
presence: {
- message: I18n.t("validations.not_answered", question: "tenancy start date (day)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (day)."),
category: :setup,
},
on: :after_log
validates :field_9,
presence: {
- message: I18n.t("validations.not_answered", question: "tenancy start date (month)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (month)."),
category: :setup,
},
on: :after_log
validates :field_10,
presence: {
- message: I18n.t("validations.not_answered", question: "tenancy start date (year)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (year)."),
category: :setup,
},
format: {
with: /\A(\d{2}|\d{4})\z/,
- message: I18n.t("validations.setup.startdate.year_not_two_or_four_digits"),
+ message: I18n.t("#{ERROR_BASE_KEY}.startdate.year_not_two_or_four_digits"),
category: :setup,
unless: -> { field_10.blank? },
},
@@ -334,7 +336,7 @@ class BulkUpload::Lettings::Year2024::RowParser
validates :field_5,
presence: {
if: proc { supported_housing? },
- message: I18n.t("validations.not_answered", question: "scheme code."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "scheme code."),
category: :setup,
},
on: :after_log
@@ -342,67 +344,67 @@ class BulkUpload::Lettings::Year2024::RowParser
validates :field_6,
presence: {
if: proc { supported_housing? },
- message: I18n.t("validations.not_answered", question: "location code."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "location code."),
category: :setup,
},
on: :after_log
validates :field_112,
presence: {
- message: I18n.t("validations.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"),
category: :not_answered,
},
inclusion: {
in: [1, 2],
- message: I18n.t("validations.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"),
if: -> { field_112.present? },
},
on: :after_log
validates :field_113,
presence: {
- message: I18n.t("validations.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"),
category: :not_answered,
},
inclusion: {
in: [1, 2],
- message: I18n.t("validations.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"),
if: -> { field_113.present? },
},
on: :after_log
validates :field_114,
presence: {
- message: I18n.t("validations.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"),
category: :not_answered,
},
inclusion: {
in: [1, 2],
- message: I18n.t("validations.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"),
if: -> { field_114.present? },
},
on: :after_log
validates :field_115,
presence: {
- message: I18n.t("validations.not_answered", question: "was the letting made under the Accessible Register?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Accessible Register?"),
category: :not_answered,
},
inclusion: {
in: [1, 2],
- message: I18n.t("validations.invalid_option", question: "was the letting made under the Accessible Register?"),
+ message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Accessible Register?"),
if: -> { field_115.present? },
},
on: :after_log
- validates :field_42, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 1 must be a number or the letter R" }, on: :after_log
- validates :field_48, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 2 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(2).zero? }
- validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 3 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(3).zero? }
- validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 4 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(4).zero? }
- validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 5 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(5).zero? }
- validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 6 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(6).zero? }
- validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 7 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(7).zero? }
- validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 8 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(8).zero? }
+ validates :field_42, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 1) }, on: :after_log
+ validates :field_48, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 2) }, on: :after_log, if: proc { details_known?(2).zero? }
+ validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 3) }, on: :after_log, if: proc { details_known?(3).zero? }
+ validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 4) }, on: :after_log, if: proc { details_known?(4).zero? }
+ validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 5) }, on: :after_log, if: proc { details_known?(5).zero? }
+ validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 6) }, on: :after_log, if: proc { details_known?(6).zero? }
+ validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 7) }, on: :after_log, if: proc { details_known?(7).zero? }
+ validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 8) }, on: :after_log, if: proc { details_known?(8).zero? }
validate :validate_needs_type_present, on: :after_log
validate :validate_data_types, on: :after_log
@@ -547,10 +549,10 @@ class BulkUpload::Lettings::Year2024::RowParser
spreadsheet_duplicate_hash.each_key do |field|
if field == "tcharge"
%w[field_125 field_126 field_127 field_128].each do |sub_field|
- errors.add(sub_field, :spreadsheet_dupe, category: :setup)
+ errors.add(sub_field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup)
end
else
- errors.add(field, :spreadsheet_dupe, category: :setup)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup)
end
end
end
@@ -568,9 +570,9 @@ private
fields.each do |field|
if setup_question?(question)
- errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup)
else
- errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])))
end
end
end
@@ -580,13 +582,13 @@ private
return if field_3.blank?
unless assigned_to
- errors.add(:field_3, "User with the specified email could not be found.")
+ errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.not_found"))
end
end
def validate_assigned_to_when_support
if field_3.blank? && bulk_upload.user.support?
- errors.add(:field_3, category: :setup, message: I18n.t("validations.not_answered", question: "what is the CORE username of the account this letting log should be assigned to?"))
+ errors.add(:field_3, category: :setup, message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "what is the CORE username of the account this letting log should be assigned to?"))
end
end
@@ -596,7 +598,7 @@ private
return if assigned_to.organisation == owning_organisation&.absorbing_organisation || assigned_to.organisation == managing_organisation&.absorbing_organisation
block_log_creation!
- errors.add(:field_3, "User must be related to owning organisation or managing organisation.")
+ errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.organisation_not_related"))
end
def assigned_to
@@ -605,14 +607,14 @@ private
def validate_uprn_exists_if_any_key_address_fields_are_blank
if field_16.blank? && !key_address_fields_provided?
- errors.add(:field_16, I18n.t("validations.not_answered", question: "UPRN."))
+ errors.add(:field_16, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "UPRN."))
end
end
def validate_address_option_found
if log.uprn.nil? && field_16.blank? && key_address_fields_provided?
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
- errors.add(field, I18n.t("validations.no_address_found"))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.address.not_found"))
end
end
end
@@ -624,19 +626,19 @@ private
def validate_address_fields
if field_16.blank? || log.errors.attribute_names.include?(:uprn)
if field_17.blank?
- errors.add(:field_17, I18n.t("validations.not_answered", question: "address line 1."))
+ errors.add(:field_17, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "address line 1."))
end
if field_19.blank?
- errors.add(:field_19, I18n.t("validations.not_answered", question: "town or city."))
+ errors.add(:field_19, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "town or city."))
end
if field_21.blank?
- errors.add(:field_21, I18n.t("validations.not_answered", question: "part 1 of postcode."))
+ errors.add(:field_21, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "part 1 of postcode."))
end
if field_22.blank?
- errors.add(:field_22, I18n.t("validations.not_answered", question: "part 2 of postcode."))
+ errors.add(:field_22, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "part 2 of postcode."))
end
end
end
@@ -661,7 +663,7 @@ private
def validate_nationality
if field_45.present? && !valid_nationality_options.include?(field_45.to_s)
- errors.add(:field_45, I18n.t("validations.household.nationality"))
+ errors.add(:field_45, I18n.t("#{ERROR_BASE_KEY}.nationality.invalid"))
end
end
@@ -682,21 +684,21 @@ private
def validate_needs_type_present
if field_4.blank?
- errors.add(:field_4, I18n.t("validations.not_answered", question: "needs type."), category: :setup)
+ errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "needs type."), category: :setup)
end
end
def validate_no_and_dont_know_disabled_needs_conjunction
if field_83 == 1 && field_84 == 1
- errors.add(:field_83, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction"))
- errors.add(:field_84, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction"))
+ errors.add(:field_83, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction"))
+ errors.add(:field_84, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction"))
end
end
def validate_dont_know_disabled_needs_conjunction
if field_84 == 1 && [field_79, field_80, field_81, field_82].count(1).positive?
%i[field_84 field_79 field_80 field_81 field_82].each do |field|
- errors.add(field, I18n.t("validations.household.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1
end
end
end
@@ -704,7 +706,7 @@ private
def validate_no_disabled_needs_conjunction
if field_83 == 1 && [field_79, field_80, field_81, field_82].count(1).positive?
%i[field_83 field_79 field_80 field_81 field_82].each do |field|
- errors.add(field, I18n.t("validations.household.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1
end
end
end
@@ -712,17 +714,17 @@ private
def validate_only_one_housing_needs_type
if [field_79, field_80, field_81].count(1) > 1
%i[field_79 field_80 field_81].each do |field|
- errors.add(field, I18n.t("validations.household.housingneeds_type.only_one_option_permitted")) if send(field) == 1
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds_type.only_one_option_permitted")) if send(field) == 1
end
end
end
def validate_no_housing_needs_questions_answered
if [field_79, field_80, field_81, field_82, field_83, field_84].all?(&:blank?)
- errors.add(:field_83, I18n.t("validations.not_answered", question: "anybody with disabled access needs."))
- errors.add(:field_82, I18n.t("validations.not_answered", question: "other access needs."))
+ errors.add(:field_83, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "anybody with disabled access needs."))
+ errors.add(:field_82, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "other access needs."))
%i[field_79 field_80 field_81].each do |field|
- errors.add(field, I18n.t("validations.not_answered", question: "disabled access needs type."))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "disabled access needs type."))
end
end
end
@@ -731,7 +733,7 @@ private
reason_fields = %i[field_107 field_108 field_109 field_110 field_111]
if field_106 == 1 && reason_fields.all? { |field| attributes[field.to_s].blank? }
reason_fields.each do |field|
- errors.add(field, I18n.t("validations.not_answered", question: "reason for reasonable preference."))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "reason for reasonable preference."))
end
end
end
@@ -741,12 +743,12 @@ private
if household_no_illness?
illness_option_fields.each do |field|
if attributes[field.to_s] == 1
- errors.add(field, I18n.t("validations.household.condition_effects.no_choices"))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.condition_effects.no_choices"))
end
end
elsif illness_option_fields.all? { |field| attributes[field.to_s].blank? }
illness_option_fields.each do |field|
- errors.add(field, I18n.t("validations.not_answered", question: "how is person affected by condition or illness."))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "how is person affected by condition or illness."))
end
end
end
@@ -757,7 +759,7 @@ private
def validate_leaving_reason_for_renewal
if field_7 == 1 && ![50, 51, 52, 53].include?(field_98)
- errors.add(:field_98, I18n.t("validations.household.reason.renewal_reason_needed_2024"))
+ errors.add(:field_98, I18n.t("#{ERROR_BASE_KEY}.reason.renewal_reason_needed"))
end
end
@@ -771,13 +773,13 @@ private
def validate_cannot_be_la_referral_if_general_needs_and_la
if field_116 == 4 && general_needs? && owning_organisation && owning_organisation.la?
- errors.add :field_116, I18n.t("validations.household.referral.la_general_needs.prp_referred_by_la")
+ errors.add :field_116, I18n.t("#{ERROR_BASE_KEY}.referral.general_needs_prp_referred_by_la")
end
end
def validate_la_with_local_housing_referral
if field_116 == 3 && owning_organisation && owning_organisation.la?
- errors.add(:field_116, I18n.t("validations.household.referral.nominated_by_local_ha_but_la"))
+ errors.add(:field_116, I18n.t("#{ERROR_BASE_KEY}.referral.nominated_by_local_ha_but_la"))
end
end
@@ -785,15 +787,15 @@ private
return if startdate.blank? || bulk_upload.form.blank?
unless bulk_upload.form.valid_start_date_for_form?(startdate)
- errors.add(:field_8, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
- errors.add(:field_9, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
- errors.add(:field_10, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_8, I18n.t("#{ERROR_BASE_KEY}.startdate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_9, I18n.t("#{ERROR_BASE_KEY}.startdate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_10, I18n.t("#{ERROR_BASE_KEY}.startdate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
end
end
def validate_data_types
unless attribute_set["field_11"].value_before_type_cast&.match?(/^\d+\.?0*$/)
- errors.add(:field_11, I18n.t("validations.invalid_number", question: "rent type."))
+ errors.add(:field_11, I18n.t("#{ERROR_BASE_KEY}.invalid_number", question: "rent type."))
end
end
@@ -825,14 +827,14 @@ private
def validate_related_location_exists
if scheme && field_6.present? && location.nil? && :field_6.present?
block_log_creation!
- errors.add(:field_6, "Location code must relate to a location that is owned by the owning organisation or managing organisation.", category: :setup)
+ errors.add(:field_6, I18n.t("#{ERROR_BASE_KEY}.location.must_relate_to_org"), category: :setup)
end
end
def validate_related_scheme_exists
if field_5.present? && :field_5.present? && owning_organisation.present? && managing_organisation.present? && scheme.nil?
block_log_creation!
- errors.add(:field_5, "This scheme code does not belong to the owning organisation or managing organisation.", category: :setup)
+ errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.scheme.must_relate_to_org"), category: :setup)
end
end
@@ -841,7 +843,7 @@ private
block_log_creation!
if errors[:field_2].blank?
- errors.add(:field_2, "This managing organisation does not have a relationship with the owning organisation.", category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.no_relationship"), category: :setup)
end
end
end
@@ -851,7 +853,7 @@ private
block_log_creation!
if field_2.present? && errors[:field_2].blank?
- errors.add(:field_2, "The managing organisation code is incorrect.", category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.not_found"), category: :setup)
end
end
end
@@ -859,7 +861,7 @@ private
def validate_managing_org_data_given
if field_2.blank?
block_log_creation!
- errors.add(:field_2, I18n.t("validations.not_answered", question: "managing organisation."), category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "managing organisation."), category: :setup)
end
end
@@ -868,7 +870,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_stock_owner"), category: :setup)
end
end
end
@@ -878,7 +880,7 @@ private
block_log_creation!
if field_1.present? && errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_found"), category: :setup)
end
end
end
@@ -886,7 +888,7 @@ private
def validate_owning_org_data_given
if field_1.blank?
block_log_creation!
- errors.add(:field_1, I18n.t("validations.not_answered", question: "owning organisation."), category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "owning organisation."), category: :setup)
end
end
@@ -899,9 +901,9 @@ private
return if errors[:field_1].present?
if bulk_upload.user.support?
- errors.add(:field_1, "This owning organisation is not affiliated with #{bulk_upload_organisation.name}.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted.support", org_name: bulk_upload_organisation.name), category: :setup)
else
- errors.add(:field_1, "You do not have permission to add logs for this owning organisation.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted.not_support"), category: :setup)
end
end
@@ -916,12 +918,12 @@ private
}.partition { |field, _| public_send(field).blank? }.map(&:to_h)
blank_charge_fields.each do |field, charge|
- errors.add(field, I18n.t("validations.financial.charges.missing_charges", sentence_fragment: charge))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.missing_charges", sentence_fragment: charge))
end
other_charge_fields.each do |field, _charge|
blank_charge_fields.each do |_blank_field, blank_charge|
- errors.add(field, I18n.t("validations.financial.charges.missing_charges", sentence_fragment: blank_charge))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.missing_charges", sentence_fragment: blank_charge))
end
end
end
@@ -936,7 +938,7 @@ private
def validate_if_log_already_exists
if log_already_exists?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("#{ERROR_BASE_KEY}.duplicate")
errors.add(:field_1, error_message) # owning_organisation
errors.add(:field_8, error_message) # startdate
diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb
index 83a8d1ca0..3a6ef4a33 100644
--- a/app/services/bulk_upload/processor.rb
+++ b/app/services/bulk_upload/processor.rb
@@ -1,15 +1,22 @@
class BulkUpload::Processor
+ include CollectionTimeHelper
attr_reader :bulk_upload
- BLANK_TEMPLATE_ERRORS = [
- I18n.t("activemodel.errors.models.bulk_upload/lettings/validator.attributes.base.blank_file"),
- I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base.blank_file"),
- ].freeze
+ def blank_template_errors
+ [
+ I18n.t("validations.lettings.#{current_collection_start_year}.bulk_upload.blank_file"),
+ I18n.t("validations.lettings.#{previous_collection_start_year}.bulk_upload.blank_file"),
+ I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base.blank_file"),
+ ].freeze
+ end
- WRONG_TEMPLATE_ERRORS = [
- *I18n.t("activemodel.errors.models.bulk_upload/lettings/validator.attributes.base", default: {}).values,
- *I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base", default: {}).values,
- ].freeze
+ def wrong_template_errors
+ [
+ *I18n.t("validations.lettings.#{current_collection_start_year}.bulk_upload.wrong_template", default: {}).values,
+ *I18n.t("validations.lettings.#{previous_collection_start_year}.bulk_upload.wrong_template", default: {}).values,
+ *I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base", default: {}).values,
+ ].freeze
+ end
def initialize(bulk_upload:)
@bulk_upload = bulk_upload
@@ -157,9 +164,9 @@ private
end
def handle_invalid_validator
- if BLANK_TEMPLATE_ERRORS.any? { |error| validator.errors.full_messages.include?(error) }
+ if blank_template_errors.any? { |error| validator.errors.full_messages.include?(error) }
@bulk_upload.update!(failure_reason: "blank_template")
- elsif WRONG_TEMPLATE_ERRORS.any? { |error| validator.errors.full_messages.include?(error) }
+ elsif wrong_template_errors.any? { |error| validator.errors.full_messages.include?(error) }
@bulk_upload.update!(failure_reason: "wrong_template")
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3b1cbf872..63d80d418 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -61,14 +61,6 @@ en:
<<: *bulk_upload__row_parser__base
bulk_upload/sales/year2023/row_parser:
<<: *bulk_upload__row_parser__base
- bulk_upload/lettings/validator:
- attributes:
- base:
- blank_file: "Template is blank - The template must be filled in for us to create the logs and check if data is correct."
- wrong_field_numbers_count: "Incorrect number of fields, please ensure you have used the correct template."
- over_max_column_count: "Too many columns, please ensure you have used the correct template."
- wrong_template: "Incorrect start dates, please ensure you have used the correct template."
- no_headers: "Your file does not contain the required header rows. Add or check the header rows and upload your file again. [Read more about using the template headers](%{guidance_link})."
bulk_upload/sales/validator:
attributes:
base:
@@ -290,7 +282,6 @@ en:
startdate:
before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme."
- year_not_two_or_four_digits: "Tenancy start year must be 2 or 4 digits."
location:
deactivated:
startdate: "The location %{postcode} is inactive on this date. Enter another date or choose another location."
@@ -313,15 +304,6 @@ en:
scheme_id: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
owning_organisation:
data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation."
- lettype:
- general_needs_mismatch: "Lettings type must be a general needs type because you selected general needs when uploading the file."
- supported_housing_mismatch: "Lettings type must be a supported housing type because you selected supported housing when uploading the file."
- needstype_general_needs: "This needs type is general needs, but the letting type is supported housing. Change either the needs type or the letting type."
- needstype_supported_housing: "This needs type is supported housing, but the letting type is general needs. Change either the needs type or the letting type."
- needstype:
- lettype_not_general_needs: "This letting type is supported housing, but the needs type is general needs. Change either the needs type or the letting type."
- lettype_not_supported_housing: "This letting type is general needs, but the needs type is supported housing. Change either the needs type or the letting type."
-
property:
uprn:
invalid: "UPRN must be 12 digits or less."
@@ -486,13 +468,8 @@ en:
child_over_19: "Answer cannot be child as you told us person %{person_num} is over 19."
housingneeds_a:
one_or_two_choices: "You can only select one option or ‘other disabled access needs’ plus ‘wheelchair-accessible housing’, ‘wheelchair access to essential rooms’ or ‘level access housing’."
- housingneeds_type:
- only_one_option_permitted: "Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected."
housingneeds:
invalid: "If somebody in the household has disabled access needs, they must have the access needs listed, or other access needs."
- no_disabled_needs_conjunction: "No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs."
- dont_know_disabled_needs_conjunction: "Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs."
- no_and_dont_know_disabled_needs_conjunction: "No disabled access needs and don’t know disabled access needs cannot be selected together."
prevten:
non_temp_accommodation: "Answer cannot be non-temporary accommodation as this is a re-let to a tenant who occupied the same property as temporary accommodation."
over_25_foster_care: "Answer cannot be a children’s home or foster care as the lead tenant is 26 or older."
@@ -507,10 +484,8 @@ en:
other_homeless: "Answer cannot be internal transfer as the tenant was considered homeless by their landlord."
prevten_invalid: "Answer cannot be internal transfer as the household situation immediately before this letting was %{prevten}."
reason_permanently_decanted: "Answer must be internal transfer as the tenant was permanently decanted from another property owned by this landlord."
- nominated_by_local_ha_but_la: "The source of the referral cannot be Nominated by local housing authority as your organisation is a local authority."
la_general_needs:
internal_transfer: "Answer cannot be internal transfer as it’s the same landlord on the tenancy agreement and the household had either a fixed-term or lifetime local authority general needs tenancy immediately before this letting."
- prp_referred_by_la: "The source of the referral cannot be referred by local authority housing department for a general needs log."
homeless:
assessed:
internal_transfer: "Answer cannot be 'assessed as homeless' as this tenancy is an internal transfer."
@@ -531,8 +506,6 @@ en:
retired_female: "Answer cannot be ‘female’ as tenant is under 60 and retired."
reason:
not_internal_transfer: "Answer cannot be ‘permanently decanted from another property owned by this landlord’ as you told us the source of referral for this tenancy was not an internal transfer."
- renewal_reason_needed: 'The reason for leaving must be "End of assured shorthold tenancy - no fault" or "End of fixed term tenancy - no fault" if the letting is a renewal.'
- renewal_reason_needed_2024: 'The reason for leaving must be "End of social or private sector tenancy - no fault", "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)", "End of social or private sector tenancy - evicted due to rent arrears" or "End of social or private sector tenancy - evicted for any other reason".'
other_not_settled: "Please give the reason for the tenant leaving their last settled home. This is where they were living before they became homeless, were living in temporary accommodation or sleeping rough."
condition_effects:
no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more."
diff --git a/config/locales/validations/lettings/2023/bulk_upload.en.yml b/config/locales/validations/lettings/2023/bulk_upload.en.yml
new file mode 100644
index 000000000..e61dbe4a1
--- /dev/null
+++ b/config/locales/validations/lettings/2023/bulk_upload.en.yml
@@ -0,0 +1,56 @@
+en:
+ validations:
+ lettings:
+ 2023:
+ bulk_upload:
+ not_answered: "You must answer %{question}"
+ invalid_option: "Enter a valid value for %{question}"
+ invalid_number: "Enter a number for %{question}"
+ spreadsheet_dupe: "This is a duplicate of a log in your file."
+ duplicate: "This is a duplicate log."
+ blank_file: "Template is blank - The template must be filled in for us to create the logs and check if data is correct."
+ wrong_template:
+ wrong_template: "Incorrect start dates, please ensure you have used the correct template."
+ no_headers: "Your file does not contain the required header rows. Add or check the header rows and upload your file again. [Read more about using the template headers](%{guidance_link})."
+ wrong_field_numbers_count: "Incorrect number of fields, please ensure you have used the correct template."
+ over_max_column_count: "Too many columns, please ensure you have used the correct template."
+ owning_organisation:
+ not_found: "The owning organisation code is incorrect."
+ not_stock_owner: "The owning organisation code provided is for an organisation that does not own stock."
+ not_permitted: "You do not have permission to add logs for this owning organisation."
+ managing_organisation:
+ no_relationship: "This managing organisation does not have a relationship with the owning organisation."
+ not_found: "The managing organisation code is incorrect."
+ not_answered: "The managing organisation code is incorrect."
+ assigned_to:
+ not_found: "User with the specified email could not be found."
+ organisation_not_related: "User must be related to owning organisation or managing organisation."
+ startdate:
+ outside_collection_window: "Enter a date within the %{year_combo} collection year, which is between 1st April %{start_year} and 31st March %{end_year}."
+ year_not_two_or_four_digits: "Tenancy start year must be 2 or 4 digits."
+ housingneeds:
+ no_and_dont_know_disabled_needs_conjunction: "No disabled access needs and don’t know disabled access needs cannot be selected together."
+ dont_know_disabled_needs_conjunction: "Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs."
+ no_disabled_needs_conjunction: "No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs."
+ housingneeds_type:
+ only_one_option_permitted: "Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected."
+ condition_effects:
+ no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more."
+ lettype:
+ needstype_general_needs: "This needs type is general needs, but the letting type is supported housing. Change either the needs type or the letting type."
+ needstype_supported_housing: "This needs type is supported housing, but the letting type is general needs. Change either the needs type or the letting type."
+ needstype:
+ lettype_not_general_needs: "This letting type is supported housing, but the needs type is general needs. Change either the needs type or the letting type."
+ lettype_not_supported_housing: "This letting type is general needs, but the needs type is supported housing. Change either the needs type or the letting type."
+ reason:
+ renewal_reason_needed: "The reason for leaving must be \"End of assured shorthold tenancy - no fault\" or \"End of fixed term tenancy - no fault\" if the letting is a renewal."
+ referral:
+ general_needs_prp_referred_by_la: "The source of the referral cannot be referred by local authority housing department for a general needs log."
+ nominated_by_local_ha_but_la: "The source of the referral cannot be Nominated by local housing authority as your organisation is a local authority."
+ scheme:
+ must_relate_to_org: "%{capitalised_location_or_scheme} code must relate to a %{location_or_scheme} that is owned by the owning organisation or managing organisation."
+ does_not_belong_to_org: "This %{scheme_or_management_group} code does not belong to the owning organisation or managing organisation."
+ declaration:
+ missing: "You must show the MHCLG privacy notice to the tenant before you can submit this log."
+ age:
+ invalid: "Age of person %{person_num} must be a number or the letter R"
\ No newline at end of file
diff --git a/config/locales/validations/lettings/2024/bulk_upload.en.yml b/config/locales/validations/lettings/2024/bulk_upload.en.yml
new file mode 100644
index 000000000..76985ee32
--- /dev/null
+++ b/config/locales/validations/lettings/2024/bulk_upload.en.yml
@@ -0,0 +1,56 @@
+en:
+ validations:
+ lettings:
+ 2024:
+ bulk_upload:
+ not_answered: "You must answer %{question}"
+ invalid_option: "Enter a valid value for %{question}"
+ invalid_number: "Enter a number for %{question}"
+ spreadsheet_dupe: "This is a duplicate of a log in your file."
+ duplicate: "This is a duplicate log."
+ blank_file: "Template is blank - The template must be filled in for us to create the logs and check if data is correct."
+ wrong_template:
+ wrong_template: "Incorrect start dates, please ensure you have used the correct template."
+ no_headers: "Your file does not contain the required header rows. Add or check the header rows and upload your file again. [Read more about using the template headers](%{guidance_link})."
+ wrong_field_numbers_count: "Incorrect number of fields, please ensure you have used the correct template."
+ over_max_column_count: "Too many columns, please ensure you have used the correct template."
+ owning_organisation:
+ not_found: "The owning organisation code is incorrect."
+ not_stock_owner: "The owning organisation code provided is for an organisation that does not own stock."
+ not_permitted:
+ not_support: "You do not have permission to add logs for this owning organisation."
+ support: "This owning organisation is not affiliated with %{org_name}."
+ managing_organisation:
+ no_relationship: "This managing organisation does not have a relationship with the owning organisation."
+ not_found: "The managing organisation code is incorrect."
+ assigned_to:
+ not_found: "User with the specified email could not be found."
+ organisation_not_related: "User must be related to owning organisation or managing organisation."
+ startdate:
+ outside_collection_window: "Enter a date within the %{year_combo} collection year, which is between 1st April %{start_year} and 31st March %{end_year}."
+ year_not_two_or_four_digits: "Tenancy start year must be 2 or 4 digits."
+ housingneeds:
+ no_and_dont_know_disabled_needs_conjunction: "No disabled access needs and don’t know disabled access needs cannot be selected together."
+ dont_know_disabled_needs_conjunction: "Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs."
+ no_disabled_needs_conjunction: "No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs."
+ housingneeds_type:
+ only_one_option_permitted: "Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected."
+ condition_effects:
+ no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more."
+ reason:
+ renewal_reason_needed: "The reason for leaving must be \"End of social or private sector tenancy - no fault\", \"End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)\", \"End of social or private sector tenancy - evicted due to rent arrears\" or \"End of social or private sector tenancy - evicted for any other reason\"."
+ referral:
+ general_needs_prp_referred_by_la: "The source of the referral cannot be referred by local authority housing department for a general needs log."
+ nominated_by_local_ha_but_la: "The source of the referral cannot be Nominated by local housing authority as your organisation is a local authority."
+ scheme:
+ must_relate_to_org: "This scheme code does not belong to the owning organisation or managing organisation."
+ location:
+ must_relate_to_org: "Location code must relate to a location that is owned by the owning organisation or managing organisation."
+ age:
+ invalid: "Age of person %{person_num} must be a number or the letter R"
+ address:
+ not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."
+ nationality:
+ invalid: "Select a valid nationality."
+ charges:
+ missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'."
\ No newline at end of file
diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
index 314db674d..8161f8a00 100644
--- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
+++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
@@ -263,7 +263,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error to all (and only) the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2023.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -300,7 +300,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2023.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -338,7 +338,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2023.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -385,7 +385,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2023.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -444,7 +444,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "does not add an error to all the fields used to determine duplicates" do
parser_too.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2023.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -479,7 +479,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2023.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -526,7 +526,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2023.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -585,7 +585,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "does not add an error to all the fields used to determine duplicates" do
parser_too.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2023.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -686,7 +686,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "cannot be nulled" do
parser.valid?
- expect(parser.errors[:field_45]).to eq(["You must show the MHCLG privacy notice to the tenant before you can submit this log."])
+ expect(parser.errors[:field_45]).to eq([I18n.t("validations.lettings.2023.bulk_upload.declaration.missing")])
end
end
end
@@ -697,8 +697,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "fetches the question's check_answer_label if it exists" do
parser.valid?
- expect(parser.errors[:field_19]).to eql(["You must answer address line 1."])
- expect(parser.errors[:field_21]).to eql(["You must answer town or city."])
+ expect(parser.errors[:field_19]).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "address line 1.")])
+ expect(parser.errors[:field_21]).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "town or city.")])
end
end
end
@@ -846,7 +846,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_5]).to be_present
- expect(parser.errors[:field_11]).to eq(["You must answer intermediate rent type."])
+ expect(parser.errors[:field_11]).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "intermediate rent type.")])
end
end
@@ -857,7 +857,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_5]).to be_present
- expect(parser.errors[:field_11]).to eq(["You must answer intermediate rent type."])
+ expect(parser.errors[:field_11]).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "intermediate rent type.")])
end
end
@@ -868,7 +868,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_5]).to be_present
- expect(parser.errors[:field_10]).to eq(["You must answer is this a London Affordable Rent letting."])
+ expect(parser.errors[:field_10]).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "is this a London Affordable Rent letting.")])
end
end
@@ -879,7 +879,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_5]).to be_present
- expect(parser.errors[:field_10]).to eq(["You must answer is this a London Affordable Rent letting."])
+ expect(parser.errors[:field_10]).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "is this a London Affordable Rent letting.")])
end
end
@@ -888,7 +888,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds error on field_12" do
parser.valid?
- expect(parser.errors[:field_12]).to eq(["You must answer product name."])
+ expect(parser.errors[:field_12]).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "product name.")])
end
end
@@ -910,8 +910,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "is not permitted" do
parser.valid?
- expect(parser.errors[:field_4]).to include("This letting type is supported housing, but the needs type is general needs. Change either the needs type or the letting type.")
- expect(parser.errors[:field_5]).to include("This needs type is general needs, but the letting type is supported housing. Change either the needs type or the letting type.")
+ expect(parser.errors[:field_4]).to include(I18n.t("validations.lettings.2023.bulk_upload.needstype.lettype_not_general_needs"))
+ expect(parser.errors[:field_5]).to include(I18n.t("validations.lettings.2023.bulk_upload.lettype.needstype_general_needs"))
end
end
end
@@ -925,8 +925,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "is not permitted" do
parser.valid?
- expect(parser.errors[:field_4]).to include("This letting type is general needs, but the needs type is supported housing. Change either the needs type or the letting type.")
- expect(parser.errors[:field_5]).to include("This needs type is supported housing, but the letting type is general needs. Change either the needs type or the letting type.")
+ expect(parser.errors[:field_4]).to include(I18n.t("validations.lettings.2023.bulk_upload.needstype.lettype_not_supported_housing"))
+ expect(parser.errors[:field_5]).to include(I18n.t("validations.lettings.2023.bulk_upload.lettype.needstype_supported_housing"))
end
end
@@ -951,7 +951,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_15]).to be_blank
- expect(parser.errors[:field_16]).to eq(["You must answer scheme code."])
+ expect(parser.errors[:field_16]).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "scheme code.")])
expect(parser.errors[:field_17]).to be_blank
end
end
@@ -979,7 +979,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_15]).to be_blank
- expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq(["This scheme code does not belong to the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.scheme.does_not_belong_to_org", scheme_or_management_group: "scheme")])
expect(parser.errors[:field_17]).to be_blank
end
end
@@ -992,7 +992,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
expect(parser.errors[:field_15]).to be_blank
expect(parser.errors[:field_16]).to be_blank
- expect(parser.errors.where(:field_17, category: :setup).map(&:message)).to eq(["You must answer location code."])
+ expect(parser.errors.where(:field_17, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "location code.")])
expect(parser.errors[:field_17].count).to eq(1)
end
end
@@ -1005,7 +1005,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
expect(parser.errors[:field_16]).to be_blank
expect(parser.errors[:field_17]).to be_blank
- expect(parser.errors.where(:field_15, category: :setup).map(&:message)).to eq(["You must answer management group code."])
+ expect(parser.errors.where(:field_15, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "management group code.")])
expect(parser.errors[:field_15].count).to eq(1)
end
end
@@ -1018,7 +1018,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
expect(parser.errors[:field_15]).to be_blank
expect(parser.errors[:field_16]).to be_blank
- expect(parser.errors.where(:field_17, category: :setup).map(&:message)).to eq(["Location code must relate to a location that is owned by the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_17, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.scheme.must_relate_to_org", capitalised_location_or_scheme: "Location", location_or_scheme: "location")])
end
end
@@ -1054,7 +1054,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
expect(parser.errors[:field_15]).to be_blank
expect(parser.errors[:field_16]).to be_blank
- expect(parser.errors.where(:field_17, category: :setup).map(&:message)).to eq(["Location code must relate to a location that is owned by the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_17, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.scheme.must_relate_to_org", capitalised_location_or_scheme: "Location", location_or_scheme: "location")])
end
end
@@ -1067,7 +1067,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_15]).to be_blank
- expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq(["This scheme code does not belong to the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.scheme.does_not_belong_to_org", scheme_or_management_group: "scheme")])
expect(parser.errors[:field_17]).to be_blank
end
end
@@ -1093,7 +1093,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_15]).to be_blank
- expect(parser.errors[:field_16]).to include("You must answer scheme name.")
+ expect(parser.errors[:field_16]).to include(I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "scheme name."))
expect(parser.errors[:field_17]).to be_blank
end
end
@@ -1122,7 +1122,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "returns a setup error" do
parser.valid?
- expect(parser.errors.where(:field_15, category: :setup).map(&:message)).to eq(["This management group code does not belong to the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_15, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.scheme.does_not_belong_to_org", scheme_or_management_group: "management group")])
expect(parser.errors[:field_16]).to be_blank
expect(parser.errors[:field_17]).to be_blank
end
@@ -1135,7 +1135,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_15]).to be_blank
- expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq(["You must answer scheme code."])
+ expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "scheme code.")])
expect(parser.errors[:field_17]).to be_blank
end
end
@@ -1147,7 +1147,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_15]).to be_blank
- expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq(["Scheme code must relate to a scheme that is owned by the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.scheme.must_relate_to_org", capitalised_location_or_scheme: "Scheme", location_or_scheme: "scheme")])
expect(parser.errors[:field_17]).to be_blank
end
end
@@ -1173,7 +1173,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
expect(parser.errors[:field_15]).to be_blank
- expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq(["Scheme code must relate to a scheme that is owned by the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_16, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.scheme.must_relate_to_org", capitalised_location_or_scheme: "Scheme", location_or_scheme: "scheme")])
expect(parser.errors[:field_17]).to be_blank
end
end
@@ -1186,7 +1186,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "returns a setup error" do
parser.valid?
- expect(parser.errors.where(:field_15, category: :setup).map(&:message)).to eq(["This management group code does not belong to the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_15, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2023.bulk_upload.scheme.does_not_belong_to_org", scheme_or_management_group: "management group")])
expect(parser.errors[:field_16]).to be_blank
expect(parser.errors[:field_17]).to be_blank
end
@@ -1212,7 +1212,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "clears the scheme answer" do
parser.valid?
- expect(parser.errors[:field_15]).to include("You must answer scheme name.")
+ expect(parser.errors[:field_15]).to include(I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "scheme name."))
expect(parser.errors[:field_16]).to be_blank
expect(parser.errors[:field_17]).to be_blank
end
@@ -1255,7 +1255,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "returns an error" do
parser.valid?
- expect(parser.errors[:field_102]).to include("Enter a valid value for what is the tenant’s main reason for the household leaving their last settled home?")
+ expect(parser.errors[:field_102]).to include(I18n.t("validations.lettings.2023.bulk_upload.invalid_option", question: "what is the tenant’s main reason for the household leaving their last settled home?"))
end
end
end
@@ -1490,7 +1490,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "returns an error" do
parser.valid?
- expect(parser.errors[:field_9]).to include("Tenancy start year must be 2 or 4 digits.")
+ expect(parser.errors[:field_9]).to include(I18n.t("validations.lettings.2023.bulk_upload.startdate.year_not_two_or_four_digits"))
end
end
@@ -1537,7 +1537,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "is not permitted as setup error" do
parser.valid?
- expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["You must answer owning organisation."])
+ expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "owning organisation.")])
end
it "blocks log creation" do
@@ -1553,7 +1553,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql("The owning organisation code is incorrect.")
+ expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql(I18n.t("validations.lettings.2023.bulk_upload.owning_organisation.not_found"))
end
it "blocks log creation" do
@@ -1571,7 +1571,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql("The owning organisation code provided is for an organisation that does not own stock.")
+ expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql(I18n.t("validations.lettings.2023.bulk_upload.owning_organisation.not_stock_owner"))
end
it "blocks log creation" do
@@ -1589,7 +1589,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql("You do not have permission to add logs for this owning organisation.")
+ expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql(I18n.t("validations.lettings.2023.bulk_upload.owning_organisation.not_permitted"))
end
it "blocks log creation" do
@@ -1652,7 +1652,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("The managing organisation code is incorrect.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.lettings.2023.bulk_upload.managing_organisation.not_answered"))
end
it "blocks log creation" do
@@ -1668,7 +1668,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("The managing organisation code is incorrect.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.lettings.2023.bulk_upload.managing_organisation.not_found"))
end
it "blocks log creation" do
@@ -1686,7 +1686,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("This managing organisation does not have a relationship with the owning organisation.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.lettings.2023.bulk_upload.managing_organisation.no_relationship"))
end
it "blocks log creation" do
@@ -1702,7 +1702,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "is reported as a setup error" do
parser.valid?
- expect(parser.errors.where(:field_4, category: :setup).map(&:message)).to eql(["You must answer needs type."])
+ expect(parser.errors.where(:field_4, category: :setup).map(&:message)).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "needs type.")])
end
end
end
@@ -1713,7 +1713,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "has setup errors on the field" do
parser.valid?
- expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to eql(["You must answer property renewal."])
+ expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "property renewal.")])
end
end
@@ -1722,7 +1722,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds a setup error" do
parser.valid?
- expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to include("Enter a valid value for is this letting a renewal?")
+ expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to include(I18n.t("validations.lettings.2023.bulk_upload.invalid_option", question: "is this letting a renewal?"))
end
end
end
@@ -1743,9 +1743,9 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds appropriate errors" do
parser.valid?
- expect(parser.errors[:field_18]).to eql(["You must answer UPRN."])
- expect(parser.errors[:field_19]).to eql(["You must answer address line 1."])
- expect(parser.errors[:field_21]).to eql(["You must answer town or city."])
+ expect(parser.errors[:field_18]).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "UPRN.")])
+ expect(parser.errors[:field_19]).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "address line 1.")])
+ expect(parser.errors[:field_21]).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "town or city.")])
end
end
@@ -1821,7 +1821,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "populates with correct error message" do
parser.valid?
- expect(parser.errors[:field_30]).to eql(["You must answer type of building."])
+ expect(parser.errors[:field_30]).to eql([I18n.t("validations.lettings.2023.bulk_upload.not_answered", question: "type of building.")])
end
end
end
@@ -2170,7 +2170,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error" do
parser.valid?
- expect(parser.errors[:field_116]).to include("Enter a valid value for was the letting made under the Choice-Based Lettings (CBL)?")
+ expect(parser.errors[:field_116]).to include(I18n.t("validations.lettings.2023.bulk_upload.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"))
end
end
end
@@ -2197,7 +2197,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error" do
parser.valid?
- expect(parser.errors[:field_118]).to include("Enter a valid value for was the letting made under the Common Housing Register (CHR)?")
+ expect(parser.errors[:field_118]).to include(I18n.t("validations.lettings.2023.bulk_upload.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"))
end
end
end
@@ -2224,7 +2224,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "adds an error" do
parser.valid?
- expect(parser.errors[:field_117]).to include("Enter a valid value for was the letting made under the Common Allocation Policy (CAP)?")
+ expect(parser.errors[:field_117]).to include(I18n.t("validations.lettings.2023.bulk_upload.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"))
end
end
end
@@ -2736,8 +2736,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds a and b" do
parser.valid?
- expect(parser.errors[:field_83]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
- expect(parser.errors[:field_84]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
+ expect(parser.errors[:field_83]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds_type.only_one_option_permitted"))
+ expect(parser.errors[:field_84]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds_type.only_one_option_permitted"))
expect(parser.errors[:field_85]).to be_blank
end
end
@@ -2747,8 +2747,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds a and c" do
parser.valid?
- expect(parser.errors[:field_83]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
- expect(parser.errors[:field_85]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
+ expect(parser.errors[:field_83]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds_type.only_one_option_permitted"))
+ expect(parser.errors[:field_85]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds_type.only_one_option_permitted"))
expect(parser.errors[:field_84]).to be_blank
end
end
@@ -2758,8 +2758,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds b and c" do
parser.valid?
- expect(parser.errors[:field_84]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
- expect(parser.errors[:field_85]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
+ expect(parser.errors[:field_84]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds_type.only_one_option_permitted"))
+ expect(parser.errors[:field_85]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds_type.only_one_option_permitted"))
expect(parser.errors[:field_83]).to be_blank
end
end
@@ -2769,8 +2769,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds a and g" do
parser.valid?
- expect(parser.errors[:field_87]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
- expect(parser.errors[:field_83]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
+ expect(parser.errors[:field_87]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds.no_disabled_needs_conjunction"))
+ expect(parser.errors[:field_83]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds.no_disabled_needs_conjunction"))
expect(parser.errors[:field_84]).to be_blank
expect(parser.errors[:field_85]).to be_blank
end
@@ -2793,8 +2793,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "sets error on housingneeds a and h" do
parser.valid?
- expect(parser.errors[:field_88]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
- expect(parser.errors[:field_83]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
+ expect(parser.errors[:field_88]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds.dont_know_disabled_needs_conjunction"))
+ expect(parser.errors[:field_83]).to include(I18n.t("validations.lettings.2023.bulk_upload.housingneeds.dont_know_disabled_needs_conjunction"))
expect(parser.errors[:field_84]).to be_blank
expect(parser.errors[:field_85]).to be_blank
end
diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
index d82effa0b..e33458eb4 100644
--- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
+++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
@@ -283,7 +283,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to all (and only) the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2024.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -339,7 +339,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2024.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -381,7 +381,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2024.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -432,7 +432,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2024.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -492,7 +492,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "does not add an error to all the fields used to determine duplicates" do
parser_too.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2024.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -527,7 +527,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2024.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -574,7 +574,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to all the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2024.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -634,7 +634,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "does not add an error to all the fields used to determine duplicates" do
parser_too.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.lettings.2024.bulk_upload.duplicate")
[
:field_1, # owning_organisation
@@ -770,7 +770,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "fetches the question's check_answer_label if it exists" do
parser.valid?
- expect(parser.errors[:field_43]).to eql(["You must answer lead tenant’s gender identity."])
+ expect(parser.errors[:field_43]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "lead tenant’s gender identity.")])
end
end
@@ -779,7 +779,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "only has one error added to the field" do
parser.valid?
- expect(parser.errors[:field_112]).to eql(["You must answer was the letting made under the Choice-Based Lettings (CBL)?"])
+ expect(parser.errors[:field_112]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?")])
end
end
@@ -789,7 +789,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "does not add an additional error" do
parser.valid?
expect(parser.errors[:field_116].length).to eq(1)
- expect(parser.errors[:field_116]).to include(match "Enter a valid value for")
+ expect(parser.errors[:field_116]).to include(match I18n.t("validations.lettings.2024.bulk_upload.invalid_option", question: ""))
end
end
end
@@ -833,7 +833,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "is not permitted" do
parser.valid?
expect(parser.errors[:field_3]).to be_present
- expect(parser.errors[:field_3]).to include("You must answer what is the CORE username of the account this letting log should be assigned to?")
+ expect(parser.errors[:field_3]).to include(I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "what is the CORE username of the account this letting log should be assigned to?"))
end
it "blocks log creation" do
@@ -915,8 +915,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "cannot be nulled" do
parser.valid?
- expect(parser.errors[:field_5]).to eq(["You must answer scheme code."])
- expect(parser.errors[:field_6]).to eq(["You must answer location code."])
+ expect(parser.errors[:field_5]).to eq([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "scheme code.")])
+ expect(parser.errors[:field_6]).to eq([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "location code.")])
end
end
@@ -942,7 +942,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_2: owning_org.old_visible_id, field_4: "2", field_11: "2", field_5: "S123", field_6: location.id } }
it "returns a setup error" do
- expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to eq(["This scheme code does not belong to the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2024.bulk_upload.scheme.must_relate_to_org")])
expect(parser.errors[:field_6]).to be_blank
end
end
@@ -952,7 +952,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "returns a setup error" do
expect(parser.errors[:field_5]).to be_blank
- expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to eq(["You must answer location code."])
+ expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "location code.")])
expect(parser.errors[:field_6].count).to eq(1)
end
end
@@ -962,7 +962,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "returns a setup error" do
expect(parser.errors[:field_5]).to be_blank
- expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to eq(["Location code must relate to a location that is owned by the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2024.bulk_upload.location.must_relate_to_org")])
end
end
@@ -991,7 +991,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "returns a setup error" do
expect(parser.errors[:field_5]).to be_blank
- expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to eq(["Location code must relate to a location that is owned by the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2024.bulk_upload.location.must_relate_to_org")])
end
end
@@ -1001,7 +1001,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
let(:attributes) { { bulk_upload:, field_4: "2", field_11: "2", field_5: "S#{other_scheme.id}", field_6: other_location.id, field_1: owning_org.old_visible_id, field_2: owning_org.old_visible_id } }
it "returns a setup error" do
- expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to eq(["This scheme code does not belong to the owning organisation or managing organisation."])
+ expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to eq([I18n.t("validations.lettings.2024.bulk_upload.scheme.must_relate_to_org")])
expect(parser.errors[:field_6]).to be_blank
end
end
@@ -1081,7 +1081,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "is not permitted" do
parser.valid?
- expect(parser.errors[:field_98]).to include('The reason for leaving must be "End of social or private sector tenancy - no fault", "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)", "End of social or private sector tenancy - evicted due to rent arrears" or "End of social or private sector tenancy - evicted for any other reason".')
+ expect(parser.errors[:field_98]).to include(I18n.t("validations.lettings.2024.bulk_upload.reason.renewal_reason_needed"))
end
end
end
@@ -1091,7 +1091,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "returns an error" do
parser.valid?
- expect(parser.errors[:field_98]).to include("Enter a valid value for what is the tenant’s main reason for the household leaving their last settled home?")
+ expect(parser.errors[:field_98]).to include(I18n.t("validations.lettings.2024.bulk_upload.invalid_option", question: "what is the tenant’s main reason for the household leaving their last settled home?"))
end
end
end
@@ -1317,7 +1317,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "returns an error" do
parser.valid?
- expect(parser.errors[:field_10]).to include("Tenancy start year must be 2 or 4 digits.")
+ expect(parser.errors[:field_10]).to include(I18n.t("validations.lettings.2024.bulk_upload.startdate.year_not_two_or_four_digits"))
end
end
@@ -1368,7 +1368,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "is not permitted as setup error" do
parser.valid?
- expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["You must answer owning organisation."])
+ expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "owning organisation.")])
end
it "blocks log creation" do
@@ -1385,7 +1385,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql("The owning organisation code is incorrect.")
+ expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql(I18n.t("validations.lettings.2024.bulk_upload.owning_organisation.not_found"))
end
it "blocks log creation" do
@@ -1404,7 +1404,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql("The owning organisation code provided is for an organisation that does not own stock.")
+ expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql(I18n.t("validations.lettings.2024.bulk_upload.owning_organisation.not_stock_owner"))
end
it "blocks log creation" do
@@ -1423,7 +1423,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql("You do not have permission to add logs for this owning organisation.")
+ expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql(I18n.t("validations.lettings.2024.bulk_upload.owning_organisation.not_permitted.not_support"))
end
it "blocks log creation" do
@@ -1492,7 +1492,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
parser = described_class.new(attributes)
parser.valid?
expect(parser).to be_block_log_creation
- expect(parser.errors[:field_1]).to include("You do not have permission to add logs for this owning organisation.")
+ expect(parser.errors[:field_1]).to include(I18n.t("validations.lettings.2024.bulk_upload.owning_organisation.not_permitted.not_support"))
end
end
@@ -1510,7 +1510,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "does not block log creation and does not add an error to field_1" do
parser = described_class.new(attributes)
parser.valid?
- expect(parser.errors[:field_1]).not_to include("You do not have permission to add logs for this owning organisation.")
+ expect(parser.errors[:field_1]).not_to include(I18n.t("validations.lettings.2024.bulk_upload.owning_organisation.not_permitted"))
end
end
end
@@ -1524,7 +1524,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("You must answer managing organisation.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "managing organisation."))
end
it "blocks log creation" do
@@ -1541,7 +1541,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("The managing organisation code is incorrect.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.lettings.2024.bulk_upload.managing_organisation.not_found"))
end
it "blocks log creation" do
@@ -1560,7 +1560,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("This managing organisation does not have a relationship with the owning organisation.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.lettings.2024.bulk_upload.managing_organisation.no_relationship"))
end
it "blocks log creation" do
@@ -1576,7 +1576,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "is reported as a setup error" do
parser.valid?
- expect(parser.errors.where(:field_4, category: :setup).map(&:message)).to eql(["You must answer needs type."])
+ expect(parser.errors.where(:field_4, category: :setup).map(&:message)).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "needs type.")])
end
end
end
@@ -1587,7 +1587,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "has setup errors on the field" do
parser.valid?
- expect(parser.errors.where(:field_7, category: :setup).map(&:message)).to eql(["You must answer property renewal."])
+ expect(parser.errors.where(:field_7, category: :setup).map(&:message)).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "property renewal.")])
end
end
@@ -1596,7 +1596,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds a setup error" do
parser.valid?
- expect(parser.errors.where(:field_7, category: :setup).map(&:message)).to include("Enter a valid value for is this letting a renewal?")
+ expect(parser.errors.where(:field_7, category: :setup).map(&:message)).to include(I18n.t("validations.lettings.2024.bulk_upload.invalid_option", question: "is this letting a renewal?"))
end
end
end
@@ -1627,10 +1627,10 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds errors to missing key address fields" do
parser.valid?
- expect(parser.errors[:field_17]).to eql(["You must answer address line 1."])
- expect(parser.errors[:field_19]).to eql(["You must answer town or city."])
- expect(parser.errors[:field_21]).to eql(["You must answer part 1 of postcode."])
- expect(parser.errors[:field_22]).to eql(["You must answer part 2 of postcode."])
+ expect(parser.errors[:field_17]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "address line 1.")])
+ expect(parser.errors[:field_19]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "town or city.")])
+ expect(parser.errors[:field_21]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "part 1 of postcode.")])
+ expect(parser.errors[:field_22]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "part 2 of postcode.")])
end
end
@@ -1658,11 +1658,11 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds appropriate errors to UPRN and key address fields" do
parser.valid?
- expect(parser.errors[:field_16]).to eql(["You must answer UPRN."])
- expect(parser.errors[:field_17]).to eql(["You must answer address line 1."])
- expect(parser.errors[:field_19]).to eql(["You must answer town or city."])
- expect(parser.errors[:field_21]).to eql(["You must answer part 1 of postcode."])
- expect(parser.errors[:field_22]).to eql(["You must answer part 2 of postcode."])
+ expect(parser.errors[:field_16]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "UPRN.")])
+ expect(parser.errors[:field_17]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "address line 1.")])
+ expect(parser.errors[:field_19]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "town or city.")])
+ expect(parser.errors[:field_21]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "part 1 of postcode.")])
+ expect(parser.errors[:field_22]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "part 2 of postcode.")])
end
end
@@ -1671,8 +1671,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds errors to UPRN and the missing key address field" do
parser.valid?
- expect(parser.errors[:field_16]).to eql(["You must answer UPRN."])
- expect(parser.errors[:field_17]).to eql(["You must answer address line 1."])
+ expect(parser.errors[:field_16]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "UPRN.")])
+ expect(parser.errors[:field_17]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "address line 1.")])
expect(parser.errors[:field_19]).to be_empty
expect(parser.errors[:field_21]).to be_empty
expect(parser.errors[:field_22]).to be_empty
@@ -1706,7 +1706,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
parser.valid?
expect(parser.errors[:field_16]).to be_empty
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
- expect(parser.errors[field]).to eql(["We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."])
+ expect(parser.errors[field]).to eql([I18n.t("validations.lettings.2024.bulk_upload.address.not_found")])
end
end
end
@@ -1721,7 +1721,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
parser.valid?
expect(parser.errors[:field_16]).to be_empty
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
- expect(parser.errors[field]).to eql(["We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."])
+ expect(parser.errors[field]).to eql([I18n.t("validations.lettings.2024.bulk_upload.address.not_found")])
end
end
end
@@ -1765,7 +1765,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "populates with correct error message" do
parser.valid?
- expect(parser.errors[:field_27]).to eql(["You must answer type of building."])
+ expect(parser.errors[:field_27]).to eql([I18n.t("validations.lettings.2024.bulk_upload.not_answered", question: "type of building.")])
end
end
end
@@ -1864,7 +1864,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to field_45" do
parser.valid?
- expect(parser.errors["field_45"]).to include("Select a valid nationality.")
+ expect(parser.errors["field_45"]).to include(I18n.t("validations.lettings.2024.bulk_upload.nationality.invalid"))
end
end
end
@@ -2185,7 +2185,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error" do
parser.valid?
- expect(parser.errors[:field_112]).to include("Enter a valid value for was the letting made under the Choice-Based Lettings (CBL)?")
+ expect(parser.errors[:field_112]).to include(I18n.t("validations.lettings.2024.bulk_upload.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"))
end
end
end
@@ -2212,7 +2212,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error" do
parser.valid?
- expect(parser.errors[:field_114]).to include("Enter a valid value for was the letting made under the Common Housing Register (CHR)?")
+ expect(parser.errors[:field_114]).to include(I18n.t("validations.lettings.2024.bulk_upload.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"))
end
end
end
@@ -2239,7 +2239,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error" do
parser.valid?
- expect(parser.errors[:field_113]).to include("Enter a valid value for was the letting made under the Common Allocation Policy (CAP)?")
+ expect(parser.errors[:field_113]).to include(I18n.t("validations.lettings.2024.bulk_upload.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"))
end
end
end
@@ -2266,7 +2266,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error" do
parser.valid?
- expect(parser.errors[:field_115]).to include("Enter a valid value for was the letting made under the Accessible Register?")
+ expect(parser.errors[:field_115]).to include(I18n.t("validations.lettings.2024.bulk_upload.invalid_option", question: "was the letting made under the Accessible Register?"))
end
end
end
@@ -2603,10 +2603,10 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to all missing charges" do
parser.valid?
- expect(parser.errors[:field_125]).to eql(["Please enter the basic rent. If there is no basic rent, please enter '0'."])
- expect(parser.errors[:field_126]).to eql(["Please enter the service charge. If there is no service charge, please enter '0'."])
- expect(parser.errors[:field_127]).to eql(["Please enter the personal service charge. If there is no personal service charge, please enter '0'."])
- expect(parser.errors[:field_128]).to eql(["Please enter the basic rent. If there is no basic rent, please enter '0'.", "Please enter the service charge. If there is no service charge, please enter '0'.", "Please enter the personal service charge. If there is no personal service charge, please enter '0'."])
+ expect(parser.errors[:field_125]).to eql([I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "basic rent")])
+ expect(parser.errors[:field_126]).to eql([I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "service charge")])
+ expect(parser.errors[:field_127]).to eql([I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "personal service charge")])
+ expect(parser.errors[:field_128]).to eql([I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "basic rent"), I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "service charge"), I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "personal service charge")])
end
end
end
@@ -2627,10 +2627,10 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "adds an error to all charges" do
parser.valid?
- expect(parser.errors[:field_125]).to eql(["Please enter the support charge. If there is no support charge, please enter '0'."])
- expect(parser.errors[:field_126]).to eql(["Please enter the support charge. If there is no support charge, please enter '0'."])
- expect(parser.errors[:field_127]).to eql(["Please enter the support charge. If there is no support charge, please enter '0'."])
- expect(parser.errors[:field_128]).to eql(["Please enter the support charge. If there is no support charge, please enter '0'."])
+ expect(parser.errors[:field_125]).to eql([I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "support charge")])
+ expect(parser.errors[:field_126]).to eql([I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "support charge")])
+ expect(parser.errors[:field_127]).to eql([I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "support charge")])
+ expect(parser.errors[:field_128]).to eql([I18n.t("validations.lettings.2024.bulk_upload.charges.missing_charges", sentence_fragment: "support charge")])
end
end
end
@@ -2857,8 +2857,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds a and b" do
parser.valid?
- expect(parser.errors[:field_79]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
- expect(parser.errors[:field_80]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
+ expect(parser.errors[:field_79]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds_type.only_one_option_permitted"))
+ expect(parser.errors[:field_80]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds_type.only_one_option_permitted"))
expect(parser.errors[:field_81]).to be_blank
end
end
@@ -2868,8 +2868,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds a and c" do
parser.valid?
- expect(parser.errors[:field_79]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
- expect(parser.errors[:field_81]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
+ expect(parser.errors[:field_79]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds_type.only_one_option_permitted"))
+ expect(parser.errors[:field_81]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds_type.only_one_option_permitted"))
expect(parser.errors[:field_80]).to be_blank
end
end
@@ -2879,8 +2879,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds b and c" do
parser.valid?
- expect(parser.errors[:field_80]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
- expect(parser.errors[:field_81]).to include("Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected.")
+ expect(parser.errors[:field_80]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds_type.only_one_option_permitted"))
+ expect(parser.errors[:field_81]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds_type.only_one_option_permitted"))
expect(parser.errors[:field_79]).to be_blank
end
end
@@ -2890,8 +2890,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds a and g" do
parser.valid?
- expect(parser.errors[:field_83]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
- expect(parser.errors[:field_79]).to include("No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
+ expect(parser.errors[:field_83]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds.no_disabled_needs_conjunction"))
+ expect(parser.errors[:field_79]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds.no_disabled_needs_conjunction"))
expect(parser.errors[:field_80]).to be_blank
expect(parser.errors[:field_81]).to be_blank
end
@@ -2914,8 +2914,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "sets error on housingneeds a and h" do
parser.valid?
- expect(parser.errors[:field_84]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
- expect(parser.errors[:field_79]).to include("Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs.")
+ expect(parser.errors[:field_84]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds.dont_know_disabled_needs_conjunction"))
+ expect(parser.errors[:field_79]).to include(I18n.t("validations.lettings.2024.bulk_upload.housingneeds.dont_know_disabled_needs_conjunction"))
expect(parser.errors[:field_80]).to be_blank
expect(parser.errors[:field_81]).to be_blank
end
From dd9bc7b191de71c40d696bef520c1dc1b4623686 Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Tue, 5 Nov 2024 10:43:17 +0000
Subject: [PATCH 06/27] CLDC-3669 Extract bulk upload validations (#2719)
---
app/services/bulk_upload/processor.rb | 6 +-
app/services/bulk_upload/sales/validator.rb | 10 +-
.../bulk_upload/sales/year2023/row_parser.rb | 77 ++++++++--------
.../bulk_upload/sales/year2024/row_parser.rb | 90 +++++++++---------
config/locales/en.yml | 8 --
.../validations/sales/2023/bulk_upload.en.yml | 29 ++++++
.../validations/sales/2024/bulk_upload.en.yml | 44 +++++++++
.../bulk_upload/sales/validator_spec.rb | 6 +-
.../sales/year2023/row_parser_spec.rb | 20 ++--
.../sales/year2024/row_parser_spec.rb | 92 +++++++++----------
10 files changed, 225 insertions(+), 157 deletions(-)
create mode 100644 config/locales/validations/sales/2023/bulk_upload.en.yml
create mode 100644 config/locales/validations/sales/2024/bulk_upload.en.yml
diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb
index 3a6ef4a33..38f67ede4 100644
--- a/app/services/bulk_upload/processor.rb
+++ b/app/services/bulk_upload/processor.rb
@@ -6,7 +6,8 @@ class BulkUpload::Processor
[
I18n.t("validations.lettings.#{current_collection_start_year}.bulk_upload.blank_file"),
I18n.t("validations.lettings.#{previous_collection_start_year}.bulk_upload.blank_file"),
- I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base.blank_file"),
+ I18n.t("validations.sales.#{current_collection_start_year}.bulk_upload.blank_file"),
+ I18n.t("validations.sales.#{previous_collection_start_year}.bulk_upload.blank_file"),
].freeze
end
@@ -14,7 +15,8 @@ class BulkUpload::Processor
[
*I18n.t("validations.lettings.#{current_collection_start_year}.bulk_upload.wrong_template", default: {}).values,
*I18n.t("validations.lettings.#{previous_collection_start_year}.bulk_upload.wrong_template", default: {}).values,
- *I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base", default: {}).values,
+ *I18n.t("validations.sales.#{current_collection_start_year}.bulk_upload.wrong_template", default: {}).values,
+ *I18n.t("validations.sales.#{previous_collection_start_year}.bulk_upload.wrong_template", default: {}).values,
].freeze
end
diff --git a/app/services/bulk_upload/sales/validator.rb b/app/services/bulk_upload/sales/validator.rb
index a473a6461..76fb6f1ae 100644
--- a/app/services/bulk_upload/sales/validator.rb
+++ b/app/services/bulk_upload/sales/validator.rb
@@ -153,7 +153,7 @@ private
def validate_file_not_empty
if File.size(path).zero? || csv_parser.body_rows.flatten.compact.empty?
- errors.add(:base, :blank_file)
+ errors.add(:base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.blank_file"))
halt_validations!
end
@@ -164,20 +164,20 @@ private
column_count = rows.map(&:size).max
- errors.add(:base, :over_max_column_count) if column_count > csv_parser.class::MAX_COLUMNS
+ errors.add(:base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.wrong_template.over_max_column_count")) if column_count > csv_parser.class::MAX_COLUMNS
end
def validate_correct_template
return if halt_validations?
- errors.add(:base, :wrong_template) if csv_parser.wrong_template_for_year?
+ errors.add(:base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.wrong_template.wrong_template")) if csv_parser.wrong_template_for_year?
end
def validate_missing_required_headers
return if halt_validations?
if csv_parser.missing_required_headers?
- errors.add :base, I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base.no_headers", guidance_link: bulk_upload_sales_log_url(id: "guidance", form: { year: bulk_upload.year }, host: ENV["APP_HOST"], anchor: "using-the-bulk-upload-template"))
+ errors.add :base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.wrong_template.no_headers", guidance_link: bulk_upload_sales_log_url(id: "guidance", form: { year: bulk_upload.year }, host: ENV["APP_HOST"], anchor: "using-the-bulk-upload-template"))
end
end
@@ -185,7 +185,7 @@ private
return if halt_validations?
unless csv_parser.correct_field_count?
- errors.add(:base, :wrong_field_numbers_count)
+ errors.add(:base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.wrong_template.wrong_field_numbers_count"))
halt_validations!
end
end
diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb
index d87c94dce..39fb41d6b 100644
--- a/app/services/bulk_upload/sales/year2023/row_parser.rb
+++ b/app/services/bulk_upload/sales/year2023/row_parser.rb
@@ -155,6 +155,8 @@ class BulkUpload::Sales::Year2023::RowParser
field_135: "What are the total monthly leasehold charges for the property?",
}.freeze
+ ERROR_BASE_KEY = "validations.sales.2023.bulk_upload".freeze
+
attribute :bulk_upload
attribute :block_log_creation, :boolean, default: -> { false }
@@ -311,32 +313,32 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_3,
presence: {
- message: I18n.t("validations.not_answered", question: "sale completion date (day)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (day)."),
category: :setup,
},
on: :after_log
validates :field_4,
presence: {
- message: I18n.t("validations.not_answered", question: "sale completion date (month)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (month)."),
category: :setup,
}, on: :after_log
validates :field_5,
presence: {
- message: I18n.t("validations.not_answered", question: "sale completion date (year)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (year)."),
category: :setup,
},
format: {
with: /\A(\d{2}|\d{4})\z/,
- message: I18n.t("validations.setup.saledate.year_not_two_or_four_digits"),
+ message: I18n.t("#{ERROR_BASE_KEY}.saledate.year_not_two_or_four_digits"),
category: :setup,
if: proc { field_5.present? },
}, on: :after_log
validates :field_7,
presence: {
- message: I18n.t("validations.not_answered", question: "purchase made under ownership scheme."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "purchase made under ownership scheme."),
category: :setup,
},
on: :after_log
@@ -352,7 +354,7 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_8,
presence: {
- message: I18n.t("validations.not_answered", question: "type of shared ownership sale."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of shared ownership sale."),
category: :setup,
if: :shared_ownership?,
},
@@ -369,7 +371,7 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_9,
presence: {
- message: I18n.t("validations.not_answered", question: "type of discounted ownership sale."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of discounted ownership sale."),
category: :setup,
if: :discounted_ownership?,
},
@@ -386,7 +388,7 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_10,
presence: {
- message: I18n.t("validations.not_answered", question: "type of outright sale."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of outright sale."),
category: :setup,
if: :outright_sale?,
},
@@ -394,7 +396,7 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_11,
presence: {
- message: I18n.t("validations.not_answered", question: "type of outright sale."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of outright sale."),
category: :setup,
if: proc { field_10 == 12 },
},
@@ -411,7 +413,7 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_12,
presence: {
- message: I18n.t("validations.not_answered", question: "company buyer."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "company buyer."),
category: :setup,
if: :outright_sale?,
},
@@ -428,7 +430,7 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_13,
presence: {
- message: I18n.t("validations.not_answered", question: "buyers living in property."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "buyers living in property."),
category: :setup,
if: :outright_sale?,
},
@@ -436,7 +438,7 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_14,
presence: {
- message: I18n.t("validations.not_answered", question: "joint purchase."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "joint purchase."),
category: :setup,
if: :joint_purchase_asked?,
},
@@ -444,7 +446,7 @@ class BulkUpload::Sales::Year2023::RowParser
validates :field_15,
presence: {
- message: I18n.t("validations.not_answered", question: "more than 2 joint buyers."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "more than 2 joint buyers."),
category: :setup,
if: :joint_purchase?,
},
@@ -560,7 +562,7 @@ class BulkUpload::Sales::Year2023::RowParser
def add_duplicate_found_in_spreadsheet_errors
spreadsheet_duplicate_hash.each_key do |field|
- errors.add(field, :spreadsheet_dupe, category: :setup)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup)
end
end
@@ -568,7 +570,7 @@ private
def validate_data_protection_answered
unless field_29 == 1
- errors.add(:field_29, I18n.t("validations.not_answered", question: "Data Protection question."), category: :setup)
+ errors.add(:field_29, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "Data Protection question."), category: :setup)
end
end
@@ -600,18 +602,19 @@ private
def validate_uprn_exists_if_any_key_address_fields_are_blank
if field_19.blank? && (field_20.blank? || field_22.blank?)
- errors.add(:field_19, I18n.t("validations.not_answered", question: "UPRN."), category: :not_answered)
+ # I18n.t("#{ERROR_BASE_KEY}.not_answered", question: question.error_display_label)
+ errors.add(:field_19, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "UPRN."), category: :not_answered)
end
end
def validate_address_fields
if field_19.blank? || log.errors.attribute_names.include?(:uprn)
if field_20.blank?
- errors.add(:field_20, I18n.t("validations.not_answered", question: "address line 1."), category: :not_answered)
+ errors.add(:field_20, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "address line 1."), category: :not_answered)
end
if field_22.blank?
- errors.add(:field_22, I18n.t("validations.not_answered", question: "town or city."), category: :not_answered)
+ errors.add(:field_22, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "town or city."), category: :not_answered)
end
end
end
@@ -1162,7 +1165,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_answered"), category: :setup)
end
end
end
@@ -1172,7 +1175,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_found"), category: :setup)
end
end
end
@@ -1182,7 +1185,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_stock_owner"), category: :setup)
end
end
end
@@ -1192,7 +1195,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "You do not have permission to add logs for this owning organisation.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted"), category: :setup)
end
end
end
@@ -1201,7 +1204,7 @@ private
return if field_2.blank?
unless assigned_to
- errors.add(:field_2, "User with the specified email could not be found.")
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.assigned_to.not_found"))
end
end
@@ -1211,7 +1214,7 @@ private
return if assigned_to.organisation == owning_organisation&.absorbing_organisation || assigned_to.organisation == managing_organisation&.absorbing_organisation
block_log_creation!
- errors.add(:field_2, "User must be related to owning organisation or managing organisation.", category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.assigned_to.organisation_not_related"), category: :setup)
end
def managing_organisation
@@ -1225,7 +1228,7 @@ private
block_log_creation!
if errors[:field_2].blank?
- errors.add(:field_2, "This user belongs to an organisation that does not have a relationship with the owning organisation.", category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.assigned_to.managing_organisation_not_related"), category: :setup)
end
end
end
@@ -1246,13 +1249,13 @@ private
if setup_question?(question)
fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) }
- errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label), category: :setup)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: question.error_display_label), category: :setup)
end
end
else
fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) }
- errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label), category: :not_answered)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: question.error_display_label), category: :not_answered)
end
end
end
@@ -1272,15 +1275,15 @@ private
if setup_question?(question)
fields.each do |field|
- if errors[field].none?
- block_log_creation!
- errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup)
- end
+ next unless errors[field].none?
+
+ block_log_creation!
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup)
end
else
fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) }
- errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])))
end
end
end
@@ -1292,15 +1295,15 @@ private
return if errors.key?(:field_3) || errors.key?(:field_4) || errors.key?(:field_5)
unless bulk_upload.form.valid_start_date_for_form?(saledate)
- errors.add(:field_3, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
- errors.add(:field_4, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
- errors.add(:field_5, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.saledate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.saledate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.saledate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
end
end
def validate_if_log_already_exists
if log_already_exists?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("#{ERROR_BASE_KEY}.duplicate")
errors.add(:field_1, error_message) # Owning org
errors.add(:field_3, error_message) # Sale completion date
@@ -1335,7 +1338,7 @@ private
def validate_buyer1_economic_status
if field_35 == 9
- errors.add(:field_35, "Buyer 1 cannot be a child under 16.")
+ errors.add(:field_35, I18n.t("#{ERROR_BASE_KEY}.ecstat1.child_under_16"))
end
end
end
diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb
index 7b72eef5c..fdef65aec 100644
--- a/app/services/bulk_upload/sales/year2024/row_parser.rb
+++ b/app/services/bulk_upload/sales/year2024/row_parser.rb
@@ -151,6 +151,8 @@ class BulkUpload::Sales::Year2024::RowParser
field_131: "What are the total monthly leasehold charges for the property?",
}.freeze
+ ERROR_BASE_KEY = "validations.sales.2024.bulk_upload".freeze
+
attribute :bulk_upload
attribute :block_log_creation, :boolean, default: -> { false }
@@ -303,32 +305,32 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_4,
presence: {
- message: I18n.t("validations.not_answered", question: "sale completion date (day)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (day)."),
category: :setup,
},
on: :after_log
validates :field_5,
presence: {
- message: I18n.t("validations.not_answered", question: "sale completion date (month)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (month)."),
category: :setup,
}, on: :after_log
validates :field_6,
presence: {
- message: I18n.t("validations.not_answered", question: "sale completion date (year)."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (year)."),
category: :setup,
},
format: {
with: /\A(\d{2}|\d{4})\z/,
- message: I18n.t("validations.setup.saledate.year_not_two_or_four_digits"),
+ message: I18n.t("#{ERROR_BASE_KEY}.saledate.year_not_two_or_four_digits"),
category: :setup,
if: proc { field_6.present? },
}, on: :after_log
validates :field_8,
presence: {
- message: I18n.t("validations.not_answered", question: "purchase made under ownership scheme."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "purchase made under ownership scheme."),
category: :setup,
},
on: :after_log
@@ -344,7 +346,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_9,
presence: {
- message: I18n.t("validations.not_answered", question: "type of shared ownership sale."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of shared ownership sale."),
category: :setup,
if: :shared_ownership?,
},
@@ -361,7 +363,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_10,
presence: {
- message: I18n.t("validations.not_answered", question: "type of discounted ownership sale."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of discounted ownership sale."),
category: :setup,
if: :discounted_ownership?,
},
@@ -369,7 +371,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_116,
numericality: {
- message: I18n.t("validations.numeric.within_range", field: "Percentage discount", min: "0%", max: "70%"),
+ message: I18n.t("#{ERROR_BASE_KEY}.numeric.within_range", field: "Percentage discount", min: "0%", max: "70%"),
greater_than_or_equal_to: 0,
less_than_or_equal_to: 70,
if: :discounted_ownership?,
@@ -387,7 +389,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_11,
presence: {
- message: I18n.t("validations.not_answered", question: "type of outright sale."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of outright sale."),
category: :setup,
if: :outright_sale?,
},
@@ -395,7 +397,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_12,
presence: {
- message: I18n.t("validations.not_answered", question: "type of outright sale."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of outright sale."),
category: :setup,
if: proc { field_11 == 12 },
},
@@ -412,7 +414,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_13,
presence: {
- message: I18n.t("validations.not_answered", question: "company buyer."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "company buyer."),
category: :setup,
if: :outright_sale?,
},
@@ -429,7 +431,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_14,
presence: {
- message: I18n.t("validations.not_answered", question: "buyers living in property."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "buyers living in property."),
category: :setup,
if: :outright_sale?,
},
@@ -437,7 +439,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_15,
presence: {
- message: I18n.t("validations.not_answered", question: "joint purchase."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "joint purchase."),
category: :setup,
if: :joint_purchase_asked?,
},
@@ -445,7 +447,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_16,
presence: {
- message: I18n.t("validations.not_answered", question: "more than 2 joint buyers."),
+ message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "more than 2 joint buyers."),
category: :setup,
if: :joint_purchase?,
},
@@ -569,7 +571,7 @@ class BulkUpload::Sales::Year2024::RowParser
def add_duplicate_found_in_spreadsheet_errors
spreadsheet_duplicate_hash.each_key do |field|
- errors.add(field, :spreadsheet_dupe, category: :setup)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup)
end
end
@@ -603,14 +605,14 @@ private
def validate_uprn_exists_if_any_key_address_fields_are_blank
if field_22.blank? && !key_address_fields_provided?
- errors.add(:field_22, I18n.t("validations.not_answered", question: "UPRN."))
+ errors.add(:field_22, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "UPRN."))
end
end
def validate_address_option_found
if log.uprn.nil? && field_22.blank? && key_address_fields_provided?
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
- errors.add(field, I18n.t("validations.no_address_found"))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.address.not_found"))
end
end
end
@@ -622,19 +624,19 @@ private
def validate_address_fields
if field_22.blank? || log.errors.attribute_names.include?(:uprn)
if field_23.blank?
- errors.add(:field_23, I18n.t("validations.not_answered", question: "address line 1."))
+ errors.add(:field_23, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "address line 1."))
end
if field_25.blank?
- errors.add(:field_25, I18n.t("validations.not_answered", question: "town or city."))
+ errors.add(:field_25, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "town or city."))
end
if field_27.blank?
- errors.add(:field_27, I18n.t("validations.not_answered", question: "part 1 of postcode."))
+ errors.add(:field_27, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "part 1 of postcode."))
end
if field_28.blank?
- errors.add(:field_28, I18n.t("validations.not_answered", question: "part 2 of postcode."))
+ errors.add(:field_28, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "part 2 of postcode."))
end
end
end
@@ -1281,7 +1283,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, I18n.t("validations.not_answered", question: "owning organisation."), category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "owning organisation."), category: :setup)
end
end
end
@@ -1291,7 +1293,7 @@ private
block_log_creation!
if field_1.present? && errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_found"), category: :setup)
end
end
end
@@ -1301,7 +1303,7 @@ private
block_log_creation!
if errors[:field_1].blank?
- errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_stock_owner"), category: :setup)
end
end
end
@@ -1315,9 +1317,9 @@ private
return if errors[:field_1].present?
if bulk_upload.user.support?
- errors.add(:field_1, "This owning organisation is not affiliated with #{bulk_upload_organisation.name}.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted.support", name: bulk_upload_organisation.name), category: :setup)
else
- errors.add(:field_1, "You do not have permission to add logs for this owning organisation.", category: :setup)
+ errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted.not_support"), category: :setup)
end
end
@@ -1325,13 +1327,13 @@ private
return if field_3.blank?
unless assigned_to
- errors.add(:field_3, "User with the specified email could not be found.")
+ errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.not_found"))
end
end
def validate_assigned_to_when_support
if field_3.blank? && bulk_upload.user.support?
- errors.add(:field_3, category: :setup, message: I18n.t("validations.not_answered", question: "what is the CORE username of the account this sales log should be assigned to?"))
+ errors.add(:field_3, category: :setup, message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "what is the CORE username of the account this sales log should be assigned to?"))
end
end
@@ -1341,7 +1343,7 @@ private
return if assigned_to.organisation == owning_organisation&.absorbing_organisation || assigned_to.organisation == managing_organisation&.absorbing_organisation
block_log_creation!
- errors.add(:field_3, "User must be related to owning organisation or managing organisation.", category: :setup)
+ errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.organisation_not_related"), category: :setup)
end
def managing_organisation
@@ -1361,7 +1363,7 @@ private
block_log_creation!
if errors[:field_2].blank?
- errors.add(:field_2, "This organisation does not have a relationship with the owning organisation.", category: :setup)
+ errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.assigned_to.managing_organisation_not_related"), category: :setup)
end
end
end
@@ -1410,13 +1412,13 @@ private
fields.each do |field|
if errors[field].none?
block_log_creation!
- errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup)
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup)
end
end
else
fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) }
- errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])))
+ errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])))
end
end
end
@@ -1428,15 +1430,15 @@ private
return if errors.key?(:field_4) || errors.key?(:field_5) || errors.key?(:field_6)
unless bulk_upload.form.valid_start_date_for_form?(saledate)
- errors.add(:field_4, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
- errors.add(:field_5, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
- errors.add(:field_6, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.saledate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.saledate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
+ errors.add(:field_6, I18n.t("#{ERROR_BASE_KEY}.saledate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
end
end
def validate_if_log_already_exists
if log_already_exists?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("#{ERROR_BASE_KEY}.duplicate")
errors.add(:field_1, error_message) # Owning org
errors.add(:field_4, error_message) # Sale completion date
@@ -1472,10 +1474,10 @@ private
def validate_buyer1_economic_status
if field_35 == 9
if field_31.present? && field_31.to_i >= 16
- errors.add(:field_35, I18n.t("validations.sales.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "1"))
- errors.add(:field_31, I18n.t("validations.sales.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "1"))
+ errors.add(:field_35, I18n.t("#{ERROR_BASE_KEY}.ecstat1.buyer_cannot_be_over_16_and_child"))
+ errors.add(:field_31, I18n.t("#{ERROR_BASE_KEY}.age1.buyer_cannot_be_over_16_and_child"))
else
- errors.add(:field_35, I18n.t("validations.sales.household.ecstat1.buyer_cannot_be_child"))
+ errors.add(:field_35, I18n.t("#{ERROR_BASE_KEY}.ecstat1.buyer_cannot_be_child"))
end
end
end
@@ -1485,23 +1487,23 @@ private
if field_42 == 9
if field_38.present? && field_38.to_i >= 16
- errors.add(:field_42, I18n.t("validations.sales.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "2"))
- errors.add(:field_38, I18n.t("validations.sales.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "2"))
+ errors.add(:field_42, I18n.t("#{ERROR_BASE_KEY}.ecstat2.buyer_cannot_be_over_16_and_child"))
+ errors.add(:field_38, I18n.t("#{ERROR_BASE_KEY}.age2.buyer_cannot_be_over_16_and_child"))
else
- errors.add(:field_42, I18n.t("validations.sales.household.ecstat2.buyer_cannot_be_child"))
+ errors.add(:field_42, I18n.t("#{ERROR_BASE_KEY}.ecstat2.buyer_cannot_be_child"))
end
end
end
def validate_nationality
if field_34.present? && !valid_nationality_options.include?(field_34.to_s)
- errors.add(:field_34, I18n.t("validations.household.nationality"))
+ errors.add(:field_34, I18n.t("#{ERROR_BASE_KEY}.nationality.invalid"))
end
end
def validate_buyer_2_nationality
if field_41.present? && !valid_nationality_options.include?(field_41.to_s)
- errors.add(:field_41, I18n.t("validations.household.nationality"))
+ errors.add(:field_41, I18n.t("#{ERROR_BASE_KEY}.nationality.invalid"))
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 63d80d418..81c94b8c4 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -61,14 +61,6 @@ en:
<<: *bulk_upload__row_parser__base
bulk_upload/sales/year2023/row_parser:
<<: *bulk_upload__row_parser__base
- bulk_upload/sales/validator:
- attributes:
- base:
- blank_file: "Template is blank - The template must be filled in for us to create the logs and check if data is correct."
- wrong_field_numbers_count: "Incorrect number of fields, please ensure you have used the correct template."
- over_max_column_count: "Too many columns, please ensure you have used the correct template."
- wrong_template: "Incorrect sale dates, please ensure you have used the correct template."
- no_headers: "Your file does not contain the required header rows. Add or check the header rows and upload your file again. [Read more about using the template headers](%{guidance_link})."
forms/bulk_upload_lettings/year:
attributes:
year:
diff --git a/config/locales/validations/sales/2023/bulk_upload.en.yml b/config/locales/validations/sales/2023/bulk_upload.en.yml
new file mode 100644
index 000000000..517f56858
--- /dev/null
+++ b/config/locales/validations/sales/2023/bulk_upload.en.yml
@@ -0,0 +1,29 @@
+en:
+ validations:
+ sales:
+ 2023:
+ bulk_upload:
+ not_answered: "You must answer %{question}"
+ invalid_option: "Enter a valid value for %{question}"
+ spreadsheet_dupe: "This is a duplicate of a log in your file."
+ duplicate: "This is a duplicate log."
+ blank_file: "Template is blank - The template must be filled in for us to create the logs and check if data is correct."
+ wrong_template:
+ wrong_template: "Incorrect sale dates, please ensure you have used the correct template."
+ no_headers: "Your file does not contain the required header rows. Add or check the header rows and upload your file again. [Read more about using the template headers](%{guidance_link})."
+ wrong_field_numbers_count: "Incorrect number of fields, please ensure you have used the correct template."
+ over_max_column_count: "Too many columns, please ensure you have used the correct template."
+ owning_organisation:
+ not_answered: "The owning organisation code is incorrect."
+ not_found: "The owning organisation code is incorrect."
+ not_stock_owner: "The owning organisation code provided is for an organisation that does not own stock."
+ not_permitted: "You do not have permission to add logs for this owning organisation."
+ assigned_to:
+ not_found: "User with the specified email could not be found."
+ organisation_not_related: "User must be related to owning organisation or managing organisation."
+ managing_organisation_not_related: "This user belongs to an organisation that does not have a relationship with the owning organisation."
+ saledate:
+ outside_collection_window: "Enter a date within the %{year_combo} collection year, which is between 1st April %{start_year} and 31st March %{end_year}."
+ year_not_two_or_four_digits: "Sale completion year must be 2 or 4 digits."
+ ecstat1:
+ child_under_16: "Buyer 1 cannot be a child under 16."
diff --git a/config/locales/validations/sales/2024/bulk_upload.en.yml b/config/locales/validations/sales/2024/bulk_upload.en.yml
new file mode 100644
index 000000000..fc68662d1
--- /dev/null
+++ b/config/locales/validations/sales/2024/bulk_upload.en.yml
@@ -0,0 +1,44 @@
+en:
+ validations:
+ sales:
+ 2024:
+ bulk_upload:
+ not_answered: "You must answer %{question}"
+ invalid_option: "Enter a valid value for %{question}"
+ spreadsheet_dupe: "This is a duplicate of a log in your file."
+ duplicate: "This is a duplicate log."
+ blank_file: "Template is blank - The template must be filled in for us to create the logs and check if data is correct."
+ wrong_template:
+ over_max_column_count: "Too many columns, please ensure you have used the correct template."
+ no_headers: "Your file does not contain the required header rows. Add or check the header rows and upload your file again. [Read more about using the template headers](%{guidance_link})."
+ wrong_field_numbers_count: "Incorrect number of fields, please ensure you have used the correct template."
+ wrong_template: "Incorrect sale dates, please ensure you have used the correct template."
+ numeric:
+ within_range: "%{field} must be between %{min} and %{max}."
+ owning_organisation:
+ not_found: "The owning organisation code is incorrect."
+ not_stock_owner: "The owning organisation code provided is for an organisation that does not own stock."
+ not_permitted:
+ support: "This owning organisation is not affiliated with %(name)."
+ not_support: "You do not have permission to add logs for this owning organisation."
+ assigned_to:
+ not_found: "User with the specified email could not be found."
+ organisation_not_related: "User must be related to owning organisation or managing organisation."
+ managing_organisation_not_related: "This organisation does not have a relationship with the owning organisation."
+ saledate:
+ outside_collection_window: "Enter a date within the %{year_combo} collection year, which is between 1st April %{start_year} and 31st March %{end_year}."
+ year_not_two_or_four_digits: "Sale completion year must be 2 or 4 digits."
+ ecstat1:
+ buyer_cannot_be_over_16_and_child: "Buyer 1's age cannot be 16 or over if their working situation is child under 16."
+ buyer_cannot_be_child: "Buyer 1 cannot have a working situation of child under 16."
+ age1:
+ buyer_cannot_be_over_16_and_child: "Buyer 1's age cannot be 16 or over if their working situation is child under 16."
+ ecstat2:
+ buyer_cannot_be_over_16_and_child: "Buyer 2's age cannot be 16 or over if their working situation is child under 16."
+ buyer_cannot_be_child: "Buyer 2 cannot have a working situation of child under 16."
+ age2:
+ buyer_cannot_be_over_16_and_child: "Buyer 2's age cannot be 16 or over if their working situation is child under 16."
+ address:
+ not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."
+ nationality:
+ invalid: "Select a valid nationality."
diff --git a/spec/services/bulk_upload/sales/validator_spec.rb b/spec/services/bulk_upload/sales/validator_spec.rb
index d196126c9..c275ce681 100644
--- a/spec/services/bulk_upload/sales/validator_spec.rb
+++ b/spec/services/bulk_upload/sales/validator_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe BulkUpload::Sales::Validator do
context "when file is empty" do
it "is not valid" do
expect(validator).not_to be_valid
- expect(validator.errors["base"]).to eql(["Template is blank - The template must be filled in for us to create the logs and check if data is correct."])
+ expect(validator.errors["base"]).to eql([I18n.t("validations.sales.2024.bulk_upload.blank_file")])
end
end
@@ -27,7 +27,7 @@ RSpec.describe BulkUpload::Sales::Validator do
it "is not valid" do
expect(validator).not_to be_valid
- expect(validator.errors["base"]).to eql(["Template is blank - The template must be filled in for us to create the logs and check if data is correct."])
+ expect(validator.errors["base"]).to eql([I18n.t("validations.sales.2024.bulk_upload.blank_file")])
end
end
@@ -54,7 +54,7 @@ RSpec.describe BulkUpload::Sales::Validator do
it "is not valid" do
expect(validator).not_to be_valid
- expect(validator.errors["base"]).to eql(["Incorrect sale dates, please ensure you have used the correct template."])
+ expect(validator.errors["base"]).to eql([I18n.t("validations.sales.2024.bulk_upload.wrong_template.wrong_template")])
end
end
diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb
index 70bd923e6..2994a418e 100644
--- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb
+++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb
@@ -406,7 +406,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
let(:attributes) { setup_section_params.merge(field_1: nil) }
it "is not permitted as setup error" do
- expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["You must answer owning organisation."])
+ expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql([I18n.t("validations.sales.2023.bulk_upload.not_answered", question: "owning organisation.")])
end
it "blocks log creation" do
@@ -418,7 +418,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
let(:attributes) { { bulk_upload:, field_1: "donotexist" } }
it "is not permitted as a setup error" do
- expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["You must answer owning organisation."])
+ expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql([I18n.t("validations.sales.2023.bulk_upload.not_answered", question: "owning organisation.")])
end
it "blocks log creation" do
@@ -432,7 +432,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
let(:attributes) { { bulk_upload:, field_1: unaffiliated_org.old_visible_id } }
it "is not permitted as setup error" do
- expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["You do not have permission to add logs for this owning organisation."])
+ expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql([I18n.t("validations.sales.2023.bulk_upload.owning_organisation.not_permitted")])
end
it "blocks log creation" do
@@ -608,7 +608,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
it "returns a setup error" do
parser.valid?
- expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to include("Sale completion year must be 2 or 4 digits.")
+ expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to include(I18n.t("validations.sales.2023.bulk_upload.saledate.year_not_two_or_four_digits"))
end
end
@@ -672,7 +672,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
it "adds an error to all (and only) the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.sales.2023.bulk_upload.duplicate")
[
:field_1, # Owning org
@@ -932,7 +932,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
it "does not set ##{age}" do
parser.valid?
- expect(parser.errors[field.to_sym]).to include(/You must answer/)
+ expect(parser.errors[field.to_sym]).to include(/#{I18n.t("validations.sales.2023.bulk_upload.not_answered", question: "")}/)
end
end
end
@@ -980,7 +980,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
let(:attributes) { valid_attributes.merge({ field_35: "9" }) }
it "a custom validation is applied" do
- validation_message = "Buyer 1 cannot be a child under 16."
+ validation_message = I18n.t("validations.sales.2023.bulk_upload.ecstat1.child_under_16")
expect(parser.errors[:field_35]).to include validation_message
end
end
@@ -1052,7 +1052,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
let(:attributes) { setup_section_params.merge(field_105: "4") }
it "returns correct errors" do
- expect(parser.errors[:field_105]).to include("Enter a valid value for was a mortgage used for the purchase of this property? - Shared ownership.")
+ expect(parser.errors[:field_105]).to include(I18n.t("validations.sales.2023.bulk_upload.invalid_option", question: "was a mortgage used for the purchase of this property? - Shared ownership."))
parser.log.blank_invalid_non_setup_fields!
parser.log.save!
expect(parser.log.mortgageused).to be_nil
@@ -1420,7 +1420,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("This user belongs to an organisation that does not have a relationship with the owning organisation.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.sales.2023.bulk_upload.assigned_to.managing_organisation_not_related"))
end
it "blocks log creation" do
@@ -1442,7 +1442,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql("The owning organisation code provided is for an organisation that does not own stock.")
+ expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql(I18n.t("validations.sales.2023.bulk_upload.owning_organisation.not_stock_owner"))
end
it "blocks log creation" do
diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb
index d1d4aeb53..4844ce490 100644
--- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb
+++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb
@@ -301,7 +301,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "fetches the question's check_answer_label if it exists" do
parser.valid?
- expect(parser.errors[:field_32]).to eql(["You must answer buyer 1’s gender identity."])
+ expect(parser.errors[:field_32]).to eql([I18n.t("validations.not_answered", question: "buyer 1’s gender identity.")])
end
end
@@ -310,7 +310,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "only has one error added to the field" do
parser.valid?
- expect(parser.errors[:field_23]).to eql(["You must answer address line 1."])
+ expect(parser.errors[:field_23]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "address line 1.")])
end
end
@@ -320,7 +320,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "does not add an additional error" do
parser.valid?
expect(parser.errors[:field_35].length).to eq(1)
- expect(parser.errors[:field_35]).to include(match "Enter a valid value for")
+ expect(parser.errors[:field_35]).to include(match I18n.t("validations.sales.2024.bulk_upload.invalid_option", question: ""))
end
end
end
@@ -463,7 +463,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "is not permitted as setup error" do
parser.valid?
- expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["You must answer owning organisation."])
+ expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "owning organisation.")])
end
it "blocks log creation" do
@@ -477,7 +477,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "is not permitted as a setup error" do
parser.valid?
- expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["The owning organisation code is incorrect."])
+ expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql([I18n.t("validations.sales.2024.bulk_upload.owning_organisation.not_found")])
end
it "blocks log creation" do
@@ -493,7 +493,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "is not permitted as setup error" do
parser.valid?
- expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["You do not have permission to add logs for this owning organisation."])
+ expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql([I18n.t("validations.sales.2024.bulk_upload.owning_organisation.not_permitted.not_support")])
end
it "blocks log creation" do
@@ -580,7 +580,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser = described_class.new(attributes)
parser.valid?
expect(parser).to be_block_log_creation
- expect(parser.errors[:field_1]).to include("You do not have permission to add logs for this owning organisation.")
+ expect(parser.errors[:field_1]).to include(I18n.t("validations.sales.2024.bulk_upload.owning_organisation.not_permitted.not_support"))
end
end
@@ -598,7 +598,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "does not block log creation and does not add an error to field_1" do
parser = described_class.new(attributes)
parser.valid?
- expect(parser.errors[:field_1]).not_to include("You do not have permission to add logs for this owning organisation.")
+ expect(parser.errors[:field_1]).not_to include(I18n.t("validations.sales.2024.bulk_upload.owning_organisation.not_permitted.not_support"))
end
end
end
@@ -631,7 +631,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "is not permitted" do
parser.valid?
expect(parser.errors[:field_3]).to be_present
- expect(parser.errors[:field_3]).to include("You must answer what is the CORE username of the account this sales log should be assigned to?")
+ expect(parser.errors[:field_3]).to include(I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "what is the CORE username of the account this sales log should be assigned to?"))
end
it "blocks log creation" do
@@ -736,7 +736,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns a setup error" do
parser.valid?
- expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to include("Sale completion year must be 2 or 4 digits.")
+ expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to include(I18n.t("validations.sales.2024.bulk_upload.saledate.year_not_two_or_four_digits"))
end
end
@@ -802,7 +802,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "adds an error to all (and only) the fields used to determine duplicates" do
parser.valid?
- error_message = "This is a duplicate log."
+ error_message = I18n.t("validations.sales.2024.bulk_upload.duplicate")
[
:field_1, # Owning org
@@ -891,7 +891,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns correct error" do
parser.valid?
- expect(parser.errors.where(:field_116).map(&:message)).to include("Percentage discount must be between 0% and 70%.")
+ expect(parser.errors.where(:field_116).map(&:message)).to include(I18n.t("validations.sales.2024.bulk_upload.numeric.within_range", field: "Percentage discount", min: "0%", max: "70%"))
end
end
@@ -909,7 +909,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns correct error" do
parser.valid?
- expect(parser.errors.where(:field_116).map(&:message)).to include("Percentage discount must be between 0% and 70%.")
+ expect(parser.errors.where(:field_116).map(&:message)).to include(I18n.t("validations.sales.2024.bulk_upload.numeric.within_range", field: "Percentage discount", min: "0%", max: "70%"))
end
end
end
@@ -942,7 +942,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns setup error" do
parser.valid?
- expect(parser.errors.where(:field_13).map(&:message)).to include("Enter a valid value for is the buyer a company?")
+ expect(parser.errors.where(:field_13).map(&:message)).to include(I18n.t("validations.invalid_option", question: "is the buyer a company?"))
expect(parser.errors.where(:field_13, category: :setup)).to be_present
end
end
@@ -954,7 +954,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns setup error" do
parser.valid?
- expect(parser.errors.where(:field_14).map(&:message)).to eql(["Enter a valid value for will the buyers live in the property?"])
+ expect(parser.errors.where(:field_14).map(&:message)).to eql([I18n.t("validations.invalid_option", question: "will the buyers live in the property?")])
expect(parser.errors.where(:field_14, category: :setup)).to be_present
end
end
@@ -1011,10 +1011,10 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "adds errors to missing key address fields" do
parser.valid?
- expect(parser.errors[:field_23]).to eql(["You must answer address line 1."])
- expect(parser.errors[:field_25]).to eql(["You must answer town or city."])
- expect(parser.errors[:field_27]).to eql(["You must answer part 1 of postcode."])
- expect(parser.errors[:field_28]).to eql(["You must answer part 2 of postcode."])
+ expect(parser.errors[:field_23]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "address line 1.")])
+ expect(parser.errors[:field_25]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "town or city.")])
+ expect(parser.errors[:field_27]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "part 1 of postcode.")])
+ expect(parser.errors[:field_28]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "part 2 of postcode.")])
end
end
@@ -1042,11 +1042,11 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "adds appropriate errors to UPRN and key address fields" do
parser.valid?
- expect(parser.errors[:field_22]).to eql(["You must answer UPRN."])
- expect(parser.errors[:field_23]).to eql(["You must answer address line 1."])
- expect(parser.errors[:field_25]).to eql(["You must answer town or city."])
- expect(parser.errors[:field_27]).to eql(["You must answer part 1 of postcode."])
- expect(parser.errors[:field_28]).to eql(["You must answer part 2 of postcode."])
+ expect(parser.errors[:field_22]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "UPRN.")])
+ expect(parser.errors[:field_23]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "address line 1.")])
+ expect(parser.errors[:field_25]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "town or city.")])
+ expect(parser.errors[:field_27]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "part 1 of postcode.")])
+ expect(parser.errors[:field_28]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "part 2 of postcode.")])
end
end
@@ -1055,8 +1055,8 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "adds errors to UPRN and the missing key address field" do
parser.valid?
- expect(parser.errors[:field_22]).to eql(["You must answer UPRN."])
- expect(parser.errors[:field_23]).to eql(["You must answer address line 1."])
+ expect(parser.errors[:field_22]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "UPRN.")])
+ expect(parser.errors[:field_23]).to eql([I18n.t("validations.sales.2024.bulk_upload.not_answered", question: "address line 1.")])
expect(parser.errors[:field_25]).to be_empty
expect(parser.errors[:field_27]).to be_empty
expect(parser.errors[:field_28]).to be_empty
@@ -1090,7 +1090,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
expect(parser.errors[:field_22]).to be_empty
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
- expect(parser.errors[field]).to eql(["We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."])
+ expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_found")])
end
end
end
@@ -1105,7 +1105,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
expect(parser.errors[:field_22]).to be_empty
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
- expect(parser.errors[field]).to eql(["We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."])
+ expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_found")])
end
end
end
@@ -1218,8 +1218,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "a custom validation is applied" do
parser.valid?
- validation_message = "Buyer 2 cannot have a working situation of child under 16."
- expect(parser.errors[:field_42]).to include validation_message
+ expect(parser.errors[:field_42]).to include I18n.t("validations.sales.2024.bulk_upload.ecstat2.buyer_cannot_be_child")
end
end
@@ -1240,9 +1239,8 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "a custom validation is applied" do
parser.valid?
- validation_message = "Buyer 2's age cannot be 16 or over if their working situation is child under 16."
- expect(parser.errors[:field_42]).to include validation_message
- expect(parser.errors[:field_38]).to include validation_message
+ expect(parser.errors[:field_42]).to include I18n.t("validations.sales.2024.bulk_upload.ecstat2.buyer_cannot_be_over_16_and_child")
+ expect(parser.errors[:field_38]).to include I18n.t("validations.sales.2024.bulk_upload.age2.buyer_cannot_be_over_16_and_child")
end
end
@@ -1264,8 +1262,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "a custom validation is applied" do
parser.valid?
- validation_message = "Buyer 1 cannot have a working situation of child under 16."
- expect(parser.errors[:field_35]).to include validation_message
+ expect(parser.errors[:field_35]).to include I18n.t("validations.sales.2024.bulk_upload.ecstat1.buyer_cannot_be_child")
end
end
@@ -1286,9 +1283,8 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "a custom validation is applied" do
parser.valid?
- validation_message = "Buyer 1's age cannot be 16 or over if their working situation is child under 16."
- expect(parser.errors[:field_35]).to include validation_message
- expect(parser.errors[:field_31]).to include validation_message
+ expect(parser.errors[:field_35]).to include I18n.t("validations.sales.2024.bulk_upload.ecstat1.buyer_cannot_be_over_16_and_child")
+ expect(parser.errors[:field_31]).to include I18n.t("validations.sales.2024.bulk_upload.age1.buyer_cannot_be_over_16_and_child")
end
end
end
@@ -1333,7 +1329,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns correct errors" do
parser.valid?
- expect(parser.errors[:field_103]).to include("Enter a valid value for was a mortgage used for the purchase of this property? - Shared ownership.")
+ expect(parser.errors[:field_103]).to include(I18n.t("validations.sales.2024.bulk_upload.invalid_option", question: "was a mortgage used for the purchase of this property? - Shared ownership."))
parser.log.blank_invalid_non_setup_fields!
parser.log.save!
@@ -1370,7 +1366,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns correct errors" do
parser.valid?
- expect(parser.errors[:field_103]).to include("Enter a valid value for was a mortgage used for the purchase of this property?")
+ expect(parser.errors[:field_103]).to include(I18n.t("validations.invalid_option", question: "was a mortgage used for the purchase of this property?"))
parser.log.blank_invalid_non_setup_fields!
parser.log.save!
@@ -1383,7 +1379,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "returns correct errors" do
parser.valid?
- expect(parser.errors[:field_103]).to include("Enter a valid value for was a mortgage used for the purchase of this property?")
+ expect(parser.errors[:field_103]).to include(I18n.t("validations.invalid_option", question: "was a mortgage used for the purchase of this property?"))
parser.log.blank_invalid_non_setup_fields!
parser.log.save!
@@ -1440,7 +1436,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
it "does not allow 3 (don't know) as an option for discounted ownership" do
parser.valid?
- expect(parser.errors[:field_117]).to include("Enter a valid value for was a mortgage used for the purchase of this property?")
+ expect(parser.errors[:field_117]).to include(I18n.t("validations.invalid_option", question: "was a mortgage used for the purchase of this property?"))
parser.log.blank_invalid_non_setup_fields!
parser.log.save!
@@ -1696,7 +1692,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
expect(parser.log.nationality_all).to be(nil)
expect(parser.log.nationality_all_group).to be(nil)
- expect(parser.errors["field_34"]).to include("Select a valid nationality.")
+ expect(parser.errors["field_34"]).to include(I18n.t("validations.sales.2024.bulk_upload.nationality.invalid"))
end
end
end
@@ -1781,7 +1777,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
expect(parser.log.nationality_all_buyer2).to be(nil)
expect(parser.log.nationality_all_buyer2_group).to be(nil)
- expect(parser.errors["field_41"]).to include("Select a valid nationality.")
+ expect(parser.errors["field_41"]).to include(I18n.t("validations.sales.2024.bulk_upload.nationality.invalid"))
end
end
end
@@ -1983,7 +1979,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("You must answer reported by.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.not_answered", question: "reported by."))
end
it "blocks log creation" do
@@ -1999,7 +1995,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("You must answer reported by.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.not_answered", question: "reported by."))
end
it "blocks log creation" do
@@ -2017,7 +2013,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql("This organisation does not have a relationship with the owning organisation.")
+ expect(setup_errors.find { |e| e.attribute == :field_2 }.message).to eql(I18n.t("validations.sales.2024.bulk_upload.assigned_to.managing_organisation_not_related"))
end
it "blocks log creation" do
@@ -2039,7 +2035,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
setup_errors = parser.errors.select { |e| e.options[:category] == :setup }
- expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql("The owning organisation code provided is for an organisation that does not own stock.")
+ expect(setup_errors.find { |e| e.attribute == :field_1 }.message).to eql(I18n.t("validations.sales.2024.bulk_upload.owning_organisation.not_stock_owner"))
end
it "blocks log creation" do
From ee3018b94435e6d037353c48021cccced6b534d4 Mon Sep 17 00:00:00 2001
From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
Date: Wed, 6 Nov 2024 13:14:59 +0000
Subject: [PATCH 07/27] CLDC-3066: Show filters button bug (#2748)
* Add show filters toggle to user and scheme pages
* Adjust spacing between buttons to match show filters button
---
app/components/create_log_actions_component.html.erb | 2 +-
app/views/logs/_create_for_org_actions.html.erb | 10 +++++-----
app/views/organisations/schemes.html.erb | 4 +++-
app/views/organisations/users.html.erb | 8 +++++---
app/views/schemes/index.html.erb | 10 +++++-----
app/views/users/index.html.erb | 4 ++--
6 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/app/components/create_log_actions_component.html.erb b/app/components/create_log_actions_component.html.erb
index 8af78b169..2e88034d7 100644
--- a/app/components/create_log_actions_component.html.erb
+++ b/app/components/create_log_actions_component.html.erb
@@ -1,6 +1,6 @@
<% if display_actions? %>