D72 · v2 suggests splitting a bulk payment oldest due first, and finance decides the split
Accepted · 2026-10-22 · zuki · Closes #148
Decision: When finance records a driver's transfer that doesn't say which charges it pays (D46: one transfer, one payment), v2 suggests how to split it: across the driver's open charges, oldest due date first, whatever their charge type (rent, admin fee, ETLE, panel claims, repo fines and sanctions alike), each charge covered in full before the next, until the payment runs out. The suggestion allocates nothing by itself. Finance decides the split: it confirms the suggestion as it is, changes it charge by charge, or sets it aside and splits the payment by hand. The split finance confirms is the one recorded.
Why: zuki on #148, 2026-10-22: "implement based on A. But finance still hold the decision as the recommendation." Syamsul Haris on #148, 2026-10-21, for finance: "need to have C capability. but can we give suggestion of A." Of the CTO's three options, A (oldest due first, across all types) clears what is overdue first, so it works with the overdue limits (D46, #158); C (finance splits every payment by hand, as in v1 today) stays possible, because finance still decides; B (rent before every other type) was not chosen.
Consequences:
- The suggestion stays within the money rules: it never allocates more than the payment (R-MON-14) or more than a charge's balance, and it uses only the driver's own charges that are open or partially paid. Money left once every open charge is covered stays unallocated on the payment; what finance does with it is unchanged by this decision.
- Two charges due the same day are ordered by a rule the Docs Engineer writes, and zuki reviews it in that rule's pull request.
- Who records and confirms payments is unchanged: finance, admin and admin_fleet until the payment and collection roles come after cutover (D63). Whether a payment is reconciled one by one or in bulk (R-MON-44) is a separate fact from how it is split.
- Migrated payments keep v1's split. The data phase's money step builds each payment's allocations from the instalments inside v1's bills (D34); this suggestion applies only to payments recorded in v2. So the money study (data phase row 2) no longer waits for #148.
- The rules: the Docs Engineer writes the suggestion, finance's choice and the same-day order as rules, and removes #148 from the money rules and the business flow page as an open question.
- Built in M6, with record_payment() and allocate(): a function that returns the suggested split for a payment, and the payments page, where finance confirms or changes it before anything is allocated (D3: the order is computed in Postgres, not in apps/web).