سامانه صدور فاکتور و حسابداری
docs: prioritize cheque accounting contract and record treasury progress
JVK committed
Nov 13, 2026 at 09:22 UTC
8d5c53d49fece5457e2d1bf3034c279bf649d697
4 files changed
+34
PROJECT_STATE.md
+5
@@ -352,3 +352,8 @@ Owner requests layer-by-layer click/functional testing of all controls and compa
352
- Owner reports payable cheques do not reduce the supplier balance or produce a journal/payment, then manually entered a separate cheque-method payment; payment amount lacks digit grouping. Investigate cheque→source→journal→balance integration, prevent duplicate recognition and preserve issued/cleared/bounced/cancelled semantics. Read-only inspection of the explicitly identified account/company/contact is authorized; never put its identifiers, banking details or individual financial rows into the public repository. No automatic historical backfill or financial-history rewrite.
353
- Current financial code checkpoint c35b7dc exact Quality42982984520/Security42982984898/WP1proof42982984592 now allSUCCESS; all financial proof steps including full candidate DOWN/UP verified. The previous held continuity update can now be published.
354
- Real-session checks: saved profile works; organization and requests available; follow-up700ecb0f confirms commerce navigation and exact sales3/purchase1 options. Organization-manager real-account acceptance remains NOT VERIFIED. Public deployed runtime with isolated synthetic data passes both direct Settings card and submenu, with panel open/collapsed and noJSerrors; do not claim account-specific resolution. TinyFish remaining prepaid balance0.008USD, auto-reload unconfigured; no further paid automation or top-up initiated.
355
+
356
+### 2026-11-13 — Treasury continuity recovered
357
+- Payment PR198 ce5bf86 exact Quality43086846384/Security43086846388 SUCCESS with242browser/all3DB. Protected merge2e869c1; Quality43399412247/Security43399412532,gate43400042808,Pages43400112210 SUCCESS. Public readback and browser evidence remain in PR198. No backend change.
358
+- Root took over contact-summary work after specialist execution limit. Two baseline failures reproduced; code now scopes to active company and effective posted trade sources/settlements, includes unallocated amounts once, retains advances, and explicitly excludes raw/unposted cheques. Real synthetic save/reload plus both directions pass; PR199 final regression/release pending. No independent final review claimed.
359
+- Cheque agent persisted no implementation. Exact runtime/source prerequisites and next acceptance contract recorded in docs/wp1/CHEQUE_NEXT.md. Automatic cheque posting and historical reconciliation remain unfinished. No historical data write or production migration; G1 not requested before a concrete proven package. Resume the dimension/source contract, then manual adapter; don't mistake contact-display repair for ledger posting.
docs/ROADMAP_CURRENT.md
+2
@@ -1,5 +1,7 @@
1
# نقشه راه جاری فینورا — ۲۰۲۶/۱۱/۱۱
2
3
+**اولویت ۱۳ نوامبر:** جداکنندهٔ مبلغ در PR198 منتشر شد؛ اصلاح ماندهٔ عملیاتی در PR199 در حال کنترل انتشار است. اتصال چک به سند هنوز پیادهسازی نشده؛ [قرارداد و ترتیب اجرای چک](wp1/CHEQUE_NEXT.md) پیش از ادامهٔ فرم دستی پیگیری میشود. این کار پایان WP1 محسوب نمیشود.
4
+
5
مرجع نیازمندی: [پرامپت مالک REV2](owner-prompts/FINORA_HARDENING_MASTER_2026-11-02_REV2.txt). دستور جدید مالک «فازها را تکمیل کن» ادامه همه بستهها را پس از گیت هر مرحله مجاز کرده است. شمارههای WP زیر با نقشههای قدیمی فاز۰/Phase1A/Stage1–3 یکی نیستند؛ [تطبیق تاریخچه](CURRENT_WORK_REGISTER_2026-10-30.md) محفوظ است.
6
7
| بسته | هدف | وضعیت واقعی | معیار پایان / شاهد |
docs/wp1/CHEQUE_NEXT.md
new
+25
@@ -0,0 +1,25 @@
1
+# Cheque issuance — source-backed next contract
2
+
3
+Status 2026-11-13: diagnosis complete; **no implemented/activated server cheque adapter**. Payment formatting PR198 is released. Contact operational summary PR199 is separate. No production financial writes or historical backfill have occurred.
4
+
5
+## Confirmed runtime gaps
6
+
7
+- `operations.js` overrides `commitSaveCheque`; it saves only the cheque record. Patching the earlier `cheques.js` handler alone cannot fix runtime posting.
8
+- `journal-engine.js` uses the generic payment profile (AP/cash) for `method=cheque`. Issuance must use AP/notes-payable; bank movement belongs to clearance.
9
+- `drilldown.js` previously summed outstanding invoices without unallocated settlements and mixed companies. PR199 fixes that operational display, not missing journals or a complete general ledger.
10
+- The staged journal source allowlist has no cheque source. Adding an allowlist value alone does not derive financial amounts/accounts or ensure atomic source linkage.
11
+- Current staged `write_lines`/`validate_saved` require separate `dimensionValues`; the browser's contact dimension refers directly to `contacts`. Caller-supplied `counterpartyId` is discarded by SQL line creation. Passing an empty dimension list would lose supplier analysis, so it is not an acceptable shortcut.
12
+
13
+## Implementation order
14
+
15
+1. Prove and implement the entity-dimension contract using the existing `dimensionTypes.sourceEntity`: company-scoped types/rules and organization-visible contact entities, with server permission checks, required/optional/unavailable rules, active/leaf semantics and derived counterparty/project identifiers. Original reversal tags must remain usable if a master record is later disabled. Do not copy or regenerate historical master data to bypass the contract.
16
+2. A dedicated atomic issuance RPC owns new outgoing-cheque + linked settlement + posted voucher. Stable request ID/fingerprint and instrument identity prevent duplicate/replayed issuance. Server selects one valid payable-control account and notes-payable account (`2111`, not `2103`); ambiguity or missing accounts fails without partial rows. No caller-supplied debit/credit lines. Validate company/contact/open fiscal date, positive safe integer IRR, permissions, expected record version for explicit reconciliation and instrument state. Due date is not issuance date.
17
+3. Issuance: Dr trade payable / Cr notes payable. Clearing: Dr notes payable / Cr bank. Bounce/cancellation requires a distinct compensating event; no in-place posted edits/deletions. Model lifecycle transition legality explicitly. Incoming cheques need their own symmetric contract; don't pretend they are covered by outgoing acceptance.
18
+4. Both UI entry points share the same instrument and settlement. A cheque-method payment selects/registers an instrument through this contract; it cannot independently credit cash. One register row plus one payment row is one event, not two settlements. Pending/uncertain outcomes retain stable intent and user edits; no blind retry/new ID and no success before server acknowledgement. Publish source+settlement+full graph atomically into the hydrated client snapshot without overwriting unrelated dirty records.
19
+5. Historical reconciliation is explicit and read-only first. Identify exact organization/company/contact, sources, vouchers and payments by stable identifiers. Amount/name/reference matches are review candidates only. Existing unlinked cheques are not automatically posted; independent prior payments must be reconciled before producing a concrete repair batch. Preserve old rows and retain compensating history.
20
+
21
+## Acceptance and release
22
+
23
+Meaningful RED→GREEN for issuance/balance/bank unchanged, replay vs changed payload, concurrent duplicate instrument, cancellation/clearance/bounce, invalid scope/period/amount/accounts/dimensions, revoked/read-only users, uncertain write and company switch. Require rollback with retained history, source-derived SQL + real nonproduction JWT/PostgREST + full UI/Pages regression and independent financial SQL review. G1 migration approval is requested only after the concrete proven package and backup/restore evidence exist. Current work does not satisfy that gate.
24
+
25
+After this urgent source contract, resume MANUAL_RPC_NEXT steps3–4 and the remaining WP1 source coverage/rollout work. Earlier successful WP1 CI does not prove these new workflows.
docs/wp1/STATUS_FA.md
+2
@@ -1,5 +1,7 @@
1
# WP1 — وضعیت جاری دفتر مالی سمت سرور
2
3
+**اولویت ۱۳ نوامبر:** جداکنندهٔ مبلغ در PR198 منتشر شد؛ اصلاح ماندهٔ عملیاتی در PR199 در حال کنترل انتشار است. اتصال چک به سند هنوز پیادهسازی نشده؛ [قرارداد و ترتیب اجرای چک](CHEQUE_NEXT.md) پیش از ادامهٔ فرم دستی پیگیری میشود. این کار پایان WP1 محسوب نمیشود.
4
+
5
**در حال انجام؛ آماده ادغام یا نصب عملیاتی نیست.** بهروزشده: ۲۰۲۶/۱۱/۱۱. هدف: ثبت مالی معتبر و تراکنشی روی سرور، حفظ تاریخچه قطعی، جداسازی شرکت/سازمان و اعلام صادقانه نتیجه ذخیره. شاخه مستقل روی WP0 PR194؛ [پیشنویس PR195](https://github.com/davoodmehraban89/Factor-easy/pull/195).
6
7
## انجامشده با شاهد