@@ -30,7 +30,7 @@ class Order(SkuLines):
3030
3131 def allocate (self , stock , shipments ):
3232 self .allocation = Allocation .for_order (self , stock , shipments )
33- self .allocation .apply ()
33+ self .allocation .decrement_source_quantities ()
3434
3535
3636@dataclass
@@ -39,7 +39,7 @@ class Stock(SkuLines):
3939 def can_allocate (self , line : OrderLine ):
4040 return line .sku in self .skus and self .quantities [line .sku ] > line .quantity
4141
42- def allocate (self , sku , quantity ):
42+ def decrement_quantity (self , sku , quantity ):
4343 for line in self .lines :
4444 if line .sku == sku :
4545 line .quantity -= quantity
@@ -61,6 +61,9 @@ class AllocationLine:
6161 quantity : int
6262 source : Stock
6363
64+ def decrement_source_quantity (self ):
65+ self .source .decrement_quantity (self .sku , self .quantity )
66+
6467
6568@dataclass
6669class Allocation :
@@ -97,12 +100,8 @@ def supplement_with(self, other_allocation):
97100 l for l in other_allocation .lines if l .sku not in self .skus
98101 )
99102
100- @property
101- def is_complete (self ):
102- return self .skus == self .order .skus
103-
104- def apply (self ):
103+ def decrement_source_quantities (self ):
105104 for line in self .lines :
106- line .source . allocate ( line . sku , line . quantity )
105+ line .decrement_source_quantity ( )
107106
108107
0 commit comments