Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb11e04

Browse filesBrowse files
committed
start on handler for change quantity [change_quantity_handler]
1 parent f4b7851 commit eb11e04
Copy full SHA for eb11e04

File tree

Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Open diff view settings
Collapse file

‎src/allocation/handlers.py‎

Copy file name to clipboardExpand all lines: src/allocation/handlers.py
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from __future__ import annotations
2-
import typing
2+
from typing import TYPE_CHECKING
33
from allocation import events, email, exceptions, model
44
from allocation.model import OrderLine
5-
if typing.TYPE_CHECKING:
5+
if TYPE_CHECKING:
66
from allocation import unit_of_work
77

88

9-
109
def add_batch(
1110
event: events.BatchCreated, uow: unit_of_work.AbstractUnitOfWork
1211
):
@@ -34,6 +33,16 @@ def allocate(
3433
return batchref
3534

3635

36+
37+
def change_batch_quantity(
38+
event: events.BatchQuantityChanged, uow: unit_of_work.AbstractUnitOfWork
39+
):
40+
with uow:
41+
product = uow.products.get_by_batchref(batchref=event.ref)
42+
product.change_batch_quantity(ref=event.ref, qty=event.qty)
43+
uow.commit()
44+
45+
3746
# pylint: disable=unused-argument
3847

3948
def send_out_of_stock_notification(
Collapse file

‎src/allocation/messagebus.py‎

Copy file name to clipboardExpand all lines: src/allocation/messagebus.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def handle(event: events.Event, uow: unit_of_work.AbstractUnitOfWork):
1616

1717
HANDLERS = {
1818
events.BatchCreated: [handlers.add_batch],
19+
events.BatchQuantityChanged: [handlers.change_batch_quantity],
1920
events.AllocationRequired: [handlers.allocate],
2021
events.OutOfStock: [handlers.send_out_of_stock_notification],
22+
2123
} # type: Dict[Type[events.Event], List[Callable]]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.