aeat.application.ledger._preflight module¶
Backend readiness preflight for bucket-scoped ledger transactions.
preflight_ledger_tax_readiness() loads a
TransactionCatalogue via
TransactionCatalogueRepository from the
active bucket and delegates to preflight_transaction_catalogue() for pure
in-memory analysis. The report is consumed by modelo readiness projection and
ledger read surfaces; it is not a calculation engine and never mutates the
catalogue it inspects.
See also
build_operator_state_projection()Modelo readiness consumer that embeds blocking ledger issues in the operator state projection.
aeat.entrypoints.cli._ledger_read_cliCLI read surface that reports these preflight issues without mutating ledger state.
aeat.application.aggregationCalculation source mesh that consumes ledger facts only after this readiness layer has reported operator-facing gaps.
- class LedgerPreflightIssueReason(*values)[source]¶
Bases:
StrEnumMachine-readable ledger facts missing before modelo calculation.
- MISSING_BUSINESS_CLASSIFICATION¶
- MISSING_CATEGORY¶
- MISSING_TAXABLE_BASE¶
- MISSING_IVA_AMOUNT¶
- MISSING_IVA_RATE¶
- MISSING_EUR_TAX_SUBSTRATE¶
- MISSING_COUNTERPARTY_EU_MEMBER_STATE¶
- DOMESTIC_COUNTERPARTY_ON_INTRA_COMMUNITY_TRANSACTION¶
- EU_MEMBER_STATE_ON_EXPORT_TRANSACTION¶
- MISSING_PROPORTIONALITY_REFERENCE¶
- UNSUPPORTED_CURRENCY¶
- UNSUPPORTED_PERIOD¶
- CENSO_RATIO_MISMATCH¶
- ANOMALY_NON_DECLARABLE_IVA_CATEGORY¶
- ANOMALY_NON_DECLARABLE_RECARGO_EQUIVALENCIA¶
- class LedgerPreflightIssue(**data)[source]¶
Bases:
BaseModelOne model-readiness issue attached to a bucket-local transaction.
- Parameters:
transaction_id (str)
reason (LedgerPreflightIssueReason)
detail (str)
- transaction_id: str¶
- reason: LedgerPreflightIssueReason¶
- detail: str¶
- class LedgerPreflightReport(**data)[source]¶
Bases:
BaseModelReadiness report for ledger facts consumed by modelo calculation.
- Parameters:
- bucket_id: BucketId¶
- period: Period¶
- checked_transaction_count: int¶
- issues: Sequence[LedgerPreflightIssue]¶
- preflight_ledger_tax_readiness(*, bucket_id, period, transaction_repository=None, raw_afectacion_ratio=None)[source]¶
Load a bucket-local catalogue and report modelo-readiness gaps.
- Parameters:
bucket_id (
str) – Bucket whose ledger catalogue is being checked.period (
Period) – Filing period used to decide whether each transaction belongs in the readiness window.transaction_repository (
TransactionCatalogueRepository|None) – OptionalTransactionCatalogueRepositoryused to load the bucket-local catalogue; a default repository is constructed whenNone.raw_afectacion_ratio (
Decimal|None) – Optional home-office usage ratio from censo data, used only to surface proportionality mismatches.
- Return type:
- Returns:
A
LedgerPreflightReportdescribing blocking or advisory ledger facts for modelo-readiness projection.
- preflight_transaction_catalogue(*, bucket_id, period, transactions, censo_ratio_mismatch_detail=None)[source]¶
Report missing ledger facts without mutating the transaction catalogue.
- Parameters:
bucket_id (
str) – Stable bucket identifier for the ledger being checked.transactions (
TransactionCatalogue) – TheTransactionCatalogueto inspect for missing facts.censo_ratio_mismatch_detail (
str|None) – Optional censo mismatch detail previously resolved from the secure ratio profile. When supplied, active HOME_OFFICE ratio rows surface it as a preflight issue.
- Return type:
Returns a
LedgerPreflightReport.