Repository navigation
fix: validate charge patches by service period - #4868
Merged
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughCharge patch validation now supports independent movement of full-service and billing period ends. Regression tests cover cancellation reconciliation for flat-fee and usage-based charges across settlement modes. ChangesCharge reconciliation
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
turip
marked this pull request as ready for review
August 6, 2026 13:27
tothandras
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
ServicePeriod.To.credits_onlyandcredit_then_invoicesettlement modes.Why
Subscription sync selects shrink or extend from the service-period change. Other charge timing fields are target metadata and can legitimately move in the opposite direction.
In particular, canceling an annual subscription with a one-time in-advance flat fee extends the charge's initially zero-length service and full-service periods to the cancellation boundary while shortening its annual billing period to that same boundary. The previous extend validator rejected the shorter billing period, causing the entire synchronization transaction to roll back.
Usage-based cancellation follows the complementary shrink path, where full-service metadata can remain later than the shortened service period. Requiring every period to move in the patch direction was therefore stricter than the charge lifecycle semantics.
Impact
Subscription cancellation can now reconcile mixed charge-period directions without replacing the charge or rolling back synchronization. Retrying the synchronization remains idempotent.
Validation
nix develop --impure .#ci -c make lint-go-fast— passes with 0 issuesnix develop --impure .#ci -c make test-nocache— passes: 6,800 tests, 9 skippedGreptile Summary
The PR changes charge-period patch validation so service direction determines whether a patch is an extend or shrink while full-service and billing endpoints reconcile independently.
Confidence Score: 5/5
The PR appears safe to merge because no blocking failure remains.
No blocking failure remains.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR Subscription[Canceled subscription] --> Sync[Subscription synchronization] Sync --> Direction{Service-period direction} Direction -->|Later end| Extend[Extend patch] Direction -->|Earlier end| Shrink[Shrink patch] Extend --> Reconcile[Reconcile service, full-service, billing, and invoice timing independently] Shrink --> Reconcile Reconcile --> Charge[Updated existing charge]Reviews (2): Last reviewed commit: "fix: validate charge patches by service ..." | Re-trigger Greptile
Context used:
Summary by CodeRabbit
Bug Fixes
Documentation