Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 4, 00:30 UTC
test(mapping): prove one ledger account can feed BS and EQ without double-counting coverage totals
davoodmehraban89 committed
Oct 31, 2026 at 08:48 UTC
d54c53729729443022d056738fff94851823674e
1 file changed
+45
backend/tests/test_coverage_preview.py
+45
@@ -83,6 +83,51 @@ def test_includes_only_file_marked_approved_unique_mapping():
83
assert not result.releasable
84
85
86
+def test_same_account_can_map_once_to_each_distinct_statement():
87
+ def add_statement_mappings(book):
88
+ notes = book["Notes"]
89
+ notes.append([
90
+ "001", 1404, "EQ", "Equity", "E01", "Equity note", "", "",
91
+ ])
92
+ headers = SHEET_HEADERS["Mapping"]
93
+ base = {
94
+ header: book["Mapping"].cell(2, index + 1).value
95
+ for index, header in enumerate(headers)
96
+ }
97
+ eq_mapping = dict(base)
98
+ eq_mapping.update({
99
+ "mapping_id": "M-EQ-001", "target_statement": "EQ",
100
+ "statement_section": "Equity", "note_number": "E01",
101
+ })
102
+ book["Mapping"].append([eq_mapping.get(header) for header in headers])
103
+ second_bs = dict(base)
104
+ second_bs.update({
105
+ "mapping_id": "M-BS-002", "account_full_code": "0020",
106
+ "general_code": "0020",
107
+ })
108
+ book["Mapping"].append([second_bs.get(header) for header in headers])
109
+
110
+ result = preview(make_change(sample_workbook(), add_statement_mappings))
111
+ assert result.account_count == 2
112
+ assert result.candidate_mapped_accounts == 2
113
+ assert result.blocked_accounts == 0
114
+ assert result.candidate_closing_exposure == "126.00"
115
+ assert len(result.accounts) == 2
116
+ assert len(result.mappings) == 3
117
+ account = next(item for item in result.accounts if item.account_code == "0010")
118
+ assert account.mapping_count == 2
119
+ assert account.included
120
+ assert account.target_statement is None
121
+ by_statement = {
122
+ note.statement: note for note in result.notes
123
+ }
124
+ assert by_statement["BS"].closing_exposure == "126.00"
125
+ assert by_statement["BS"].account_codes == ("0010", "0020")
126
+ assert by_statement["EQ"].closing_exposure == "110.25"
127
+ assert by_statement["EQ"].account_codes == ("0010",)
128
+ assert all(item.included for item in result.mappings)
129
+
130
+
131
def test_multiple_mapping_rows_are_blocked_not_silently_deduplicated():
132
result = preview(sample_workbook(extra_mapping=True))
133
assert result.candidate_mapped_accounts == 0