File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 33from datetime import date
44from typing import Optional , List , Set
55from allocation import exceptions
6- from allocation import email
76
87
98class Product :
@@ -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 exceptions .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 import exceptions , model , unit_of_work
5+ from allocation import email , exceptions , model , unit_of_work
66from allocation .model import OrderLine
77
88
@@ -28,6 +28,10 @@ def allocate(
2828 product = uow .products .get (sku = line .sku )
2929 if product is None :
3030 raise exceptions .InvalidSku (f'Invalid sku { line .sku } ' )
31- batchref = product .allocate (line )
32- uow .commit ()
33- return batchref
31+ try :
32+ batchref = product .allocate (line )
33+ uow .commit ()
34+ return batchref
35+ except exceptions .OutOfStock :
36+ email .send_mail ('stock@made.com' , f'Out of stock for { line .sku } ' )
37+ raise
You can’t perform that action at this time.
0 commit comments