test(mapping): cover high precision eligible exposure subtraction
davoodmehraban89 committed
Nov 1, 2026 at 15:08 UTC
afc9dc53905fdfd0bd453f18eecba40caa1cf8b4
1 file changed
+34
backend/tests/test_mapping_precision.py
new
+34
@@ -0,0 +1,34 @@
1
+from decimal import Decimal
2
+
3
+from aram_backend.ledger_parser import LedgerRecord
4
+from aram_backend.mapping_matcher import classify_ledger_rows, summarize_mapping_coverage
5
+
6
+
7
+def ledger(row: int, account: str, closing: str) -> LedgerRecord:
8
+ return LedgerRecord(
9
+ row_number=row,
10
+ account_code=account,
11
+ account_name="precision test",
12
+ source_year=1404,
13
+ entry_type="O",
14
+ t1_code=None,
15
+ t2_code=None,
16
+ t3_code=None,
17
+ t4_code=None,
18
+ opening=Decimal("0"),
19
+ debit=Decimal("0"),
20
+ credit=Decimal("0"),
21
+ closing=Decimal(closing),
22
+ )
23
+
24
+
25
+def test_eligible_closing_subtraction_keeps_large_decimal_precision():
26
+ rows = [
27
+ ledger(3, "8999", "100000000000000000000000000000.01"),
28
+ ledger(4, "8161", "100000000000000000000000000000.02"),
29
+ ]
30
+
31
+ summary = summarize_mapping_coverage(classify_ledger_rows(rows, ()))
32
+
33
+ assert summary.source_closing == Decimal("200000000000000000000000000000.03")
34
+ assert summary.eligible_closing == Decimal("100000000000000000000000000000.02")