Skip to content

Commit 5c953da

Browse files
committed
new service to add a batch [add_batch_service]
1 parent 1e1f238 commit 5c953da

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

service_layer/services.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from __future__ import annotations
2+
from typing import Optional
3+
from datetime import date
24

35
from domain import model
46
from domain.model import OrderLine
@@ -13,6 +15,14 @@ def is_valid_sku(sku, batches):
1315
return sku in {b.sku for b in batches}
1416

1517

18+
def add_batch(
19+
ref: str, sku: str, qty: int, eta: Optional[date],
20+
repo: AbstractRepository, session,
21+
) -> None:
22+
repo.add(model.Batch(ref, sku, qty, eta))
23+
session.commit()
24+
25+
1626
def allocate(
1727
orderid: str, sku: str, qty: int,
1828
repo: AbstractRepository, session

0 commit comments

Comments
 (0)