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

CRM-17647 fix ContributionForm to use skipCleanMoney on update & upda… #11575

Merged

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jan 23, 2018

Overview

As part of resolving issues around currency separators this PR adds tests to submitting the contribution form in update mode. Identified instances of mis-recording amounts have been fixed but there may well be more & we need to fix the underlying issue.

Before

tests don't cover both separator variants, BAO is cleaning the values when they should be & are being cleaned in the form

After

Additional tests. BAO not being permitted to cleanMoney

Technical Details

The underlying issue is the attempt to 'cleanMoney' in the Contribution_BAO is unreliable. At some point it was determined that money might have already been cleaned before this point (true) & some unreliable extra handling was added (bad).

To get back to reliability around handling numbers with a thousand separator we need to

  1. ensure all amounts are cleaned close to the point where they are submitted on the form layer
  2. remove all places where BAO or processing functions clean money - in order to do this we will
    a) make sure that all core places in code that call Contribute_BAO_Contribution::create pass 'skipCleanMoney' (the api already does)
    b) add a deprecation notice so that any code that calls it without skipCleanMoney gets a notice for a few versions
    c) remove cleaning money from the contribution BAO.

Comments

#11539 has tests identifying where the BAO is being allowed to attempt to clean money

@@ -1040,7 +1040,7 @@ public static function processContribution(

$contribParams['skipLineItem'] = 1;
// create contribution record
$contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ids is empty & deprecated

@@ -1636,7 +1632,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) {
if (!empty($params['note']) && !empty($submittedValues['note'])) {
unset($params['note']);
}
$contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
$contribution = CRM_Contribute_BAO_Contribution::create($params);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ids is deprecated & we have $params['id'] set

@eileenmcnaughton eileenmcnaughton force-pushed the currency_contribution_update branch 2 times, most recently from 35a7090 to 7637daa Compare January 23, 2018 08:35
@totten
Copy link
Member

totten commented Jan 23, 2018

jenkins, test this please

@eileenmcnaughton
Copy link
Contributor Author

@monishdeb are you able to review this? Am trying to get instances of 'BAO is called without skipCleanMoney' down to zero so we can deprecate & remove the (unreliable) BAO-cleaning - per #11539

@monishdeb
Copy link
Member

I have tested the patch in my local and fixes are straighforward, doesn't cause any unintended regression. Changes in unit-tests makes sense. Happy with this patch, merging now.

@monishdeb monishdeb merged commit aa80cc7 into civicrm:master Feb 6, 2018
@monishdeb monishdeb deleted the currency_contribution_update branch February 6, 2018 09:38
@eileenmcnaughton
Copy link
Contributor Author

thanks!

@mlutfy mlutfy added this to the 4.7.31 milestone Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants