-
-
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
Fix Bug where Payment Balance is sometimes miscalculated #16546
Conversation
(Standard links)
|
@eileenmcnaughton style warning need to remove https://github.com/civicrm/civicrm-core/pull/16546/files#diff-7a5b0e2d131dabc49178460fc63328c0R4020 as well |
d9e8cf6
to
1924a66
Compare
This seems to be fine to me but would appreciate others to comment @monishdeb @mattwire |
@@ -4043,19 +4045,13 @@ public static function getPaymentInfo($id, $component = 'contribution', $getTrxn | |||
$contributionId = $id; | |||
} | |||
|
|||
$total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId); | |||
$baseTrxnId = !empty($total['trxn_id']) ? $total['trxn_id'] : NULL; | |||
$oldCalculation = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton It would be helpful to have a comment explaining why this variable is called oldCalculation
as it's a mystery to me. Non-blocking to merging of this PR but if you get chance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - because I think it is weird & should go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattwire - I've expanded the code comments
I'm happy with this from an r-code perspective. Could really do with an r-run from someone like @monishdeb @pradpnayak @elcapo |
I observed that when this function is called without the mystical the paymentBalance is miscalculated The payment balance is calculated as the Contribution Total less the amount paid (for less queries the total is passed into getContributionBalance & used if passed in). We were passing in the Balance as the total causing the balance to be calculated as the Balance less any amount paid. From what I can tell this function has been honed & cleaned up but because the parameter never made much sense the impact of different variants was not really tested. This removes & fixes
1924a66
to
4924bfe
Compare
Betty and I are reviewing PR's and we came across this PR.
@mattwire or @eileenmcnaughton could one of you merge this PR? |
Thanks @jaapjansma |
Overview
Fixes a bug where Add Refund is displayed instead of Add Payment on partially paid event contributions
Before
Notice that when viewing a partially paid transaction getPaymentInfo is called twice - the first time is with usingLineTotal = TRUE & results in the Record Payment button about half way up.
The second is at the bottom & the mystery param is not passed i - resulting in RecordRefund
After
Technical Details
I observed that when this function is called without the mystical the paymentBalance is miscalculated
The payment balance is calculated as the Contribution Total less the amount paid (for less queries the
total is passed into getContributionBalance & used if passed in). We were passing in the Balance
as the total causing the balance to be calculated as the Balance less any amount paid.
From what I can tell this function has been honed & cleaned up but because the parameter never made much sense
the impact of different variants was not really tested. This removes & fixes
Comments
@monishdeb @pradpnayak