Let invoice senders revoke and resend#490
Merged
Merged
Conversation
Previously only the payer could take an invoice off the table (reject), and the sender (worker) had no way to pull back an invoice they'd sent — so a mistaken invoice was stuck until the payer rejected it, with no clear resend path. Adds: - POST /api/gigs/[id]/invoice/[invoiceId]/revoke — sender-only; cancels a draft/sent/expired invoice (status='cancelled') and notifies the payer. Idempotent for already-cancelled/rejected; refuses paid invoices. - Gig-page InvoiceButton: a "Revoke invoice" control on the worker's active invoices, and a "Resend invoice" button on revoked/rejected ones that pre-fills the invoice form from the original (line items, notes, PR links, category) so they can fix and send a fresh one. - Dashboard "Invoices Sent" tab: Revoke on active invoices and a Resend hand-off to the gig page. Resend creates a brand-new invoice via the existing create route, which already permits it because a cancelled/rejected invoice no longer counts as an open (draft/sent) one. No migration needed — 'cancelled' is already an allowed status. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A worker who sent an invoice had no way to take it back. The only mechanism to get a mistaken invoice off the table was for the payer to reject it — and after that there was no clear way for the sender to resend a corrected one.
What this adds
POST /api/gigs/[id]/invoice/[invoiceId]/revoke— sender-only (the worker who billed). Cancels adraft/sent/expiredinvoice (status='cancelled') and notifies the payer. Idempotent for already-cancelled/rejected; refusespaid.InvoiceButton— a Revoke invoice control on the worker's active invoices, plus a Resend invoice button on revoked/rejected ones that pre-fills the invoice form from the original (line items, notes, PR links, category). For sats-denominated gigs the stored amounts are USD, so prices are left blank on resend and re-entered.Resend just creates a fresh invoice through the existing create route, which already allows it — a cancelled/rejected invoice no longer counts as an open (
draft/sent) one, so the retry guard doesn't block it.Notes
cancelledis already an allowed status and workers already have an UPDATE RLS policy.Testing
vitest runon the gigs API suite — 93 passed (incl. 4 new revoke tests).tsc --noEmitclean;eslintclean on changed files.🤖 Generated with Claude Code