Add unified shift reporting
This commit is contained in:
1 parent
1b060377aa
commit
41a5ae7a63
30 files changed
+3751
-9
No files matched your search
@@ -0,0 +1,29 @@
|
||||
"""Compose historical ERP reads with pure shift-production aggregation."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Protocol
|
||||
|
||||
from production_analytics.calculations.shift_production import (
|
||||
ShiftProductionSummary,
|
||||
aggregate_shift_production,
|
||||
validate_shift_window,
|
||||
)
|
||||
from production_analytics.erp import ProductionConfirmation
|
||||
|
||||
|
||||
class ProductionConfirmationReader(Protocol):
|
||||
def get_confirmations(
|
||||
self, *, workplace: str, start: datetime, end: datetime
|
||||
) -> list[ProductionConfirmation]: ...
|
||||
|
||||
|
||||
class ShiftProductionService:
|
||||
def __init__(self, gateway: ProductionConfirmationReader) -> None:
|
||||
self.gateway = gateway
|
||||
|
||||
def summarize(
|
||||
self, *, workplace: str, start: datetime, end: datetime
|
||||
) -> ShiftProductionSummary:
|
||||
workplace = validate_shift_window(workplace=workplace, start=start, end=end)
|
||||
confirmations = self.gateway.get_confirmations(workplace=workplace, start=start, end=end)
|
||||
return aggregate_shift_production(confirmations, workplace=workplace, start=start, end=end)
|
||||
Reference in new issue
Block a user