O3-5413: Add bill refund request and approval workflow - #108
O3-5413: Add bill refund request and approval workflow#108UjjawalPrabhat wants to merge 4 commits into
Conversation
|
@NethmiRodrigo @wikumChamith @ibacher Could you please review this PR? |
|
@UjjawalPrabhat thank you for the work done, the changes LGTM, but if you don't mind, For when rejecting a refund request (REFUND_REQUESTED → PAID), consider clearing the refund request metadata for clarity. (Optional but could make the system cleaner when cleared) |
NethmiRodrigo
left a comment
There was a problem hiding this comment.
Thanks @UjjawalPrabhat, but can we have a separate endpoint to handle refunds ?
The whole point of recording that metadata is to have this record for reporting or auditing purposes so clearing it would be bad |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #108 +/- ##
============================================
+ Coverage 27.04% 27.65% +0.61%
- Complexity 497 515 +18
============================================
Files 190 190
Lines 4337 4400 +63
Branches 492 505 +13
============================================
+ Hits 1173 1217 +44
- Misses 3062 3081 +19
Partials 102 102 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
NethmiRodrigo
left a comment
There was a problem hiding this comment.
@UjjawalPrabhat please test your changes out locally, since this fails on runtime.
@VeronicaMuthee if a refund request gets denied, what should the workflow be? Should we set the bill status back to paid or to a new status saying refund denied? And can the refund request reason be null, i.e should we allow a cashier to request for a refund without specifying a reason?
c566ff5 to
3af57d5
Compare
Reply from @VeronicaMuthee in the ticket:
|
|
We don't use conventional commits on backend modules, so please remove that from the PR title. |
NethmiRodrigo
left a comment
There was a problem hiding this comment.
Thanks @UjjawalPrabhat! Continuing to enjoy the work you're bringing to this module — the service layer design is solid and the test coverage there is thorough. A few things to sort out before we merge, mainly around wiring the REST layer up to the service methods you wrote.
b5270bf to
de94d59
Compare
|
@UjjawalPrabhat — heads up, I wasn't able to run your changes locally because the liquibase changeset used I previously mentioned in this same PR to please test your changes locally. You can use the sdk, just setup a sdk and then deploy this module to the sdk, then run the sdk and you should have an openmrs instance running with your changes. It’s just -
Had I not run this locally and checked we wouldn’t have known it failed at runtime, which is bad |
|
@ibacher @wikumChamith could you review as well? I updated the PR because
I’ve added |
|
Also, FYI @ibacher, the build job is failing to start
|
|
This will change the whole pattern. What if we introduce a new data model for refunds? That's the same approach we're taking for payments. PROS:
CONS: We need to start again :) @ibacher, @NethmiRodrigo , what do you think? |
So, right now we have a requirement scenario for refunding only a fully paid bill. I was okay with this approach because we don't yet have a solid requirement for partial refunds, and because partial refunds can get complicated. The same reason I'm not exactly a huge fan of our payment model right now. If there is a bill with multiple items, refunding a specific amount might mean refunding for a specific line item, (which is something we can support). But we don't track which payment was made for which line item. |
I actually think paying for individual items separately doesn't make sense. I've never seen something like that. In most systems, you just create a separate bill to do that. I think we should get rid of the one bill per patient rule. |
b4fa139 to
95dee67
Compare
Because of the semi-strict status state machine in this module maybe we shouldn't allow the frontend to control this at all, but just provide operations, e.g.,
I don't think it matters which payment is made towards which line-item, but we can separately track the line items associated with a refund. Paying for things individually on a single bill doesn't make much sense, but refunding individual items probably needs to be supported (with the ability to mark a refund as applying to the whole bill). |
@wikumChamith Actually, we accidentally did, lol, happened after that large refactor somewhere.
@ibacher in that case, we would need to update the status of the individual line items right, and allow cashiers to select the line item that they want to request a refund for? Do we only change the status of the entire bill, if all line items are selected for refunds? |
|
@VeronicaMuthee pinging you just to keep you in the loop on the ^ conversation :) |
The best option here is to implement this in a more flexible way, so we have more wiggle room in the future. That's why I suggested having a separate data model for refunds. |
Alrighty, lets do it this way then |
Summary
This PR adds backend support for the frontend to enable refund requests and approval for paid bills.
REFUND_REQUESTEDandREFUNDEDtoBillStatusenumPAID → REFUND_REQUESTEDandREFUND_REQUESTED → REFUNDEDstatus transitions, enforcingREFUND_MONEYprivilege for issuing refundssynchronizeBillStatus()from overwriting refund statuses during payment recalculationRelated Issue
O3-5413