File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 22from dataclasses import dataclass
33from datetime import date
44from typing import Optional , List , Set
5- from allocation .adapters import email
65
76
87class OutOfStock (Exception ):
@@ -22,7 +21,6 @@ def allocate(self, line: OrderLine) -> str:
2221 self .version_number += 1
2322 return batch .reference
2423 except StopIteration :
25- email .send_mail ("stock@made.com" , f"Out of stock for { line .sku } " )
2624 raise OutOfStock (f"Out of stock for sku { line .sku } " )
2725
2826
Original file line number Diff line number Diff line change 22from typing import Optional
33from datetime import date
44
5+ from allocation .adapters import email
56from allocation .domain import model
67from allocation .domain .model import OrderLine
78from allocation .service_layer import unit_of_work
@@ -33,6 +34,10 @@ def allocate(
3334 product = uow .products .get (sku = line .sku )
3435 if product is None :
3536 raise InvalidSku (f"Invalid sku { line .sku } " )
36- batchref = product .allocate (line )
37- uow .commit ()
38- return batchref
37+ try :
38+ batchref = product .allocate (line )
39+ uow .commit ()
40+ return batchref
41+ except model .OutOfStock :
42+ email .send_mail ("stock@made.com" , f"Out of stock for { line .sku } " )
43+ raise
You can’t perform that action at this time.
0 commit comments