-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Make getTotalPayments return 0 instead of NULL #16129
Conversation
(Standard links)
|
5ce8232
to
b651748
Compare
@mattwire I agree with this but changing to returning float could break any strict comparisons. I think it's only called twice outside tests so I put up this PR to explicitly cast in one to be sure. The other is the dreaded subtractCurrencies.... |
@mattwire - so the only other thing this feeds is subtract currencies. I'm not too sure what effect changing to a float will have there |
b651748
to
8dc614e
Compare
@eileenmcnaughton I've updated this slightly so that If tests pass I think this is good to merge? |
I haven't gotten my head around it bu @agileware-fj might have |
I think it should be fine with just
instead of assigning it to
Tested by calling this function at different stages of a payment (Pending, Pending refund, Partially Paid, etc). It returns the correct total amount in all the cases.
|
@mattwire please go ahead & merge once you have considered @jitendrapurohit's feedback |
8dc614e
to
5ab2fd4
Compare
@jitendrapurohit Thanks for the review - you are right. Merge on pass |
Overview
When the sum of all payments on a contribution = 0 the function returns NULL because it's returning the result of an SQL query. But that's not much use and means we have to do extra work to coalesce NULL into 0 when coding.
Before
NULL returned if no payments made on a contribution.
After
0 returned if no payments made on a contribution.
Technical Details
NULL != 0! Especially for money. This makes the function return what you'd expect it to return.
Comments
@eileenmcnaughton Related to #16025