Browse Source

Correctly map equity ranges (#1964)

pull/1980/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
f4bb3e2610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/validations/sales/financial_validations.rb
  2. 8
      spec/models/validations/sales/financial_validations_spec.rb

4
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,

8
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

Loading…
Cancel
Save