cadrumo.core.decimal.printed_units module¶
Removal of the currency UNIT a document prints beside an amount.
A printed amount carries its unit: 1.200,00 €, EUR 1200.00,
1200.00 EUR. The unit is not a digit, so a reader that copies the printed
form faithfully hands the decimal authority a string it must refuse, and the
field is lost for having been read too literally. This module owns the one rule
that separates the unit from the number.
It lives in core because both halves of the extraction contract need it and
they sit on opposite sides of the dependency direction: the reading adapter
grounds the model’s VALUE, and the application’s anchor check parses the printed
ANCHOR it claims to come from. Two spellings of this rule would let the two
halves disagree about the same string – which is exactly the state that
reported a correctly-read taxable base as contradicted by its own anchor.
Only a unit this module can name is removed. A symbol from the closed set below, or the exact currency code the same document reported. Anything else is left in place so the decimal authority still refuses it, because “strip whatever is not a digit” turns a misread into a filing figure. Removing a unit says nothing about WHICH currency an amount is in: that is the currency field’s own claim, and its validator refuses to guess a code from a symbol.
- CURRENCY_UNIT_SYMBOLS¶
Currency symbols treated as unit markers beside an amount.
- without_currency_unit(text, currency_unit=None)[source]¶
Return text with at most ONE leading or trailing currency unit removed.
- Parameters:
text (
str) – The amount as the document printed it, or as a reader copied it.currency_unit (
str|None) – The ISO-4217 code this document reported for itself. Required for a code to be recognised as a unit: the ISO authority validates SHAPE rather than membership, so accepting any three letters would reduce1200.00 IVAto a figure the document never printed under that label.Nonerecognises only a symbol.
- Return type:
- Returns:
The text with one unit removed, or unchanged when it carries none this rule can name. At most one is removed, so
1200 EUR EURkeeps one and still fails the decimal authority.