Skip to content

Conversation

@turip
Copy link
Member

@turip turip commented Jun 7, 2025

Overview

See description here: #2961

This patch only contains the schema changes to make the other PR a bit shorter.

Summary by CodeRabbit

  • New Features

    • Introduced "Billing Invoice Split Line Group" as a new entity for grouping and managing invoice lines.
    • Added support for linking invoice lines to split line groups, including new fields and relationships.
    • Enabled querying, updating, and managing split line groups from subscription, subscription phase, and subscription item entities.
    • Provided new filtering, sorting, and pagination options for split line groups.
    • Extended API and UI capabilities to create, update, and delete split line groups and their associations.
  • Database Changes

    • Added a new table for split line groups with relevant fields and indexes.
    • Updated invoice lines table to reference split line groups via a new column and foreign key.
  • Chores

    • Improved schema organization by introducing reusable mixins for common invoice fields.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 7, 2025

📝 Walkthrough

Walkthrough

This change introduces a new entity, BillingInvoiceSplitLineGroup, to the billing domain model and database schema. It adds a new table, relationships, and full CRUD/query support in the codebase. The BillingInvoiceLine entity now optionally references a split line group, and corresponding schema, migration, and API changes are made throughout related entities, including subscriptions and their phases/items.

Changes

File(s) / Area Change Summary
Schema & Migrations
openmeter/ent/schema/billing.go
openmeter/ent/schema/subscription.go
Added BillingInvoiceSplitLineGroup schema, mixins, fields, edges; linked to invoice lines and subscription entities.
tools/migrate/migrations/20250609172811_billing-split-line-group.up.sql
tools/migrate/migrations/20250609172811_billing-split-line-group.down.sql
Migration: creates/drops billing_invoice_split_line_groups table, adds/removes split_line_group_id to billing_invoice_lines, sets up foreign keys and indexes.
Database Table/Schema Definitions
openmeter/ent/db/migrate/schema.go Defines new table, columns, foreign keys, and indexes for split line groups; updates invoice lines table and foreign key relationships.
Entity Model & CRUD
openmeter/ent/db/billinginvoicesplitlinegroup.go
openmeter/ent/db/billinginvoicesplitlinegroup_create.go
openmeter/ent/db/billinginvoicesplitlinegroup_update.go
openmeter/ent/db/billinginvoicesplitlinegroup_delete.go
openmeter/ent/db/billinginvoicesplitlinegroup_query.go
Implements model struct, create, update, delete, query builders, edge accessors, and stringer for BillingInvoiceSplitLineGroup.
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go
openmeter/ent/db/billinginvoicesplitlinegroup/where.go
Defines schema constants, ordering, and predicate functions for split line group entity.
openmeter/ent/db/billinginvoiceline.go
openmeter/ent/db/billinginvoiceline/billinginvoiceline.go
openmeter/ent/db/billinginvoiceline/where.go
Adds split_line_group_id field and edge to BillingInvoiceLine, updates struct, scan/assign, query, predicates, and ordering.
openmeter/ent/db/billinginvoiceline_create.go
openmeter/ent/db/billinginvoiceline_update.go
Adds create/update builder support for split_line_group_id and edge, validation, and deduplicates field handling.
openmeter/ent/db/billinginvoiceline_query.go Adds query and eager-loading support for the split line group edge on invoice lines.
openmeter/ent/db/setorclear.go Adds SetOrClear methods for nullable fields on split line group and invoice line update structs.
Client, Transaction, and Exposure
openmeter/ent/db/client.go
openmeter/ent/db/tx.go
openmeter/ent/db/expose.go
Adds split line group client to main and transactional clients, initializes, and exposes it.
openmeter/ent/db/hook/hook.go Adds mutator adapter type for split line group mutations.
Runtime & Column Validation
openmeter/ent/db/runtime.go
openmeter/ent/db/ent.go
Registers split line group schema in runtime and column validation.
Predicates
openmeter/ent/db/predicate/predicate.go Adds predicate type and error wrapper for split line group.
Pagination
openmeter/ent/db/paginate.go Adds pagination support for split line group queries.
Subscription Entities: Model, CRUD, Query, Update
openmeter/ent/db/subscription.go
openmeter/ent/db/subscription/subscription.go
openmeter/ent/db/subscription/where.go
openmeter/ent/db/subscription_create.go
openmeter/ent/db/subscription_query.go
openmeter/ent/db/subscription_update.go
Adds edge, methods, query, predicates, create, and update support for split line groups on subscriptions.
openmeter/ent/db/subscriptionitem.go
openmeter/ent/db/subscriptionitem/subscriptionitem.go
openmeter/ent/db/subscriptionitem/where.go
openmeter/ent/db/subscriptionitem_create.go
openmeter/ent/db/subscriptionitem_query.go
openmeter/ent/db/subscriptionitem_update.go
Adds edge, methods, query, predicates, create, and update support for split line groups on subscription items.
openmeter/ent/db/subscriptionphase.go
openmeter/ent/db/subscriptionphase/subscriptionphase.go
openmeter/ent/db/subscriptionphase/where.go
openmeter/ent/db/subscriptionphase_create.go
openmeter/ent/db/subscriptionphase_query.go
openmeter/ent/db/subscriptionphase_update.go
Adds edge, methods, query, predicates, create, and update support for split line groups on subscription phases.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@turip turip force-pushed the refactor/split-lines-v2-ddl branch from a83f392 to 9871466 Compare June 9, 2025 10:50
@turip turip added release-note/ignore Ignore this change when generating release notes area/billing labels Jun 9, 2025
@turip turip marked this pull request as ready for review June 9, 2025 12:57
@turip turip requested a review from a team as a code owner June 9, 2025 12:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
openmeter/ent/schema/billing.go (1)

402-409: Consider documenting the temporary nature of this field

The comment indicates this field is "only valid for ubp lines" and that the table will "eventually become the 'ubp' table". This suggests a planned refactoring that should be tracked properly.

Would you like me to create an issue to track this technical debt and the planned refactoring of the billing invoice lines table?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 637e267 and 27c7182.

