From f4bb3e2610e10f3933ceea382030794253351a09 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 12 Oct 2023 12:02:39 +0100 Subject: [PATCH] Correctly map equity ranges (#1964) --- app/models/validations/sales/financial_validations.rb | 4 ++-- .../validations/sales/financial_validations_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index 82c57e75d..410f6d250 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -114,8 +114,8 @@ private }.freeze DEFAULT_EQUITY_RANGES = { - 2 => 10..75, - 30 => 25..75, + 2 => 25..75, + 30 => 10..75, 18 => 25..75, 16 => 10..75, 24 => 25..75, diff --git a/spec/models/validations/sales/financial_validations_spec.rb b/spec/models/validations/sales/financial_validations_spec.rb index ab41885ff..68cf19a14 100644 --- a/spec/models/validations/sales/financial_validations_spec.rb +++ b/spec/models/validations/sales/financial_validations_spec.rb @@ -311,16 +311,16 @@ RSpec.describe Validations::Sales::FinancialValidations do record.type = 2 record.equity = 1 financial_validator.validate_equity_in_range_for_year_and_type(record) - expect(record.errors["equity"]).to include(match I18n.t("validations.financial.equity.under_min", min_equity: 10)) - expect(record.errors["type"]).to include(match I18n.t("validations.financial.equity.under_min", min_equity: 10)) + expect(record.errors["equity"]).to include(match I18n.t("validations.financial.equity.under_min", min_equity: 25)) + expect(record.errors["type"]).to include(match I18n.t("validations.financial.equity.under_min", min_equity: 25)) end it "adds an error for type 30, equity below min with the correct percentage" do record.type = 30 record.equity = 1 financial_validator.validate_equity_in_range_for_year_and_type(record) - expect(record.errors["equity"]).to include(match I18n.t("validations.financial.equity.under_min", min_equity: 25)) - expect(record.errors["type"]).to include(match I18n.t("validations.financial.equity.under_min", min_equity: 25)) + expect(record.errors["equity"]).to include(match I18n.t("validations.financial.equity.under_min", min_equity: 10)) + expect(record.errors["type"]).to include(match I18n.t("validations.financial.equity.under_min", min_equity: 10)) end it "does not add an error for equity in range with the correct percentage" do