More tax rate handling

This commit is contained in:
Raphael Michel
2026-07-14 09:26:39 +02:00
parent b3eec43645
commit 40959ee24a
2 changed files with 9 additions and 6 deletions
+5 -2
View File
@@ -66,11 +66,14 @@ def _normalize_decimal(d: Decimal) -> Decimal:
20.010 → 20.01
20.100 → 20.1
But unlike of Decimal.normalize(), 20.000 will not become 2e+1
But unlike of Decimal.normalize(), 20.000 will not become 2e+1. Very small decimals might still be represented
in scientific notation when printed.
"""
normalized = d.normalize()
sign, digit, exponent = normalized.as_tuple()
return normalized if exponent <= 0 else normalized.quantize(1)
if exponent > 0:
return normalized.quantize(1)
return normalized
class NormalizedDecimalField(DecimalField):