diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index a2d1de7fd..ae9ee66cc 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -116,9 +116,8 @@ module Validations::Sales::SoftValidations end def grant_outside_common_range? - return unless grant - return unless type && saledate - return unless !form.start_year_after_2024? || type == 21 || type == 8 + return unless grant && type && saledate + return if form.start_year_after_2024? && (type == 21 || type == 8) !grant.between?(9_000, 16_000) end diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index 170c474b7..e417fbd8e 100644 --- a/spec/models/validations/sales/soft_validations_spec.rb +++ b/spec/models/validations/sales/soft_validations_spec.rb @@ -682,28 +682,28 @@ RSpec.describe Validations::Sales::SoftValidations do expect(record).not_to be_grant_outside_common_range end - it "returns true for logs after 2024 with RTA" do + it "returns false for logs after 2024 with RTA" do record.grant = 100_000 record.type = 8 record.saledate = Time.zone.local(2025, 1, 1) - expect(record).to be_grant_outside_common_range + expect(record).not_to be_grant_outside_common_range end - it "returns true for logs after 2024 with socialBuy" do + it "returns false for logs after 2024 with socialBuy" do record.grant = 100_000 record.type = 21 record.saledate = Time.zone.local(2025, 1, 1) - expect(record).to be_grant_outside_common_range + expect(record).not_to be_grant_outside_common_range end - it "returns false for logs after 2024 with other type" do + it "returns true for logs after 2024 with other type" do record.grant = 100_000 record.type = 9 record.saledate = Time.zone.local(2025, 1, 1) - expect(record).not_to be_grant_outside_common_range + expect(record).to be_grant_outside_common_range end end