From: Pradeep Nayak Date: Tue, 2 Sep 2014 20:35:03 +0000 (+0530) Subject: -- CRM-14853, change payment instrument id when contribution status is changed from... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=182228d5d016685d41dd5438c733e26694e9816c;p=civicrm-core.git -- CRM-14853, change payment instrument id when contribution status is changed from In-progress/Pending to Completed ---------------------------------------- * CRM-14853: Bookkeeping report represents payment type incorrectly https://issues.civicrm.org/jira/browse/CRM-14853 --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index eee3a4d96a..90e05757fd 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2718,9 +2718,15 @@ WHERE contribution_id = %1 "; $params['trxnParams']['net_amount'] = $params['prevContribution']->net_amount; $params['trxnParams']['trxn_id'] = $params['prevContribution']->trxn_id; $params['trxnParams']['status_id'] = $params['prevContribution']->contribution_status_id; - $params['trxnParams']['payment_instrument_id'] = $params['prevContribution']->payment_instrument_id; - $params['trxnParams']['check_number'] = $params['prevContribution']->check_number; + + if (!(($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatuses) + || $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatuses)) + && $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatuses))) { + $params['trxnParams']['payment_instrument_id'] = $params['prevContribution']->payment_instrument_id; + $params['trxnParams']['check_number'] = $params['prevContribution']->check_number; + } + //if financial type is changed if (!empty($params['financial_type_id']) && $params['contribution']->financial_type_id != $params['prevContribution']->financial_type_id) { diff --git a/CRM/Upgrade/Incremental/sql/4.5.beta9.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.5.beta9.mysql.tpl index e17299ebe6..dc34c88a3b 100644 --- a/CRM/Upgrade/Incremental/sql/4.5.beta9.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.5.beta9.mysql.tpl @@ -14,3 +14,14 @@ INSERT INTO civicrm_navigation ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight ) VALUES ( {$domainID}, 'civicrm/admin/options/grant_status?reset=1', '{ts escape="sql" skip="true"}Grant Status{/ts}', 'Grant Status', 'access CiviGrant,administer CiviCRM', 'AND', @parent_id, '1', NULL, 2 ); + +-- CRM-14853 +UPDATE civicrm_financial_trxn cft +INNER JOIN ( SELECT max(cft.id) trxn_id, ceft.entity_id contribution_id +FROM civicrm_financial_trxn cft +LEFT JOIN civicrm_entity_financial_trxn ceft ON ceft.financial_trxn_id = cft.id +WHERE ceft.entity_table = 'civicrm_contribution' +GROUP BY ceft.entity_id ) as temp ON temp.trxn_id = cft.id +INNER JOIN civicrm_contribution cc ON cc.id = temp.contribution_id +AND cc.payment_instrument_id <> cft.payment_instrument_id +SET cft.payment_instrument_id = cc.payment_instrument_id; \ No newline at end of file