Skip to content

Commit 40bd56d

Browse files
committed
new service to add a batch [add_batch_service]
1 parent e6fc68c commit 40bd56d

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

services.py

Lines changed: 11 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
import model
46
from model import OrderLine
@@ -11,6 +13,15 @@ class InvalidSku(Exception):
1113
def is_valid_sku(sku, batches):
1214
return sku in {b.sku for b in batches}
1315

16+
17+
def add_batch(
18+
ref: str, sku: str, qty: int, eta: Optional[date],
19+
repo: AbstractRepository, session,
20+
):
21+
repo.add(model.Batch(ref, sku, qty, eta))
22+
session.commit()
23+
24+
1425
def allocate(
1526
orderid: str, sku: str, qty: int, repo: AbstractRepository, session
1627
) -> str:

0 commit comments

Comments
 (0)