-
-
Notifications
You must be signed in to change notification settings - Fork 812
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-21445 Fix divide by zero with contribution page discount #11292
CRM-21445 Fix divide by zero with contribution page discount #11292
Conversation
test this please |
I'm clear that the first part of this (the changes to CRM/Contribute/BAO/Contribution.php) make sense as it adds a conditional around a piece of code that would be attempting to divide by zero if the conditional were false. I need to spend a little more time looking at the latter one |
@mattwire I just did the following test on master
The only error I observed was a notice about function signature on getCurrency (which I will fix). Can you recheck? |
a3ea2e2
to
a87fb55
Compare
@eileenmcnaughton Definitely still an issue for me. Testing again here I think you need to have more than one payment processor enabled on the contribution page to see the error. I've just updated the patch for latest master which removes a couple of lines as #11286 is now merged. |
jenkins test this please |
test this please |
OK - now I have replicated it - I found that the code you are removing is to cope with the situation where there is a separate membership payment configured. I think it's required when contribution = 0 & membership has a value or vise versa. I think something like this might work - although have got myself in a muddle as to replication so will walk away for a bit
|
Just following on from this - I feel like maybe rather than formTotalAmount it should be $form->amounts = array('total_amount' => x, 'first_payment_amount' => y, 'second_payment_amount' => z) or similar |
@mattwire I'm going to put up an alternative for the changes to CRM/Contribute/Form/ContributionBase.php but I'd like to merge the changes to BAO_Contribution since they make sense (if I can get a clean PR on those) |
a87fb55
to
8dc9d46
Compare
Hey @eileenmcnaughton I've just pushed an updated PR that just has the changes to BAO_Contribution |
Thanks @mattwire - can you update the PR description? |
@eileenmcnaughton PR description updated |
Jenkins test this please |
Thanks @mattwire -the jenkins error is PHP Files:
Maybe casting first & then the if will cheer it up? |
8dc9d46
to
c627727
Compare
$eftParams['amount'] = CRM_Contribute_BAO_Contribution_Utils::formatAmount($paid); | ||
civicrm_api3('EntityFinancialTrxn', 'create', $eftParams); | ||
$contributionTotalAmount = (float) $entityParams['contribution_total_amount']; | ||
if (!empty($contributionTotalAmount)) { |
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 we need to create proportional entry in civicrm_entity_financial_trxn table even though the contribution total is 0.00 with civicrm_entity_financial_trxn.amount as 0.00. If there are no such entries then there would be problem while assigning transactions in financial batch or hopefully in quickbook reports as this transaction won't be listed because of missing entries.
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.
@pradnayak Ok. Happy to go with your PR if that's the case
I have some concerns at https://github.com/civicrm/civicrm-core/pull/11292/files#r164339620 |
I closed mine :( |
@pradpnayak Yes please. as yours keeps the financial_trxn stuff in |
@mattwire @pradpnayak so we are closing this one? |
Closing in favour of #11601 |
Overview
When you apply a 100% discount you cannot submit the contribution page:
Fix divide by zero when amount is 0.