aeat.application.invoices._creation module¶
Application service for creating one rich catalogue Invoice.
The operator-facing aeat app ledger invoice catalogue create verb needs
a path to mint a linkable invoice. The slim
BusinessOperationInvoice written by
invoice add is an operator-edit record with no linked_transaction_ids
field, so link --invoice-id cannot resolve it (the documented sharp edge of
2026-06-10-ledger-invoice-unification-adr). Only the rich
Invoice in the
InvoiceCatalogue carries
linked_transaction_ids and is the reconciliation authority link targets.
create_catalogue_invoice() builds a strict Invoice from
operator-friendly fields — synthesising a single line item from a taxable base
and IVA rate, mirroring the single-line synthesis the import path uses — and
persists it through the sanctioned InvoiceCatalogueRepository (no
parallel write path). The returned Invoice.invoice_id is the
content-addressed hash link --invoice-id resolves, closing the documented
add->link gap without collapsing the two stores.
- numeric_iva_rate_slots()[source]¶
Return the closed set of operator-supplied IVA percentage slots.
A copy of the module-private mapping
_resolve_iva_rate_slot()andbuild_catalogue_invoice()consume internally, exposed for other invoice-creation transports (e.g. the manual-entry wizard) that must validate a percentage against the same accepted set before it reachesbuild_catalogue_invoice().
- class CatalogueInvoiceCreateResult(**data)[source]¶
Bases:
BaseModelResult of persisting one rich catalogue invoice.
- Parameters:
invoice (Invoice)
catalogue (InvoiceCatalogue)
- invoice: Invoice¶
- catalogue: InvoiceCatalogue¶
- build_catalogue_invoice(*, bucket_id, kind, counterparty_name, counterparty_tax_id, counterparty_country, invoice_number, issued_at, taxable_base, iva_rate, currency, payment_status=PaymentStatus.PENDING, notes='', iva_category=None, operation_type=None)[source]¶
Return a strict rich
Invoicefrom operator-supplied fields.A single line item is synthesised from
taxable_baseand the resolved IVA rate slot; the invoice totals are derived from that line so theInvoicearithmetic invariants hold. The returned invoice carries no linked transactions yet —link --invoice-idpopulates them later.iva_categorycarries the intra-community classification the M349 recapitulative resolver reads for historical goods/triangulation records.operation_typecarries the explicit Modelo 349 clave for invoice records that need a key not represented by an IVA category.- Return type:
- Parameters:
bucket_id (str | None)
kind (InvoiceKind)
counterparty_name (str)
counterparty_tax_id (str)
counterparty_country (str)
invoice_number (str)
issued_at (date)
taxable_base (Decimal)
iva_rate (Decimal | None)
currency (str)
payment_status (PaymentStatus)
notes (str)
iva_category (IvaCategory | None)
operation_type (IntracomOperationType | None)
- create_catalogue_invoice(*, bucket_id, kind, counterparty_name, counterparty_tax_id, counterparty_country, invoice_number, issued_at, taxable_base, iva_rate, currency, payment_status=PaymentStatus.PENDING, notes='', iva_category=None, operation_type=None, repository=None)[source]¶
Persist one rich catalogue
Invoiceand return the updated catalogue.The invoice is built via
build_catalogue_invoice(), merged into the loadedInvoiceCatalogue, and written back through the sanctionedInvoiceCatalogueRepository. A duplicate logical identity (same derivedinvoice_idalready present) is refused so an accidental re-create cannot silently overwrite a linked record.- Return type:
- Parameters:
bucket_id (str)
kind (InvoiceKind)
counterparty_name (str)
counterparty_tax_id (str)
counterparty_country (str)
invoice_number (str)
issued_at (date)
taxable_base (Decimal)
iva_rate (Decimal | None)
currency (str)
payment_status (PaymentStatus)
notes (str)
iva_category (IvaCategory | None)
operation_type (IntracomOperationType | None)
repository (InvoiceCatalogueRepositoryProtocol | None)