Skip to content

Commit 43d7961

Browse files
committed
start on handler for change quantity [change_quantity_handler]
1 parent d4b4d28 commit 43d7961

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/allocation/service_layer/handlers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22
from typing import TYPE_CHECKING
3+
from allocation.adapters import email
34
from allocation.domain import events, model
45
from 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

src/allocation/service_layer/messagebus.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def handle(
2323

2424
HANDLERS = {
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]]

0 commit comments

Comments
 (0)