diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index fd4d9ad26..7a5ab648a 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -57,7 +57,7 @@ module Validations::Sales::FinancialValidations if [2, 16, 18, 24].include? record.type threshold = 10 - elsif record.type == 30 + else threshold = 1 end diff --git a/spec/models/validations/sales/financial_validations_spec.rb b/spec/models/validations/sales/financial_validations_spec.rb index 142143976..d3446bdee 100644 --- a/spec/models/validations/sales/financial_validations_spec.rb +++ b/spec/models/validations/sales/financial_validations_spec.rb @@ -188,10 +188,25 @@ RSpec.describe Validations::Sales::FinancialValidations do record.stairbought = 0 + record.type = 28 + financial_validator.validate_percentage_bought_at_least_threshold(record) + expect(record.errors["stairbought"]).to eq(["The minimum increase in equity while staircasing is 1%"]) + record.errors.clear + record.type = 30 financial_validator.validate_percentage_bought_at_least_threshold(record) expect(record.errors["stairbought"]).to eq(["The minimum increase in equity while staircasing is 1%"]) record.errors.clear + + record.type = 31 + financial_validator.validate_percentage_bought_at_least_threshold(record) + expect(record.errors["stairbought"]).to eq(["The minimum increase in equity while staircasing is 1%"]) + record.errors.clear + + record.type = 32 + financial_validator.validate_percentage_bought_at_least_threshold(record) + expect(record.errors["stairbought"]).to eq(["The minimum increase in equity while staircasing is 1%"]) + record.errors.clear end it "doesn't add an error to stairbought if the percentage bought is greater than or equal to the threshold (which depends on the shared ownership type)" do @@ -219,16 +234,12 @@ RSpec.describe Validations::Sales::FinancialValidations do record.stairbought = 1 - record.type = 30 + record.type = 28 financial_validator.validate_percentage_bought_at_least_threshold(record) expect(record.errors["stairbought"]).to be_empty record.errors.clear - end - - it "doesn't add an error to stairbought if the percentage bought is less than the smallest possible threshold and the shared ownership type is not one which should have a threshold associated with it" do - record.stairbought = 0 - record.type = 28 + record.type = 30 financial_validator.validate_percentage_bought_at_least_threshold(record) expect(record.errors["stairbought"]).to be_empty record.errors.clear