Files
openfoodnetwork/app/models/concerns/product_stock.rb
Matt-Yorkley c0ee72319f Remove dead code: Product#variants?
This only makes sense in the context of Products which only have "master" variants, and we removed that option a while back.

Remove #variants? check from ProductStock concern
2022-10-19 16:30:12 +11:00

18 lines
342 B
Ruby

# frozen_string_literal: true
require 'active_support/concern'
module ProductStock
extend ActiveSupport::Concern
def on_demand
raise 'Cannot determine product on_demand value of product with multiple variants' if variants.size > 1
variants.first.on_demand
end
def on_hand
variants.map(&:on_hand).reduce(:+)
end
end