Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
docs: add phase 2 treasury core plan
Davood Mehraban committed
Oct 5, 2026 at 16:28 UTC
d29ccb5500f1317b5156029a9fef53f2351a1eed
1 file changed
+49
docs/superpowers/plans/2026-10-05-phase-2-treasury-core.md
new
+49
@@ -0,0 +1,49 @@
1
+# Phase 2 Treasury Core Implementation Plan
2
+
3
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox syntax for tracking.
4
+
5
+**Goal:** Deliver an end-to-end simulated treasury workflow without a live bank: users/roles, bank accounts, beneficiaries, manual/file payment intake, validation, maker-checker, limits, whitelist, audit, and operational queues.
6
+
7
+**Architecture:** Keep the core as pure TypeScript domain services with explicit tenant boundaries and immutable audit events. Add a simulation service that composes intake, validation, approval, queueing and settlement without external banking side effects. UI remains a thin Persian-first RTL shell over the same domain contracts.
8
+
9
+**Tech Stack:** TypeScript strict, Vitest, Next.js 16.3.8, React 19, ESLint 9, GitHub Actions.
10
+
11
+**Spec:** docs/ROADMAP.md Phase 2 plus docs/specs/PHASE_1_FOUNDATION_SPEC.md invariants.
12
+
13
+## Global Constraints
14
+- IRR amounts are non-negative safe integers.
15
+- Maker cannot approve own payment.
16
+- Approval is bound to payment version.
17
+- UNKNOWN must never be automatically resubmitted.
18
+- Tenant boundaries apply to all core records and decisions.
19
+- No live-bank calls in Phase 2.
20
+
21
+## Review Focus
22
+- Cross-tenant references must be rejected.
23
+- Duplicate beneficiaries/accounts/payment imports must not create ambiguous records.
24
+- File intake must reject malformed rows atomically before queueing.
25
+- Limits and whitelist checks must run before approval/queueing.
26
+- Audit events must be append-only representations of every material state/action.
27
+
28
+---
29
+
30
+### Task 1: Treasury master data
31
+Create tenant-scoped users/roles, bank accounts and beneficiaries with Iranian account validation and duplicate protection. TDD then commit.
32
+
33
+### Task 2: Intake and validation
34
+Create manual and CSV/file intake contracts, normalized parsing, row validation, deterministic references and atomic batch result. TDD then commit.
35
+
36
+### Task 3: Policy engine
37
+Create whitelist and configurable transaction/daily limits; enforce tenant scope and policy before approval. TDD then commit.
38
+
39
+### Task 4: Maker-checker workflow and operational queues
40
+Compose payment versioning, approval invalidation, SoD, queue categories and simulated settlement. TDD then commit.
41
+
42
+### Task 5: Immutable audit ledger
43
+Create hash-chained append-only audit event model and verification routine for tamper evidence. TDD then commit.
44
+
45
+### Task 6: Persian RTL Treasury Core UI
46
+Create dashboard/core workflow views with semantic RTL navigation, queues, payment intake and approval summaries. Build/lint/typecheck.
47
+
48
+### Task 7: CI and Phase 2 gate
49
+Add GitHub Actions for install/typecheck/test/lint/build; record acceptance evidence; push branch and verify GitHub status.