From ea2ca75d149924b05acd29978636400e8d366de7 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 24 May 2019 13:57:09 +1200 Subject: [PATCH] [REF] minor code re-org This simply moves the blocks that are wrapped in if ( == 'changedStatus') into one block & puts them directly after the block which handles early returns for (some) status changes --- CRM/Contribute/BAO/Contribution.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index ad3e88caa4..bc6840e43b 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3656,10 +3656,6 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac ) { return; } - if ($context == 'changedAmount' || $context == 'changeFinancialType') { - // @todo we should stop passing $params by reference - splitting this out would be a step towards that. - $params['trxnParams']['total_amount'] = $params['trxnParams']['net_amount'] = ($params['total_amount'] - $params['prevContribution']->total_amount); - } if ($context == 'changedStatus') { if ($previousContributionStatus == 'Completed' && (self::isContributionStatusNegative($params['contribution']->contribution_status_id)) @@ -3692,9 +3688,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $params['trxnParams']['from_financial_account_id'] = $arAccountId; } } - } - if ($context == 'changedStatus') { if (($previousContributionStatus == 'Pending' || $previousContributionStatus == 'In Progress') && ($currentContributionStatus == 'Completed') @@ -3748,6 +3742,11 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac } } + if ($context == 'changedAmount' || $context == 'changeFinancialType') { + // @todo we should stop passing $params by reference - splitting this out would be a step towards that. + $params['trxnParams']['total_amount'] = $params['trxnParams']['net_amount'] = ($params['total_amount'] - $params['prevContribution']->total_amount); + } + $trxn = CRM_Core_BAO_FinancialTrxn::create($params['trxnParams']); // @todo we should stop passing $params by reference - splitting this out would be a step towards that. $params['entity_id'] = $trxn->id; -- 2.25.1