Skip to content

Conversation

@turip
Copy link
Member

@turip turip commented Oct 15, 2025

Overview

This patch duplicates the line provisioning logic for invoice lines and detailed lines in anticipation for #3514 this will make the PR more readable.

The code is almos an exact copy of the line provisioning logic as DetailedLine is a type alias for Line.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when upserting detailed invoice lines, ensuring correct parent-child relationships and consistent handling of attributes (period, tax settings, subscription data, metadata).
    • Stricter validation: only usage-based invoice-level lines are accepted for upsert; invalid types now return clearer, contextual errors.
  • Refactor

    • Simplified and consolidated the invoice line upsert flow for better maintainability and fewer edge cases.
    • Removed unused logic and reduced dependencies to streamline processing.

@turip turip requested a review from a team as a code owner October 15, 2025 14:56
@turip turip added release-note/misc Miscellaneous changes area/billing labels Oct 15, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

📝 Walkthrough

Walkthrough

Removes DetailedLine diff generation with parent IDs and the samber/lo import. Refactors invoice line upsert flow: introduces invoiceLineUpsertConfig and a dedicated upsertDetailedLines path, enforces UsageBased type for invoice-level lines, and centralizes parent-child linkage and detailed line attribute handling with improved error wrapping.

Changes

Cohort / File(s) Summary
Remove DetailedLine diff with parent IDs and lo dependency
openmeter/billing/adapter/invoicelinediff.go
Deleted GetDetailedLineDiffWithParentID() and the samber/lo import; removes mapping-based construction of DetailedLine diffs including ParentLineID updates.
Refactor upsert flow for invoice and detailed lines
openmeter/billing/adapter/invoicelines.go
Introduced invoiceLineUpsertConfig and upsertDetailedLines; split basic vs. detailed line handling; enforce UsageBased type for invoice-level lines; centralize parent-child linkage and detailed attributes; replace previous diff-based detailed-line upsert; improved contextual error handling.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly indicates a refactor of detailed line provisioning logic, which aligns with a significant aspect of the changeset by highlighting the new dedicated detailed line upsert flow and the removal of the old mapping logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/split-line-provisioning-logic

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 and usage tips.

@turip turip changed the title refactor: split line provisioning logic refactor: detailed line provisioning logic Oct 15, 2025
@turip turip requested a review from chrisgacsal October 15, 2025 15:03
@turip turip enabled auto-merge (squash) October 15, 2025 15:12
@turip turip merged commit bb7aeac into main Oct 15, 2025
29 of 30 checks passed
@turip turip deleted the refactor/split-line-provisioning-logic branch October 15, 2025 15:31
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