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 3
3
from datetime import date
4
4
from typing import Optional , List , Set
5
5
from allocation import exceptions
6
- from allocation import email
7
6
8
7
9
8
class Product :
@@ -22,7 +21,6 @@ def allocate(self, line: OrderLine) -> str:
22
21
self .version_number += 1
23
22
return batch .reference
24
23
except StopIteration :
25
- email .send_mail ('stock@made.com' , f'Out of stock for { line .sku } ' )
26
24
raise exceptions .OutOfStock (f'Out of stock for sku { line .sku } ' )
27
25
28
26
Original file line number Diff line number Diff line change 2
2
from typing import Optional
3
3
from datetime import date
4
4
5
- from allocation import exceptions , model , unit_of_work
5
+ from allocation import email , exceptions , model , unit_of_work
6
6
from allocation .model import OrderLine
7
7
8
8
@@ -28,6 +28,10 @@ def allocate(
28
28
product = uow .products .get (sku = line .sku )
29
29
if product is None :
30
30
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