Skip to content

Commit fdde96a

Browse files
committed
PC-50: add validations for calculation_formula
1 parent 6124c9d commit fdde96a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

app/models/item.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Item < ApplicationRecord
66
validate :category_must_be_active
77
validate :fixed_parameters_values_must_be_numeric
88
validate :pricing_options_values_must_be_numeric
9+
validates :calculation_formula, presence: true, if: :requires_calculation_formula?
910

1011
def self.ransackable_attributes(_auth_object = nil)
1112
%w[category_id created_at id is_disabled name updated_at]
@@ -63,4 +64,8 @@ def numeric?(val)
6364
false
6465
end
6566
end
67+
68+
def requires_calculation_formula?
69+
is_fixed || is_open || is_selectable_options
70+
end
6671
end

0 commit comments

Comments
 (0)