TTTOP TECH MAPPUBLIC DOCUMENTATION

06 · Current focus

Savings
Down Payment

Current implementation: verified ledger, period allocation, target progress, READY_FOR_CONTRACT และ atomic transition to contract

PENDING → VERIFIED / REJECTEDOPEN → PARTIAL → PAIDSAVING → READY → CONVERTED

Implementation in one sentence

เงินฝากไม่นับเป็น balance จนกว่าจะ VERIFIED; จากนั้น backend กระจายยอดไป period ตามลำดับ และเปลี่ยนบัญชีเป็น READY_FOR_CONTRACT เมื่อ verified sum ถึง target

State machine observed in code

AccountSAVING → READY_FOR_CONTRACT → CONVERTED
TransactionPENDING → VERIFIED | REJECTED
PeriodOPEN → PARTIAL → PAID
ContractPENDING_APPROVAL → approval/activation → ACTIVE

Current flow

01

Create account

Normalize DAILY/WEEKLY/MONTHLY plan, validate canonical target, prevent conflicting active account/contract, create first OPEN period.

02

Deposit

Positive amount, optional idempotency, duplicate reference guard; transaction always starts PENDING.

03

Verify & allocate

VERIFIED funds allocate to earliest unpaid period; period becomes PARTIAL/PAID and additional periods are created as needed.

04

Reach target

verified_total ≥ target_amount changes a SAVING account to READY_FOR_CONTRACT.

05

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 conceptCurrent implementation
Missed paymentNo background job/route marks savings periods missed or overdue.
PauseNo savings pause route/status. Contract payment-pause support request exists separately.
CancellationSchema comment includes CANCELLED; no active savings cancellation handler found.
ResumeNo route or transition found.
NotificationNo reminder worker, queue, or notification API found.
RefundSchema comment includes REFUNDED; no active savings refund route found.
Verifier UIBackend verify route exists; no direct current frontend caller found.
Conversion UIBackend 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).