cadrumo.application.ledger.postal_shape_finding module¶
Say so when a party’s postal code field does not hold a postal code.
The free-text validator keeps whatever the reader put in the field, trimmed and
otherwise untouched, and that permissiveness is deliberate: dropping an
unreadable value would destroy the printed anchor the operator reviews, leaving
them a blank field and nothing to correct it against. So an address line the
reader lifted whole – "Calle Mayor 3, 28013 Madrid" – reaches the draft and
the operator payload intact, under a label that says postal code, and reads as
one until somebody looks.
Nothing unsafe follows from it, which is why this is a visibility problem rather
than a correctness one:
territorial_scope_for_spanish_postal_code() answers None
for anything that is not five digits rather than defaulting to the peninsula, so
an unreadable code costs an answer and never invents one.
The judgement is borrowed, not restated. Whether a code is readable is asked
by handing it to that resolver and seeing whether it answers; whether the country
already settled the territory is asked of
territorial_scope_for_country(). Neither rule is spelled here.
A second copy of “five digits” sitting upstream of the authority that owns it is
the drift this module is placed to avoid, and it would be the weaker copy.
Why it does not fire on every non-numeric code. A British SW1A 1AA and a
Dutch 1011 AB are correctly printed postal codes that are not five digits,
and flagging them would refuse confirmation on a large, entirely legitimate
population for no gain – every discrepancy kind blocks by construction. Alert
fatigue is a real failure mode: a check that fires mostly on documents that are
fine teaches an operator to clear it without reading, and then it is worth less
than nothing on the one document that mattered.
So the question asked is not is this five digits but does this field being unreadable cost anything. The postal code is the SUB-national evidence, consulted only where the country did not settle the territory on its own. A party whose printed country resolves – any country but Spain – is already established, and its postal code is decorative. Spain deliberately resolves to no scope, because the State names the Member State while Canarias, Ceuta y Melilla and the peninsula stay undecided inside it; a party with no country printed is unsettled for the plainer reason. Those two are exactly the parties whose postal code was load-bearing, and exactly the ones this reports.
See also
deterministic_findings()The one list this check is enrolled in, which both readers call.
territorial_scope_for_spanish_postal_code()The authority on whether a printed code can be read at all.
- postal_shape_findings(draft, *, operation)[source]¶
Return a finding per party whose postal code was populated but unreadable.
Only where the country did not already settle that party’s territory, so every finding names a code that was actually needed.
- Parameters:
draft (
InvoiceDraft) – The draft to check, carrying each party’s printed postal code and printed country as the reader recovered them.operation (
PinnedAuthorityOperation) – The caller-owned pinned authority operation used for country and Spanish-territory lookups.
- Return type:
- Returns:
The findings, in party declaration order. Empty when every populated code reads, when the countries settled the territories, or when no code was recovered at all – an absent field is an honest absence and is not reported as a misread one.