diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index 1e404aac4..233f32b6b 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -27,12 +27,4 @@ module Validations::Sales::FinancialValidations record.errors.add :cashdis, I18n.t("validations.financial.cash_discount_invalid") end end - - def validate_percentage(record) - return unless record.discount - - if record.discount.negative? || record.discount > 100 - record.errors.add :discount, I18n.t("validations.financial.percentage.invalid_percentage") - end - end end diff --git a/config/locales/en.yml b/config/locales/en.yml index a29c3f03b..ff6101978 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -275,8 +275,6 @@ en: out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}" not_provided: "Enter how much rent and other charges the household pays %{period}" cash_discount_invalid: "Cash discount must be £0 - £999,999" - percentage: - invalid_percentage: "Percentage discount must be between 0 - 100" household: reasonpref: not_homeless: "Answer cannot be ‘homeless or about to lose their home’ as the tenant was not homeless immediately prior to this letting" diff --git a/spec/models/validations/sales/financial_validations_spec.rb b/spec/models/validations/sales/financial_validations_spec.rb index d6d735296..4bc19afbe 100644 --- a/spec/models/validations/sales/financial_validations_spec.rb +++ b/spec/models/validations/sales/financial_validations_spec.rb @@ -99,31 +99,4 @@ RSpec.describe Validations::Sales::FinancialValidations do expect(record.errors["cashdis"]).to be_empty end end - - describe "#validate_percentage" do - let(:record) { FactoryBot.create(:sales_log, ownershipsch: 2, type: 9) } - - it "does not add an error when percentage discount is not yet given" do - financial_validator.validate_percentage(record) - expect(record.errors["discount"]).to be_empty - end - - it "does not add an error when percentage discount is in correct range" do - record.discount = 2 - financial_validator.validate_percentage(record) - expect(record.errors["discount"]).to be_empty - end - - it "adds an error when percentage declared is below zero" do - record.discount = -2 - financial_validator.validate_percentage(record) - expect(record.errors["discount"]).to include(match I18n.t("validations.financial.percentage.invalid_percentage")) - end - - it "adds an error when percentage declared is above 100" do - record.discount = 102 - financial_validator.validate_percentage(record) - expect(record.errors["discount"]).to include(match I18n.t("validations.financial.percentage.invalid_percentage")) - end - end end