mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
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
18 lines
342 B
Ruby
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
|