-
Notifications
You must be signed in to change notification settings - Fork 4
Incorrect Accrued Payment Calculation Due to exclude Usage on CompletedWork #868
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA filter condition in the Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-11-11T08:11:43.757ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
|
Can you hold off on merging this until I get back next week? I want to make sure we aren't overriding manually rejected completed works. I am also curious how this came up. Once a delivery is rejected we wouldn't expect it to be approved later, that is meant to be a terminal status. |
I was not able to figure out the exact reason behind this but adding the ticket where all this happened. |
Technical Summary
While debugging an interrupt issue, I identified a bug in how accrued payments are calculated.
When a visit is initially marked as rejected, the corresponding CompletedWork record is also marked as rejected. However, if the visit is later approved through the visit import workflow, the CompletedWork record is not updated accordingly. Because the queryset excludes rejected records.
This results in inconsistencies between the visit status and the CompletedWork status, leading to inaccurate payment accruals. The bulk approval/reject UI flow does not apply this exclusion logic, which further introduces inconsistent behavior between the two flows.
To ensure consistency across both flows and to correctly include updated records in the accrual calculation, I have removed the exclusion condition from the queryset.
Safety Assurance
Safety story
I’ve removed the exclude filter, as the payment accrual method already handles these scenarios correctly. Given its existing logic and safeguards, I’m confident this change is safe and maintains the intended behaviour.
Automated test coverage
Already exisit
QA Plan
No QA
Labels & Review