Repository navigation
Conversation
Add a ledger package under services/contract for an organization's prepaid credit accounts. It defines LedgerEntry and endpoints to record deposits, withdrawals, and adjustments, read the balance, and list entries. A deposit is tied to an off-cycle invoice and counts toward the balance only once that invoice is paid. A withdrawal never makes the balance negative; callers choose between a partial withdrawal and none.
|
The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).
|
This branch has not been deployed
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.
Adds a
ledgerpackage underservices/contractfor an organization's prepaid credit (for example, Seer credit bought through an off-cycle invoice). It sits in its own folder to keep it apart from the contract and invoice messages.ContractServicein getsentry implements these endpoints. It is implemented in getsentry/getsentry#22745.Messages
LedgerEntryandLedgerEntryType: deposit, withdrawal, adjustment. Amounts are signed.counts_toward_balanceis false only for a deposit whose invoice is unpaid.RecordLedgerDeposit: links credit to an off-cycle invoice. Allows one deposit per invoice, so a retry returns the existing entry.RecordLedgerWithdrawal: never makes the balance negative. If the balance is too small,allow_partialpicks between withdrawing what is there and withdrawing nothing.shortfall_centstells the caller what it still has to bill. Retries are safe throughidempotency_key.RecordLedgerAdjustment: a manual correction, positive or negative. A refund is a negative adjustment. The refunded invoice stays paid, so its deposit still counts and the adjustment cancels it out.GetLedgerBalance: the balance, plus deposits still waiting on payment.ListLedgerEntries: newest first, with a cursor.Not covered here
Disputes. The plan is for a dispute to suspend the whole account through account status. The ledger does not model it.