aeat.application.invoices._reconciliation module

Application service for invoice reconciliation workflows.

reconcile_invoice_catalogues() accepts an InvoiceCatalogue and a TransactionCatalogue directly. reconcile_invoice_repositories() is the CLI-facing backend: it loads an InvoiceCatalogueRepository and a TransactionCatalogueRepository, optionally applies every suggested link, and writes the mutated catalogues back.

class ReconciliationSkippedSuggestion(**data)[source]

Bases: BaseModel

A reconciliation suggestion the backend could not safely apply.

Parameters:
  • invoice_id (str)

  • transaction_id (str)

  • reason (str)

invoice_id: str
transaction_id: str
reason: str
class InvoiceReconciliationResult(**data)[source]

Bases: BaseModel

Complete backend result for an invoice reconciliation run.

Parameters:
suggestions: tuple[ReconciliationSuggestion, ...]
applied: int
skipped: tuple[ReconciliationSkippedSuggestion, ...]
invoices: InvoiceCatalogue
transactions: TransactionCatalogue
reconcile_invoice_catalogues(invoices, transactions, *, apply=False)[source]

Build reconciliation suggestions and optionally apply them in memory.

Parameters:
Return type:

InvoiceReconciliationResult

Returns:

An InvoiceReconciliationResult containing suggestions, mutated catalogues when applied, and every skipped suggestion with its backend reason.

reconcile_invoice_repositories(*, bucket_id, apply=False, invoice_repository=None, transaction_repository=None)[source]

Reconcile persisted invoice and transaction catalogues and return an InvoiceReconciliationResult.

This is the CLI-facing backend workflow. It owns catalogue loading, optional mutation, and persistence so entrypoints can remain a thin rendering layer.

Return type:

InvoiceReconciliationResult

Parameters: