backend phase 13 & frontend phase 6
This commit is contained in:
@@ -20,6 +20,24 @@
|
||||
- **MVP:** weekly batches; EVV + dispute-window gating; per-session accrual for engagements; `nurse_clawbacks` with next-batch netting and write-off; unique booking↔payout link; `iranian_holidays`-aware scheduling; verified-IBAN payouts with reconciliation references.
|
||||
- **DEFERRED:** on-demand / instant nurse withdrawal; per-nurse configurable payout frequency; automated clawback recovery beyond netting.
|
||||
|
||||
## (d1) Rules confirmed in build (backend b13)
|
||||
These fill gaps the requirements left open; the payout engine was built to them:
|
||||
- **Clawback netting recovers *whole* clawbacks up to a batch's earnings.** A `nurse_clawbacks` row is atomic —
|
||||
it is recovered in full or not at all — so a batch nets the largest set of whole pending clawbacks (oldest first)
|
||||
that fits within the nurse's earnings that week; `net_amount = gross_earnings − clawback_applied ≥ 0` (never
|
||||
negative). A single clawback **larger than a batch's earnings** stays fully `pending` and recovers from a later,
|
||||
larger batch (it is not partially recovered). The recovery is a real ledger movement (`DEBIT nurse_payable /
|
||||
CREDIT nurse_clawback_receivable`), not just a status flag, so the derived balances reconcile.
|
||||
- **A booking with an active (non-failed/-rejected) refund is held out of payout batches** — its money was (partly)
|
||||
reversed, so paying its frozen `nurse_payout_amount` would overpay. It is excluded until resolved (this is the
|
||||
operational reading of "no open dispute", since there is no separate dispute table yet).
|
||||
- **PAYA vs SATNA** is chosen per payout by the `payout_satna_threshold_irr` config (SATNA for net amounts at/above
|
||||
the threshold, else PAYA).
|
||||
- **Optional BNPL settlement gate:** `require_bnpl_settlement_for_payout` (config, **default off**) — when on, a
|
||||
BNPL-paid booking is payout-eligible only once its provider settlement (`settled_at`) is received.
|
||||
- The weekly **cron trigger is DEFERRED** — batches are admin-triggered; the cadence lives in
|
||||
`nurse_payout_interval_days` (default 7) for the future scheduler.
|
||||
|
||||
## (d) Supporting database entities
|
||||
`nurse_payout_batches`, `nurse_payouts` (with `gross_earnings_irr`, `clawback_applied_irr`, `net_amount_irr`, `iban_snapshot`), `nurse_payout_booking_links` (unique per booking), **`nurse_clawbacks`**, `ledger_entries`, **`iranian_holidays`**, `bookings.dispute_window_ends_at`, `nurse_bank_accounts`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user