mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-18 00:17:25 +00:00
19 lines
348 B
Ruby
19 lines
348 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
|