prevent saving the enterprise fee when a per order calculator is selected along with 'Inherit from product'

This commit is contained in:
Mohamed ABDELLANI
2023-03-03 10:57:30 +01:00
parent 2836751698
commit 7eca32e84f
2 changed files with 10 additions and 1 deletions

View File

@@ -58,6 +58,14 @@ class EnterpriseFee < ApplicationRecord
elsif inherits_tax_category_changed?
self.tax_category_id = nil if inherits_tax_category?
end
if inherits_tax_category? && PER_ORDER_CALCULATORS.include?(calculator_type)
errors.add(:inherits_tax_category,
I18n.t("activerecord.errors.models." \
"enterpise_fee.cannot_inherit_from_product_when_per_order_calculator_selected"))
throw :abort
end
true
end
end

View File

@@ -113,7 +113,8 @@ en:
using_producer_stock_settings_but_count_on_hand_set: "must be blank because using producer stock settings"
on_demand_but_count_on_hand_set: "must be blank if on demand"
limited_stock_but_no_count_on_hand: "must be specified because forcing limited stock"
enterpise_fee:
cannot_inherit_from_product_when_per_order_calculator_selected: "You cannot select 'Inherit From Product' when a per order calculator is selected"
# Used by active_storage_validations
errors:
messages: