Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 4, 14:15 UTC
dependabot/npm_and_yarn/frontend/globals-17.15.0
add-index-html-10623938925177053894
arena/094f314c-aram
arena/2d4eda07-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
dependabot/github_actions/actions/checkout-7
dependabot/github_actions/actions/setup-node-6
dependabot/github_actions/actions/setup-python-7
dependabot/github_actions/actions/upload-artifact-7
dependabot/npm_and_yarn/frontend/eslint-plugin-react-hooks-7.1.1
dependabot/npm_and_yarn/frontend/globals-17.15.0
dependabot/npm_and_yarn/frontend/vite-8.4.0
dependabot/npm_and_yarn/frontend/vitest-5.1.2
dependabot/npm_and_yarn/frontend/vitest/coverage-v8-5.1.2
dependabot/pip/backend/mypy-gte-1.13-and-lt-3
dependabot/pip/backend/pytest-cov-gte-6.0-and-lt-8
dependabot/pip/backend/setuptools-gte-75-and-lt-85
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 | """Phase 5 editability: update/delete notes, mappings, note rows (Draft-guarded). |
| 2 | |
| 3 | Covers the owner's requirement that codes/accounts/notes/subnotes be editable, and |
| 4 | proves edits are refused on a locked year (D-07) with HTTP 409. |
| 5 | """ |
| 6 | |
| 7 | from __future__ import annotations |
| 8 | |
| 9 | _BALANCED_CSV = ( |
| 10 | "حساب,kol,ACCOUNT_NAME,year,نوع,T1_CODE,T2_CODE,T3_CODE,T4_CODE,OPENING,Debit,Credit,CLOSING\n" |
| 11 | "8348,14,نقد,1404,O,,,,,0,100,0,100\n" |
| 12 | "1001,24,پرداختنی,1404,O,,,,,0,0,100,-100\n" |
| 13 | ).encode() |
| 14 | |
| 15 | |
| 16 | def _year(client): |
| 17 | return client.post( |
| 18 | "/api/v1/companies", json={"code": "ED", "name": "شرکت", "year": 1404} |
| 19 | ).json()["year_id"] |
| 20 | |
| 21 | |
| 22 | def _note(client, year_id, number="10", title="دارایی", statement="BS", section="Assets"): |
| 23 | return client.post( |
| 24 | f"/api/v1/years/{year_id}/notes", |
| 25 | json={"note_number": number, "title": title, "statement": statement, "section": section}, |
| 26 | ).json()["note_id"] |
| 27 | |
| 28 | |
| 29 | class TestNoteEditing: |
| 30 | def test_update_note(self, api_client): |
| 31 | y = _year(api_client) |
| 32 | n = _note(api_client, y) |
| 33 | r = api_client.put( |
| 34 | f"/api/v1/years/{y}/notes/{n}", json={"title": "عنوان جدید", "section": "Liabilities"} |
| 35 | ) |
| 36 | assert r.status_code == 200, r.text |
| 37 | assert r.json()["title"] == "عنوان جدید" |
| 38 | |
| 39 | def test_delete_note_cascades_rows(self, api_client): |
| 40 | y = _year(api_client) |
| 41 | n = _note(api_client, y) |
| 42 | api_client.post( |
| 43 | f"/api/v1/years/{y}/notes/{n}/rows", |
| 44 | json={"row_order": 0, "label": "جمع", "formula_logic": None}, |
| 45 | ) |
| 46 | r = api_client.delete(f"/api/v1/years/{y}/notes/{n}") |
| 47 | assert r.status_code == 200, r.text |
| 48 | assert api_client.get(f"/api/v1/notes/{n}/rows").status_code == 404 |
| 49 | |
| 50 | def test_delete_note_with_mapping_refused(self, api_client): |
| 51 | y = _year(api_client) |
| 52 | n = _note(api_client, y) |
| 53 | api_client.post( |
| 54 | f"/api/v1/years/{y}/mappings", json={"account_code": "148348", "target_note_id": n} |
| 55 | ) |
| 56 | r = api_client.delete(f"/api/v1/years/{y}/notes/{n}") |
| 57 | assert r.status_code == 409 |
| 58 | |
| 59 | def test_update_missing_note_404(self, api_client): |
| 60 | y = _year(api_client) |
| 61 | assert ( |
| 62 | api_client.put(f"/api/v1/years/{y}/notes/999", json={"title": "x"}).status_code == 404 |
| 63 | ) |
| 64 | |
| 65 | |
| 66 | class TestMappingEditing: |
| 67 | def test_update_and_delete_mapping(self, api_client): |
| 68 | y = _year(api_client) |
| 69 | n1 = _note(api_client, y, "10") |
| 70 | n2 = _note(api_client, y, "11") |
| 71 | m = api_client.post( |
| 72 | f"/api/v1/years/{y}/mappings", json={"account_code": "148348", "target_note_id": n1} |
| 73 | ).json()["mapping_id"] |
| 74 | r = api_client.put(f"/api/v1/years/{y}/mappings/{m}", json={"target_note_id": n2}) |
| 75 | assert r.status_code == 200, r.text |
| 76 | r = api_client.delete(f"/api/v1/years/{y}/mappings/{m}") |
| 77 | assert r.status_code == 200, r.text |
| 78 | |
| 79 | def test_update_mapping_to_foreign_note_404(self, api_client): |
| 80 | y = _year(api_client) |
| 81 | n = _note(api_client, y) |
| 82 | m = api_client.post( |
| 83 | f"/api/v1/years/{y}/mappings", json={"account_code": "148348", "target_note_id": n} |
| 84 | ).json()["mapping_id"] |
| 85 | assert ( |
| 86 | api_client.put( |
| 87 | f"/api/v1/years/{y}/mappings/{m}", json={"target_note_id": 999} |
| 88 | ).status_code |
| 89 | == 404 |
| 90 | ) |
| 91 | |
| 92 | |
| 93 | class TestNoteRowEditing: |
| 94 | def test_update_row_formula_valid_and_invalid(self, api_client): |
| 95 | y = _year(api_client) |
| 96 | n = _note(api_client, y) |
| 97 | row = api_client.post( |
| 98 | f"/api/v1/years/{y}/notes/{n}/rows", |
| 99 | json={"row_order": 0, "label": "جمع", "formula_logic": None}, |
| 100 | ).json()["row_id"] |
| 101 | r = api_client.put( |
| 102 | f"/api/v1/years/{y}/notes/{n}/rows/{row}", |
| 103 | json={"label": "جمع کل", "formula_logic": 'acct("148348")'}, |
| 104 | ) |
| 105 | assert r.status_code == 200, r.text |
| 106 | bad = api_client.put( |
| 107 | f"/api/v1/years/{y}/notes/{n}/rows/{row}", json={"formula_logic": "acct("} |
| 108 | ) |
| 109 | assert bad.status_code == 422 |
| 110 | |
| 111 | def test_delete_row(self, api_client): |
| 112 | y = _year(api_client) |
| 113 | n = _note(api_client, y) |
| 114 | row = api_client.post( |
| 115 | f"/api/v1/years/{y}/notes/{n}/rows", |
| 116 | json={"row_order": 0, "label": "جمع", "formula_logic": None}, |
| 117 | ).json()["row_id"] |
| 118 | assert api_client.delete(f"/api/v1/years/{y}/notes/{n}/rows/{row}").status_code == 200 |
| 119 | |
| 120 | |
| 121 | class TestLockedYearEditing: |
| 122 | def test_edit_locked_year_refused_409(self, api_client): |
| 123 | # R2: approval needs all 15 controls to run, so build a complete year |
| 124 | # (prior year + carry-forward + designated notes) through the API. |
| 125 | from helpers_complete_year import complete_year_via_api |
| 126 | |
| 127 | y, notes = complete_year_via_api(api_client, code="EDL") |
| 128 | n_a = notes["cash"] |
| 129 | ap = api_client.post(f"/api/v1/years/{y}/approve", json={}) |
| 130 | assert ap.status_code == 200 and ap.json()["approved"] is True, ap.text |
| 131 | lk = api_client.post(f"/api/v1/years/{y}/lock", json={}) |
| 132 | assert lk.status_code == 200, lk.text |
| 133 | # Editing a note on the locked year is refused by the D-07 guard. |
| 134 | r = api_client.put(f"/api/v1/years/{y}/notes/{n_a}", json={"title": "تغییر"}) |
| 135 | assert r.status_code == 409, r.text |