Expand description
Formatting helpers for monetary amounts, rates, and decimal numbers. Formatting helpers for monetary amounts, rates, and decimal numbers.
All functions accept raw integer representations — cents for monetary values
and scaled integers for rates — and return formatted Strings suitable for
insertion into NF-e XML elements.
Functions§
- format_
cents - Format a cents integer to a decimal string with the given number of decimal places.
- format_
cents_ 2 - Format a cents integer to a decimal string with 2 decimal places.
- format_
cents_ 10 - Format a cents integer to a decimal string with 10 decimal places (for unit prices).
- format_
cents_ or_ none - Format an optional cents value to a decimal string, returning
Nonewhen the input isNone. - format_
cents_ or_ zero - Format an optional cents value to a decimal string, defaulting to
"0.00"(or"0.+nzeros") when the input isNone. - format_
decimal - Format a floating-point number with
decimal_placesdecimal places. - format_
rate - Format a rate stored as hundredths of a percent to a decimal string.
- format_
rate4 - Format a PIS/COFINS rate stored as
value × 10 000to a 4-decimal string. - format_
rate4_ or_ zero - Format an optional
rate4value (scaled by 10 000) to a 4-decimal string, defaulting to"0.0000"when the input isNone. - format_
rate_ 4 - Format a rate (stored as hundredths) with 4 decimal places.