Requested changes on VariantOverrride

- change was not exactly equivalent, so reverting +
  rubo comment
This commit is contained in:
cyrillefr
2024-07-09 16:06:45 +02:00
parent ce8a2b3251
commit 6d22652dfa

View File

@@ -52,7 +52,14 @@ class VariantOverride < ApplicationRecord
return
end
update!(count_on_hand: (count_on_hand || 0) + quantity)
# rubocop:disable Rails/SkipsModelValidations
# Cf. conversation https://github.com/openfoodfoundation/openfoodnetwork/pull/12647
if quantity > 0
increment! :count_on_hand, quantity
elsif quantity < 0
decrement! :count_on_hand, -quantity
end
# rubocop:enable Rails/SkipsModelValidations
end
def default_stock?