06 · Current focus
Savings
Down Payment
Current implementation: verified ledger, period allocation, target progress, READY_FOR_CONTRACT และ atomic transition to contract
Implementation in one sentence
เงินฝากไม่นับเป็น balance จนกว่าจะ VERIFIED; จากนั้น backend กระจายยอดไป period ตามลำดับ และเปลี่ยนบัญชีเป็น READY_FOR_CONTRACT เมื่อ verified sum ถึง target
State machine observed in code
SAVING → READY_FOR_CONTRACT → CONVERTEDPENDING → VERIFIED | REJECTEDOPEN → PARTIAL → PAIDPENDING_APPROVAL → approval/activation → ACTIVECurrent flow
Create account
Normalize DAILY/WEEKLY/MONTHLY plan, validate canonical target, prevent conflicting active account/contract, create first OPEN period.
Deposit
Positive amount, optional idempotency, duplicate reference guard; transaction always starts PENDING.
Verify & allocate
VERIFIED funds allocate to earliest unpaid period; period becomes PARTIAL/PAID and additional periods are created as needed.
Reach target
verified_total ≥ target_amount changes a SAVING account to READY_FOR_CONTRACT.
Convert atomically
Lock matching account/contract, apply down payment and loan amount, set account CONVERTED and contract PENDING_APPROVAL.
Due-date model
Period end = start + 1 day / 7 days / 1 month − 1 day according to DAILY / WEEKLY / MONTHLY. Next period starts the day after previous period_end. There is no separate due-date API.
Explicit gaps — not implemented
ไม่มีการแต่ง business rule เพิ่ม รายการต่อไปนี้คือสิ่งที่ไม่พบใน current code
| Requested concept | Current implementation |
|---|---|
| Missed payment | No background job/route marks savings periods missed or overdue. |
| Pause | No savings pause route/status. Contract payment-pause support request exists separately. |
| Cancellation | Schema comment includes CANCELLED; no active savings cancellation handler found. |
| Resume | No route or transition found. |
| Notification | No reminder worker, queue, or notification API found. |
| Refund | Schema comment includes REFUNDED; no active savings refund route found. |
| Verifier UI | Backend verify route exists; no direct current frontend caller found. |
| Conversion UI | Backend atomic route exists; no direct current frontend caller found. |
MAP/CODE CONFLICT: existing flow inventory marks savings conversion BROKEN. Current router has an active atomic conversion handler and disables the legacy handler with if (false).