From 6be860db286889e149725e43eee6db39b0c19466 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:32:19 +0000 Subject: [PATCH] CLDC-868 purchase price validations PO review (#1285) * feat: wip behaviour * feat: hide in cya * feat: show in cya * feat: purchase price range service and rake task * feat: fix hodate validation and use purchase price ranges * db:update * feat: more saledate -> exdate fixing * feat: add min and max conditional text * refactor: linting * refactor: remove duplicated behaviour * refactor: linting * feat: update tests * test: add validation tests * test: add purchase price rangeimport service tests * refactor: linting * feat: allow translation text and title text to display currency formatting even when not a log field * feat: use i18n * feat: update i18n * refactor: pratical -> practical * refactor: linting * refactor: revert unnecessary change * feat: respond to PR comments * tests: update after merge * feat: improve currency interruption screen display * feat: update docs * feat: fix typo * feat: missing end after merge * feat: respond to PR comments * feat: add soft validation to beds and la pages * db:update * feat: revert saledate/exdate work * feat: revert saledate/exdate work * feat: revert saledate/exdate work * feat: revert saledate/exdate work * feat: revert saledate/exdate work * feat: PO comment responses * tests: update * refactor: linting * refactor: simplification * refactor: railsification * test: fix * refactor: use number_to_currency units * refactor: remove duplicated copy * db:update * feat: add value check for discounted and outright sale * feat: rename files * test: update * test: update * test: update * db: update --- ...ed_ownership_value_check.rb => about_price_value_check.rb} | 4 ++-- ...ed_ownership_value_check.rb => about_price_value_check.rb} | 2 +- .../form/sales/subsections/discounted_ownership_scheme.rb | 1 + app/models/form/sales/subsections/outright_sale.rb | 1 + app/models/form/sales/subsections/property_information.rb | 4 ++-- app/models/form/sales/subsections/shared_ownership_scheme.rb | 2 +- .../sales/subsections/discounted_ownership_scheme_spec.rb | 1 + spec/models/form/sales/subsections/outright_sale_spec.rb | 1 + .../form/sales/subsections/property_information_spec.rb | 4 ++-- spec/models/form_handler_spec.rb | 4 ++-- 10 files changed, 14 insertions(+), 10 deletions(-) rename app/models/form/sales/pages/{about_price_shared_ownership_value_check.rb => about_price_value_check.rb} (84%) rename app/models/form/sales/questions/{about_price_shared_ownership_value_check.rb => about_price_value_check.rb} (85%) diff --git a/app/models/form/sales/pages/about_price_shared_ownership_value_check.rb b/app/models/form/sales/pages/about_price_value_check.rb similarity index 84% rename from app/models/form/sales/pages/about_price_shared_ownership_value_check.rb rename to app/models/form/sales/pages/about_price_value_check.rb index 5b668006a..94df02243 100644 --- a/app/models/form/sales/pages/about_price_shared_ownership_value_check.rb +++ b/app/models/form/sales/pages/about_price_value_check.rb @@ -1,4 +1,4 @@ -class Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck < ::Form::Page +class Form::Sales::Pages::AboutPriceValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @depends_on = [ @@ -34,7 +34,7 @@ class Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::AboutPriceSharedOwnershipValueCheck.new(nil, nil, self), + Form::Sales::Questions::AboutPriceValueCheck.new(nil, nil, self), ] end end diff --git a/app/models/form/sales/questions/about_price_shared_ownership_value_check.rb b/app/models/form/sales/questions/about_price_value_check.rb similarity index 85% rename from app/models/form/sales/questions/about_price_shared_ownership_value_check.rb rename to app/models/form/sales/questions/about_price_value_check.rb index 6758b68a3..2b51cd7fb 100644 --- a/app/models/form/sales/questions/about_price_shared_ownership_value_check.rb +++ b/app/models/form/sales/questions/about_price_value_check.rb @@ -1,4 +1,4 @@ -class Form::Sales::Questions::AboutPriceSharedOwnershipValueCheck < ::Form::Question +class Form::Sales::Questions::AboutPriceValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "value_value_check" diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index 74e408cfd..a44f10ee9 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -14,6 +14,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self), Form::Sales::Pages::GrantValueCheck.new(nil, nil, self), Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_outright_ownership", nil, self), + Form::Sales::Pages::AboutPriceValueCheck.new("about_price_discounted_ownership_value_check", nil, self), Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_discounted_ownership", nil, self), Form::Sales::Pages::MortgageValueCheck.new("discounted_ownership_mortgage_used_mortgage_value_check", nil, self), diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index 69f77c4b2..256c1c8dc 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -9,6 +9,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection def pages @pages ||= [ Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_outright_sale", nil, self), + Form::Sales::Pages::AboutPriceValueCheck.new("about_price_outright_sale_value_check", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_outright_sale", nil, self), Form::Sales::Pages::MortgageValueCheck.new("outright_sale_mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self), diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index eb057c48c..a43607d7c 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/app/models/form/sales/subsections/property_information.rb @@ -9,13 +9,13 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection def pages @pages ||= [ Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), - Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck.new("about_price_shared_ownership_bedrooms_value_check", nil, self), + Form::Sales::Pages::AboutPriceValueCheck.new("about_price_bedrooms_value_check", nil, self), Form::Sales::Pages::PropertyUnitType.new(nil, nil, self), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_property_type_value_check", nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), Form::Sales::Pages::Postcode.new(nil, nil, self), Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self), - Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck.new("about_price_shared_ownership_la_value_check", nil, self), + Form::Sales::Pages::AboutPriceValueCheck.new("about_price_la_value_check", nil, self), Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self), ] end diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index 3012d2a69..1f0cd6450 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -22,7 +22,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self), Form::Sales::Pages::PreviousTenure.new(nil, nil, self), Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self), - Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck.new("about_price_shared_ownership_value_check", nil, self), + Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_equity_value_check", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self), Form::Sales::Pages::MortgageValueCheck.new("mortgage_used_mortgage_value_check", nil, self), diff --git a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb index 12cf9b38a..5d1d30037 100644 --- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb @@ -20,6 +20,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model about_price_not_rtb grant_value_check purchase_price_outright_ownership + about_price_discounted_ownership_value_check discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount mortgage_used_discounted_ownership discounted_ownership_mortgage_used_mortgage_value_check diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb index 47c062478..b7b0dc846 100644 --- a/spec/models/form/sales/subsections/outright_sale_spec.rb +++ b/spec/models/form/sales/subsections/outright_sale_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do expect(outright_sale.pages.map(&:id)).to eq( %w[ purchase_price_outright_sale + about_price_outright_sale_value_check mortgage_used_outright_sale outright_sale_mortgage_used_mortgage_value_check mortgage_amount_outright_sale diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb index c9ab36136..e65e8dd36 100644 --- a/spec/models/form/sales/subsections/property_information_spec.rb +++ b/spec/models/form/sales/subsections/property_information_spec.rb @@ -15,13 +15,13 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do expect(property_information.pages.map(&:id)).to eq( %w[ property_number_of_bedrooms - about_price_shared_ownership_bedrooms_value_check + about_price_bedrooms_value_check property_unit_type monthly_charges_property_type_value_check property_building_type property_postcode property_local_authority - about_price_shared_ownership_la_value_check + about_price_la_value_check property_wheelchair_accessible ], ) diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 17ebd4db0..fb7bad4b2 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -54,14 +54,14 @@ RSpec.describe FormHandler do it "is able to load a current sales form" do form = form_handler.get_form("current_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(180) + expect(form.pages.count).to eq(182) expect(form.name).to eq("2022_2023_sales") end it "is able to load a previous sales form" do form = form_handler.get_form("previous_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(180) + expect(form.pages.count).to eq(182) expect(form.name).to eq("2021_2022_sales") end end