aeat.application.invoices._source_resolver module

Source-mesh resolver for governed invoice records.

InvoiceCatalogueSourceResolver reads the InvoiceCatalogue selected by bucket_id through InvoiceCatalogueRepository and also adapts slim BusinessOperationInvoice records when their repository is available. It projects those records into the calculation mesh as CalculationSourceResolution values for COLLECTIBLE_INVOICE and PAYABLE_INVOICE.

The rich Invoice aggregate remains the reconciliation and link authority; the slim ledger-mounted invoice records are operator-editable source-kind records. Both paths converge here only after they can be represented as registry InvoiceObservation facts, with Modelo 349 summary bindings, detail rows, transaction ids, and source provenance emitted through one resolver envelope.

invoice_direction_to_source_kind(kind)[source]

Map an invoice direction to its settlement source kind.

The single contractual home for the direction↔settlement relationship, consumed by both InvoiceCatalogueSourceResolver and the operator aeat app ledger invoice CLI. An issued invoice (we billed a customer) is collectible; a received invoice (a vendor billed us) is payable.

Return type:

BusinessOperationInvoiceDirection

Returns:

The BusinessOperationInvoiceDirection settling kind.

Parameters:

kind (InvoiceKind)

class InvoiceCatalogueSourceResolver(*, invoice_repository=None, business_invoice_repository=None)[source]

Bases: object

Resolve invoice-source bindings and detail rows from persisted invoice records.

The resolver owns both invoice source kinds in the calculation mesh. It filters records by CalculationSourceContext, turns declarable intracommunity entries into InvoiceObservation facts, and returns a CalculationSourceResolution carrying binding values, Modelo 349 detail rows, linked transaction ids, and stable source provenance.

Parameters:
resolver_id
owned_sources
resolve(context)[source]
Return type:

CalculationSourceResolution

Parameters:

context (CalculationSourceContext)