-
Notifications
You must be signed in to change notification settings - Fork 40
Update settlement flows #1081
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
Update settlement flows #1081
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Implement settlement processing to update settlement flows by handling
|
adfa4a7 to
5a6cb7a
Compare
272c758 to
1f038a2
Compare
5a6cb7a to
6c57b83
Compare
6c57b83 to
a8812eb
Compare
1f038a2 to
89d2900
Compare
a8812eb to
435894f
Compare
89d2900 to
70dbe40
Compare
435894f to
b28fced
Compare
70dbe40 to
8e325f2
Compare
b28fced to
92de60f
Compare
8e325f2 to
85d4ef5
Compare
92de60f to
e2bc145
Compare
Merge activity
|
### TL;DR
Refactored payer report status management and added functionality to clear unsettled usage when reports are settled.
### What changed?
- Added a new `ClearUnsettledUsage` SQL query to delete unsettled usage records for an originator up to a specific time
- Added a `FetchPayerReport` query to retrieve a single payer report by ID
- Replaced string manipulation in SQL queries with proper PostgreSQL array parameters using `pq.Array`
- Simplified the report status management API by replacing generic status transition methods with specific, purpose-named methods:
- `SetReportSubmitted`
- `SetReportSettled`
- `SetReportAttestationApproved`
- `SetReportAttestationRejected`
- Implemented the `PayerReportSubsetSettled` event handler to properly mark reports as settled and clear associated unsettled usage
- Added comprehensive tests for the new settlement functionality
### How to test?
1. Create a payer report with unsettled usage
2. Call `SetReportSettled` on the report
3. Verify that:
- The report status changes to `SubmissionSettled`
- Unsettled usage records for that originator up to the report's end minute are cleared
- Unsettled usage records after the end minute remain intact
- Unsettled usage for other originators is not affected
### Why make this change?
This change improves the settlement process by automatically clearing unsettled usage records once a report is settled on-chain. This prevents double-counting of usage in future reports and maintains data integrity. The refactored API also makes the code more maintainable by providing clear, purpose-specific methods for state transitions rather than generic methods that could be misused.
TL;DR
Refactored payer report status management and added functionality to clear unsettled usage when reports are settled.
What changed?
ClearUnsettledUsageSQL query to delete unsettled usage records for an originator up to a specific timeFetchPayerReportquery to retrieve a single payer report by IDpq.ArraySetReportSubmittedSetReportSettledSetReportAttestationApprovedSetReportAttestationRejectedPayerReportSubsetSettledevent handler to properly mark reports as settled and clear associated unsettled usageHow to test?
SetReportSettledon the reportSubmissionSettledWhy make this change?
This change improves the settlement process by automatically clearing unsettled usage records once a report is settled on-chain. This prevents double-counting of usage in future reports and maintains data integrity. The refactored API also makes the code more maintainable by providing clear, purpose-specific methods for state transitions rather than generic methods that could be misused.