@davoodmehraban89 / Aram-1 / commits / 94e8331
Fork 0

fix(mapping): preserve exact decimal coverage totals

davoodmehraban89 committed Nov 1, 2026 at 15:06 UTC 94e83316ebd16ddf0cc512bc8c2290c70d577b10
1 file changed +10 -8
backend/src/aram_backend/mapping_matcher.py
+10 -8
@@ -3,7 +3,7 @@ from __future__ import annotations
3 from collections import defaultdict
4 from collections.abc import Iterable, Iterator, Mapping
5 from dataclasses import dataclass
6 -from decimal import Decimal
6 +from decimal import Decimal, localcontext
7
8 from aram_backend.ledger_parser import LedgerRecord
9 from aram_backend.mapping_source_parser import MappingSourceRow
@@ -150,13 +150,15 @@ def summarize_mapping_coverage(
150 amounts = {key: Decimal(0) for key in counts}
151 total_rows = 0
152 source_closing = Decimal(0)
153 - for result in results:
154 - if result.status not in counts:
155 - raise MappingMatchError(f"unknown result status: {result.status}")
156 - total_rows += 1
157 - source_closing += result.closing
158 - counts[result.status] += 1
159 - amounts[result.status] += result.closing
153 + with localcontext() as context:
154 + context.prec = 1000
155 + for result in results:
156 + if result.status not in counts:
157 + raise MappingMatchError(f"unknown result status: {result.status}")
158 + total_rows += 1
159 + source_closing += result.closing
160 + counts[result.status] += 1
161 + amounts[result.status] += result.closing
162
163 return MappingCoverageSummary(
164 total_source_rows=total_rows,