-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
CRM-17281 Pledge payments: fix rounding bug with miscalculation for multiple payments against a pledge #10861
Conversation
…han the usual installment amount.
This code is from #9585 - that patch also involved quite a lot of cleanup - unfortunately a lot of that cleanup can't be used now as it is stale :-( The following comments are ones I added to the last commit but copying here to make them easier to see This PR fixes a bug where payments are miscalculated with weird results. If a payment
|
…g pledge payments. This PR fixes a bug where payments are miscalculated with weird results. If a payment changes the amount of future payments in such a way as to make an irregular amount e.g 10 is split over 3 payments, the payment amount needs to be recorded as .33 not .333333, assuming a currency with 2 decimal places. This commit ensures the rounding takes place & is locked in by the accompanying unit test. Note that we discussed this & agreed to use a function as a placeholder for the number of decimal places.
…multiple payments against a pledge.
I'm having serious serious issues reading this code. Renaming the variable is a step towards making sense of it. actually refers to the next pledge payment installment that is unpaid, matching from the oldest
I spent a lot of time trying to understand why the removed line
Was there in the first place, & tbh I really couldn't. It's worth noting that there is a clear reproducable problem that this line causes which can be seen in the UI or the unit test & which removing it fixes in both instances. While I don't think it will, even if we just move the bug I think this is a step forwards since the test means this variant cannot come back & the code makes baby-steps towards legibility in this PR. As a reviewers collaboration I would normally merge this at this stage but at the moment we have an unresolved process here so @colemanw would you be able to merge this please? @mlutfy can you please confirm there is nothing in the final version you are uncomfortable with. |
I reviewed the changes and looks good! |
@civicrm-builder retest this please |
Overview
FIX miscalculation of remaining pledge payments when a payment is made that exceeds them and the cent values do not accurately spread over the payments (e.g 12 payments to pay $100)
FROM @mlutfy #9585
Before
No test, payment miscalculates remaining payments when a payment is made that pays off multiple payments
After
Payments covered are set to zero rather than the overhang value remaining outstanding
Technical Details
Note that we added a placeholder function for the number of decimal places a payment can be in, rather than hard-coding it.
Comments