aeat.application.invoices._importing module¶
Application service for importing invoice records.
import_invoices_from_path() loads the persisted InvoiceCatalogue
from the InvoiceCatalogueRepository, merges the parsed invoices, and
writes the updated catalogue back.
- class InvoiceRowPayload[source]¶
Bases:
TypedDictTyped shape for a single decoded invoice row from JSON input.
All fields are optional at the decode boundary because JSON sources may omit fields that are defaulted downstream in
parse_invoice_payload(). The downstream coercion stage fills in application defaults beforeInvoicevalidation runs.
- class InvoiceImportResult(**data)[source]¶
Bases:
BaseModelResult DTO returned by invoice import application services.
- Parameters:
rows (int)
imported (int)
skipped (int)
dry_run (bool)
catalogue (InvoiceCatalogue | None)
- rows: int¶
- imported: int¶
- skipped: int¶
- dry_run: bool¶
- catalogue: InvoiceCatalogue | None¶
- parse_invoice_payload(raw, *, default_kind)[source]¶
Parse JSON invoice payloads into validated
Invoicemodels.
- merge_invoice_import(catalogue, invoices)[source]¶
Merge imported invoices into
cataloguewithout duplicating IDs.- Parameters:
catalogue (
InvoiceCatalogue) – TheInvoiceCatalogueto merge the imported invoices into.invoices (
Sequence[Invoice]) – Sequence ofInvoicerows produced by an importer; rows whoseinvoice_idalready exists incatalogueare skipped to preserve catalogue identity.
- Return type:
Returns an
InvoiceImportResultwith the updated catalogue and counts of imported and skipped invoices.
- import_invoices_from_path(path, *, kind, dry_run=False, repository=None)[source]¶
Import invoices from
paththrough the secure invoice repository.Returns an
InvoiceImportResult.- Return type:
- Parameters:
path (Path)
kind (InvoiceKind | str)
dry_run (bool)
repository (InvoiceCatalogueRepositoryProtocol | None)