cadrumo.application.ledger.classifier_inputs module¶
The facts an IVA classification is derived from, each with where it came from.
An IVA category decides whether tax is charged, self-assessed, or not due at all. When a later audit asks why a document was classified the way it was, the answer has to be a record of the inputs rather than a re-run of the code — the code will have moved on, and a re-run cannot show what the profile said at the time.
So every input arrives here as a typed row carrying its own source, and the two sources are not interchangeable:
Document evidence is anchorable. It was printed, so an operator can be pointed at the printed form and shown what was read.
A profile fact is authoritative and unanchorable. The taxpayer’s censo regime is true of the filer whichever document is being classified; there is no phrase on the page to highlight, and pretending otherwise would have the envelope claim the document said something it never said.
What this module deliberately does NOT do is decide the classification, or map
its inputs into the substrate classifier’s own criteria record. It collects
facts and states their provenance. The mapping needs one authority this
pipeline does not consult (see
CounterpartyTaxablePersonStatus), and inventing it here would
put a legal conclusion behind an unverified reading.
See also
IvaInvoiceClassificationCriteriaThe substrate classifier’s input record these facts eventually feed.
InvoiceDraftThe read document these evidence-sourced facts are derived from.
- class ClassifierInputFact(**data)[source]¶
Bases:
BaseModelOne fact a classification stood on, and where it came from.
- Variables:
name – Which input this is.
value – The fact, as its closed-enum token.
source – Whether the document established it or the profile did.
anchor – The verbatim printed form it was read from, when the document established it.
Nonefor a profile fact, which has no printed form on this document to point at.authority – What vouches for a profile fact.
Nonefor document evidence, which is vouched for by its own anchor.
- Parameters:
data (Any)
- name: str¶
- value: str¶
- source: ClassifierInputSource¶
- anchor: str | None¶
- authority: str | None¶
- class ClassifierInputs(**data)[source]¶
Bases:
BaseModelEvery fact collected for one document’s IVA classification.
- Variables:
counterparty_taxable_person – What the document established about the counterparty.
UNKNOWNwhen nothing was established.filer_iva_regime – The taxpayer’s own censo-registered IVA regime, or
Nonewhen no profile was resolvable.facts – One row per input, each stating its own source.
- Parameters:
data (Any)
- counterparty_taxable_person: CounterpartyTaxablePersonStatus¶
- filer_iva_regime: IVARegime | None¶
- facts: tuple[ClassifierInputFact, ...]¶
- collect_classifier_inputs(draft, *, profile=None)[source]¶
Collect the classification facts from a read document and the filer’s profile.
Absence resolves to UNKNOWN and can never resolve to consumer. The function has no branch that produces a consumer verdict, which is stronger than a default that happens to be safe: a factura simplificada legitimately prints no recipient at all, so treating absence as evidence about the recipient would silently reclassify that whole legitimate population.
- Parameters:
draft (
InvoiceDraft) – The read document. Only its printed identifiers are consulted.profile (
TaxpayerProfile|None) – The filer’s ownTaxpayerProfile, when one is resolvable.Nonerecords no regime fact rather than assuming a regime — guessing the filer’s regime would change the tax on every document they file.
- Returns:
The facts, each with its source.
- Return type: