fix: subscription sync do not reuse old lines#3874
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughModified GetLinesForSubscription to broaden which invoice lines are returned by including manually-managed deleted lines and to restrict split-line-group queries to only non-deleted groups. Added multi-line documentation comments to the InvoiceLineService.GetLinesForSubscription method. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
openmeter/billing/adapter/stdinvoicelines.go (1)
892-894: Nit: consider groupingWhereclauses together for readability.The
DeletedAtIsNil()filter works correctly here, but it's separated from the otherWhereclauses by theWithBillingInvoiceLinescall. Grouping allWherepredicates together would make the query easier to scan at a glance.♻️ Suggested reorder
dbGroups, err := tx.db.BillingInvoiceSplitLineGroup.Query(). Where(billinginvoicesplitlinegroup.Namespace(in.Namespace)). Where(billinginvoicesplitlinegroup.SubscriptionID(in.SubscriptionID)). + Where(billinginvoicesplitlinegroup.DeletedAtIsNil()). WithBillingInvoiceLines(func(q *db.BillingInvoiceLineQuery) { tx.expandLineItems(q) q.WithBillingInvoice(func(q *db.BillingInvoiceQuery) { q.WithBillingWorkflowConfig() }) }). - Where(billinginvoicesplitlinegroup.DeletedAtIsNil()). All(ctx)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@openmeter/billing/adapter/stdinvoicelines.go` around lines 892 - 894, Move the DeletedAtIsNil() predicate next to the other Where(...) calls to group filters together for readability: locate the query that chains WithBillingInvoiceLines(...).Where(...).Where(billinginvoicesplitlinegroup.DeletedAtIsNil()).All(ctx) and reorder so all Where(...) calls (including billinginvoicesplitlinegroup.DeletedAtIsNil()) appear consecutively before WithBillingInvoiceLines(...) or, if WithBillingInvoiceLines must remain, ensure all Where(...) predicates are adjacent (e.g., Where(...).Where(billinginvoicesplitlinegroup.DeletedAtIsNil()).WithBillingInvoiceLines(...).All(ctx)) to make the filters easier to scan.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@openmeter/billing/service.go`:
- Around line 49-56: Doc comment for GetLinesForSubscription has a typo
"manually lines"; update the comment above the GetLinesForSubscription method to
read "manually edited lines" (or "manually managed lines") so the sentence
becomes "...but the manually edited lines are included..." to improve clarity
and grammar while keeping the intent unchanged.
---
Nitpick comments:
In `@openmeter/billing/adapter/stdinvoicelines.go`:
- Around line 892-894: Move the DeletedAtIsNil() predicate next to the other
Where(...) calls to group filters together for readability: locate the query
that chains
WithBillingInvoiceLines(...).Where(...).Where(billinginvoicesplitlinegroup.DeletedAtIsNil()).All(ctx)
and reorder so all Where(...) calls (including
billinginvoicesplitlinegroup.DeletedAtIsNil()) appear consecutively before
WithBillingInvoiceLines(...) or, if WithBillingInvoiceLines must remain, ensure
all Where(...) predicates are adjacent (e.g.,
Where(...).Where(billinginvoicesplitlinegroup.DeletedAtIsNil()).WithBillingInvoiceLines(...).All(ctx))
to make the filters easier to scan.
Overview
Useful for backfill scenarios.
Notes for reviewer
Summary by CodeRabbit
Bug Fixes
Documentation