raystack / raystack/frontier

Store the invoice amount_remaining so local rows can tell what is still owed

Open
#1,907 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
344
Forks
47
Avg merge
4d 4h
Merged PRs (30d)
26

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the invoice schema and migration, then trace stripeInvoiceToInvoice, the sync update, and CheckOrganizationDelete. Confirm how payable states are represented and identify other checks that ask whether an invoice still needs payment. Done means amount_remaining is persisted and synced, existing rows are backfilled, and deletion no longer treats fully covered invoices as owed.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, database, payments
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.