From 4c7d3a491af0e38df1011e29258ea8699fc653b0 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 5 Aug 2019 12:59:47 +0100 Subject: [PATCH] Don't decrement variant stock if override is on_demand --- lib/open_food_network/scope_variant_to_hub.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/open_food_network/scope_variant_to_hub.rb b/lib/open_food_network/scope_variant_to_hub.rb index 52ea5f5100..0e4f36e7e9 100644 --- a/lib/open_food_network/scope_variant_to_hub.rb +++ b/lib/open_food_network/scope_variant_to_hub.rb @@ -41,7 +41,11 @@ module OpenFoodNetwork # - updates variant_override.count_on_hand # - does not create stock_movement # - does not update stock_item.count_on_hand + # If it is a variant override with on_demand: + # - don't change stock or call super (super would change the variant's stock) def move(quantity, originator = nil) + return if @variant_override.andand.on_demand + if @variant_override.andand.stock_overridden? @variant_override.move_stock! quantity else