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: BaseModel

Result of deleting one rich catalogue invoice.

Parameters:
invoice: Invoice
catalogue: InvoiceCatalogue
resolve_catalogue_invoice(catalogue, invoice_id)[source]

Return one InvoiceCatalogue invoice 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:
Return type:

Invoice

Returns:

The resolved Invoice.

Parameters:
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:

Invoice

Returns:

The resolved Invoice.

Parameters:
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_ids is refused: deleting it from the catalogue alone would leave the transaction side citing a vanished invoice — a one-sided link verify_link_consistency flags. The operator must unlink first. The write rides the sanctioned InvoiceCatalogueRepository; no parallel write path is introduced.

Return type:

CatalogueInvoiceRemoveResult

Parameters: