cadrumo.application.ledger.confirm_establishment module¶
Where the establishment ladder is actually reached: the confirm path.
The ladder, its four rungs, the identification and establishment split, the country vocabulary, the alpha-3 correspondence and the Spanish postal derivation were each built and each gated. None of them was called from a live path. This module is the call: it takes the document an operator is confirming and the direction they settled it under, resolves BOTH parties’ territories through the authorities that own them, and hands the answers to the criteria assembly in the one channel that carries who established what.
Two parties, two authorities, and they are not interchangeable. The filer’s own territory is a profile fact – system-authoritative, declared once, and identical whichever document is being confirmed – so it is read from the profile and never from the paper. Only the counterparty’s territory is a document question, and it is answered by the ladder. Resolving the filer from their printed address block would ask a probabilistic reader for something already known with certainty, and resolving the counterparty from the profile would answer a question about one entity with a fact about another.
Neither authority is doubled by the assembly. The criteria assembly can derive a scope from a printed country and postal code itself, and this module deliberately hands it NEITHER for the parties it has already resolved. A scope supplied as a declared fact and a scope re-derived from the same printed values are two answers to one question, and the second one is reached exactly when the first refused – so the duplication would not merely be redundant, it would resurrect every answer the ladder declined to give. The ladder’s refusals are the reason it exists.
An exhausted ladder yields no territory and says so. There is no branch here that answers without evidence. The peninsula is the majority population, so a default there is invisible in testing while silently placing Canarian and Ceutan counterparties inside a territory their operations are not subject to. What an exhausted ladder produces instead is a review item naming the counterparty, so the question reaches a person.
The review items are surfaced, not yet refused, and that is a stated interim. The fourth amendment’s design is one question per new counterparty whose paper is non-decisive, deduped by an operator answer persisted at counterparty level. The persisting verb has no operator-facing surface yet, so refusing here would make every domestic invoice permanently unconfirmable rather than asking once – a refusal nobody can answer is not a review gate. The items are therefore carried onto the confirmation result, where the review surface reads them, and the refusal follows the answer channel rather than preceding it.
See also
resolve_draft_counterparty_establishment()The ladder this module routes the counterparty into.
resolve_filer_territorial_scope()The profile authority for the filer’s own side.
UserProfileRecordThe record that authority reads the filer’s territory out of, and the reason the filer’s side is never asked of the paper: it is a declared system-authoritative fact, so an absent record is a setup gap rather than an unreadable document.
assemble_classification_criteria()What the resolved scopes are carried into.
DeclaredFactsThe one channel a resolved scope reaches the assembly through.
IvaTerritorialScopeThe closed territory axis both authorities resolve into.
- class ConfirmedEstablishment(**data)[source]¶
Bases:
BaseModelBoth parties’ territories as one confirm resolved them, and what is still open.
- Variables:
counterparty – What the ladder settled about the counterparty, including the rung that settled it, any contradiction against a remembered fact, and the registration conflict that marks a foreign-registered entity operating establishedly in Spain. Carried whole rather than flattened to its scope: an auditor asking why a record says what it says needs the rung, and a caller told only the territory cannot distinguish an exhausted ladder from a conflicted one.
filer_scope – The taxpayer’s own territory, from their profile.
Nonewhen the profile could not establish it, which is a setup gap surfaced as a review item rather than a value invented here.declared – The scopes in the form the criteria assembly consumes, each beside who established it, with the issuer and customer slots filled by the DIRECTION the operator settled rather than by the order the document printed its parties in.
assembly – The criteria the rule table consumes, or every input that stopped them. Present whether or not the scopes resolved: the missing-input list is what tells an operator all their gaps at once.
category – The IVA treatment this document resolves to, and what established it. The confirm path takes the persisted category from here and from nowhere else.
review_items – The resolvable questions this document leaves open, in the review gate’s own blocker shape so one surface reads them all.
- Parameters:
data (Any)
- counterparty: CounterpartyEstablishment¶
- filer_scope: IvaTerritorialScope | None¶
- declared: DeclaredFacts¶
- assembly: ClassificationAssembly¶
- category: IvaCategoryResolution¶
- review_items: tuple[ConfirmationBlocker, ...]¶
- resolve_confirmed_establishment(*, bucket_id, legends, operation, draft, kind, invoice_date=None, rate_tier=None, supply_nature=None, repository)[source]¶
Resolve both parties’ territories for one confirm, and classify the operation.
The confirm path’s single call into the establishment and classification apparatus. Everything it reaches – the ladder, the profile authority, the declared-facts channel, the criteria assembly and the rule table behind it – had no production caller before this function, so this is the whole of what makes them reachable.
- Parameters:
bucket_id (
str) – Active profile bucket, for the ladder’s confirmed-fact rung.legends (
tuple[RegimeLegend,...]) – The dated registry declarations selected by the enclosing pinned authority operation. The same tuple is used by the ladder and the regime contradiction check; this function does not resolve a second vocabulary.operation (
PinnedAuthorityOperation) – The caller-owned pinned authority operation retained for all establishment and classification catalogue lookups.draft (
InvoiceDraft) – The pre-direction reading of the document being confirmed.kind (
InvoiceKind) – Which side of the invoice the filer is on, as the operator settled it at confirm. Never the reader’s suggestion, and never inferred here: it decides which party the ladder is even asked about.invoice_date (
date|None) – The operator’s date override, when they supplied one. It layers over the printed date exactly as it does on every other field, and it must reach HERE rather than only the writer: the tier a rate belonged to changes by statute, so classifying against the printed date while the record is dated otherwise answers about a rate the supply was never charged at.rate_tier (
IvaRateKind|None) – The tier the document’s lines charged, resolved by the reading stage. Reaches the criteria as the axis ruleR05consults, which is what makes the rule table – rather than a second copy of its mapping – produce a domestic category.supply_nature (
SupplyNature|None) – The operator’s own statement of whether the supply is goods or services, when they have made one. It is demanded only on the branches where the law forks on it – cross-border and reverse charge – and the ADR sanctions exactly two sources for the axis: a printed statutory citation, which decides by law, and this assertion. It enters stamped as an OPERATOR assertion so the classifier’s inputs stay facts about who established them; a document citing art. 69 and an operator saying “services” are different kinds of claim and must not arrive looking alike.repository (
CounterpartyEstablishmentRepositoryProtocol) – Injected counterparty-fact store.
- Returns:
both territories where they resolved, the criteria or the inputs that stopped them, the resolved IVA category, and every question left for a person.
- Return type: