From 0b053c18af41ecffc8f498059136e421d37c1857 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 6 Aug 2020 10:17:50 +0100 Subject: [PATCH] Merge decoorator with original file from spree --- app/models/spree/stock_location.rb | 19 ++----------------- app/models/spree/stock_location_decorator.rb | 9 --------- 2 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 app/models/spree/stock_location_decorator.rb diff --git a/app/models/spree/stock_location.rb b/app/models/spree/stock_location.rb index 57cfd3f2b1..a1e19233c0 100644 --- a/app/models/spree/stock_location.rb +++ b/app/models/spree/stock_location.rb @@ -49,26 +49,11 @@ module Spree end def move(variant, quantity, originator = nil) - stock_item_or_create(variant).stock_movements.create!(quantity: quantity, - originator: originator) + variant.move(quantity, originator) end def fill_status(variant, quantity) - if item = stock_item(variant) - - if item.count_on_hand >= quantity - on_hand = quantity - backordered = 0 - else - on_hand = item.count_on_hand - on_hand = 0 if on_hand < 0 - backordered = item.backorderable? ? (quantity - on_hand) : 0 - end - - [on_hand, backordered] - else - [0, 0] - end + variant.fill_status(quantity) end private diff --git a/app/models/spree/stock_location_decorator.rb b/app/models/spree/stock_location_decorator.rb deleted file mode 100644 index 87702616c7..0000000000 --- a/app/models/spree/stock_location_decorator.rb +++ /dev/null @@ -1,9 +0,0 @@ -Spree::StockLocation.class_eval do - def move(variant, quantity, originator = nil) - variant.move(quantity, originator) - end - - def fill_status(variant, quantity) - variant.fill_status(quantity) - end -end