cadrumo.application.ledger.structured_invoice_ports module

Application-owned contract for deterministic structured-invoice reads.

The inbound e-invoice parser owns syntax, XML handling, and format-specific vocabularies. The ledger use case needs only the values a structured record states, so an outer binding translates the parser’s result into these syntax-neutral in-memory records before it crosses into the application.

class StructuredInvoiceClassificationKind(*values)[source]

Bases: StrEnum

Application-relevant class of a structured invoice document.

ORDINARY
CORRECTIVE
SUMMARY
class StructuredInvoiceClassification(source_code, kind)[source]

Bases: object

A document class translated from a syntax-specific source code.

Parameters:
source_code: str
kind: StructuredInvoiceClassificationKind
class StructuredInvoiceLine(description, quantity, unit_price, taxable_base, iva_rate, iva_amount)[source]

Bases: object

One syntax-neutral line read from a structured invoice.

Parameters:
description: str | None
quantity: Decimal | None
unit_price: Decimal | None
taxable_base: Decimal | None
iva_rate: Decimal | None
iva_amount: Decimal | None
class StructuredInvoiceRecord(shape, supplier_tax_id, customer_tax_id, supplier_name, customer_name, supplier_postal_code, customer_postal_code, supplier_country_code, customer_country_code, invoice_number, invoice_series, invoice_classification, rectifies_invoice_number, invoice_date, currency, taxable_base, iva_amount, grand_total, recargo_amount, retencion_amount, suplidos_amount, iva_category, regime_legend, record_text, lines, iva_breakdown)[source]

Bases: object

The structured-record facts consumed by ledger extraction.

Parameters:
shape: DocumentShape
supplier_tax_id: str | None
customer_tax_id: str | None
supplier_name: str | None
customer_name: str | None
supplier_postal_code: str | None
customer_postal_code: str | None
supplier_country_code: str | None
customer_country_code: str | None
invoice_number: str | None
invoice_series: str | None
invoice_classification: StructuredInvoiceClassification | None
rectifies_invoice_number: str | None
invoice_date: str | None
currency: str | None
taxable_base: Decimal | None
iva_amount: Decimal | None
grand_total: Decimal | None
recargo_amount: Decimal | None
retencion_amount: Decimal | None
suplidos_amount: Decimal | None
iva_category: str | None
regime_legend: str | None
record_text: str
lines: tuple[StructuredInvoiceLine, ...]
iva_breakdown: tuple[tuple[Decimal | None, Decimal | None, Decimal | None], ...]
class StructuredInvoiceReader(*args, **kwargs)[source]

Bases: Protocol

Required capability for reading one structured invoice from bytes.