Skip to content

Commit ff9bff9

Browse files
committed
munged line-by-line allocation into one fn
1 parent 19bc13e commit ff9bff9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

domain_model.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def allocate_to(order, source):
2424
return allocations
2525

2626

27-
def allocate_to_shipments(order, shipments, allocations):
27+
def allocate_to_sources(order, sources, allocations):
2828
for sku, quantity in order.items():
2929
if sku in allocations:
3030
continue
31-
for shipment in shipments:
32-
allocate_line(sku, quantity, shipment, allocations)
31+
for source in sources:
32+
allocate_line(sku, quantity, source, allocations)
3333
if sku in allocations:
3434
break
3535

@@ -45,6 +45,6 @@ def allocate(order, stock, shipments):
4545
if skus(order) <= skus(shipment):
4646
return allocate_to(order, shipment)
4747

48-
allocations = allocate_to(order, stock)
49-
allocate_to_shipments(order, shipments, allocations)
48+
allocations = {}
49+
allocate_to_sources(order, [stock] + shipments, allocations)
5050
return allocations

0 commit comments

Comments
 (0)