The local invoice rows store only the Stripe total. "Total" and "still owed" differ when the customer's credit balance covers an invoice: the total is positive, the amount remaining is zero, and nothing needs paying.
Today that mismatch has one visible effect: CheckOrganizationDelete judges local rows by total, so the org delete button can grey out over an invoice with nothing due, telling the user to pay something unpayable. It clears when the provider marks the invoice paid and the sync picks it up — minutes in practice, and in the safe direction (the button under-promises; the real delete judges live provider data by amount_remaining and is correct). See the discussion on #1881 and the partial fix in #1906, which unfroze the synced total.
Closing it fully means storing amount_remaining next to amount:
- migration adding the column, backfilled from
amount for payable states
stripeInvoiceToInvoice mapping it, and the sync update writing it
- the delete check (and anything else asking "does this invoice still want money") judging on it instead of the total
Worth batching with any other billing-schema change rather than shipping alone.
🤖 Generated with Claude Code
The local invoice rows store only the Stripe total. "Total" and "still owed" differ when the customer's credit balance covers an invoice: the total is positive, the amount remaining is zero, and nothing needs paying.
Today that mismatch has one visible effect:
CheckOrganizationDeletejudges local rows by total, so the org delete button can grey out over an invoice with nothing due, telling the user to pay something unpayable. It clears when the provider marks the invoice paid and the sync picks it up — minutes in practice, and in the safe direction (the button under-promises; the real delete judges live provider data byamount_remainingand is correct). See the discussion on #1881 and the partial fix in #1906, which unfroze the synced total.Closing it fully means storing
amount_remainingnext toamount:amountfor payable statesstripeInvoiceToInvoicemapping it, and the sync update writing itWorth batching with any other billing-schema change rather than shipping alone.
🤖 Generated with Claude Code