From 6c33210510a6554e291bdb700e6c58332c1a4822 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2024 08:11:20 +0100 Subject: [PATCH 1/2] Bump fugit from 1.10.0 to 1.11.1 (#2595) Bumps [fugit](https://github.com/floraison/fugit) from 1.10.0 to 1.11.1. - [Changelog](https://github.com/floraison/fugit/blob/master/CHANGELOG.md) - [Commits](https://github.com/floraison/fugit/compare/v1.10.0...v1.11.1) --- updated-dependencies: - dependency-name: fugit dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7fdef3710..2f51d6a29 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -141,7 +141,7 @@ GEM coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crack (1.0.0) bigdecimal @@ -180,7 +180,7 @@ GEM rubocop smart_properties erubi (1.13.0) - et-orbi (1.2.7) + et-orbi (1.2.11) tzinfo event_stream_parser (1.0.0) excon (0.109.0) @@ -198,8 +198,8 @@ GEM faraday-net_http (3.1.0) net-http ffi (1.16.3) - fugit (1.10.0) - et-orbi (~> 1, >= 1.2.7) + fugit (1.11.1) + et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) From eb355d6829cf9584ed1355341f1c22cccad80a02 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:19:29 +0100 Subject: [PATCH 2/2] Update equity validation for resale (#2559) --- app/models/sales_log.rb | 4 ++++ app/models/validations/sales/financial_validations.rb | 3 ++- .../validations/sales/financial_validations_spec.rb | 10 +++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 6ac2979c8..ad6984e07 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -542,4 +542,8 @@ class SalesLog < Log def address_search_given? address_line1_input.present? && postcode_full_input.present? end + + def is_resale? + resale == 1 + end end diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index 3e1d3dfb8..9a119475f 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -96,9 +96,10 @@ module Validations::Sales::FinancialValidations if record.equity < range.min record.errors.add :type, I18n.t("validations.financial.equity.under_min", min_equity: range.min) record.errors.add :equity, :under_min, message: I18n.t("validations.financial.equity.under_min", min_equity: range.min) - elsif record.equity > range.max + elsif !record.is_resale? && record.equity > range.max record.errors.add :type, I18n.t("validations.financial.equity.over_max", max_equity: range.max) record.errors.add :equity, :over_max, message: I18n.t("validations.financial.equity.over_max", max_equity: range.max) + record.errors.add :resale, I18n.t("validations.financial.equity.over_max", max_equity: range.max) end end diff --git a/spec/models/validations/sales/financial_validations_spec.rb b/spec/models/validations/sales/financial_validations_spec.rb index dd71d0b24..d9f47d39a 100644 --- a/spec/models/validations/sales/financial_validations_spec.rb +++ b/spec/models/validations/sales/financial_validations_spec.rb @@ -338,7 +338,7 @@ RSpec.describe Validations::Sales::FinancialValidations do end describe "#validate_equity_in_range_for_year_and_type" do - let(:record) { FactoryBot.build(:sales_log, saledate:) } + let(:record) { FactoryBot.build(:sales_log, saledate:, resale: nil) } context "with a log in the 22/23 collection year" do let(:saledate) { Time.zone.local(2023, 1, 1) } @@ -373,6 +373,14 @@ RSpec.describe Validations::Sales::FinancialValidations do expect(record.errors["equity"]).to include(match I18n.t("validations.financial.equity.over_max", max_equity: 75)) expect(record.errors["type"]).to include(match I18n.t("validations.financial.equity.over_max", max_equity: 75)) end + + it "does not add an error if it's a resale" do + record.type = 2 + record.equity = 90 + record.resale = 1 + financial_validator.validate_equity_in_range_for_year_and_type(record) + expect(record.errors).to be_empty + end end context "with a log in 23/24 collection year" do