mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
21 lines
463 B
Ruby
21 lines
463 B
Ruby
class OrderCycleDistributedVariants
|
|
def initialize(order_cycle, distributor)
|
|
@order_cycle = order_cycle
|
|
@distributor = distributor
|
|
end
|
|
|
|
def distributes_order_variants?(order)
|
|
unavailable_order_variants(order).empty?
|
|
end
|
|
|
|
def unavailable_order_variants(order)
|
|
order.line_item_variants - available_variants
|
|
end
|
|
|
|
def available_variants
|
|
return [] unless @order_cycle
|
|
|
|
@order_cycle.variants_distributed_by(@distributor)
|
|
end
|
|
end
|