Source code for cadrumo.application.inventory.ports
"""Application-owned capabilities for bucket-scoped inventory operations.The inventory service coordinates ledger persistence and bucket-event emission,but it does not know which encrypted repositories implement either capability.An executable composition root supplies this complete bundle for each bucket."""from__future__importannotationsfromcollections.abcimportCallablefromdataclassesimportdataclassfromtypingimportProtocolfrom...domain.buckets.protocolsimportBucketEventHistoryRepositoryProtocolfrom...domain.contribuyente.inventory.recordsimport(InventoryClosingAuthorityRecord,InventoryLedger,InventoryLedgerDocument,)
[docs]classInventoryLedgerServiceRepositoryProtocol(Protocol):"""Complete ledger capability required by :class:`InventoryService`."""
[docs]defload(self)->InventoryLedgerDocument:"""Load the bucket's inventory document."""...
[docs]defsave(self,document:InventoryLedgerDocument)->None:"""Persist a validated inventory document."""...
[docs]defcreate(self,ledger:InventoryLedger)->InventoryLedgerDocument:"""Atomically create one activity/year ledger."""...
[docs]defrecord_closing_authority(self,actividad_id:str,authority_record:InventoryClosingAuthorityRecord,*,year:int,)->InventoryLedger:"""Atomically record one closing-authority record."""...
[docs]defremove(self,actividad_id:str,*,year:int)->InventoryLedger:"""Atomically remove one activity/year ledger."""...
[docs]@dataclass(frozen=True,slots=True)classInventoryServicePorts:"""Required persisted authorities for one inventory service instance."""inventory_repository_factory:InventoryRepositoryFactorybucket_event_repository:BucketEventHistoryRepositoryProtocol
[docs]classInventoryServicePortsFactory(Protocol):"""Construct the complete inventory capability bundle for one bucket."""def__call__(self,*,bucket_id:str)->InventoryServicePorts:"""Return inventory capabilities bound to ``bucket_id``."""...