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

Add canonical cross-agent project continuity state

davoodmehraban89 committed Sep 29, 2026 at 09:28 UTC 9436b9014f8ce59e1a8c8dc238d1050831785c8f
1 file changed +266
PROJECT_STATE.md new
+266
@@ -0,0 +1,266 @@
1 +# PROJECT STATE — FINORA / FACTOR-EASY
2 +
3 +> **MANDATORY CONTINUITY FILE — READ THIS FIRST**
4 +>
5 +> Repository: `davoodmehraban89/Factor-easy`
6 +> Canonical branch: `main`
7 +> Working product name: **Finora**
8 +> Current public release identity: **Finora 1.0**
9 +>
10 +> This file is the single continuity/state document for any AI assistant, coding agent, developer, or future chat working on this repository. It must remain in the repository and must be updated continuously.
11 +
12 +## Non-negotiable continuity protocol
13 +
14 +Before doing any project work:
15 +
16 +1. Open this file from the current remote `main` branch.
17 +2. Inspect the actual current repository head and relevant production state. Never assume this file is newer than GitHub/Supabase evidence.
18 +3. Read the latest user request and record any material new requirement, scope change, architectural decision, or requested phase change in **Current change ledger** below **before implementation**.
19 +4. Continue from the latest verified checkpoint. Do not redo completed work unless a regression or contradiction is proven.
20 +5. For financial/accounting changes, preserve data and auditability. Never perform destructive historical migration without preview, reconciliation, backup/rollback and explicit authority where required.
21 +6. Execute continuously: **inspect → implement → test → fix → retest → commit/push → verify → continue**.
22 +7. After every durable checkpoint/commit and before ending a work session, update this file with:
23 + - what changed;
24 + - exact completion status;
25 + - important commit SHA(s);
26 + - tests/CI/deployment evidence;
27 + - database migration(s), if any;
28 + - unresolved risks/blockers;
29 + - exact next executable work.
30 +8. A phase may be marked **COMPLETED** only after its acceptance criteria and available release gates are verified. Never infer completion from chat text alone.
31 +9. If execution is interrupted, the next worker must be able to resume using only the repository plus this file.
32 +10. If this file conflicts with verified remote code/database evidence, correct this file immediately and record the correction in the change ledger.
33 +
34 +## Current change ledger
35 +
36 +| Date | Request / decision | Status | Evidence / next action |
37 +|---|---|---|---|
38 +| 2026-09-29 | Establish a permanent in-repository continuity file so any future AI/chat can resume without relying on conversation history. Every material request must be recorded here before implementation and every durable checkpoint must update this file. | COMPLETED | Canonical file created at repository root: `PROJECT_STATE.md`. |
39 +| 2026-09-29 | Continue product under working name Finora; final commercial brand may change later. Do not block engineering on naming. | ACTIVE DECISION | Rebrand must be a controlled migration when a final name is chosen. |
40 +| 2026-09-29 | Six-phase redesign/ERP roadmap supersedes older phase numbering. | ACTIVE ROADMAP | Phases 1–3 verified complete; Phase 4 is next. |
41 +
42 +## Current verified project state
43 +
44 +The detailed handoff below was verified against the repository after Phase 3. Always re-check the live `main` head before modifying code.
45 +
46 +# Finora / Factor-easy — Durable Handoff
47 +
48 +Date: 2026-09-29
49 +Repository: davoodmehraban89/Factor-easy
50 +Canonical branch: main
51 +Verified head at handoff: 8761d21189d9c4058c3019ea6e42d4103fc83556
52 +Working product name: Finora
53 +Current public release identity: Finora 1.0
54 +
55 +## Source-of-truth rule
56 +A successor must verify GitHub and Supabase before changing anything. This file is a recovery map, not a substitute for remote evidence.
57 +
58 +## Master six-phase roadmap
59 +1. UX/product architecture redesign and scalable navigation shell.
60 +2. Master Data + Accounting Core foundation: chart, fiscal years, branches, global projects, generic hierarchical analytic dimensions, templates.
61 +3. Double-entry operational accounting: journal engine, automatic postings, ledgers/trial balance, source immutability.
62 +4. Projects, contracts, deductions, guarantees and contractor accounting.
63 +5. Complementary ERP + integrations: inventory, costing, fixed assets, multi-currency/cost centers, import/backup/permissions/settings redesign.
64 +6. Reports, control, migration and final release: professional accounting statements/reports, reconciliation/cutover of Finora 1.0 history, QA/security/performance/audit/backup/rollback/release.
65 +
66 +The older docs/ACCOUNTING_CORE_ROADMAP_V1.md contains historical labels “Phase 5..8”. Do not treat those numbers as the current master phase numbering. Preserve its accounting decisions, but follow the six-phase roadmap above.
67 +
68 +## Verified completion state
69 +
70 +### Phase 1 — COMPLETED
71 +Verification: docs/PHASE_1_REDESIGN_VERIFICATION.md
72 +Acceptance commit: c51e49a3f7863886e8a997858d6f2c44165eb5de
73 +
74 +Delivered:
75 +- compact RTL module rail
76 +- contextual second-level panel
77 +- collapsible desktop navigation with persisted preference
78 +- command/menu search and Ctrl/Cmd+K
79 +- topbar company/fiscal context and quick action
80 +- canonical view-to-module mapping
81 +- responsive/mobile compatibility
82 +- print isolation
83 +- existing operational capabilities retained
84 +
85 +### Phase 2 — COMPLETED
86 +Verification: docs/PHASE_2_REDESIGN_VERIFICATION.md
87 +Acceptance commit: 39702975a08ded8997787858383e20dab7d9afa9
88 +Acceptance CI: Quality success 36438531727; Security success 36438531722; Pages success 36438530674.
89 +
90 +Delivered:
91 +- three fixed account levels: GL/کل, Subsidiary/معین, Detail/تفصیلی
92 +- generic user-defined analytic dimensions
93 +- configurable hierarchy depth 1..8
94 +- leaf/terminal-only posting semantics
95 +- depth locked after values exist
96 +- safe delete/reference guards
97 +- account-dimension required/optional/unavailable rules
98 +- entity-backed contacts/projects/branches
99 +- fiscal years and locks
100 +- branch master
101 +- global projects and legacy contact-project migration
102 +- company activity types and optional starter templates
103 +- sync/backup/Supabase collection support
104 +
105 +Critical dimension invariant:
106 +A dimension’s hierarchy depth is explicitly configured. Once values exist, depth cannot be changed directly. Used financial identities are not destructively deleted; they are deactivated/versioned/migrated. Group nodes are non-postable when leaf-only is enabled. Storage is normalized and not limited to floating1..floating4.
107 +
108 +### Phase 3 — COMPLETED
109 +Verification: docs/PHASE_3_REDESIGN_VERIFICATION.md
110 +Final evidence commit: 8761d21189d9c4058c3019ea6e42d4103fc83556
111 +Final head CI: Quality success 36443016075; Security success 36443016203; Pages success 36443015338.
112 +Implementation head documented in Phase 3 verification: b0f3e2587c6cc04beaf579505cb975a939459d6e.
113 +
114 +Delivered:
115 +- journal vouchers/lines and normalized line dimensions
116 +- draft -> posted -> reversed lifecycle
117 +- balanced debit/credit validation
118 +- posting-account and analytic-dimension validation
119 +- fiscal-year resolution/lock
120 +- sequential voucher numbering
121 +- source event/version uniqueness
122 +- immutable posted vouchers; reversal instead of destructive edit
123 +- manual journal UI with dynamic dimensions
124 +- journal register and trial balance
125 +- automatic posting profiles for sale, purchase, receipt, payment, expense and other income
126 +- cash/credit aware sales/purchases
127 +- VAT split behavior
128 +- source-to-voucher adapter
129 +- sync/backup persistence
130 +- source-document immutability when linked to posted vouchers
131 +- protection of used accounting masters/rules from destructive mutation
132 +
133 +Important correction:
134 +Earlier chat messages said Phase 3 was incomplete while execution was still catching up. GitHub remote evidence later closed and verified Phase 3. Current verified truth is Phase 3 COMPLETED.
135 +
136 +## Production Supabase
137 +Project ref: hcsixhqbyuhpshfwqpjx
138 +Public tables: profiles, licenses, records; RLS enabled.
139 +At handoff: profiles 4 rows, licenses 4 rows, records 84 rows.
140 +
141 +Relevant migrations:
142 +- 20260928141512 allow_accounting_foundation_collections
143 +- 20260928145306 allow_phase3_double_entry_collections
144 +
145 +Phase 3 allowed collections:
146 +- postingProfiles
147 +- journalVouchers
148 +- journalLines
149 +- journalLineDimensions
150 +
151 +At final Phase 3 verification there were no Phase 3 journal rows requiring conversion/backfill. Historical Finora 1.0 accounting cutover was intentionally deferred.
152 +
153 +Security advisor at handoff:
154 +- five WARN findings for authenticated-callable SECURITY DEFINER functions: admin_cancel_license, admin_extend_license, admin_set_license, has_active_license, is_admin. These are known and were previously reviewed as intentional with internal authorization/RLS dependencies; do not blindly revoke authenticated execute.
155 +- leaked password protection disabled in Supabase Auth; still an external/manual hardening item.
156 +Performance advisor: no findings.
157 +
158 +## Existing operational capabilities that must not regress
159 +Sales invoices, purchase invoices, contacts/counterparties, products/services, receipts/payments with partial settlement, cheques, expenses/income, companies, global projects, reporting, formal/nonformal printing, Excel import, backup/cloud sync, admin/license controls, dashboard/drilldowns.
160 +
161 +## Phase 4 — NEXT WORK
162 +Phase 4 is the next master phase. Scope:
163 +- first-class contracts
164 +- contract amendments/status/lifecycle
165 +- employer/contractor/subcontractor relationships
166 +- contract/project links
167 +- deduction masters and schedules: retention, insurance, withholding tax, advance recovery, penalties, configurable other deductions
168 +- guarantees: type, issuer/beneficiary, bank/institution, number, amount, issue/expiry, collateral, extension/release history
169 +- optional memorandum/off-balance posting profiles for guarantees
170 +- project/contract profitability and deduction/guarantee reporting
171 +- source-to-voucher traceability for all new operations
172 +- permissions, audit, reversal, sync/backup, migration, tests
173 +
174 +Phase 4 acceptance must require master data + transaction lifecycle + posting + reversal + permissions + audit + reports + migration + tests + reconciliation. Forms alone do not complete a module.
175 +
176 +## Phase 5 — AFTER PHASE 4
177 +Complementary ERP/integration:
178 +- inventory/warehouse and costing
179 +- standard item/service master refinement
180 +- fixed assets
181 +- multi-currency
182 +- cost centers/advanced analytics
183 +- Excel/import center
184 +- backup/restore
185 +- company settings/permissions redesign
186 +- integration/API architecture
187 +
188 +## Phase 6 — FINAL
189 +- journal/GL/subsidiary/detail/analytic ledgers
190 +- trial balance variants
191 +- P&L, financial position, cash flow
192 +- AR/AP aging
193 +- project/contract reports
194 +- historical Finora 1.0 reconciliation and controlled cutover
195 +- QA/security/performance
196 +- audit/backup/rollback
197 +- production release
198 +
199 +## Accounting architecture decisions that are not to be casually reversed
200 +- posted journal lines become accounting truth; operational documents remain source documents
201 +- posted vouchers are immutable; corrections use reversal/amendment
202 +- counterparties/projects/branches/contracts are global masters, not cloned into account trees
203 +- do not create one ledger account per customer/supplier
204 +- analytic dimensions are generic normalized assignments, not fixed four columns
205 +- account determines which dimensions are required/optional/unavailable
206 +- group/non-leaf analytic nodes are not postable when leaf-only rules apply
207 +- historical identity/meaning must survive structural changes
208 +- templates are optional/editable setup accelerators, not hard-coded accounting rules
209 +- bank design supports stable ledger account + Bank Account master/dimension as scalable default
210 +- no destructive historical migration without preview/reconciliation/rollback
211 +
212 +## Known verification boundary
213 +The execution environment used for these phases did not provide an authenticated interactive browser/device walkthrough. Do not claim browser E2E or physical-printer validation unless actually performed. CI, source verification, Supabase checks and Pages deployment were used as release evidence.
214 +
215 +## Successor startup procedure
216 +1. Connect official GitHub and Supabase tools.
217 +2. Verify repository main head and read this file.
218 +3. Read docs/PHASE_1_REDESIGN_VERIFICATION.md, docs/PHASE_2_REDESIGN_VERIFICATION.md, docs/PHASE_3_REDESIGN_VERIFICATION.md, docs/ACCOUNTING_CORE_ROADMAP_V1.md, docs/RD_IRAN_ACCOUNTING_ERP_2026-09-28.md.
219 +4. Verify latest Quality/Security/Pages results.
220 +5. Verify Supabase migrations/RLS/advisors.
221 +6. Do not redo Phases 1–3 unless a regression is found.
222 +7. Start Phase 4 from the current remote state.
223 +8. Work continuously: inspect -> implement -> test -> fix -> retest -> commit/push -> verify -> continue.
224 +9. Never report a phase complete until its acceptance criteria and release gates are actually verified.
225 +
226 +
227 +## Mandatory interpretation of roadmap status
228 +
229 +The **current master roadmap is six phases**, regardless of older historical documents that use four phases or labels such as Phase 5–8.
230 +
231 +- **Phase 1 — COMPLETED:** scalable UX/product shell and information architecture.
232 +- **Phase 2 — COMPLETED:** master data + accounting-core foundation.
233 +- **Phase 3 — COMPLETED:** double-entry operational accounting and automatic source posting.
234 +- **Phase 4 — NEXT:** projects/contracts/deductions/guarantees and contractor accounting.
235 +- **Phase 5 — PENDING:** complementary ERP/integrations, inventory/costing/assets/multi-currency/settings/permissions/import.
236 +- **Phase 6 — PENDING:** professional reports, historical reconciliation/cutover, QA/security/performance/audit/backup/rollback/final release.
237 +
238 +Do not confuse the older completed Finora 1.0 four-phase delivery with this current six-phase redesign roadmap.
239 +
240 +## How to record future work
241 +
242 +For every new material user request, add a row to **Current change ledger** before implementation using one of:
243 +- `REQUESTED`
244 +- `IN PROGRESS`
245 +- `COMPLETED`
246 +- `BLOCKED`
247 +- `DEFERRED`
248 +
249 +When completing it, update the same row with commit/migration/test evidence and adjust **Current verified project state / roadmap status / next work** if affected. Do not create a separate private handoff that can drift from this file.
250 +
251 +## Required companion evidence
252 +
253 +When relevant, verify rather than merely trust:
254 +- `docs/PHASE_1_REDESIGN_VERIFICATION.md`
255 +- `docs/PHASE_2_REDESIGN_VERIFICATION.md`
256 +- `docs/PHASE_3_REDESIGN_VERIFICATION.md`
257 +- `docs/ACCOUNTING_CORE_ROADMAP_V1.md`
258 +- `docs/RD_IRAN_ACCOUNTING_ERP_2026-09-28.md`
259 +- `docs/PRODUCTION_RUNBOOK.md`
260 +- GitHub Actions Quality/Security/Pages results
261 +- production Supabase migrations, RLS, advisors and data compatibility
262 +
263 +## End-of-session requirement
264 +
265 +**Do not leave the project after making durable changes without updating `PROJECT_STATE.md`.**
266 +If a session is interrupted before the final update, the next worker must first reconcile this file against GitHub/Supabase evidence, then continue.