سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 4, 00:30 UTC
Define accounting core roadmap with floating details contracts and guarantees
davoodmehraban89 committed
Sep 28, 2026 at 16:37 UTC
8f7294812bf12509d4e60f6c1eba4409555b2f72
1 file changed
+215
docs/ACCOUNTING_CORE_ROADMAP_V1.md
new
+215
@@ -0,0 +1,215 @@
1
+# Finora Accounting Core Roadmap — v1.x
2
+
3
+Date: 2026-09-28
4
+Status: Architecture approved for implementation planning
5
+Baseline: Finora 1.0
6
+
7
+## Objective
8
+Move Finora from document/income-expense management to a double-entry accounting system without breaking the current sales, purchase, settlement, cheque, project, print, backup or cloud-sync workflows.
9
+
10
+## Core accounting model
11
+
12
+### 1. Chart of Accounts
13
+Three fixed account levels:
14
+1. General Ledger / کل
15
+2. Subsidiary / معین
16
+3. Detail Account / تفصیلی
17
+
18
+Each account has: id, code, title, parentId, level, normalBalance (debit/credit), nature, postingAllowed, active, companyId, fiscalYearId.
19
+
20
+Posting is allowed only to the last configured posting level. Parent accounts aggregate children and never receive direct journal postings.
21
+
22
+### 2. Floating detail dimensions
23
+Four configurable floating-detail dimensions are attached to journal lines, not embedded below the account tree.
24
+
25
+Default dimension definitions:
26
+- Floating Detail 1: Branch / شعبه
27
+- Floating Detail 2: Counterparty / طرف حساب
28
+- Floating Detail 3: Project / پروژه
29
+- Floating Detail 4: Contract / deduction/payment analytic dimension
30
+
31
+The engine must not hard-code those labels. A company can rename/enable/disable dimension types and define which dimensions are allowed or required for each posting account.
32
+
33
+Journal line shape:
34
+accountId + debit + credit + floating1Id + floating2Id + floating3Id + floating4Id + documentRef + description.
35
+
36
+### 3. Global projects
37
+Projects become first-class company masters, independent from contacts. A project is defined once and can then be linked to any number of counterparties, contracts, invoices, purchases, payments, expenses and journal lines.
38
+
39
+Existing contact-owned projects are legacy data and require a controlled migration to global project records. Historical IDs must be preserved or mapped so prior documents remain traceable.
40
+
41
+### 4. Counterparties
42
+Contacts remain first-class masters and automatically become values in the Counterparty floating-detail dimension.
43
+
44
+Contact role does not itself create a ledger account. Posting profiles determine the control account:
45
+- customer sale -> Accounts Receivable control account
46
+- supplier purchase -> Accounts Payable control account
47
+- both -> the same counterparty dimension can be used under both receivable and payable control accounts.
48
+
49
+This prevents duplicate customer/supplier ledgers and preserves one counterparty identity.
50
+
51
+### 5. Contracts
52
+Contracts are first-class masters:
53
+contract number, title, employer/contractor counterparty, company, branch, project, start/end date, gross value, currency, status, insurance/tax attributes, retention rules, attachments/references and guarantee links.
54
+
55
+Contracts can be linked to sales/purchase invoices, payments, deductions, guarantees and journal entries.
56
+
57
+### 6. Deductions
58
+Deduction types are masters rather than free text:
59
+- retention / حسن انجام کار
60
+- insurance deduction / سپرده یا کسر بیمه
61
+- withholding tax / مالیات تکلیفی
62
+- advance recovery / استهلاک پیشپرداخت
63
+- penalties / وجه التزام
64
+- other configurable deductions
65
+
66
+Each deduction type has a posting profile and can optionally be represented in Floating Detail 4. The financial meaning remains in the deduction record and posting rule; the floating dimension is analytic, not the accounting source of truth.
67
+
68
+### 7. Guarantees
69
+Guarantees are first-class masters:
70
+type, issuer/beneficiary, bank/institution, guarantee number, contract/project, issue/expiry dates, amount, status, collateral, extension/release history and document references.
71
+
72
+Guarantees should support memorandum/off-balance accounting through dedicated posting profiles where the company uses such accounts.
73
+
74
+## Double-entry engine
75
+
76
+Every financial source document creates a journal voucher with balanced journal lines. Posted vouchers are immutable; corrections use reversal/amendment rather than destructive edits.
77
+
78
+Core entities:
79
+- fiscalYears
80
+- accountGroups (optional presentation layer)
81
+- accounts
82
+- dimensionTypes
83
+- dimensionValues
84
+- accountDimensionRules
85
+- postingProfiles
86
+- journalVouchers
87
+- journalLines
88
+- projects
89
+- projectLinks
90
+- contracts
91
+- contractDeductions
92
+- guarantees
93
+
94
+Voucher lifecycle:
95
+draft -> validated -> posted -> reversed.
96
+
97
+Hard invariants:
98
+- total debit = total credit
99
+- no posting to inactive/non-posting accounts
100
+- required dimensions must be present
101
+- dimension value must be permitted for the account/company/fiscal year
102
+- posted voucher cannot be silently edited/deleted
103
+- source document can have at most one active posted voucher per posting event
104
+- fiscal-year lock prevents backdated mutation
105
+- all records are owner/company scoped and RLS protected.
106
+
107
+## Default posting profiles
108
+
109
+Sales invoice:
110
+Dr Accounts Receivable [counterparty, branch, project, contract]
111
+Cr Sales/Revenue [branch, project, contract]
112
+Cr Tax/VAT Payable when applicable
113
+
114
+Purchase invoice:
115
+Dr Inventory/Expense/Asset [branch, project, contract]
116
+Dr Recoverable VAT when applicable
117
+Cr Accounts Payable [counterparty, branch, project, contract]
118
+
119
+Receipt:
120
+Dr Cash/Bank
121
+Cr Accounts Receivable [counterparty/project/contract]
122
+
123
+Payment:
124
+Dr Accounts Payable [counterparty/project/contract]
125
+Cr Cash/Bank
126
+
127
+Contract deductions use configured receivable/payable/control accounts and retain the same contract/project/counterparty dimensions.
128
+
129
+## New four-phase implementation
130
+
131
+### Phase 5 — Accounting Foundation and Chart of Accounts
132
+Owner: Architecture/Accounting Core
133
+Deliverables:
134
+- fiscal year master and opening/locking model
135
+- three-level chart of accounts UI and coding validation
136
+- account nature and posting-level rules
137
+- four configurable floating-detail dimensions
138
+- branch master
139
+- counterparty synchronization into floating detail 2
140
+- global project master replacing contact-owned project definition
141
+- account-to-dimension required/allowed rules
142
+- safe migration layer for existing projects/documents
143
+- Supabase collections/RLS/migrations and backup/sync support
144
+Acceptance:
145
+- chart can be created/imported
146
+- global project is defined once and linked to multiple contacts/documents
147
+- contacts appear automatically as dimension values without duplication
148
+- no existing Finora 1.0 document is orphaned.
149
+
150
+### Phase 6 — Double-entry Journal and Automatic Posting
151
+Owner: Financial Engine
152
+Deliverables:
153
+- journal voucher/line engine
154
+- debit-credit validation and posting locks
155
+- manual journal UI
156
+- automatic posting profiles for sale, purchase, receipt, payment and expense/income
157
+- account ledger, subsidiary ledger, detail ledger and floating-detail ledger
158
+- opening entries, voucher numbering, reversal
159
+- migration/reconciliation report comparing legacy balances to accounting balances
160
+Acceptance:
161
+- every posted source document generates a balanced voucher
162
+- customer/supplier balances reconcile to control accounts
163
+- trial balance is balanced
164
+- no posted voucher can be destructively edited.
165
+
166
+### Phase 7 — Contracts, Deductions, Guarantees and Advanced Analytics
167
+Owner: Contracts/Accounting Integration
168
+Deliverables:
169
+- contracts menu and master
170
+- deduction rules and contract deduction schedules
171
+- guarantees menu and lifecycle
172
+- contract/project/branch/counterparty analytic links
173
+- optional memorandum posting profiles for guarantees
174
+- project and contract profitability, retention/insurance/tax tracking
175
+Acceptance:
176
+- a contract can connect to multiple documents/payments/guarantees
177
+- deductions are traceable from contract to voucher
178
+- guarantees have expiry/status history and accounting references
179
+- reports reconcile to journal data.
180
+
181
+### Phase 8 — Professional Accounting Reports, Migration and Release
182
+Owner: QA/Release
183
+Deliverables:
184
+- journal, general ledger, subsidiary ledger, detail ledger
185
+- floating-detail ledgers 1..4
186
+- trial balance 2/4/6/8-column as configured
187
+- account turnover and balance reports
188
+- project/branch/counterparty/contract analytic reports
189
+- balance sheet and profit/loss mapping framework
190
+- period close/lock
191
+- full regression, security, performance and production migration
192
+Acceptance:
193
+- trial balance debit/credit equality
194
+- source-to-voucher drilldown and voucher-to-source drillback
195
+- legacy Finora 1.0 balances reconciled before cutover
196
+- production backup and rollback point created before migration
197
+- all automated quality/security/deployment gates pass.
198
+
199
+## Workstream responsibilities
200
+1. Architecture & requirements: accounting model, posting contracts, migration invariants.
201
+2. Implementation: schema, engine, UI, synchronization and source-document integration.
202
+3. UX/UI: chart editor, voucher entry, dimension selectors, contracts/guarantees and reports.
203
+4. QA & verification: balanced-voucher tests, reconciliation, migration fixtures, regression.
204
+5. Security & release: RLS, fiscal locks, immutable posting controls, backups and production rollout.
205
+
206
+These are coordinated workstreams; implementation must not claim independent agents unless an actual multi-agent runtime is available.
207
+
208
+## Key architectural decisions
209
+- Do not create one project tree inside every counterparty.
210
+- Do not create one ledger account per customer/supplier.
211
+- Do not use floating details as substitutes for double-entry accounts.
212
+- Do not let document totals remain the accounting source of truth after Phase 6; posted journal lines become the accounting ledger.
213
+- Keep operational documents as source documents and link them bidirectionally to vouchers.
214
+- Keep project, contract, branch and counterparty identities global within a company/fiscal context.
215
+- Preserve Finora 1.0 source IDs during migration for auditability.