Skip to content

feat: add gathering invoice line schema - #4720

Merged
turip merged 2 commits into
mainfrom
feat/gathering-invoice-line-schema
Jul 16, 2026
Merged

feat: add gathering invoice line schema#4720
turip merged 2 commits into
mainfrom
feat/gathering-invoice-line-schema

Conversation

@turip

@turip turip commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

  • add a schema-local standard invoice line intent mixin for fields shared by gathering and standard lines
  • add the billing_gathering_invoice_lines Ent schema and relationships
  • add generated Ent artifacts and the Atlas migration

Why

This establishes the database wiring needed to split gathering lines from the legacy invoice-line table. Application reads, writes, and data migration are intentionally left for follow-up work.

Impact

This PR is schema-only. It does not switch billing behavior or migrate existing gathering lines.

Validation

  • go test ./openmeter/ent/...
  • make migrate-check-validate
  • make migrate-check-lint
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added support for persisting gathering-stage invoice lines with service-period, pricing, tax, annotations/metadata, and discount details.
    • Introduced new billing gathering invoice line records with relationships to invoices, split line groups, subscriptions (phase/item), charges, and tax codes.
    • Added database integrity rules to prevent duplicate child invoice line references.
    • Added migration support for creating/removing gathering invoice line records.
  • Bug Fixes

    • Updated billing gathering invoice line foreign-key storage mappings for consistent charge linkage.

Greptile Summary

This PR adds database support for gathering-stage invoice lines. The main changes are:

  • A shared invoice-line intent mixin for gathering and standard lines.
  • A new gathering invoice-line Ent schema and related entity edges.
  • Generated Ent models, queries, mutations, and migration metadata.
  • Atlas migrations for the new table, constraints, foreign keys, and indexes.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the updated schema and migration code.

Important Files Changed

Filename Overview
openmeter/ent/schema/billing.go Adds the shared intent mixin and the gathering invoice-line schema, fields, indexes, and relationships.
openmeter/ent/schema/charges.go Adds the inverse relationship from charges to gathering invoice lines.
openmeter/ent/schema/subscription.go Adds gathering invoice-line relationships for subscriptions, phases, and items.
openmeter/ent/schema/taxcode.go Adds the inverse relationship from tax codes to gathering invoice lines.
tools/migrate/migrations/20260716092057_create_billing_gathering_invoice_lines.up.sql Creates the gathering invoice-line table with its constraints, foreign keys, and indexes.
tools/migrate/migrations/20260716092057_create_billing_gathering_invoice_lines.down.sql Drops the gathering invoice-line indexes and table during rollback.

Reviews (4): Last reviewed commit: "fix: reject empty gathering line child r..." | Re-trigger Greptile

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)
  • Context used - api/spec/AGENTS.md (source)

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 025bca32-a611-4833-bd5d-bb79a741f5c7

📥 Commits

Reviewing files that changed from the base of the PR and between 1a36de3 and d2fc9da.

