سامانه صدور فاکتور و حسابداری
Refine accounting architecture for hierarchical user-defined dimensions
davoodmehraban89 committed
Sep 28, 2026 at 17:10 UTC
dbe3aa4eea494acee54074b043d2328e73ee4c2a
1 file changed
+205
docs/ACCOUNTING_CORE_ROADMAP_V1.md
+205
@@ -213,3 +213,208 @@ These are coordinated workstreams; implementation must not claim independent age
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.
216
+
217
+
218
+## 2026-09-28 R&D refinement — fully user-defined floating dimensions
219
+
220
+The earlier fixed presets are replaced by a generic hierarchical analytic-dimension engine.
221
+
222
+### Dimension definitions
223
+A company may create any analytic/floating dimension it needs, for example:
224
+- Branch
225
+- Employee
226
+- Cost element
227
+- Department
228
+- Project
229
+- Contract
230
+- Vehicle
231
+- Sales channel
232
+- Bank account identifier
233
+- Product family
234
+- Region
235
+
236
+Each dimension definition contains:
237
+- id, companyId, code, title
238
+- maxDepth
239
+- leafOnlyPosting = true by default
240
+- active
241
+- sourceType: manual | entity-backed
242
+- optional sourceEntity: contact | project | branch | employee | bankAccount | contract | custom
243
+- allowMultipleSelectionPerLine = false by default
244
+- hierarchyMode = strict-tree
245
+- defaultApplicability: optional | required | unavailable
246
+
247
+### Hierarchical values and leaf enforcement
248
+Dimension values form an arbitrary tree up to the configured maxDepth.
249
+
250
+A non-leaf/group node is analytical only and cannot be posted to when leafOnlyPosting is enabled.
251
+
252
+Example:
253
+Employees
254
+ -> Operations
255
+ -> Personnel
256
+ -> Employee 10027 - Ali Rezaei
257
+
258
+If a node is configured to have/accept children and has actual children, only selectable leaf nodes are valid for journal posting.
259
+
260
+If a configured hierarchy requires a deeper level but the user has not created a valid child value yet, the parent remains non-postable and cannot be linked to an account rule.
261
+
262
+### Account-to-dimension applicability
263
+Each posting account may reference zero, one, or many dimensions.
264
+
265
+For every account + dimension rule:
266
+- applicability: required | optional | unavailable
267
+- allowedValuesMode: all | selected-branches | selected-leaves | expression/range
268
+- defaultValueId optional
269
+- inheritedDefaultSource optional
270
+- effectiveFrom/effectiveTo
271
+- validationPriority
272
+
273
+When a journal line account is selected, Finora resolves only the dimensions relevant to that account and prompts the user for the required values. Irrelevant dimensions remain hidden.
274
+
275
+This follows the same principle used by enterprise ERPs: the account structure determines which dimensions are valid/required, rather than showing every dimension on every posting.
276
+
277
+### Entity-backed dimensions
278
+A dimension can be backed by a master entity instead of manually duplicating values.
279
+
280
+Examples:
281
+- Counterparty dimension <- Contacts
282
+- Project dimension <- Projects
283
+- Branch dimension <- Branches
284
+- Employee dimension <- Employees
285
+- Contract dimension <- Contracts
286
+- Bank-account dimension <- Bank Accounts
287
+
288
+The source master owns identity and business attributes. The analytic dimension references that identity for posting/reporting.
289
+
290
+This prevents duplicate records and preserves one definition usable under many accounts.
291
+
292
+### Dimension groups vs posting values
293
+Headers and grouping nodes are never accounting identities by themselves.
294
+
295
+Example:
296
+Cost Elements
297
+ -> Administrative & General
298
+ -> Payroll
299
+ -> Base Salary
300
+ -> Overtime
301
+ -> Benefits
302
+ -> Rent
303
+ -> Cost of Sales
304
+ -> Materials
305
+ -> Cable
306
+ -> Copper
307
+ -> Packaging
308
+
309
+If “Payroll” or “Materials” has children, the system can be configured so those group nodes cannot be posted. Only terminal values such as Base Salary or Cable are selectable.
310
+
311
+### Four-slot compatibility without four-slot limitation
312
+Finora UI may initially expose four fast analytic slots for ease of migration and familiar Iranian workflows, but the storage/validation model must not be limited to four dimensions.
313
+
314
+Journal lines store dimension assignments as a normalized collection:
315
+journalLineDimension(lineId, dimensionId, dimensionValueId)
316
+
317
+This allows four dimensions today and more later without schema redesign.
318
+
319
+## Company-type templates
320
+
321
+Finora should offer optional setup templates during company onboarding.
322
+
323
+Initial template catalog:
324
+1. Trading / بازرگانی
325
+2. Service / خدماتی
326
+3. Manufacturing / تولیدی
327
+4. Contracting / پیمانکاری
328
+5. Retail / فروشگاهی
329
+6. Distribution / پخش
330
+7. Nonprofit / موسسه غیرانتفاعی
331
+8. Professional services / خدمات حرفهای
332
+9. Holding / multi-company management (later)
333
+
334
+The user chooses:
335
+- Apply recommended template
336
+- Start empty
337
+
338
+Templates are editable after installation and are not hard-coded business rules.
339
+
340
+### Template contents
341
+A template can seed:
342
+- chart of accounts
343
+- account nature/type
344
+- posting profiles
345
+- recommended dimensions
346
+- account-to-dimension applicability
347
+- default document numbering
348
+- default reports
349
+- optional starter branches/projects/cost structures
350
+
351
+### Example template behavior
352
+
353
+Trading:
354
+- AR/AP, sales, purchases, inventory, cash/bank, VAT
355
+- Counterparty dimension required on AR/AP
356
+- Branch optional/required by company setup
357
+- Project optional
358
+
359
+Service:
360
+- service revenue, payroll/contractor expense, admin expenses, AR/AP
361
+- Project/Department/Employee dimensions commonly recommended
362
+- Cost-element dimension for management analysis
363
+
364
+Manufacturing:
365
+- raw material, WIP, finished goods, direct labor, overhead, COGS
366
+- Cost Center/Department/Product/Production Order dimensions as recommended
367
+- stricter inventory and costing posting profiles
368
+
369
+Contracting:
370
+- project/contract revenue and cost
371
+- retention, insurance deposits, advances, guarantees, subcontractors
372
+- Project and Contract dimensions required on relevant accounts
373
+- Counterparty required on employer/subcontractor control accounts
374
+
375
+Retail:
376
+- cash/POS/bank, sales, VAT, inventory, discounts, COGS
377
+- Branch/Store dimension recommended
378
+- Counterparty optional for anonymous retail sales
379
+
380
+## Bank design clarification
381
+
382
+Do not model every physical bank account as a duplicated chart node unless the customer explicitly prefers that structure.
383
+
384
+Finora supports both approaches:
385
+
386
+A. account-based:
387
+Cash & Bank -> Banks -> Bank Melli
388
+
389
+B. dimension-based:
390
+Cash & Bank -> Bank
391
++ Bank Account dimension -> Melli / Account 0101...
392
++ optional Branch dimension
393
+
394
+Recommended default for scalable setups is a stable ledger account plus a Bank Account master/dimension. This avoids chart explosion when a company has many accounts in the same bank and permits the same bank-account identity to participate in treasury reconciliation, payments and accounting.
395
+
396
+## Posting UX
397
+
398
+When the user selects an account during a journal entry:
399
+1. Resolve the active account structure/rules.
400
+2. Show only required/optional dimensions for that account.
401
+3. Pre-fill defaults from source masters/document context when valid.
402
+4. Prevent group/non-leaf dimension nodes from selection.
403
+5. Validate allowed combinations before posting.
404
+6. Show the composed accounting string as a readable preview, but store account and dimensions separately.
405
+
406
+For RTL/Persian usability, Finora should display account and analytic segments as separate controls by default and optionally show a composed code string for power users.
407
+
408
+## Governance and lifecycle
409
+
410
+Dimension structure changes must be versioned/effective-dated after accounting activity exists.
411
+
412
+Do not silently repurpose an existing posted dimension value.
413
+
414
+Allowed lifecycle:
415
+draft -> active -> inactive/closed
416
+
417
+Historical journal lines retain the original identity and label snapshot/reference.
418
+
419
+Account-structure changes affecting required dimensions must pass a validation/migration preview before activation.
420
+