-
Notifications
You must be signed in to change notification settings - Fork 152
fix: only support qty=1 for flat fee lines #2893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: only support qty=1 for flat fee lines #2893
Conversation
Given that product catalog drives invoicing (we are not used as standalone invoicing engine) and flat price only supports qty=1 we are no longer allowing flat fee lines with other qty on the invoice's root. Detailed lines are also represented as flat fee lines, there we allow qty to be anything positive.
📝 WalkthroughWalkthroughThe changes update invoice line validation logic to enforce that valid flat fee lines must have a quantity of 1, while other statuses require only a positive quantity. Corresponding test data is updated to set affected invoice line quantities from 3 to 1, ensuring alignment with the new validation rules. No changes to function signatures occurred. Changes
Possibly related PRs
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 ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
openmeter/billing/invoiceline.go (1)
518-531: Validation logic correctly implements the flat fee quantity requirements.The conditional validation properly enforces:
- Quantity = 1 for valid invoice lines (root level)
- Positive quantity for other statuses (detailed lines)
The inline comments provide good context about the product catalog constraint driving this requirement.
Consider making the error message more descriptive to help users understand the constraint:
- errs = append(errs, errors.New("quantity should be 1 for invoice's flat fee lines")) + errs = append(errs, errors.New("quantity must be exactly 1 for flat fee lines (product catalog constraint)"))
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
openmeter/billing/invoiceline.go(1 hunks)test/app/custominvoicing/invocing_test.go(2 hunks)test/billing/invoice_test.go(2 hunks)test/billing/suite.go(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: Artifacts / Container image
- GitHub Check: E2E
- GitHub Check: CI
- GitHub Check: Quickstart
- GitHub Check: Lint
- GitHub Check: Developer environment
- GitHub Check: Commit hooks
- GitHub Check: Test
- GitHub Check: Migration Checks
- GitHub Check: Build
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (go)
🔇 Additional comments (5)
test/app/custominvoicing/invocing_test.go (2)
194-194: LGTM! Test data correctly updated for new validation rule.The quantity has been properly changed from 3 to 1 to comply with the new validation rule that flat fee lines must have a quantity of exactly 1.
362-363: LGTM! Test data correctly updated to preserve total amount.The changes correctly maintain the same total billing amount (3 × 200 = 1 × 600 = 600) while complying with the new validation rule that requires flat fee lines to have a quantity of 1. This ensures the test logic remains valid while adhering to the updated constraints.
test/billing/invoice_test.go (2)
180-182: LGTM! Test data updated to comply with new flat fee validation rule.The quantity change from 3 to 1 correctly aligns with the new validation requirement that flat fee lines must have a quantity of exactly 1.
495-497: LGTM! Consistent update for flat fee quantity validation.This change mirrors the previous update, ensuring all flat fee lines in the test suite comply with the new quantity=1 validation rule.
test/billing/suite.go (1)
370-370: Test data correctly updated to comply with new validation rules.The quantity change from 3 to 1 aligns with the new requirement that flat fee lines at the invoice's root level must have a quantity of 1.
Overview
Given that product catalog drives invoicing (we are not used as standalone invoicing engine) and flat price only supports qty=1 we are no longer allowing flat fee lines with other qty on the invoice's root.
Detailed lines are also represented as flat fee lines, there we allow qty to be anything positive.
Summary by CodeRabbit
Bug Fixes
Tests