⛔ Files ignored due to path filters (63)
  • openmeter/ent/db/billinggatheringinvoiceline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline/billinggatheringinvoiceline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline_delete.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice/billinginvoice.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge/charge.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/client.go is excluded by !**/ent/db/**
  • openmeter/ent/db/cursor.go is excluded by !**/ent/db/**
  • openmeter/ent/db/ent.go is excluded by !**/ent/db/**
  • openmeter/ent/db/entmixinaccessor.go is excluded by !**/ent/db/**
  • openmeter/ent/db/expose.go is excluded by !**/ent/db/**
  • openmeter/ent/db/hook/hook.go is excluded by !**/ent/db/**
  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • openmeter/ent/db/paginate.go is excluded by !**/ent/db/**
  • openmeter/ent/db/predicate/predicate.go is excluded by !**/ent/db/**
  • openmeter/ent/db/runtime.go is excluded by !**/ent/db/**
  • openmeter/ent/db/setorclear.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription/subscription.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem/subscriptionitem.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase/subscriptionphase.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode/taxcode.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/tx.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (6)
  • openmeter/ent/schema/billing.go
  • openmeter/ent/schema/charges.go
  • openmeter/ent/schema/subscription.go
  • openmeter/ent/schema/taxcode.go
  • tools/migrate/migrations/20260716092057_create_billing_gathering_invoice_lines.down.sql
  • tools/migrate/migrations/20260716092057_create_billing_gathering_invoice_lines.up.sql
🚧 Files skipped from review as they are similar to previous changes (5)
  • openmeter/ent/schema/taxcode.go
  • openmeter/ent/schema/subscription.go
  • openmeter/ent/schema/charges.go
  • tools/migrate/migrations/20260716092057_create_billing_gathering_invoice_lines.up.sql
  • openmeter/ent/schema/billing.go

📝 Walkthrough

Walkthrough

Changes

Adds shared invoice-line intent fields, a new BillingGatheringInvoiceLine Ent entity, related entity edges, and SQL migrations with foreign keys, indexes, uniqueness, validation, and rollback support.

Gathering invoice lines

Layer / File(s) Summary
Invoice line schema and intent fields
openmeter/ent/schema/billing.go
Adds shared pricing, tax, service-period, subscription, and billing-period fields, plus the BillingGatheringInvoiceLine entity and its indexes and relationships.
Gathering invoice line database storage
tools/migrate/migrations/20260716092057_create_billing_gathering_invoice_lines.*.sql
Creates and removes the gathering invoice lines table, foreign keys, indexes, filtered uniqueness constraint, and non-empty child reference check.
Related entity edge wiring
openmeter/ent/schema/billing.go, openmeter/ent/schema/charges.go, openmeter/ent/schema/subscription.go, openmeter/ent/schema/taxcode.go
Adds gathering-line relationships and explicit foreign-key storage keys across invoices, split groups, charges, subscriptions, and tax codes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: tothandras

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding the gathering invoice line schema and related Ent/migration updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/gathering-invoice-line-schema

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

Comment @coderabbitai help to get the list of available commands.

@turip
turip marked this pull request as ready for review July 16, 2026 08:48
@turip
turip requested a review from a team as a code owner July 16, 2026 08:48
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/gathering-invoice-line-schema

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

Comment @coderabbitai help to get the list of available commands.

@turip
turip force-pushed the feat/gathering-invoice-line-schema branch from 512a0d5 to d743881 Compare July 16, 2026 08:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@openmeter/ent/schema/billing.go`:
- Around line 307-315: Add an Annotations method to
StandardInvoiceLineIntentMixin that defines a database check constraint
requiring child_unique_reference_id to be non-empty, matching the existing
constraint pattern used by the standard detailed line schema.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c8d2ec9-edab-4097-95a6-456ac6cec27c

📥 Commits

Reviewing files that changed from the base of the PR and between 106e6d4 and d743881.

⛔ Files ignored due to path filters (63)
  • openmeter/ent/db/billinggatheringinvoiceline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline/billinggatheringinvoiceline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline_delete.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinggatheringinvoiceline_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice/billinginvoice.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoice_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge/charge.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/charge_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/client.go is excluded by !**/ent/db/**
  • openmeter/ent/db/cursor.go is excluded by !**/ent/db/**
  • openmeter/ent/db/ent.go is excluded by !**/ent/db/**
  • openmeter/ent/db/entmixinaccessor.go is excluded by !**/ent/db/**
  • openmeter/ent/db/expose.go is excluded by !**/ent/db/**
  • openmeter/ent/db/hook/hook.go is excluded by !**/ent/db/**
  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • openmeter/ent/db/paginate.go is excluded by !**/ent/db/**
  • openmeter/ent/db/predicate/predicate.go is excluded by !**/ent/db/**
  • openmeter/ent/db/runtime.go is excluded by !**/ent/db/**
  • openmeter/ent/db/setorclear.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription/subscription.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscription_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem/subscriptionitem.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionitem_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase/subscriptionphase.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/subscriptionphase_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode/taxcode.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/tx.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (6)
  • openmeter/ent/schema/billing.go
  • openmeter/ent/schema/charges.go
  • openmeter/ent/schema/subscription.go
  • openmeter/ent/schema/taxcode.go
  • tools/migrate/migrations/20260716050537_create_billing_gathering_invoice_lines.down.sql
  • tools/migrate/migrations/20260716050537_create_billing_gathering_invoice_lines.up.sql

Comment thread openmeter/ent/schema/billing.go
@turip turip added release-note/misc Miscellaneous changes area/billing labels Jul 16, 2026
@turip
turip force-pushed the feat/gathering-invoice-line-schema branch from d743881 to 1a36de3 Compare July 16, 2026 09:26
@turip
turip force-pushed the feat/gathering-invoice-line-schema branch from 1a36de3 to d2fc9da Compare July 16, 2026 10:41
@turip
turip merged commit 74a5b4b into main Jul 16, 2026
27 checks passed
@turip
turip deleted the feat/gathering-invoice-line-schema branch July 16, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants