@davoodmehraban89 / Factor-easy / commits / 68d9c99
Fork 0

سامانه صدور فاکتور و حسابداری

docs(treasury): record source scope, one-batch amendment design and pending QA

davoodmehraban89 committed Oct 14, 2026 at 11:01 UTC 68d9c99368f17cbd81ae77dc3f98971e07e4123b
1 file changed +7
PROJECT_STATE.md
+7
@@ -239,6 +239,13 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
239 - **Required tests:** isolated browser mock with synthetic user/company and payment: open+cancel zero ledger writes; revise→reversal→new balanced posted voucher→same visible row after reload; original posted lines/metadata untouched; treasury totals count current revision once; reject allocated or cheque; fiscal-year lock; double-click/idempotency; aborted sync fail-closed and no duplicate blind retry. Existing Chromium Golden accounting and 3 disposable PostgreSQL, Security/CodeQL, exact main Release+Pages gates. No production financial data writes, schema/RLS/role/Auth changes, new paid costs. If tests reveal unsatisfied integrity, do not merge.
240 - **Owner acceptance:** native browser authenticated test still OPEN. Rollback targeted code PR; legitimate future financial reversals remain historical and cannot be destroyed by reverting code.
241
242 +### 2026-10-14 Treasury correction implementation — 5/5 syntax PASS, Chromium+Golden+DB+Security PENDING
243 +- **Delivered on isolated branch:** `js/payments.js` adds `paymentPostingStatus`, `paymentCurrentVisible`, `paymentVisibleRecords`, `paymentEffectiveRecords` and `paymentAmendPosted` / `paymentCancelPosted`. A posted unallocated non-cheque cash/card/bank receipt/payment opens in **its original form** with unchanged reference/date/contact/direction and no journal write on open/cancel. On Save, it validates permissions, active company, open fiscal year, source-voucher posting and immutable contact/direction/invoice allocation, then **synchronously stages** balanced original-voucher reversal and corrected posted source with a new internal revision before the first async boundary. Debounced `finora_sync_records` sends the resulting diff as one batch and a server ack is required before employee success. A synchronous exception restores local journal/source/profile staging before sync. Cancel only reverses the internal accounting, clearly warning it **does not** undo actual bank/card movement.
244 +- **Employee UX:** central `حسابداری ← مدیریت اسناد` treasury table in `js/journal-ui.js` and `js/document-management.js` lists one current visible receipt/payment and routes «اصلاح» directly to `view-payments` existing form; earlier source versions remain in accounting audit. `js/payments.js` treasury list also folds technical rows; `invoiceOutstanding` / `purchaseOutstanding` count effective current settled records only; `js/accounting.js` project cash totals exclude reversed/historical versions and retain legacy unlinked treatment.
245 +- **Safety boundary:** only **unallocated cash/card/bank** receipt/payment documents with currently posted canonical vouchers. Cheques, invoice-linked settlement, historical unlinked, locked fiscal years, cross-company and different-party/direction edits fail closed. Do not allow actual banking cancellation from local accounting UI; real bank/cheque movements require external reconciliation. No production financial rows altered, and no schema/RLS/Auth/role or paid service change.
246 +- **Tests authored:** four new `scripts/accounting-document-workflow.spec.js` isolated real-DOM scenarios: employee central-manager → same form → cancel=no writes; amendment → original journal reversed + balancing compensator + new posting in **one server diff** with one visible row, same reference, old lines unchanged, reload; denial for cheque, invoice-linked and fiscal lock; cancellation keeps original history; simulated one-RPC network failure produces no partial server commit and no false UI success. Syntax 5/5 PASS on actual branch files; **real browser/Golden/three disposable PostgreSQL/Security PR-head and exact-main release NOT VERIFIED at this checkpoint**. Fail CI → fix/retest, never release red.
247 +- **Remaining risk:** client-side multi-record staging uses existing shared sync RPC and auto-retry; single-call SQL atomicity, lost-ack retry behavior and concurrency cannot be considered owner-accepted solely from synthetic browser tests. Full integrated receipt→invoice settlement/cheque/bank reconciliation and independent authorized two-user tests remain Phase 3/Phase 5 dependencies. Owner live acceptance open; original Phase 0 startup F0-01 open.
248 +
249 ## Current change ledger
250 | 2026-10-07 | Owner requested accounting/product usability refinement from live screenshots: automatic non-user-entered floating-detail codes, contextual in-product guides (especially accounting/chart/dimensions), remove duplicate product internal tax ID and use product code as internal item ID, strengthen in-control product/person search, introduce hierarchical product group/subgroup coding with deterministic 6-digit product codes, and keep sale/purchase commercial-document workspace layout stable while only semantic fields change. | **IMPLEMENTED / LOCAL VERIFICATION PASSED / CI PENDING** | Baseline main = `7e58c75f7d754f378d94ca3f356c1ae580aa7ee3`. Automatic dimension type/value codes, contextual guides, product-code-as-internal-ID, normalized multi-token search, and additive six-digit product coding implemented. Existing historical codes preserved. Commercial sale/purchase workspaces now share a stable `صدور سند تجاری` header/actions layout; duplicate purchase sidebar injection removed; the public selector is the single document-type selector and the legacy internal invoice-kind control is hidden. Local syntax/static/commerce/UX/accounting phases 2–6/Golden checks passed; protected-branch CI remains pending. |
251