feat(timesheets): draft state + withdraw endpoint (PMS-183) #157
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-183-timesheet-withdraw"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Backend half of PMS-183: a real
draft -> submit -> approvetimesheet lifecycle, plus a withdraw endpoint so a submitted (not-yet-approved) timesheet can be pulled back to draft.Changes
time_entries.approval_statusCHECK to include'draft'and makes it the column default. A freshly logged entry now starts unsubmitted instead of immediatelypendingapproval. Existing rows are left untouched (no in-flight approval disturbed).GET /timesheets) now reports'draft'for an unsubmitted week instead of folding it into'pending', and the empty-week fallback is'draft'.POST /api/v1/timesheets/{user_id}/{week_start}/withdraw:pendingentries back to'draft'.approved(an approved week has already gated billing).Tests
service_desk_time_slice_happy_path: extended to coverwithdraw -> draft, resubmit-> pending, and a withdraw-after-approve-> 409.approved_time_rolls_into_actuals(projects): now submits before approving, since an entry no longer auto-startspending.settings.rsfailures (billing module-seed) that fail identically onmainand are unrelated to this change.Pairs with a mokosh-apps PR adding the submit-confirmation modal (certification checkbox) and the Withdraw action.
🤖 Generated with Claude Code
Give time entries a real draft -> submit -> approve lifecycle. Migration 033 widens the approval_status CHECK to include 'draft' and makes it the default, so a freshly logged entry starts unsubmitted instead of immediately pending approval (existing rows are left untouched). The week summary now reports 'draft' for an unsubmitted week instead of folding it into 'pending'. Add POST /timesheets/{user_id}/{week_start}/withdraw: it moves the week's still-pending entries back to draft so the owner can edit and resubmit, is owner-only (admins may target anyone, like submit), and 409s once any entry in the week is approved. The projects actuals test now submits before approving (the entry no longer auto-starts pending), and the time-tracking happy path covers withdraw -> resubmit and the approved-week 409. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>