Skip to content
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

comment possible breakage from CRM-16460 #10287

Merged
merged 1 commit into from
Apr 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,9 @@ protected function submit($submittedValues, $action, $pledgePaymentID) {
) {
unset($submittedValues['tax_amount']);
}
// @todo - look to remove this line. I believe it relates to CRM-16460
// and possibly contributes to fixing the issue described there but
// would cause breakage for negative values in some cases.
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
Expand Down
2 changes: 2 additions & 0 deletions CRM/Price/BAO/PriceSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,8 @@ public static function processAmount($fields, &$params, &$lineItem, $component =
$params['amount_level'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $amount_level) . $displayParticipantCount . CRM_Core_DAO::VALUE_SEPARATOR;
}
}
// @todo this was a fix for CRM-16460 but is too deep in the system for formatting
// and probably causes negative amounts to save as $0 depending on server config.
$params['amount'] = CRM_Utils_Money::format($totalPrice, NULL, NULL, TRUE);
$params['tax_amount'] = $totalTax;
if ($component) {
Expand Down
6 changes: 5 additions & 1 deletion tests/phpunit/CRM/Contribute/Form/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,11 @@ public function testSubmitWithNoteCreditCard() {
}

/**
* Test that if a negative contribution is entered it does not get reset to $0
* Test that if a negative contribution is entered it does not get reset to $0.
*
* Note that this fails locally for me & I believe there may be an issue for some sites
* with negative numbers. Grep for CRM-16460 to find the places I think that might
* be affected if you hit this.
*/
public function testEnterNegativeContribution() {
$form = new CRM_Contribute_Form_Contribution();
Expand Down