Skip to content

Commit bedb7e8

Browse files
committed
remove requirement for nonmixed allocations
1 parent 29ccd64 commit bedb7e8

2 files changed

Lines changed: 3 additions & 16 deletions

File tree

‎domain_model.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,11 @@ def for_source(order: Order, source: Stock):
8585

8686
@staticmethod
8787
def for_order(order: Order, stock: Stock, shipments: List[Shipment]):
88-
split_allocation = Allocation(lines=[], order=order)
88+
allocation = Allocation(lines=[], order=order)
8989
for source in [stock] + sorted(shipments):
9090
source_allocation = Allocation.for_source(order, source)
91-
if source_allocation.is_complete:
92-
return source_allocation
93-
split_allocation.supplement_with(source_allocation)
94-
return split_allocation
91+
allocation.supplement_with(source_allocation)
92+
return allocation
9593

9694

9795
def supplement_with(self, other_allocation):

‎test_allocation.py‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,6 @@ def test_can_allocate_to_both_preferring_stock():
120120
assert stock.quantities['sku4'] == 996
121121

122122

123-
def test_mixed_allocation_are_avoided_if_possible():
124-
order = Order({'sku1': 10, 'sku2': 10})
125-
shipment = Shipment({'sku1': 1000, 'sku2': 1000}, eta=tomorrow)
126-
stock = Stock({'sku1': 1000})
127-
128-
order.allocate(stock, shipments=[shipment])
129-
130-
assert order.allocation.sources['sku1'] == shipment
131-
assert order.allocation.sources['sku2'] == shipment
132-
133-
134123
def test_allocated_to_earliest_suitable_shipment_in_list():
135124
order = Order({'sku1': 10, 'sku2': 10})
136125
shipment1 = Shipment({'sku1': 1000, 'sku2': 1000}, eta=today)

0 commit comments

Comments
 (0)