fix(decimal): exact sums must handle only zero amounts
davoodmehraban89 committed
Oct 31, 2026 at 00:36 UTC
992a93a5db4e6608d649037351b2f0b90f7bf904
1 file changed
+1
-1
backend/src/aram_backend/reconciliation_review.py
+1
-1
@@ -118,7 +118,7 @@ def _key(
118
def _sum_exact(amounts: Sequence[Decimal]) -> Decimal:
119
if not amounts:
120
return Decimal(0)
121
- integer_digits = max(1, *(amount.adjusted() + 1 for amount in amounts if amount))
121
+ integer_digits = max((amount.adjusted() + 1 for amount in amounts if amount), default=1)
122
decimal_places = max(0, *(-amount.as_tuple().exponent for amount in amounts))
123
with localcontext() as context:
124
context.prec = max(100, integer_digits + decimal_places + len(str(len(amounts))) + 8)