Repository navigation
fix(ledger): return unused promotional credit to wash on void - #5461
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| return nil, fmt.Errorf("get transaction %s: %w", id.ID, err) | ||
| // Only promotional issuance includes payment legs for the same charge in | ||
| // this group. External and invoice payments are posted in separate groups. | ||
| func findIssuanceTransactions(group ledger.TransactionGroup, issueID models.NamespacedID, chargeID string) (issuanceTransactions, error) { |
There was a problem hiding this comment.
Helper skips required input type
findIssuanceTransactions takes three related arguments and checks their combined state inside the function. The repository requires a named <Operation>Input with Validate() error for non-trivial operations like this. Group the arguments into an input type and validate it at the function boundary. This repository requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: openmeter/ledger/creditvoid/service.go
Line: 525
Comment:
**Helper skips required input type**
`findIssuanceTransactions` takes three related arguments and checks their combined state inside the function. The repository requires a named `<Operation>Input` with `Validate() error` for non-trivial operations like this. Group the arguments into an input type and validate it at the function boundary. This repository requirement must be satisfied before merging.
**Context Used:** AGENTS.md ([source](https://github.com/openmeterio/openmeter/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Fixes #5435.
Voiding a promotional grant reversed issuance but left the unused amount on the open customer receivable. For custom currencies that receivable counted toward booked and spendable credit, so the balance could stay the same after a successful void.
Reverse the original promotional settlement and authorization for the voided amount in the same transaction group as the issuance correction. This returns unused credit to wash and preserves the funding for credit already consumed. Previously completed voids require a separate repair.
Verified with PostgreSQL-backed credit grant and customer balance tests, transaction and routing rule tests, and scoped lint. The custom-currency regression checks booked and spendable balances as well as open receivable, authorized receivable, and wash.
Summary by CodeRabbit