File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
src/allocation/service_layer Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22from typing import TYPE_CHECKING
3+ from allocation .adapters import email
34from allocation .domain import events , model
45from allocation .domain .model import OrderLine
56
@@ -40,6 +41,16 @@ def allocate(
4041 return batchref
4142
4243
44+ def change_batch_quantity (
45+ event : events .BatchQuantityChanged ,
46+ uow : unit_of_work .AbstractUnitOfWork ,
47+ ):
48+ with uow :
49+ product = uow .products .get_by_batchref (batchref = event .ref )
50+ product .change_batch_quantity (ref = event .ref , qty = event .qty )
51+ uow .commit ()
52+
53+
4354# pylint: disable=unused-argument
4455
4556
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ def handle(
2323
2424HANDLERS = {
2525 events .BatchCreated : [handlers .add_batch ],
26+ events .BatchQuantityChanged : [handlers .change_batch_quantity ],
2627 events .AllocationRequired : [handlers .allocate ],
2728 events .OutOfStock : [handlers .send_out_of_stock_notification ],
2829} # type: Dict[Type[events.Event], List[Callable]]
You can’t perform that action at this time.
0 commit comments