⛔ Files ignored due to path filters (1)
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum
📒 Files selected for processing (45)
  • openmeter/ent/db/billinginvoiceline.go (20 hunks)
  • openmeter/ent/db/billinginvoiceline/billinginvoiceline.go (9 hunks)
  • openmeter/ent/db/billinginvoiceline/where.go (5 hunks)
  • openmeter/ent/db/billinginvoiceline_create.go (15 hunks)
  • openmeter/ent/db/billinginvoiceline_query.go (9 hunks)
  • openmeter/ent/db/billinginvoiceline_update.go (15 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup/where.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup_create.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup_delete.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup_query.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup_update.go (1 hunks)
  • openmeter/ent/db/client.go (14 hunks)
  • openmeter/ent/db/ent.go (2 hunks)
  • openmeter/ent/db/expose.go (1 hunks)
  • openmeter/ent/db/hook/hook.go (1 hunks)
  • openmeter/ent/db/migrate/schema.go (7 hunks)
  • openmeter/ent/db/paginate.go (1 hunks)
  • openmeter/ent/db/predicate/predicate.go (1 hunks)
  • openmeter/ent/db/runtime.go (4 hunks)
  • openmeter/ent/db/setorclear.go (3 hunks)
  • openmeter/ent/db/subscription.go (3 hunks)
  • openmeter/ent/db/subscription/subscription.go (4 hunks)
  • openmeter/ent/db/subscription/where.go (1 hunks)
  • openmeter/ent/db/subscription_create.go (3 hunks)
  • openmeter/ent/db/subscription_query.go (8 hunks)
  • openmeter/ent/db/subscription_update.go (7 hunks)
  • openmeter/ent/db/subscriptionitem.go (3 hunks)
  • openmeter/ent/db/subscriptionitem/subscriptionitem.go (4 hunks)
  • openmeter/ent/db/subscriptionitem/where.go (1 hunks)
  • openmeter/ent/db/subscriptionitem_create.go (3 hunks)
  • openmeter/ent/db/subscriptionitem_query.go (8 hunks)
  • openmeter/ent/db/subscriptionitem_update.go (7 hunks)
  • openmeter/ent/db/subscriptionphase.go (3 hunks)
  • openmeter/ent/db/subscriptionphase/subscriptionphase.go (4 hunks)
  • openmeter/ent/db/subscriptionphase/where.go (1 hunks)
  • openmeter/ent/db/subscriptionphase_create.go (3 hunks)
  • openmeter/ent/db/subscriptionphase_query.go (8 hunks)
  • openmeter/ent/db/subscriptionphase_update.go (7 hunks)
  • openmeter/ent/db/tx.go (2 hunks)
  • openmeter/ent/schema/billing.go (4 hunks)
  • openmeter/ent/schema/subscription.go (3 hunks)
  • tools/migrate/migrations/20250609104934_billing-split-line-group.down.sql (1 hunks)
  • tools/migrate/migrations/20250609104934_billing-split-line-group.up.sql (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (19)
openmeter/ent/db/ent.go (1)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (2)
  • Table (65-65)
  • ValidColumn (120-127)
openmeter/ent/db/subscriptionphase/where.go (6)
openmeter/ent/db/subscription/where.go (2)
  • HasBillingSplitLineGroups (892-900)
  • HasBillingSplitLineGroupsWith (903-912)
openmeter/ent/db/subscriptionitem/where.go (2)
  • HasBillingSplitLineGroups (1289-1297)
  • HasBillingSplitLineGroupsWith (1300-1309)
openmeter/ent/db/subscriptionphase.go (2)
  • SubscriptionPhase (18-48)
  • SubscriptionPhase (104-121)
openmeter/ent/schema/subscription.go (5)
  • SubscriptionPhase (66-68)
  • SubscriptionPhase (70-77)
  • SubscriptionPhase (79-88)
  • SubscriptionPhase (90-96)
  • SubscriptionPhase (98-107)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (2)
  • Table (65-65)
  • FieldID (19-19)
openmeter/ent/db/subscriptionphase/subscriptionphase.go (4)
  • Table (48-48)
  • FieldID (16-16)
  • BillingSplitLineGroupsTable (71-71)
  • BillingSplitLineGroupsColumn (76-76)
openmeter/ent/db/predicate/predicate.go (2)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/tx.go (4)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/predicate/predicate.go (1)
  • BillingInvoiceSplitLineGroup (113-113)
openmeter/ent/db/client.go (2)
  • BillingInvoiceSplitLineGroupClient (3435-3437)
  • NewBillingInvoiceSplitLineGroupClient (3440-3442)
openmeter/ent/db/expose.go (4)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/predicate/predicate.go (1)
  • BillingInvoiceSplitLineGroup (113-113)
openmeter/ent/db/client.go (1)
  • NewBillingInvoiceSplitLineGroupClient (3440-3442)
openmeter/ent/db/billinginvoicesplitlinegroup_delete.go (5)
openmeter/ent/db/ent.go (3)
  • IsConstraintError (367-373)
  • ConstraintError (351-354)
  • NotFoundError (284-286)
openmeter/ent/db/mutation.go (1)
  • BillingInvoiceSplitLineGroupMutation (21698-21731)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/db/predicate/predicate.go (1)
  • BillingInvoiceSplitLineGroup (113-113)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (3)
  • Table (65-65)
  • FieldID (19-19)
  • Label (17-17)
openmeter/ent/db/hook/hook.go (2)
openmeter/ent/db/mutation.go (1)
  • BillingInvoiceSplitLineGroupMutation (21698-21731)
openmeter/ent/db/ent.go (2)
  • Value (67-67)
  • Mutation (78-78)
openmeter/ent/db/subscription/subscription.go (3)
openmeter/ent/db/subscriptionitem/subscriptionitem.go (8)
  • ByBillingSplitLineGroupsCount (309-313)
  • OrderOption (168-168)
  • ByBillingSplitLineGroups (316-320)
  • Table (72-72)
  • FieldID (18-18)
  • BillingSplitLineGroupsInverseTable (98-98)
  • BillingSplitLineGroupsTable (95-95)
  • BillingSplitLineGroupsColumn (100-100)
openmeter/ent/db/subscriptionphase/subscriptionphase.go (8)
  • ByBillingSplitLineGroupsCount (218-222)
  • OrderOption (125-125)
  • ByBillingSplitLineGroups (225-229)
  • Table (48-48)
  • FieldID (16-16)
  • BillingSplitLineGroupsInverseTable (74-74)
  • BillingSplitLineGroupsTable (71-71)
  • BillingSplitLineGroupsColumn (76-76)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (3)
  • OrderOption (150-150)
  • Table (65-65)
  • FieldID (19-19)
openmeter/ent/db/subscriptionphase_create.go (4)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/subscriptionphase/where.go (1)
  • ID (14-16)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (2)
  • Table (65-65)
  • FieldID (19-19)
openmeter/ent/db/subscriptionphase/subscriptionphase.go (4)
  • Table (48-48)
  • BillingSplitLineGroupsTable (71-71)
  • BillingSplitLineGroupsColumn (76-76)
  • FieldID (16-16)
openmeter/ent/schema/subscription.go (3)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/predicate/predicate.go (1)
  • BillingInvoiceSplitLineGroup (113-113)
openmeter/ent/db/subscriptionphase/subscriptionphase.go (5)
openmeter/ent/db/subscription/subscription.go (8)
  • ByBillingSplitLineGroupsCount (263-267)
  • OrderOption (153-153)
  • ByBillingSplitLineGroups (270-274)
  • Table (56-56)
  • FieldID (16-16)
  • BillingSplitLineGroupsInverseTable (89-89)
  • BillingSplitLineGroupsTable (86-86)
  • BillingSplitLineGroupsColumn (91-91)
openmeter/ent/db/subscriptionitem/subscriptionitem.go (8)
  • ByBillingSplitLineGroupsCount (309-313)
  • OrderOption (168-168)
  • ByBillingSplitLineGroups (316-320)
  • Table (72-72)
  • FieldID (18-18)
  • BillingSplitLineGroupsInverseTable (98-98)
  • BillingSplitLineGroupsTable (95-95)
  • BillingSplitLineGroupsColumn (100-100)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (3)
  • OrderOption (150-150)
  • Table (65-65)
  • FieldID (19-19)
openmeter/ent/db/customer/customer.go (3)
  • OrderOption (150-150)
  • Table (62-62)
  • FieldID (16-16)
openmeter/ent/db/billinginvoiceline/billinginvoiceline.go (3)
  • OrderOption (297-297)
  • Table (109-109)
  • FieldID (19-19)
openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
openmeter/ent/db/subscription/subscription.go (8)
  • ByBillingSplitLineGroupsCount (263-267)
  • OrderOption (153-153)
  • ByBillingSplitLineGroups (270-274)
  • Table (56-56)
  • FieldID (16-16)
  • BillingSplitLineGroupsInverseTable (89-89)
  • BillingSplitLineGroupsTable (86-86)
  • BillingSplitLineGroupsColumn (91-91)
openmeter/ent/db/subscriptionphase/subscriptionphase.go (8)
  • ByBillingSplitLineGroupsCount (218-222)
  • OrderOption (125-125)
  • ByBillingSplitLineGroups (225-229)
  • Table (48-48)
  • FieldID (16-16)
  • BillingSplitLineGroupsInverseTable (74-74)
  • BillingSplitLineGroupsTable (71-71)
  • BillingSplitLineGroupsColumn (76-76)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (3)
  • OrderOption (150-150)
  • Table (65-65)
  • FieldID (19-19)
openmeter/ent/db/billinginvoiceline/billinginvoiceline.go (3)
  • OrderOption (297-297)
  • Table (109-109)
  • FieldID (19-19)
openmeter/ent/db/subscription_update.go (3)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (3)
  • Table (65-65)
  • Columns (97-117)
  • FieldID (19-19)
openmeter/ent/db/subscription/subscription.go (5)
  • Table (56-56)
  • BillingSplitLineGroupsTable (86-86)
  • Columns (102-117)
  • BillingSplitLineGroupsColumn (91-91)
  • FieldID (16-16)
openmeter/ent/db/runtime.go (7)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (6)
  • CurrencyValidator (139-139)
  • DefaultCreatedAt (133-133)
  • DefaultUpdatedAt (135-135)
  • UpdateDefaultUpdatedAt (137-137)
  • ValueScanner (143-146)
  • DefaultID (141-141)
openmeter/ent/db/billinginvoiceline/billinginvoiceline.go (6)
  • CurrencyValidator (257-257)
  • DefaultCreatedAt (251-251)
  • DefaultUpdatedAt (253-253)
  • UpdateDefaultUpdatedAt (255-255)
  • ValueScanner (261-263)
  • DefaultID (259-259)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/billinginvoiceusagebasedlineconfig/billinginvoiceusagebasedlineconfig.go (2)
  • ValueScanner (64-66)
  • DefaultID (62-62)
openmeter/billing/discount.go (1)
  • Discounts (78-81)
openmeter/productcatalog/price.go (1)
  • Price (84-91)
openmeter/ent/db/billinginvoiceline_query.go (6)
openmeter/ent/db/billinginvoicesplitlinegroup_query.go (1)
  • BillingInvoiceSplitLineGroupQuery (25-39)
openmeter/ent/db/client.go (1)
  • BillingInvoiceSplitLineGroupClient (3435-3437)
openmeter/ent/schema/billing.go (10)
  • BillingInvoiceLine (320-322)
  • BillingInvoiceLine (324-330)
  • BillingInvoiceLine (332-419)
  • BillingInvoiceLine (421-431)
  • BillingInvoiceLine (433-474)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/billinginvoiceline.go (2)
  • BillingInvoiceLine (28-106)
  • BillingInvoiceLine (253-278)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/db/billinginvoiceline/where.go (2)
  • SplitLineGroupID (198-200)
  • ID (17-19)
openmeter/ent/db/migrate/schema.go (5)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (3)
  • Columns (97-117)
  • Table (65-65)
  • BillingInvoiceLinesTable (67-67)
openmeter/ent/db/subscription/subscription.go (2)
  • Columns (102-117)
  • Table (56-56)
openmeter/ent/db/subscriptionitem/subscriptionitem.go (2)
  • Columns (104-128)
  • Table (72-72)
openmeter/ent/db/subscriptionphase/subscriptionphase.go (2)
  • Columns (80-93)
  • Table (48-48)
openmeter/ent/db/billinginvoiceline/billinginvoiceline.go (2)
  • Columns (184-218)
  • Table (109-109)
openmeter/ent/db/billinginvoiceline.go (5)
openmeter/ent/db/billinginvoiceline/where.go (4)
  • PeriodStart (102-104)
  • PeriodEnd (107-109)
  • Currency (112-115)
  • SplitLineGroupID (198-200)
pkg/currencyx/currency.go (1)
  • Code (12-12)
openmeter/productcatalog/tax.go (1)
  • TaxConfig (36-39)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/db/ent.go (2)
  • NotFoundError (284-286)
  • NotLoadedError (330-332)
openmeter/ent/db/subscriptionphase_query.go (4)
openmeter/ent/db/subscriptionphase.go (2)
  • SubscriptionPhase (18-48)
  • SubscriptionPhase (104-121)
openmeter/ent/db/billinginvoicesplitlinegroup_query.go (1)
  • BillingInvoiceSplitLineGroupQuery (25-39)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/subscriptionitem_query.go (8)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (2)
  • OrderOption (150-150)
  • FieldID (19-19)
openmeter/ent/db/subscriptionitem.go (2)
  • SubscriptionItem (21-73)
  • SubscriptionItem (131-158)
openmeter/ent/schema/subscription.go (5)
  • SubscriptionItem (109-111)
  • SubscriptionItem (113-120)
  • SubscriptionItem (122-185)
  • SubscriptionItem (187-192)
  • SubscriptionItem (194-203)
openmeter/ent/db/predicate/predicate.go (2)
  • SubscriptionItem (262-262)
  • BillingInvoiceSplitLineGroup (113-113)
openmeter/ent/db/billinginvoicesplitlinegroup_query.go (1)
  • BillingInvoiceSplitLineGroupQuery (25-39)
openmeter/ent/db/client.go (1)
  • BillingInvoiceSplitLineGroupClient (3435-3437)
openmeter/ent/schema/billing.go (5)
  • BillingInvoiceSplitLineGroup (582-584)
  • BillingInvoiceSplitLineGroup (586-591)
  • BillingInvoiceSplitLineGroup (593-632)
  • BillingInvoiceSplitLineGroup (634-641)
  • BillingInvoiceSplitLineGroup (643-659)
openmeter/ent/db/subscriptionitem/where.go (1)
  • ID (15-17)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: CI
🔇 Additional comments (118)
openmeter/ent/db/ent.go (1)

32-32: LGTM: Correct integration of new entity.

The import and column validation registration for BillingInvoiceSplitLineGroup follows the established pattern and is placed in the correct alphabetical order within the existing structure.

Also applies to: 137-137

openmeter/ent/db/tx.go (1)

49-50: LGTM: Proper transactional client integration.

The BillingInvoiceSplitLineGroup client field and initialization follow the established pattern for other entity clients and maintain correct alphabetical ordering.

Also applies to: 250-250

openmeter/ent/db/expose.go (1)

124-125: LGTM: Consistent client initialization.

The BillingInvoiceSplitLineGroup client initialization follows the established pattern and maintains proper alphabetical ordering within the client structure.

tools/migrate/migrations/20250609104934_billing-split-line-group.down.sql (1)

1-13: LGTM: Proper rollback migration structure.

The migration script correctly reverses the schema changes in the proper order: foreign key constraints first, then indexes, and finally the table. This prevents constraint violations during rollback execution.

openmeter/ent/db/predicate/predicate.go (1)

112-124: LGTM: Consistent predicate implementation.

The BillingInvoiceSplitLineGroup predicate type and BillingInvoiceSplitLineGroupOrErr helper function follow the established pattern used for other entity predicates and maintain proper alphabetical ordering.

openmeter/ent/db/hook/hook.go (1)

204-214: LGTM! Consistent adapter pattern implementation.

The new BillingInvoiceSplitLineGroupFunc adapter follows the exact same pattern as all other mutation adapters in this file, with proper type assertion and error handling.

openmeter/ent/schema/subscription.go (3)

58-58: LGTM! Proper edge definition for Subscription entity.

The new billing_split_line_groups edge establishes a clear one-to-many relationship to the BillingInvoiceSplitLineGroup entity.


105-105: LGTM! Consistent edge definition for SubscriptionPhase entity.

The edge definition matches the pattern used in the Subscription entity, maintaining consistency across related entities.


201-201: LGTM! Consistent edge definition for SubscriptionItem entity.

The edge definition follows the same pattern, completing the relationship model across all subscription-related entities.

openmeter/ent/db/subscription/where.go (1)

891-912: LGTM! Consistent predicate implementation for new edge.

Both HasBillingSplitLineGroups and HasBillingSplitLineGroupsWith predicates follow the established pattern used by all other edge predicates in this file, enabling proper relationship querying capabilities.

openmeter/ent/db/subscriptionitem/where.go (1)

1288-1309: LGTM! New edge predicates follow established patterns correctly.

The added predicates for the billing_split_line_groups edge are implemented consistently with the existing edge predicates in the file. The functions correctly:

  • Use one-to-many (sqlgraph.O2M) edge configuration
  • Follow the standard HasEdge and HasEdgeWith naming pattern
  • Implement proper SQL graph traversal logic
  • Maintain consistency with similar predicates like HasBillingLines

Since this is generated code as part of the broader BillingInvoiceSplitLineGroup entity integration, the implementation should be reliable.

openmeter/ent/db/runtime.go (5)

25-25: LGTM: Import addition is correct.

The import for the new billinginvoicesplitlinegroup package is properly added and follows the established import pattern.


514-515: LGTM: Second mixin layer support added correctly.

The addition of billinginvoicelineMixinFields1 properly supports the second mixin layer for BillingInvoiceLine, which is consistent with the schema changes introducing new fields through additional mixins.


533-533: LGTM: Field descriptor reference updated correctly.

The currency field descriptor reference has been updated from billinginvoicelineMixinFields0[2] to billinginvoicelineMixinFields1[2] to reflect the new mixin structure where currency is now in the second mixin layer.


537-537: LGTM: Ratecard discounts field index updated.

The field index for ratecard_discounts has been updated to billinginvoicelineFields[7], which reflects the correct position in the fields array after schema modifications.


603-637: LGTM: New entity initialization follows established patterns.

The initialization code for BillingInvoiceSplitLineGroup correctly follows the established patterns used throughout the file:

  • Proper mixin handling with two mixin layers (ResourceMixin and InvoiceLineBaseMixin)
  • Standard field descriptor setup for namespace, timestamps, and currency validation
  • Correct value scanner configuration for complex types:
    • RatecardDiscounts using field.TypeValueScanner[*billing.Discounts]
    • Price using field.TypeValueScanner[*productcatalog.Price]
  • Default ID generator setup

The implementation is consistent with other entities in the codebase and properly handles the custom Go types with appropriate value scanners.

openmeter/ent/db/subscriptionphase/where.go (1)

752-773: LGTM! Clean implementation of billing split line groups predicates.

The new predicate functions follow the established pattern perfectly, using the same sqlgraph approach as existing edge predicates like HasBillingLines() and HasBillingLinesWith(). The implementation is consistent with the codebase conventions.

openmeter/ent/db/subscriptionphase.go (3)

58-62: LGTM! Proper edge field addition and loadedTypes expansion.

The new BillingSplitLineGroups edge field is correctly added to the SubscriptionPhaseEdges struct, and the loadedTypes array is appropriately expanded from [3]bool to [4]bool to track the loading state of the new edge.


94-101: LGTM! Correct implementation of edge accessor method.

The BillingSplitLineGroupsOrErr() method follows the established pattern and correctly uses loadedTypes[3] for the new edge, maintaining consistency with other edge accessor methods.


236-239: LGTM! Consistent query method implementation.

The QueryBillingSplitLineGroups() method follows the same pattern as other edge query methods, properly delegating to the client's query method.

openmeter/ent/db/subscription_create.go (3)

16-16: LGTM! Correct import addition.

The import for the billinginvoicesplitlinegroup package is properly added to support the new edge functionality.


229-242: LGTM! Consistent edge addition methods.

The AddBillingSplitLineGroupIDs() and AddBillingSplitLineGroups() methods follow the established pattern perfectly, matching the implementation style of other edge addition methods like AddBillingLineIDs() and AddBillingLines().


511-526: LGTM! Proper SQL graph edge specification.

The edge specification for billing_split_line_groups correctly uses:

  • sqlgraph.O2M (one-to-many) relationship
  • Proper table and column references
  • Correct target field specification

This maintains consistency with other edge specifications in the same method.

openmeter/ent/db/subscriptionitem.go (3)

83-87: LGTM! Consistent edge integration for SubscriptionItem.

The BillingSplitLineGroups edge field and loadedTypes array expansion follow the same pattern as implemented in other entity files, maintaining consistency across the codebase.


121-128: LGTM! Proper edge accessor implementation.

The BillingSplitLineGroupsOrErr() method correctly implements the edge accessor pattern, using loadedTypes[3] for the new edge and following the established error handling approach.


345-348: LGTM! Consistent query method implementation.

The QueryBillingSplitLineGroups() method maintains consistency with other edge query methods and properly delegates to the client implementation.

openmeter/ent/db/paginate.go (1)

780-826: Generated pagination method follows established patterns correctly.

The new Paginate method for BillingInvoiceSplitLineGroupQuery is correctly generated and follows the exact same implementation pattern as all other pagination methods in this file. The type check on line 826 ensures proper interface compliance.

tools/migrate/migrations/20250609104934_billing-split-line-group.up.sql (3)

3-27: Well-structured table creation with appropriate schema design.

The new billing_invoice_split_line_groups table schema is well-designed with:

  • Standard entity fields (id, namespace, metadata, timestamps, soft delete)
  • Domain-specific billing fields (period, currency, tax_config, price)
  • Proper foreign key relationships to subscription entities
  • Consistent use of ON DELETE SET NULL for maintaining data integrity

28-35: Excellent index strategy for performance and data integrity.

The indexing strategy is well thought out:

  • Unique index on id for primary key lookups
  • Namespace-based indexes for tenant isolation
  • Conditional unique index on namespace + unique_reference_id properly handles soft-deleted records by excluding NULL values

37-37: Non-breaking foreign key addition to existing table.

The addition of the nullable split_line_group_id column to billing_invoice_lines is properly implemented:

  • Nullable column ensures no breaking changes to existing data
  • Foreign key constraint with ON DELETE SET NULL maintains referential integrity
  • Constraint naming follows established conventions
openmeter/ent/db/subscriptionitem_create.go (3)

16-16: LGTM: Import addition is correctly placed and necessary.

The import for billinginvoicesplitlinegroup package is properly added to support the new edge relationship functionality.


291-304: LGTM: Edge methods follow established patterns consistently.

The new AddBillingSplitLineGroupIDs and AddBillingSplitLineGroups methods are implemented correctly:

  • Method signatures and parameter handling match existing edge methods
  • ID extraction logic in AddBillingSplitLineGroups follows the same pattern as AddBillingLines
  • Proper delegation to the underlying mutation object

610-625: LGTM: SQL graph creation logic is correctly implemented.

The edge specification for billing_split_line_groups is properly configured:

  • Uses appropriate O2M relationship type for one-to-many association
  • References correct table/column constants and target ID specification
  • Follows the same pattern as the existing billing_lines edge above
openmeter/ent/db/subscriptionphase_create.go (3)

16-16: LGTM: Import addition is consistent and necessary.

The import for billinginvoicesplitlinegroup package is properly added, maintaining consistency with the corresponding changes in subscriptionitem_create.go.


185-198: LGTM: Edge methods are consistently implemented.

The AddBillingSplitLineGroupIDs and AddBillingSplitLineGroups methods maintain perfect consistency with:

  • The corresponding methods in subscriptionitem_create.go
  • Existing edge method patterns in this file
  • Proper ID extraction and delegation logic

420-435: LGTM: SQL graph creation follows correct patterns.

The edge specification is properly implemented:

  • Consistent O2M relationship configuration with subscriptionitem_create.go
  • Uses appropriate package constants for table and column references
  • Correct target ID specification
  • Maintains the established pattern for edge creation in this file
openmeter/ent/db/subscription/subscription.go (4)

51-52: LGTM! Edge constant follows established naming conventions.

The new EdgeBillingSplitLineGroups constant maintains consistency with existing edge naming patterns.


85-91: LGTM! Table and column constants are correctly defined.

The relationship constants properly reference the billing_invoice_split_line_groups table with subscription_id as the foreign key column, maintaining consistency with the database schema.


262-274: LGTM! Ordering functions follow established patterns.

Both ByBillingSplitLineGroupsCount and ByBillingSplitLineGroups correctly implement the ordering interface using sqlgraph.OrderByNeighborsCount and sqlgraph.OrderByNeighborTerms respectively, consistent with other edge ordering functions.


317-323: LGTM! SQL graph step correctly defines the relationship.

The newBillingSplitLineGroupsStep() function properly configures a one-to-many (sqlgraph.O2M) relationship from subscription to billing split line groups with correct table and column references.

openmeter/ent/db/subscriptionphase/subscriptionphase.go (4)

45-46: LGTM! Edge constant maintains consistency.

The EdgeBillingSplitLineGroups constant follows the same naming convention as the subscription entity.


70-76: LGTM! Relationship constants are entity-appropriate.

The constants correctly use subscription_phase_id as the foreign key column, properly linking billing split line groups to subscription phases.


217-229: LGTM! Ordering functions maintain established patterns.

Both ordering functions correctly implement the same interface pattern as other entities, ensuring consistent query behavior across the schema.


251-257: LGTM! SQL graph step properly configured.

The step function correctly defines the one-to-many relationship with the appropriate foreign key column for subscription phases.

openmeter/ent/db/billinginvoicesplitlinegroup_delete.go (4)

15-26: LGTM! Delete builder follows standard Ent patterns.

The BillingInvoiceSplitLineGroupDelete struct and Where method correctly implement the standard Ent delete builder interface.


28-40: LGTM! Execution methods properly handle hooks and errors.

Both Exec and ExecX methods follow the established pattern with proper hook integration and panic-on-error behavior.


42-57: LGTM! SQL execution correctly implements delete logic.

The sqlExec method properly constructs the delete specification using sqlgraph.NewDeleteSpec with correct table and field references, and includes appropriate constraint error handling.


59-88: LGTM! Single delete builder properly handles not found case.

The BillingInvoiceSplitLineGroupDeleteOne implementation correctly returns NotFoundError when no entity is affected, following the standard Ent pattern for single entity operations.

openmeter/ent/db/subscription.go (5)

66-67: LGTM! New edge properly added to edges struct.

The BillingSplitLineGroups edge correctly follows the established pattern for slice-type edges.


72-72: LGTM! LoadedTypes array correctly expanded.

The array size increased from 5 to 6 to accommodate the new edge loading state tracking.


115-122: LGTM! Edge accessor follows established pattern.

The BillingSplitLineGroupsOrErr() method correctly implements the standard edge accessor pattern with appropriate error handling for unloaded edges.


127-127: LGTM! Index correctly updated for array expansion.

The AddonsOrErr() method properly updated its loadedTypes index from 4 to 5 to account for the new edge insertion.


284-287: LGTM! Query method follows established pattern.

The QueryBillingSplitLineGroups() method correctly delegates to the subscription client, maintaining consistency with other edge query methods.

openmeter/ent/db/subscriptionitem/subscriptionitem.go (3)

69-70: Edge constants properly defined following established patterns.

The new EdgeBillingSplitLineGroups constant and related table/column constants follow the exact same pattern as existing edges like EdgeBillingLines, ensuring consistency in the codebase.

Also applies to: 94-100


308-320: Ordering functions correctly implemented.

The ByBillingSplitLineGroupsCount and ByBillingSplitLineGroups functions follow the same pattern as existing ordering functions, using the appropriate sqlgraph methods for neighbor counting and term ordering.


342-348: Graph step creation follows correct pattern.

The newBillingSplitLineGroupsStep function correctly defines an O2M (one-to-many) relationship from subscription items to billing split line groups, which is the appropriate relationship type for this use case.

openmeter/ent/db/subscription_update.go (4)

15-15: Import correctly added for new entity package.

The import for billinginvoicesplitlinegroup package is properly added to support the new edge relationship operations.


197-210: Add methods properly implemented for both update builders.

The AddBillingSplitLineGroupIDs and AddBillingSplitLineGroups methods are correctly implemented for both SubscriptionUpdate and SubscriptionUpdateOne, following the exact same pattern as existing edge add methods.

Also applies to: 806-819


280-299: Clear and remove methods consistently implemented.

The clear and remove methods for billing_split_line_groups edge follow the established patterns, providing complete edge management functionality for both update builders.

Also applies to: 889-908


535-579: SQL edge specifications correctly implemented.

The edge specifications in both sqlSave methods properly handle the O2M relationship using the correct table (subscription.BillingSplitLineGroupsTable) and column (subscription.BillingSplitLineGroupsColumn) constants, following the same pattern as existing edge relationships.

Also applies to: 1174-1218

openmeter/ent/db/subscriptionitem_update.go (6)

15-15: LGTM: Import addition is consistent with new entity support.

The import for the new billinginvoicesplitlinegroup package is correctly added to support the new edge functionality.


342-355: LGTM: Edge management methods follow established patterns.

The AddBillingSplitLineGroupIDs and AddBillingSplitLineGroups methods follow the same implementation pattern as other edge management methods in the file, properly delegating to the mutation layer and handling ID extraction.


389-408: LGTM: Clear and remove methods are correctly implemented.

The clear and remove methods for the billing split line groups edge follow the established patterns for edge management, providing both ID-based and entity-based variants.


678-722: LGTM: SQL edge specifications are correctly defined.

The SQL save logic properly handles the new edge relationship with:

  • Correct relationship type (O2M, inverse=false)
  • Proper table and column references
  • Consistent edge clearing, removal, and addition logic following the same pattern as the "billing_lines" edge

1049-1115: LGTM: SubscriptionItemUpdateOne methods mirror the bulk update functionality.

The edge management methods for SubscriptionItemUpdateOne correctly mirror the functionality provided by SubscriptionItemUpdate, maintaining consistency between single and bulk update operations.


1415-1459: LGTM: SQL logic for single entity updates is consistent.

The SQL save logic for SubscriptionItemUpdateOne properly implements the same edge management patterns as the bulk update variant, ensuring consistent behavior across different update operations.

openmeter/ent/db/billinginvoiceline_query.go (9)

21-21: LGTM: Import addition supports new edge functionality.

The import for billinginvoicesplitlinegroup package is correctly added to enable query operations on the new edge relationship.


37-37: LGTM: Query field addition follows established pattern.

The withSplitLineGroup field is properly added to the query struct, following the same naming convention and type pattern as other edge query fields.


107-127: LGTM: Query chaining method is correctly implemented.

The QuerySplitLineGroup method properly implements query chaining for the split line group edge with:

  • Correct edge configuration (M2O, inverse=true)
  • Proper table and column references
  • Consistent error handling and SQL graph setup

520-520: LGTM: Clone method updated to include new field.

The clone operation correctly includes the withSplitLineGroup field to ensure proper query builder cloning behavior.


547-556: LGTM: Eager-loading method follows established pattern.

The WithSplitLineGroup method correctly implements eager-loading functionality with proper query builder configuration and option handling.


736-748: LGTM: LoadedTypes array properly updated.

The loadedTypes array size is correctly updated from 10 to 11, and the new boolean for withSplitLineGroup is properly positioned in the array to maintain consistency with the loading logic.


783-788: LGTM: Eager-loading integration is correctly implemented.

The eager-loading logic for the split line group is properly integrated into the sqlAll method, following the same pattern as other many-to-one relationships.


884-915: LGTM: Loading method properly handles nullable foreign key.

The loadSplitLineGroup method correctly implements the loading logic with:

  • Proper null check for the optional SplitLineGroupID field (lines 888-890)
  • Correct foreign key handling and batch loading
  • Appropriate error handling for unexpected foreign key values
  • Consistent implementation pattern matching other loading methods

1234-1236: LGTM: Query specification includes foreign key column when needed.

The query spec method correctly adds the SplitLineGroupID column when the split line group edge is being eagerly loaded, ensuring the foreign key is available for the loading process.

openmeter/ent/db/billinginvoicesplitlinegroup/where.go (1)

1-1150: LGTM!

This auto-generated predicate file follows standard Ent framework patterns and provides comprehensive filtering capabilities for the new BillingInvoiceSplitLineGroup entity.

openmeter/ent/db/subscription_query.go (1)

17-17: LGTM!

The integration of the billing_split_line_groups edge follows the established patterns for O2M relationships in the query builder. The implementation is consistent with other edges in terms of query methods, eager loading, and error handling.

Also applies to: 29-38, 164-184, 395-405, 456-465, 556-562, 612-620, 756-788

openmeter/ent/db/billinginvoiceline.go (1)

18-18: LGTM!

The integration of new fields (PeriodStart, PeriodEnd, Currency, TaxConfig) and the SplitLineGroup edge is properly implemented. The nullable foreign key SplitLineGroupID is correctly handled, and all edge indices have been properly updated throughout the file.

Also applies to: 46-53, 94-95, 112-113, 134-134, 148-157, 263-263, 340-365, 493-499, 539-542, 637-648, 725-729

openmeter/ent/db/subscriptionphase_update.go (6)

15-15: LGTM - Import added for new entity support.

The import for billinginvoicesplitlinegroup package is correctly added to support the new edge operations.


163-176: LGTM - Add methods follow established patterns.

The AddBillingSplitLineGroupIDs and AddBillingSplitLineGroups methods correctly follow the same implementation pattern used for other edges like billing_lines.


225-244: LGTM - Clear and remove methods implemented correctly.

The clear and remove operations for billing_split_line_groups edge are implemented consistently with existing edge patterns, providing proper entity and ID-based removal methods.


430-474: LGTM - SQL edge handling follows correct patterns.

The SQL generation for the billing_split_line_groups edge operations (clear, remove, add) correctly uses sqlgraph.EdgeSpec with proper relationship configuration (O2M, non-inverse) matching the schema definition.


624-637: LGTM - Single entity update methods implemented consistently.

The SubscriptionPhaseUpdateOne builder includes the same complete set of methods for managing the billing_split_line_groups edge, maintaining consistency with the bulk update builder.

Also applies to: 686-705


921-965: LGTM - Single entity SQL operations match bulk operations.

The SQL edge handling in SubscriptionPhaseUpdateOne.sqlSave correctly mirrors the bulk operation logic, ensuring consistent behavior across both update builders.

openmeter/ent/db/billinginvoiceline/billinginvoiceline.go (6)

34-41: LGTM - New field constants follow established conventions.

The new field constants (FieldPeriodStart, FieldPeriodEnd, FieldCurrency, FieldTaxConfig, FieldSplitLineGroupID) are properly defined following the existing naming pattern and are correctly positioned in the constants section.

Also applies to: 82-83


88-89: LGTM - Edge and relationship constants properly defined.

The EdgeSplitLineGroup constant and related table/column definitions (SplitLineGroupTable, SplitLineGroupInverseTable, SplitLineGroupColumn) correctly establish the relationship metadata following Ent conventions.

Also applies to: 117-123


193-196: LGTM - Columns slice updated to include new fields.

The Columns slice is properly updated to include all new fields (FieldPeriodStart, FieldPeriodEnd, FieldCurrency, FieldTaxConfig, FieldSplitLineGroupID), ensuring they are available for database operations.

Also applies to: 217-217


334-347: LGTM - Ordering functions implemented consistently.

The ordering functions for new fields (ByPeriodStart, ByPeriodEnd, ByCurrency, BySplitLineGroupID) follow the established pattern using sql.OrderByField and proper option handling.

Also applies to: 449-452


466-471: LGTM - Edge ordering function correctly implemented.

The BySplitLineGroupField function properly uses sqlgraph.OrderByNeighborTerms with the newSplitLineGroupStep() helper, following the same pattern as other edge ordering functions.


563-569: LGTM - SQL graph step function correctly defines relationship.

The newSplitLineGroupStep() function properly defines the many-to-one relationship using sqlgraph.M2O with correct table and column references, enabling proper SQL generation for edge traversal.

openmeter/ent/db/subscriptionitem_query.go (7)

17-17: LGTM - Import added for new entity support.

The import for billinginvoicesplitlinegroup package is correctly added to support the new edge query operations.


34-34: LGTM - Query struct updated with new edge field.

The withBillingSplitLineGroups field is properly added to the SubscriptionItemQuery struct to track eager-loading state for the new edge.


138-158: LGTM - Query chaining method implemented correctly.

The QueryBillingSplitLineGroups method properly implements query chaining for the new edge, following the same pattern as other edge query methods with correct SQL graph step configuration.


355-355: LGTM - Clone method updated to preserve edge state.

The Clone method correctly includes the new withBillingSplitLineGroups field in the cloning operation, ensuring all query state is properly preserved.


395-404: LGTM - Eager loading method implemented consistently.

The WithBillingSplitLineGroups method properly implements eager loading configuration for the new edge, following the established pattern with option handling and query setup.


484-488: LGTM - SQL loading logic properly integrated.

The sqlAll method correctly updates the loadedTypes array size to 4 and includes proper loading logic for the billing_split_line_groups edge with appropriate initialization and assignment functions.

Also applies to: 533-541


640-672: LGTM - Batch loading method implemented correctly.

The loadBillingSplitLineGroups method properly implements batched loading for the new edge relationship, following the same foreign key pattern as other edges with correct error handling and node assignment.

openmeter/ent/db/subscriptionphase_query.go (1)

17-671: LGTM! The billing split line groups edge integration is correctly implemented.

The changes properly integrate the new billing_split_line_groups edge into the SubscriptionPhase query builder, following the established patterns for edge management in the ent framework. The implementation includes:

  • Correct array size adjustment for loaded types tracking
  • Proper O2M (One-to-Many) relationship configuration
  • Consistent error handling with nil foreign key checks
  • Standard eager-loading and query chaining support
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (1)

1-298: LGTM! Standard ent-generated entity metadata.

This auto-generated file correctly defines the schema constants, validators, and ordering functions for the new BillingInvoiceSplitLineGroup entity. The edge definitions properly establish relationships with:

  • billing_invoice_lines (O2M)
  • subscription (M2O)
  • subscription_phase (M2O)
  • subscription_item (M2O)
openmeter/ent/db/billinginvoicesplitlinegroup.go (1)

1-411: LGTM! Well-structured entity model with comprehensive edge support.

The auto-generated BillingInvoiceSplitLineGroup entity properly implements:

  • Appropriate field types including domain-specific types (currencyx.Code, productcatalog.TaxConfig)
  • Robust edge accessor methods with proper error handling for unloaded edges
  • Correct SQL scanning for nullable fields and JSON unmarshalling for complex types
  • Standard query, update, and transaction unwrapping methods

The entity successfully encapsulates the split line group concept for organizing billing invoice lines by subscription context.

openmeter/ent/db/migrate/schema.go (3)

736-739: Column reordering looks good.

The reordering of period_start, period_end, currency, and tax_config columns to appear earlier in the column definition provides better logical grouping of related billing fields.


760-760: Foreign key relationship properly implemented.

The new split_line_group_id column and its foreign key constraint to BillingInvoiceSplitLineGroups table are correctly defined with SetNull on delete, which is appropriate for an optional relationship.

Also applies to: 795-800


974-1046: New table structure is well-designed.

The BillingInvoiceSplitLineGroups table follows the established patterns with:

  • Proper column definitions and types
  • Appropriate foreign key constraints with SetNull on delete
  • Comprehensive indexes including a unique constraint on namespace + unique_reference_id with soft delete support
openmeter/ent/schema/billing.go (2)

295-318: Well-structured mixin for common invoice line fields

The InvoiceLineBaseMixin effectively encapsulates shared fields between invoice lines and split line groups, promoting code reuse and consistency.


582-659:

Details

❓ Verification inconclusive

Verify the unique index strategy for split line groups

The unique index on (namespace, unique_reference_id) with the condition unique_reference_id IS NOT NULL AND deleted_at IS NULL allows multiple null values, which is appropriate for optional fields. However, ensure that the unique_reference_id generation logic is well-defined to prevent conflicts.


🏁 Script executed:

#!/bin/bash
# Check how unique_reference_id is generated and used in the codebase
rg -A 5 "unique_reference_id" --type go

Length of output: 73248


Ensure collision-free generation of unique_reference_id for split line groups

The partial unique index on (namespace, unique_reference_id) with the condition
unique_reference_id IS NOT NULL AND deleted_at IS NULL correctly allows multiple NULLs while enforcing uniqueness when populated. Since the Ent schema does not auto-generate this field, please verify in your creation logic that you consistently set unique_reference_id to a globally unique value (for example, a UUID or other deterministic ID) before persisting.

• Schema location: openmeter/ent/schema/billing.goBillingInvoiceSplitLineGroup.Fields() & Indexes()
• Migration index: ent/db/migrate/schema.gobillinginvoicesplitlinegroup_namespace_unique_reference_id

openmeter/ent/db/billinginvoiceline_update.go (1)

1-2585: Generated code changes are consistent and well-structured

The update operations for the new fields (period_start, period_end, tax_config) and the split_line_group edge follow Ent's established patterns correctly. The validation for TaxConfig (lines 782-786, 2054-2058) ensures data integrity.

openmeter/ent/db/client.go (6)

34-34: Import correctly added.

The new import follows the established pattern and maintains alphabetical ordering.


102-103: Client integration follows established patterns.

The new entity client is properly integrated across all initialization points, hooks, interceptors, and mutation handling, maintaining consistency with other entities in the codebase.

Also applies to: 183-183, 318-318, 380-380, 441-441, 463-463, 511-512


2951-2965: Edge query method properly implemented.

The QuerySplitLineGroup method correctly implements the many-to-one relationship from BillingInvoiceLine to BillingInvoiceSplitLineGroup.


3434-3629: Complete entity client implementation.

The BillingInvoiceSplitLineGroupClient provides all standard CRUD operations and edge queries, following the established Ent framework patterns consistently.


7087-7101: Subscription edge queries correctly implemented.

The QueryBillingSplitLineGroups methods on Subscription, SubscriptionItem, and SubscriptionPhase clients properly implement the one-to-many relationships to BillingInvoiceSplitLineGroup.

Also applies to: 7630-7644, 7827-7841


8025-8025: Hook and interceptor types updated correctly.

The new entity is properly added to both the hooks and interceptors type definitions, maintaining alphabetical ordering.

Also applies to: 8039-8039

openmeter/ent/db/billinginvoicesplitlinegroup_query.go (1)

1-884: Generated query builder looks good.

This auto-generated file correctly implements the query builder for the new BillingInvoiceSplitLineGroup entity with proper support for edges, eager loading, aggregation, and concurrency control.

openmeter/ent/db/setorclear.go (1)

1024-1037: SetOrClear methods correctly implemented.

The new SetOrClear methods for BillingInvoiceLine and BillingInvoiceSplitLineGroup follow the established pattern and properly handle nullable fields. This supports the schema changes for the new split line group functionality.

Also applies to: 1150-1163, 1388-1527

openmeter/ent/db/billinginvoiceline_create.go (1)

1-2762: LGTM!

The auto-generated code correctly implements the new BillingInvoiceSplitLineGroup integration with proper:

  • Field setters for period_start, period_end, currency, tax_config, and split_line_group_id
  • Edge relationship configuration for the M2O split_line_group edge
  • Field validation including currency format and tax config validation
  • Consistent upsert operation support for all new fields
openmeter/ent/db/billinginvoicesplitlinegroup_create.go (1)

837-854: Good design: Currency field is immutable during upserts

The UpdateNewValues() method correctly treats the currency field as immutable alongside ID, Namespace, and CreatedAt. This prevents accidental currency changes during updates, which is a good practice for maintaining data consistency in billing systems.

openmeter/ent/db/billinginvoiceline/where.go (1)

1-2127: Generated code follows consistent patterns

The predicate implementations for the new fields (PeriodStart, PeriodEnd, Currency, TaxConfig, SplitLineGroupID) and edges (SplitLineGroup) are correctly generated and follow the established patterns in the codebase.

openmeter/ent/db/billinginvoicesplitlinegroup_update.go (1)

1-1208: Update builders properly implemented

The update builders for BillingInvoiceSplitLineGroup are correctly generated with:

  • Comprehensive field setters with proper nil handling
  • Correct edge management for both O2M (billing_invoice_lines) and M2O (subscription relationships) edges
  • Appropriate error handling and constraint error wrapping
  • Proper value scanning for complex types

@turip turip enabled auto-merge (squash) June 9, 2025 13:10
@turip turip requested review from hekike and tothandras June 9, 2025 13:21

// Subscriptions metadata
field.String("subscription_id").
Optional().
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.Immutable()?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
openmeter/ent/schema/billing.go (2)

612-615: Review comment has been addressed.

The immutable flags have been added to feature_key and price fields as requested in the past review comments.

Also applies to: 617-622


625-638: Good use of immutable constraints.

The subscription metadata fields (subscription_id, subscription_phase_id, subscription_item_id) are correctly marked as immutable, as noted in the past review. This prevents accidental modifications to these reference fields.

🧹 Nitpick comments (3)
openmeter/ent/schema/billing.go (3)

331-333: Track the TODO for field renaming.

The TODO comment indicates that period_start and period_end should be renamed to service_period_start and service_period_end for consistency. This should be tracked to ensure the migration is completed.

Would you like me to create an issue to track this field renaming task?


403-409: Consider the design implications of the split_line_group_id field.

The comment indicates this field is "only valid for ubp lines" but is added to the general BillingInvoiceLine table. This suggests that the table might eventually be split or specialized. Consider whether this field should be part of a more specific entity or if the current design is a stepping stone to a future refactoring.


599-601: Consider adding validation for unique_reference_id format.

Based on the past review comments, this field has a specific format like 01JMAY1MBNCBHZ9WZ2CM7GFESQ/default/input_tokens_used/v[0]/period[0]. Consider adding a validation function to ensure the format is correct when the field is populated.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27c7182 and f9df1b8.

⛔ Files ignored due to path filters (1)
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum
📒 Files selected for processing (16)
  • openmeter/ent/db/billinginvoiceline.go (23 hunks)
  • openmeter/ent/db/billinginvoiceline/billinginvoiceline.go (10 hunks)
  • openmeter/ent/db/billinginvoiceline/where.go (7 hunks)
  • openmeter/ent/db/billinginvoiceline_create.go (21 hunks)
  • openmeter/ent/db/billinginvoiceline_update.go (19 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup/where.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup_create.go (1 hunks)
  • openmeter/ent/db/billinginvoicesplitlinegroup_update.go (1 hunks)
  • openmeter/ent/db/migrate/schema.go (7 hunks)
  • openmeter/ent/db/runtime.go (4 hunks)
  • openmeter/ent/db/setorclear.go (3 hunks)
  • openmeter/ent/schema/billing.go (4 hunks)
  • tools/migrate/migrations/20250609172811_billing-split-line-group.down.sql (1 hunks)
  • tools/migrate/migrations/20250609172811_billing-split-line-group.up.sql (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tools/migrate/migrations/20250609172811_billing-split-line-group.down.sql
🚧 Files skipped from review as they are similar to previous changes (7)
  • openmeter/ent/db/billinginvoicesplitlinegroup/where.go
  • openmeter/ent/db/billinginvoiceline/billinginvoiceline.go
  • openmeter/ent/db/billinginvoicesplitlinegroup.go
  • openmeter/ent/db/runtime.go
  • openmeter/ent/db/migrate/schema.go
  • openmeter/ent/db/billinginvoiceline.go
  • openmeter/ent/db/setorclear.go
🧰 Additional context used
🧬 Code Graph Analysis (2)
openmeter/ent/db/billinginvoicesplitlinegroup_update.go (9)
openmeter/ent/db/ent.go (7)
  • Hook (66-66)
  • Mutation (78-78)
  • Value (67-67)
  • NotFoundError (284-286)
  • IsConstraintError (367-373)
  • ConstraintError (351-354)
  • ValidationError (259-262)
openmeter/ent/db/mutation.go (1)
  • BillingInvoiceSplitLineGroupMutation (21698-21731)
openmeter/ent/db/billinginvoicesplitlinegroup.go (2)
  • BillingInvoiceSplitLineGroup (23-67)
  • BillingInvoiceSplitLineGroup (127-146)
openmeter/ent/schema/billing.go (10)
  • BillingInvoiceSplitLineGroup (583-585)
  • BillingInvoiceSplitLineGroup (587-592)
  • BillingInvoiceSplitLineGroup (594-640)
  • BillingInvoiceSplitLineGroup (642-649)
  • BillingInvoiceSplitLineGroup (651-670)
  • BillingInvoiceLine (317-319)
  • BillingInvoiceLine (321-327)
  • BillingInvoiceLine (329-420)
  • BillingInvoiceLine (422-432)
  • BillingInvoiceLine (434-475)
openmeter/ent/db/predicate/predicate.go (2)
  • BillingInvoiceSplitLineGroup (113-113)
  • BillingInvoiceLine (71-71)
openmeter/ent/db/billinginvoiceline.go (2)
  • BillingInvoiceLine (28-106)
  • BillingInvoiceLine (253-278)
openmeter/ent/db/billinginvoicesplitlinegroup/where.go (8)
  • ID (15-17)
  • UpdatedAt (80-82)
  • DeletedAt (85-87)
  • Name (90-92)
  • Description (95-97)
  • ServicePeriodStart (106-108)
  • ServicePeriodEnd (111-113)
  • UniqueReferenceID (116-118)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (17)
  • Table (65-65)
  • Columns (97-117)
  • FieldID (19-19)
  • FieldMetadata (23-23)
  • FieldUpdatedAt (27-27)
  • FieldDeletedAt (29-29)
  • FieldName (31-31)
  • FieldDescription (33-33)
  • FieldTaxConfig (37-37)
  • FieldServicePeriodStart (39-39)
  • FieldServicePeriodEnd (41-41)
  • FieldUniqueReferenceID (43-43)
  • ValueScanner (143-146)
  • FieldRatecardDiscounts (45-45)
  • FieldFeatureKey (47-47)
  • BillingInvoiceLinesTable (67-67)
  • BillingInvoiceLinesColumn (72-72)
openmeter/ent/db/migrate/schema.go (1)
  • BillingInvoiceLinesTable (766-860)
openmeter/ent/db/billinginvoiceline_create.go (8)
pkg/currencyx/currency.go (1)
  • Code (12-12)
openmeter/productcatalog/tax.go (1)
  • TaxConfig (36-39)
openmeter/ent/db/billinginvoiceline/where.go (6)
  • ID (17-19)
  • Currency (102-105)
  • Name (92-94)
  • PeriodStart (143-145)
  • PeriodEnd (148-150)
  • SplitLineGroupID (198-200)
openmeter/ent/db/billinginvoicesplitlinegroup/where.go (3)
  • ID (15-17)
  • Currency (100-103)
  • Name (90-92)
openmeter/ent/db/ent.go (1)
  • ValidationError (259-262)
openmeter/billing/errors.go (1)
  • ValidationError (119-119)
openmeter/ent/db/billinginvoiceline/billinginvoiceline.go (11)
  • CurrencyValidator (257-257)
  • FieldCurrency (35-35)
  • FieldTaxConfig (37-37)
  • FieldManagedBy (59-59)
  • Table (109-109)
  • Columns (184-218)
  • FieldID (19-19)
  • FieldPeriodStart (53-53)
  • FieldPeriodEnd (55-55)
  • FieldSplitLineGroupID (83-83)
  • FieldType (65-65)
openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (6)
  • CurrencyValidator (139-139)
  • FieldCurrency (35-35)
  • FieldTaxConfig (37-37)
  • Table (65-65)
  • Columns (97-117)
  • FieldID (19-19)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Artifacts / Benthos Collector Container image
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Commit hooks
  • GitHub Check: Quickstart
  • GitHub Check: Lint
  • GitHub Check: Developer environment
  • GitHub Check: E2E
  • GitHub Check: CI
  • GitHub Check: Build
  • GitHub Check: Migration Checks
  • GitHub Check: Test
🔇 Additional comments (39)
tools/migrate/migrations/20250609172811_billing-split-line-group.up.sql (3)

1-26: Well-designed table schema with proper relationships and constraints.

The new billing_invoice_split_line_groups table follows excellent database design practices:

  • Appropriate data types for all fields (character(26) for ULID IDs, jsonb for flexible data)
  • Comprehensive field set covering business requirements (currency, tax config, service periods, pricing)
  • Proper foreign key relationships to subscription-related tables with SET NULL on delete
  • Consistent with existing schema patterns in the codebase

27-34: Excellent index strategy for performance and data integrity.

The indexing approach is well thought out:

  • Unique index on ID for primary key enforcement
  • Namespace index for tenant-based queries
  • Composite unique index on (namespace, id) for efficient lookups
  • Conditional unique index ensuring uniqueness of reference IDs only for active, non-deleted records

The partial index condition (unique_reference_id IS NOT NULL) AND (deleted_at IS NULL) is particularly well-designed for supporting soft deletes while maintaining business constraints.


35-36: Clean integration with existing table structure.

The modification to billing_invoice_lines properly establishes the relationship:

  • Nullable foreign key allows optional association with split line groups
  • Foreign key constraint ensures referential integrity
  • SET NULL on delete prevents orphaned references while preserving data integrity
openmeter/ent/db/billinginvoiceline_update.go (11)

21-21: Correct import for the new entity.

Properly imports the billinginvoicesplitlinegroup package to support the new relationship.


115-133: Good code consolidation for tax_config field.

The consolidation of setter, nillable setter, and clearer methods for tax_config removes duplication and follows a cleaner pattern. This is consistent with how other similar fields should be handled.


233-259: Clean consolidation of period field setters.

The refactoring of period_start and period_end setters eliminates code duplication while maintaining the same functionality. This follows the established pattern used elsewhere in the codebase.


469-487: Standard field setter implementation for split_line_group_id.

The implementation follows Ent patterns correctly:

  • Regular setter for direct value assignment
  • Nillable setter for optional value handling
  • Clearer method for removing the association
  • Consistent naming and method signatures

520-523: Proper edge setter implementation.

The SetSplitLineGroup method correctly establishes the relationship by using the entity's ID, following the standard Ent pattern for M2O relationships.


639-643: Appropriate edge clearer method.

The ClearSplitLineGroup method properly removes the edge relationship, maintaining consistency with other similar edge management methods.


782-786: Proper validation integration.

The validation check for tax_config using v.Validate() is correctly integrated into the check method, ensuring data integrity during updates.


944-972: Correct SQL edge specification for split_line_group.

The SQL edge handling properly:

  • Uses M2O relationship with inverse=true indicating the foreign key is on this side
  • References the correct table and column names from the migration
  • Handles both clearing and adding edge operations
  • Follows the established pattern for similar relationships

1728-1746: Consistent implementation in UpdateOne builder.

The BillingInvoiceLineUpdateOne builder includes the same complete set of methods for managing the split_line_group_id field, maintaining consistency between bulk and single update operations.


1779-1782: Proper edge setter in UpdateOne builder.

The single-entity update builder correctly implements the same edge management pattern as the bulk update builder.


2233-2261: Correct SQL implementation in UpdateOne.

The single-entity update SQL generation correctly mirrors the bulk update implementation, ensuring consistent behavior across both update patterns.

openmeter/ent/schema/billing.go (2)

295-316: Good refactoring to extract common invoice line fields.

The introduction of InvoiceLineBaseMixin properly encapsulates common fields (currency and tax_config) that are shared between invoice line entities. This follows the DRY principle and improves maintainability.

Also applies to: 324-324


642-649: Well-designed unique constraint.

The unique partial index on (namespace, unique_reference_id) with the condition unique_reference_id IS NOT NULL AND deleted_at IS NULL is properly implemented. This ensures uniqueness only for non-deleted entries with a reference ID.

openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go (1)

1-299: Generated code looks correct.

This is auto-generated code by Ent framework that properly implements the schema defined in billing.go. No manual changes should be made to this file.

openmeter/ent/db/billinginvoiceline_create.go (8)

22-22: LGTM: Import addition for split line group relationship

The import is properly positioned and necessary for the new edge relationship to BillingInvoiceSplitLineGroup.


113-117: LGTM: New field setter methods are well-implemented

The setter methods follow Ent's standard patterns and provide appropriate nullable variants for optional fields. The type usage is consistent with the schema definition.

Also applies to: 119-131, 175-185, 321-333


374-377: LGTM: Edge setter method correctly implemented

The SetSplitLineGroup method follows Ent's standard pattern for establishing relationships via foreign key assignment.


690-697: LGTM: Database spec generation correctly implemented

The createSpec() method properly handles the new fields and edge relationship. The many-to-one relationship configuration and pointer assignment for optional SplitLineGroupID are correctly implemented.

Also applies to: 726-733, 791-807


1088-1104: LGTM: Upsert methods comprehensively implemented

All upsert builders (single, bulk) include proper setter, updater, and clearer methods for the new fields. The implementation maintains consistency across all upsert operation types.

Also applies to: 1190-1212, 1406-1422, 1593-1612, 1712-1738, 1964-1983, 2327-2346, 2446-2472, 2698-2717


1-2762: LGTM: Comprehensive and consistent implementation

The changes successfully add support for new fields (currency, tax_config, period_start, period_end, split_line_group_id) and the split_line_group edge relationship. The implementation:

  • Follows Ent framework patterns consistently
  • Includes proper validation for required fields
  • Handles optional fields with nullable setters
  • Implements complete CRUD and upsert support
  • Configures the database relationship correctly

The generated code appears to correctly implement the schema changes described in the PR objectives.


1465-1470:

Details

❓ Verification inconclusive

LGTM: Immutable field handling in upsert operations

Adding currency and type fields to the ignore list in UpdateNewValues suggests these are intended to be immutable after creation, which is a reasonable design choice for key identifying fields.

Verify that making currency and type immutable in upsert operations aligns with business requirements:

Also applies to: 2198-2203


🏁 Script executed:

#!/bin/bash
# Search for any existing usage patterns of currency updates
rg -A 3 -B 3 "SetCurrency|UpdateCurrency" --type go

Length of output: 20136


🏁 Script executed:

#!/bin/bash
# Search for any existing usage patterns of type updates
rg -A 3 -B 3 "SetType|UpdateType" --type go

Length of output: 54246


Immutable Currency and Type Ignored on Upsert—Confirm Business Requirements

  • Verified that UpdateNewValues now ignores billinginvoiceline.FieldCurrency and billinginvoiceline.FieldType when resolving conflicts:
    • File: openmeter/ent/db/billinginvoiceline_create.go, lines 1465–1470
    • File: openmeter/ent/db/billinginvoiceline_create.go, lines 2198–2203
  • Searches show SetCurrency/UpdateCurrency and SetType/UpdateType exist for other entities’ upserts, but will not apply here due to the new ignore logic.

Please confirm that currency and type must remain immutable on billing invoice line upserts per your business rules.


550-562:

Details

✅ Verification successful

LGTM: Validation logic properly implemented

The validation correctly enforces required fields and applies appropriate validators. The currency conversion to string and tax config's Validate() method call are properly implemented.

Verify that the productcatalog.TaxConfig.Validate() method provides comprehensive validation:

Also applies to: 584-589


🏁 Script executed:

#!/bin/bash
# Search for the TaxConfig Validate method implementation
ast-grep --pattern 'func ($$$) Validate() error {
  $$$
}'

Length of output: 69177


To pinpoint the TaxConfig type and its Validate() implementation, let’s inspect the mutation accessor and the type definition:


🏁 Script executed:

#!/bin/bash
# 1. Locate the TaxConfig accessor in the billing invoice line mutation
grep -n -C3 'TaxConfig' openmeter/ent/db/billinginvoiceline_mutation.go || true

# 2. Find where TaxConfig is declared anywhere in the repo
rg -n 'type TaxConfig' -n .

# 3. Search specifically for a Validate() method on TaxConfig
ast-grep --pattern $'func ($_ TaxConfig) Validate() error { $$$ }'

Length of output: 534


Let’s inspect the TaxConfig definition and its Validate() implementation in openmeter/productcatalog/tax.go:


🏁 Script executed:

#!/bin/bash
# 1. Locate the TaxConfig type
grep -n '^type TaxConfig' openmeter/productcatalog/tax.go

# 2. See if a Validate method is defined on TaxConfig
grep -n 'func .*TaxConfig.*Validate' openmeter/productcatalog/tax.go || true

# 3. Dump the first 200 lines of the file for context
sed -n '1,200p' openmeter/productcatalog/tax.go

Length of output: 2747


✅ Validation logic approved – TaxConfig.Validate is comprehensive

  • TaxConfig.Validate checks both Behavior (if set) and Stripe sub-config, aggregating all errors.
  • StripeTaxConfig.Validate enforces the txcd_######## regex correctly.
  • No missing validation paths or unhandled cases remain.

All required validators are in place; no further changes needed.

openmeter/ent/db/billinginvoicesplitlinegroup_create.go (3)

1-1: Generated code looks structurally correct

The file follows standard Ent patterns for entity creation. The implementation includes proper field setters, validation, edge management, and bulk operations support.


753-784: Correct handling of immutable fields in upsert operations

The UpdateNewValues method properly ignores immutable fields (ID, Namespace, CreatedAt, Currency, FeatureKey, Price, and subscription-related IDs) during upsert operations, which aligns with the schema definition.


314-361: Comprehensive validation implementation

The validation logic correctly checks all required fields and applies custom validators for namespace, currency, tax_config, and price fields. Error messages are descriptive and follow consistent patterns.

openmeter/ent/db/billinginvoicesplitlinegroup_update.go (3)

21-185: Update builders correctly exclude immutable fields

The update implementation appropriately excludes setter methods for immutable fields (Currency, FeatureKey, Price, and subscription-related IDs), preventing modifications to fields that should remain constant after entity creation.


256-261: Proper automatic timestamp update handling

The update operations correctly set the UpdatedAt field automatically when not explicitly provided, ensuring proper audit trail for entity modifications.

Also applies to: 626-632


186-225: Well-implemented edge management for billing invoice lines

The update builders provide comprehensive edge management methods (Add, Remove, Clear) for the one-to-many relationship with BillingInvoiceLine entities, following standard Ent patterns.

Also applies to: 544-583

openmeter/ent/db/billinginvoiceline/where.go (8)

101-105: LGTM: Basic Currency predicate added.

The new basic Currency predicate function follows the standard ent pattern and correctly handles the currencyx.Code type conversion to string.


152-160: LGTM: Basic predicates for InvoiceID and ParentLineID added.

These basic equality predicates follow the standard ent pattern for string fields.


197-200: LGTM: Basic SplitLineGroupID predicate added.

The new basic equality predicate for the split_line_group_id field follows the standard pattern for string fields.


552-634: LGTM: Comprehensive Currency predicates added.

The full set of predicates for the Currency field is correctly implemented. The currencyx.Code to string conversion is consistently applied across all predicate types (EQ, NEQ, In, NotIn, comparison, string operations, etc.).


636-644: LGTM: TaxConfig null check predicates added.

The IsNil/NotNil predicates for the tax_config field follow the standard ent pattern for nullable fields.


926-1004: LGTM: Extended PeriodStart and PeriodEnd predicates added.

The comprehensive predicate sets for PeriodStart and PeriodEnd fields follow the standard ent pattern for time.Time fields, providing full comparison and filtering capabilities.


1711-1784: LGTM: Comprehensive SplitLineGroupID predicates added.

The full predicate set for the new split_line_group_id field correctly implements all standard string field predicates including equality, comparison, string operations, and null checks. This enables rich querying capabilities for the new split line group relationship.


1884-1905: LGTM: SplitLineGroup edge predicates added.

The edge predicates HasSplitLineGroup and HasSplitLineGroupWith follow the standard ent pattern for many-to-one relationships. This enables filtering invoice lines based on their association with split line groups and applying conditions on the related split line group entities.

@turip turip requested a review from hekike June 9, 2025 18:22
@turip turip merged commit 3f97ca0 into main Jun 9, 2025
23 checks passed
@turip turip deleted the refactor/split-lines-v2-ddl branch June 9, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants