aeat.application.invoices._lifecycle module¶
Application lifecycle services for the rich catalogue Invoice.
Reads and mutates the InvoiceCatalogue aggregate.
The reconciliation catalogue gained create and list operator verbs but
no way to inspect or delete a single record. Without a single-record read an
operator cannot confirm the long content-addressed invoice_id that
aeat app ledger link --invoice-id resolves, nor see which transactions a
catalogue invoice already binds; without a delete a mistaken
catalogue create is permanent. These two services close that CRUD gap over
the same sanctioned InvoiceCatalogueRepository write path
(composition-service-no-parallel-write-path), keeping the slim-vs-rich
split intact.
resolve_catalogue_invoice() resolves a full id or an unambiguous prefix
to one Invoice. remove_catalogue_invoice() deletes one record,
refusing an invoice that still carries linked_transaction_ids so the
bidirectional link recorded on the transaction side is never silently orphaned
into a one-sided inconsistency (verify_link_consistency).
- class CatalogueInvoiceRemoveResult(**data)[source]¶
Bases:
BaseModelResult of deleting one rich catalogue invoice.
- Parameters:
invoice (Invoice)
catalogue (InvoiceCatalogue)
- invoice: Invoice¶
- catalogue: InvoiceCatalogue¶
- resolve_catalogue_invoice(catalogue, invoice_id)[source]¶
Return one
InvoiceCatalogueinvoice by full id or unambiguous prefix.A catalogue invoice carries a long content-addressed id; operators rarely type it in full. An exact match wins outright. Otherwise a case-sensitive prefix is accepted only when it is unambiguous: a prefix that matches more than one invoice is refused with the candidate set named, never silently resolved to the first hit.
- Raises:
InvoiceNotFoundError – when no invoice matches the id or prefix.
InvoiceValidationError – when a prefix matches more than one invoice.
- Return type:
- Returns:
The resolved
Invoice.- Parameters:
catalogue (InvoiceCatalogue)
invoice_id (str)
- resolve_catalogue_invoice_from_repository(*, bucket_id, invoice_id, repository=None)[source]¶
Load the catalogue and resolve one invoice by id or unambiguous prefix.
- Return type:
- Returns:
The resolved
Invoice.- Parameters:
bucket_id (str)
invoice_id (str)
repository (InvoiceCatalogueRepositoryProtocol | None)
- remove_catalogue_invoice(*, bucket_id, invoice_id, repository=None)[source]¶
Delete one rich catalogue invoice and return the updated catalogue.
The id is resolved by full match or unambiguous prefix. An invoice that still carries
linked_transaction_idsis refused: deleting it from the catalogue alone would leave the transaction side citing a vanished invoice — a one-sided linkverify_link_consistencyflags. The operator must unlink first. The write rides the sanctionedInvoiceCatalogueRepository; no parallel write path is introduced.- Return type:
- Parameters:
bucket_id (str)
invoice_id (str)
repository (InvoiceCatalogueRepositoryProtocol | None)