From de1d28c27e2b1a065f24a1275f054aecdf8a252d Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:46:52 +0000 Subject: [PATCH] Increase soft max for old persons shared ownership savings (#2778) --- .../validations/sales/soft_validations.rb | 4 ++- .../sales/soft_validations_spec.rb | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index fe05ec13c..5095e5ff9 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -58,7 +58,9 @@ module Validations::Sales::SoftValidations end def savings_over_soft_max? - savings && savings > 100_000 + soft_max = form.start_year_2025_or_later? && type == 24 ? 200_000 : 100_000 + + savings && savings > soft_max end def deposit_over_soft_max? diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index c8e8618fc..99c615250 100644 --- a/spec/models/validations/sales/soft_validations_spec.rb +++ b/spec/models/validations/sales/soft_validations_spec.rb @@ -371,6 +371,33 @@ RSpec.describe Validations::Sales::SoftValidations do expect(record) .not_to be_mortgage_over_soft_max end + + context "with log for 2025 of after" do + before do + record.saledate = Time.zone.local(2025, 5, 1) + end + + it "allows savings over 100_000 for old persons shared ownership" do + record.savings = 100_001 + record.type = 24 + expect(record) + .not_to be_savings_over_soft_max + end + + it "does not allows savings over 200_000 for old persons shared ownership" do + record.savings = 200_001 + record.type = 24 + expect(record) + .to be_savings_over_soft_max + end + + it "does not allows savings over 100_000 for other type" do + record.savings = 100_001 + record.type = 8 + expect(record) + .to be_savings_over_soft_max + end + end end end