-
Notifications
You must be signed in to change notification settings - Fork 152
fix: emulate metadata on standard invoice queries #3842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This patch makes sure that even if we are storing fake data for gathering invoices we are returning the up-to-date data when querying the invoices themselves.
📝 WalkthroughWalkthroughAdds emulation for Gathering-status invoices: new Service methods fetch and merge customer override/profile data into StandardInvoice fields (Customer, Supplier, Workflow) and integrate this emulation into ListInvoices and GetInvoiceByID. A test verifies merged customer, supplier, and workflow app data. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@openmeter/billing/service/gatheringinvoice.go`:
- Around line 53-60: The code dereferences mergedProfile.Customer when building
billing.InvoiceCustomer (using mergedProfiles[invoice.CustomerID()] and
assigning invoice.Customer), which can be nil; add a guard that checks if
mergedProfile or mergedProfile.Customer is nil and immediately return a
descriptive error (or propagate a typed error) before constructing
billing.InvoiceCustomer so callers fail fast with a clear message identifying
the invoice/customer ID and that the merged profile has no Customer.
In `@test/billing/invoice_test.go`:
- Around line 4316-4325: Add a test call to BillingService.ListInvoices (e.g.,
s.BillingService.ListInvoices(ctx, billing.ListInvoicesInput{...})) after the
GetInvoiceByID assertions and assert that at least one returned invoice contains
the same emulated Customer, Supplier and Workflow values you validated for
GetInvoiceByID (check fields like invoice.Customer.CustomerID,
invoice.Customer.Name, invoice.Supplier.Name and
invoice.Workflow.Apps.Invoicing.GetID()). Ensure you use the same identifiers
(gatheringInvoiceID/customerEntity/profile/sandboxApp) to match expectations and
fail the test if the list response does not include an invoice with those
emulated values.
Overview
This patch makes sure that even if we are storing fake data for gathering invoices we are returning the up-to-date data when querying the invoices themselves.
Notes for reviewer
Summary by CodeRabbit