Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 3, 17:00 UTC
codex/aram-mapping-source-parser-20261101
add-index-html-10623938925177053894
arena/094f314c-aram
chatgpt-phase1b2-autopilot
codex/adr-future-connectors-pi-v1
codex/aram-account-note-source-trace-20261031
codex/aram-actions-node24-maintenance-20261031
codex/aram-analyst-review-workbook-20261031
codex/aram-bs-candidate-statement-20261031
codex/aram-cash-flow-direct-candidate-20261031
codex/aram-clean-reference-year-integrity-20261030
codex/aram-cross-statement-controls-20261031
codex/aram-equity-changes-candidate-20261031
codex/aram-five-statement-cli-20261031
codex/aram-five-statement-integration-20261031
codex/aram-five-statement-orchestrator-20261031
codex/aram-gate3-coverage-target-guard-20261030
codex/aram-gate3-hidden-xlsx-guard-20261030
codex/aram-gate3-integration-validation-20261030
codex/aram-gate3-mapping-change-preview-20261030
codex/aram-gate3-stale-note-guard-20261030
codex/aram-income-statement-candidate-20261031
codex/aram-manifest-referential-integrity-20261031
codex/aram-mapping-source-parser-20261101
codex/aram-multidimensional-mapping-20261101
codex/aram-multistatement-mapping-20261031
codex/aram-pipeline-manifest-schema-20261031
codex/aram-readonly-mapping-coverage-20261031
codex/aram-reconciliation-review-gate-20261031
codex/aram-same-flush-fiscal-lock-20261030
codex/aram-synthetic-windows-demo-20261031
codex/aram-trial-balance-diagnostic-20261031
codex/aram-windows-background-detail-search-20261031
codex/aram-windows-detail-review-20261031
codex/aram-windows-five-statement-pilot-20261031
codex/aram-windows-statement-figures-20261031
codex/gate-2a-pilot-workbook
codex/gate-2a-pilot-workbook-6864754244772568979
codex/gate3-authenticated-principal-boundary-20261030
codex/gate3-authored-draft-staging-20261030
codex/gate3-carry-forward-preview-20261023
codex/gate3-draft-staging-audit-20261030
codex/gate3-mapping-batch-freshness-20261030
codex/gate3-mapping-batch-review-20261030
codex/gate3-mapping-core
codex/gate3-mapping-coverage-20261023
codex/gate3-mapping-excel-20261023
codex/gate3-note-mapping-review-20261023
codex/gate3-signed-year-scope-20261030
codex/gate3-unapproved-proposal-storage-20261030
codex/payvast-mapping-discovery-20261023
codex/phase-2a-backend-foundation
codex/phase-2b-post-merge-record
codex/phase-2b-source-registration
codex/phase-2b-source-registration-12955190277775369594
codex/post-gate2a-control-reconciliation
codex/post-pr18-acceptance-record
codex/project-control-foundation
codex/t1-repo-hygiene-20261023
codex/t2-ci-hardening-20261023
codex/t3-explicit-migrations-20261023
codex/t6a-readonly-diagnostics-20261023
codex/v1-01-safety-gate-hardening
codex/v1-year-isolation-followup-20261023
codex/windows-native-pilot-shell-20261030
docs/aram-master-control-plan-20261111
docs/aram-roadmap-dashboard-20261030
docs/financial-statement-reconciliation-1402-1404-20261110
feat/gate3-governed-mapping-20261101
feat/gate3-package9-1-security-20261103
feat/gate3-package9-isolated-20261103
fix/password-unicode-validation-20261111
governance/aram-5-1-3-controls-20261030
governance/role-based-operating-model
jules-1168663913887856558-73b8a885
jules-gate-2b-mapping-workflow-foundation-4137724387867065330
phase-1b1-audit-report-7365389436990903239
phase-2a-backend-foundation-10237597358138521261
phase1b2-postmerge-metadata-fix
refactor/drg-parent-year-id-15088443704684163304
source-data-cleanup
| 1 | """Source-account -> note trace tests on one synthetic XLSX snapshot.""" |
| 2 | from dataclasses import replace |
| 3 | |
| 4 | import pytest |
| 5 | |
| 6 | from aram_backend.coverage_preview import CoverageError |
| 7 | from aram_backend.desktop_five_statement_details import build_preview_details |
| 8 | from aram_backend.desktop_five_statement_integrity import validate_desktop_pipeline_result |
| 9 | from test_five_statement_pipeline_integration import build_pipeline |
| 10 | |
| 11 | |
| 12 | def test_all_account_to_statement_mappings_are_visible_without_double_counting(): |
| 13 | result = build_pipeline() |
| 14 | coverage = result.mapping_coverage |
| 15 | assert coverage.account_count == len(result.trial_balance.accounts) == 6 |
| 16 | assert len(coverage.mappings) == 11 |
| 17 | assert coverage.source_sha256 == result.source_sha256 |
| 18 | assert all(not getattr(coverage, flag) for flag in ( |
| 19 | "financial_statement", "trusted_approvals", "releasable", |
| 20 | )) |
| 21 | valid = validate_desktop_pipeline_result(result) |
| 22 | assert valid is None |
| 23 | details = build_preview_details(result) |
| 24 | revenue_rows = [ |
| 25 | row for row in details if row.item == "حساب REV / Revenue" |
| 26 | ] |
| 27 | assert len(revenue_rows) == 3 |
| 28 | assert {row.statement for row in revenue_rows} == { |
| 29 | "سود و زیان", "ترازنامه", "تغییرات حقوق مالکانه", |
| 30 | } |
| 31 | assert all("ردیف نگاشت" in row.trace for row in revenue_rows) |
| 32 | assert all("اکسل" in row.source_detail for row in revenue_rows) |
| 33 | assert all(row.opening_or_source == "-40" for row in revenue_rows) |
| 34 | assert all(row.closing_or_presentation == "" for row in revenue_rows) |
| 35 | assert all("فاقد تأیید مستقل" in row.trace for row in revenue_rows) |
| 36 | |
| 37 | |
| 38 | def test_serialized_pipeline_contains_nonofficial_mapping_coverage_with_source_rows(): |
| 39 | payload = build_pipeline().to_dict() |
| 40 | trace = payload["mapping_coverage"] |
| 41 | assert trace["source_sha256"] == payload["source_sha256"] |
| 42 | assert trace["financial_statement"] is False |
| 43 | assert trace["releasable"] is False |
| 44 | assert len(trace["mappings"]) == 11 |
| 45 | assert any(row["mapping_id"] == "SYNTH-M-06" for row in trace["mappings"]) |
| 46 | |
| 47 | |
| 48 | @pytest.mark.parametrize("field,corrupt", [ |
| 49 | ("closing_exposure", "999999"), |
| 50 | ("source_row", 999999), |
| 51 | ("account_excel_row", 999999), |
| 52 | ("mapping_excel_row", 1), |
| 53 | ("mapping_id", ""), |
| 54 | ("included", 1), |
| 55 | ]) |
| 56 | def test_mapping_trace_corruption_is_rejected_before_display(field, corrupt): |
| 57 | result = build_pipeline() |
| 58 | trace = result.mapping_coverage |
| 59 | mapping = replace(trace.mappings[0], **{field: corrupt}) |
| 60 | changed = replace(result, mapping_coverage=replace( |
| 61 | trace, mappings=(mapping,) + trace.mappings[1:], |
| 62 | )) |
| 63 | with pytest.raises(CoverageError, match="DESKTOP_PREVIEW_MAPPING"): |
| 64 | build_preview_details(changed) |
| 65 | |
| 66 | |
| 67 | def test_note_exposure_inconsistent_with_included_account_mappings_is_rejected(): |
| 68 | result = build_pipeline() |
| 69 | coverage = result.mapping_coverage |
| 70 | altered = replace(coverage.notes[0], closing_exposure="1.000000001") |
| 71 | changed = replace(result, mapping_coverage=replace( |
| 72 | coverage, notes=(altered,) + coverage.notes[1:], |
| 73 | )) |
| 74 | with pytest.raises(CoverageError, match="DESKTOP_PREVIEW_MAPPING_NOTE"): |
| 75 | validate_desktop_pipeline_result(changed) |
| 76 | |
| 77 | |
| 78 | def test_mismatched_account_name_and_closing_against_trial_balance_is_rejected(): |
| 79 | result = build_pipeline() |
| 80 | coverage = result.mapping_coverage |
| 81 | corrupted = replace(coverage.accounts[0], closing_exposure="999") |
| 82 | changed = replace(result, mapping_coverage=replace( |
| 83 | coverage, accounts=(corrupted,) + coverage.accounts[1:], |
| 84 | )) |
| 85 | with pytest.raises(CoverageError, match="DESKTOP_PREVIEW_MAPPING_SOURCE"): |
| 86 | validate_desktop_pipeline_result(changed) |
| 87 | |
| 88 | |
| 89 | def test_mismatched_source_file_digest_and_scope_rejected(): |
| 90 | result = build_pipeline() |
| 91 | coverage = result.mapping_coverage |
| 92 | for changed_coverage in ( |
| 93 | replace(coverage, source_sha256="f" * 64), |
| 94 | replace(coverage, company_code="002"), |
| 95 | replace(coverage, fiscal_year=1403), |
| 96 | replace(coverage, financial_statement=True), |
| 97 | ): |
| 98 | with pytest.raises(CoverageError, match="DESKTOP_PREVIEW_MAPPING_PROVENANCE"): |
| 99 | validate_desktop_pipeline_result( |
| 100 | replace(result, mapping_coverage=changed_coverage) |
| 101 | ) |
| 102 | |
| 103 | |
| 104 | def test_presentation_source_exposure_cannot_disagree_with_account_mapping(): |
| 105 | result = build_pipeline() |
| 106 | wrong = replace(result.balance_sheet.lines[0], source_closing_exposure="999") |
| 107 | changed = replace(result, balance_sheet=replace( |
| 108 | result.balance_sheet, |
| 109 | lines=(wrong,) + result.balance_sheet.lines[1:], |
| 110 | )) |
| 111 | with pytest.raises(CoverageError, match="DESKTOP_PREVIEW_NOTE_SOURCE_MISMATCH"): |
| 112 | validate_desktop_pipeline_result(changed) |
| 113 | |
| 114 | |
| 115 | def test_duplicate_mapping_id_fails_closed(): |
| 116 | result = build_pipeline() |
| 117 | coverage = result.mapping_coverage |
| 118 | duplicated = replace( |
| 119 | coverage.mappings[1], mapping_id=coverage.mappings[0].mapping_id, |
| 120 | ) |
| 121 | changed = replace(result, mapping_coverage=replace( |
| 122 | coverage, mappings=( |
| 123 | coverage.mappings[0], duplicated, |
| 124 | *coverage.mappings[2:], |
| 125 | ), |
| 126 | )) |
| 127 | with pytest.raises(CoverageError, match="DESKTOP_PREVIEW_MAPPING_ROW"): |
| 128 | validate_desktop_pipeline_result(changed) |
| 129 | |
| 130 | |
| 131 | def test_account_note_mappings_remain_diagnostic_when_cash_transactions_missing(): |
| 132 | from aram_backend.synthetic_five_statement_demo import cash_transactions |
| 133 | |
| 134 | result = build_pipeline(transactions=cash_transactions()[:-1]) |
| 135 | assert not result.eligible_for_analyst_review |
| 136 | rows = build_preview_details(result) |
| 137 | mapping_rows = [row for row in rows if "ردیف نگاشت" in row.trace] |
| 138 | assert len(mapping_rows) == 11 |
| 139 | assert all("مسدود" in row.state for row in mapping_rows) |