mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Don't mark on_demand items and shipments as "backordered"
This commit is contained in:
@@ -100,13 +100,13 @@ module VariantStock
|
||||
# Here we depend only on variant.total_on_hand and variant.on_demand.
|
||||
# This way, variant_overrides only need to override variant.total_on_hand and variant.on_demand.
|
||||
def fill_status(quantity)
|
||||
if on_hand >= quantity
|
||||
on_hand = quantity
|
||||
backordered = 0
|
||||
else
|
||||
on_hand = [0, total_on_hand].max
|
||||
backordered = on_demand ? (quantity - on_hand) : 0
|
||||
end
|
||||
on_hand = if total_on_hand >= quantity || on_demand
|
||||
quantity
|
||||
else
|
||||
[0, total_on_hand].max
|
||||
end
|
||||
|
||||
backordered = 0
|
||||
|
||||
[on_hand, backordered]
|
||||
end
|
||||
|
||||
@@ -155,9 +155,9 @@ module Spree
|
||||
order.shipment.update!(order)
|
||||
end
|
||||
|
||||
it "creates a shipment with backordered items" do
|
||||
it "creates a shipment without backordered items" do
|
||||
expect(order.shipment.manifest.first.quantity).to eq 10
|
||||
expect(order.shipment.manifest.first.states).to eq 'on_hand' => 1, 'backordered' => 9
|
||||
expect(order.shipment.manifest.first.states).to eq 'on_hand' => 10
|
||||
expect(order.shipment.manifest.first.variant).to eq line_item.variant
|
||||
end
|
||||
|
||||
@@ -165,17 +165,17 @@ module Spree
|
||||
expect(variant_on_demand.reload.on_hand).to eq(-9)
|
||||
end
|
||||
|
||||
it "marks the inventory units as backorderd" do
|
||||
it "does not mark inventory units as backorderd" do
|
||||
backordered_units = order.shipments.first.inventory_units.any?(&:backordered?)
|
||||
expect(backordered_units).to be true
|
||||
expect(backordered_units).to be false
|
||||
end
|
||||
|
||||
it "marks the shipment as backorderd" do
|
||||
expect(order.shipments.first.backordered?).to be true
|
||||
it "does not mark the shipment as backorderd" do
|
||||
expect(order.shipments.first.backordered?).to be false
|
||||
end
|
||||
|
||||
it "does not allow the order to be shipped" do
|
||||
expect(order.ready_to_ship?).to be false
|
||||
it "allows the order to be shipped" do
|
||||
expect(order.ready_to_ship?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user