Browse Source

Fix soft validation

pull/2209/head
Kat 2 years ago
parent
commit
469019db7e
  1. 5
      app/models/validations/sales/soft_validations.rb
  2. 12
      spec/models/validations/sales/soft_validations_spec.rb

5
app/models/validations/sales/soft_validations.rb

@ -116,9 +116,8 @@ module Validations::Sales::SoftValidations
end end
def grant_outside_common_range? def grant_outside_common_range?
return unless grant return unless grant && type && saledate
return unless type && saledate return if form.start_year_after_2024? && (type == 21 || type == 8)
return unless !form.start_year_after_2024? || type == 21 || type == 8
!grant.between?(9_000, 16_000) !grant.between?(9_000, 16_000)
end end

12
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 expect(record).not_to be_grant_outside_common_range
end 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.grant = 100_000
record.type = 8 record.type = 8
record.saledate = Time.zone.local(2025, 1, 1) 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 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.grant = 100_000
record.type = 21 record.type = 21
record.saledate = Time.zone.local(2025, 1, 1) 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 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.grant = 100_000
record.type = 9 record.type = 9
record.saledate = Time.zone.local(2025, 1, 1) 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
end end

Loading…
Cancel
Save