Skip to content

D67 · A rental returns or is repossessed before it ends, and rent stops when the car is back

Accepted · 2026-10-20 · zuki · Closes #155 · Partly superseded by D69 (how v1's deduction_stopped rows map) and D92 (a voluntary return may go through returned; rent stops the day the car is back)

Decision: A rental's statuses are V13's (pending, booked, active, paused, ended, cancelled) plus three from the higher-ups' General Flow:

Status Set at Rent
returning The return starts (VEH-13). return_reason is set here. Billed until the return inspection
repossessing A repo request opens (REP-01). return_reason is repossessed from here on. Billed until the car is recovered
returned The car is back at the pool and its BAST is still to come (VEH-15) Not billed
  • ended is the flow's Closed. It is set by the BAST (VEH-16, COL-18), with its end reason. In a voluntary return today, the return inspection and the BAST are one event on the day the car comes back, so a return goes from returning to ended in one step. A repossession goes through returned when its BAST comes on a later day.
  • Rent stops when the car is back. billing_ends_on is the day of the return inspection, or for a repossession the day the car is recovered, never the BAST's day.
  • Every status from pending to returned is live (R-RNT-01, R-RNT-02): until the rental ends or is cancelled, the car can't be booked and the driver can't take another car.
  • pending stays (approved, no car yet), and cancelled stays, for a booking cancelled before handover.
  • paused stays, as the result of a flow and never its trigger. A rental is paused only by a step of a defined flow, which records why. No step in v2 pauses one yet; the flow that needs it names its reason in a decision or a rule. A paused rental isn't billed.
  • A rate change (D38) makes a new row for active rentals only. booked and pending rentals take the new rate in place, because they haven't billed yet. returning and repossessing rentals keep their last rate until they end.

Why: The higher-ups' answers on #155 (Syamsul Haris, 2026-10-20): returning, repossessing and returned count as live; a rental in return or repo keeps its last rate; a voluntary return is one event today; for a repo, rent is cut at the repossession, not at the BAST; cancelled stays. zuki's answers on 2026-10-20: keep pending; rent stops at the return inspection; keep paused as a result of a flow, with a clear reason, never as a trigger. zuki's answer on #162: booked and pending rentals take a new rate in place. The CTO's proposal had dropped ended and paused and added closed. ended stays as the flow's Closed instead, because BE pack G2's rate chains already end rows with it (D38).

Consequences:

  • The schema: rental_status gains returning, repossessing and returned, and a paused rental keeps its reason. These are edited in place before cutover (D11), in a Backend Engineer pack after G2 (#212) and before the data phase's rentals step. The two "one live rental" indexes cover pending to returned. The rate change also reaches booked and pending rows, as asked on #162.
  • The rules: a DOC pack updates R-RNT-01, R-RNT-02 and R-RNT-07; adds a rule per new status and its transition; adds rules for when rent stops (R-MON-36 bills active, returning and repossessing, up to billing_ends_on) and for paused; and updates the return inspection's and the BAST's rules. The business flow page marks VEH-13, VEH-15 and REP-01 as statuses.
  • The functions that move a rental through these statuses are M5's (#156 decides the repo tasks). D66's stage change runs in the function that ends a repossessed rental.
  • The data phase's rentals step maps v1's onboarding rows onto these statuses. A v1 row with deduction_stopped becomes paused, with a reason saying it came from v1. The Backend Engineer counts these rows on the v1 copy first and posts the counts on #155, so zuki can review them before cutover.