feat(billing): Add invoice, list charges, and rollover endpoints#211
feat(billing): Add invoice, list charges, and rollover endpoints#211noahsmartin merged 2 commits intomainfrom
Conversation
|
The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).
|
d78268e to
e9db102
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ac36a32. Configure here.
Add new endpoints and supporting messages for the charge and contract services: - charge: ListChargesForInvoice - contract: GetInvoice, GetUnchargedInvoices, RolloverContract - contract: Invoice and InvoiceLineItem shared messages Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ac36a32 to
3001778
Compare
|
|
||
| // True if additional matching invoices existed beyond max_items and were | ||
| // not included in this response. | ||
| bool truncated = 2; |
There was a problem hiding this comment.
why not just return what the next offset should be
There was a problem hiding this comment.
I'm not opposed to it, but the other pagination API already uses this "truncated" boolean. Seems like matching it is better than starting a new standard
brendanhsentry
left a comment
There was a problem hiding this comment.
why are all the invoice protos in the contract directory?
| message Invoice { | ||
| uint64 invoice_id = 1; | ||
| repeated InvoiceLineItem line_items = 2; | ||
| // Not just a sum of line items since there may be credit applied |
There was a problem hiding this comment.
currently, we create invoice line items for credits which I think makes it easier to understand everything that went into the final amount billed.
There was a problem hiding this comment.
This could be like an overpayment that gets applied, not a typical "credit". Maybe those will also end up in the line items too though
we're keeping the data in the contract service because the contract is highly tied to the billing period either way. The invoice service just mediates the tallying and charging but doesn't store anything |

Add new endpoints and supporting messages for the charge and contract services:
charge: ListChargesForInvoice
This is used by the invoicer when we get uncharged invoices. We first list all charges to confirm that it is really not charged yet (in case the charge was written but we failed to update the invoice model)
contract: GetInvoice, GetUnchargedInvoices, RolloverContract
get invoice is used by the invoicer in an async task that will be provided just the invoice_id
get uncharged invoices is the main mechanism for charging (and also retrying) similar to how we get contracts that aren't invoiced
rollover contract is the API for creating a new billing period and creating the invoice model (done as one operation to avoid race conditions/satisfy FK requirements)