Expand description
Money: exact amounts, and the amounts written in mail.
Amounts are kept in cents so sums never drift. Mail writes them in every national style (“1 234,56 €”, “€1,234.56”, “$20.00 USD”, “-8,49 €”).
Two readers: find_amount, the first amount after a word like “total” or
“you received”; and payment_amount, for receipts, which also knows that
the amount paid is stated in a sentence, on the total’s line, or last, and
that a company’s share capital in the legal footer is never it.
Structs§
- Amount
- An amount found in a message, with its currency (ISO 4217).
- Found
- An amount found in a message, where it was, and what follows it.
- Money
- An amount in cents. Written in euros in configuration files:
-250,68.5. - Placed 🔒
- An amount written next to a currency mark, and where it starts and ends.
Constants§
- CURRENCIES 🔒
- Currency marks, longest first so “EUR” is not read as something shorter.
Functions§
- all_
amounts 🔒 - Every amount written next to a currency mark, in order. A minus sign right before the number makes it negative (“-8,49 €”, a discount).
- currency_
at 🔒 - A currency mark starting at
i: a symbol, or a code that is a whole word. - find_
amount - The amount a message is about: the first after a word after which it
usually comes (
MoneyWords::keywords: “total”, “you received”), else the first. - grouped_
digits 🔒 - The digits of a whole part whose thousands are grouped by threes: “1 234” → “1234”. When the groups are not threes (“3 25”, a reference then a price), only the last group is the number.
- in_
number 🔒 - Characters that can be inside a written number: digits, separators, spaces.
- is_
legal 🔒 - last 🔒
- line_
amounts 🔒 - The amounts of one line, each with the rest of the line after it.
- line_
amounts_ 🔒after - The amounts of a line starting at character
from(asfoldcounts them: folding keeps one character per character). - number_
after 🔒 - The number that starts just after position
start(one space allowed), and where it ends. - number_
before 🔒 - The number that ends just before position
end(one space allowed). - parse_
number 🔒 - “1 234,56”, “1,234.56”, “25,00”, “12,5”, “1250”, “20.00” → cents.
- payment_
amount - The amount a payment message is about, in this order of trust:
- stated 🔒
- stated_
amount - The amount stated by a sentence (“Vous avez payé 387,00 € à…”), with what follows it.
- total 🔒
- without_
code 🔒 - “EUR à Exemple” → “à Exemple”: a currency code repeated after the symbol is not what follows.