@davoodmehraban89 / Aram-2 Mirror · read-only / commits / e370523
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 3, 19:30 UTC

fix(trace): tie BS, IS and EQ displayed note exposures back to exact source mapping notes

davoodmehraban89 committed Nov 1, 2026 at 00:06 UTC e3705232979866e0e2a5366f8998c209a5662de2
1 file changed +24
backend/src/aram_backend/desktop_five_statement_integrity.py
+24
@@ -270,6 +270,30 @@ def validate_desktop_pipeline_result(result: FiveStatementPipelineResult) -> Non
270 if seen_note_keys != set(note_amounts):
271 raise CoverageError("DESKTOP_PREVIEW_MAPPING_NOTE_INVALID")
272
273 + # Every displayed BS/IS/EQ candidate note must use the same exact
274 + # unrounded exposure as the account-to-note mapping built from this XLSX.
275 + # Do not infer accounting signs or reconcile unlike statements together.
276 + candidates_by_statement = (
277 + ("BS", result.balance_sheet.lines),
278 + ("IS", result.income_statement.lines),
279 + ("EQ", result.equity_changes.note_movements),
280 + )
281 + covered_notes = {
282 + (note.statement, note.section, note.note_number, note.subnote_code):
283 + _money(note.closing_exposure)
284 + for note in coverage.notes
285 + }
286 + for statement, lines in candidates_by_statement:
287 + for line in lines:
288 + key = (
289 + statement, line.statement_section,
290 + line.note_number, line.subnote_code,
291 + )
292 + if key not in covered_notes:
293 + raise CoverageError("DESKTOP_PREVIEW_NOTE_SOURCE_MISSING")
294 + if _money(line.source_closing_exposure) != covered_notes[key]:
295 + raise CoverageError("DESKTOP_PREVIEW_NOTE_SOURCE_MISMATCH")
296 +
297 overall = _require_bool(result, "eligible_for_analyst_review")
298 if overall:
299 if (not _require_bool(reconciliation, "eligible_for_analyst_review")