From f70a8e6961263b3384dfe829b09812cd6d874512 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 4 Jul 2018 11:52:22 +1200 Subject: [PATCH] Fix mis-allocation of financial transactions Per https://lab.civicrm.org/dev/core/issues/211 there seems to be an issue with assigning entity_financial_trxn entries the wrong financial_trxn_id - I cannot find any recent change that would have caused this (unless it's simply the greater use of the payment edit block) - it has been reported as working in 5.0.2. --- CRM/Financial/Form/PaymentEdit.php | 4 ++-- tests/phpunit/CRM/Financial/Form/PaymentEditTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CRM/Financial/Form/PaymentEdit.php b/CRM/Financial/Form/PaymentEdit.php index 68d0398c51..3f53f37e84 100644 --- a/CRM/Financial/Form/PaymentEdit.php +++ b/CRM/Financial/Form/PaymentEdit.php @@ -204,13 +204,13 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { } foreach (array($previousFinanciaTrxn, $newFinancialTrxn) as $financialTrxnParams) { - civicrm_api3('FinancialTrxn', 'create', $financialTrxnParams); + $financialTrxn = civicrm_api3('FinancialTrxn', 'create', $financialTrxnParams); $trxnParams = array( 'total_amount' => $financialTrxnParams['total_amount'], 'contribution_id' => $this->_contributionID, ); $contributionTotalAmount = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionID, 'total_amount'); - CRM_Contribute_BAO_Contribution::assignProportionalLineItems($trxnParams, $submittedValues['id'], $contributionTotalAmount); + CRM_Contribute_BAO_Contribution::assignProportionalLineItems($trxnParams, $financialTrxn['id'], $contributionTotalAmount); } } else { diff --git a/tests/phpunit/CRM/Financial/Form/PaymentEditTest.php b/tests/phpunit/CRM/Financial/Form/PaymentEditTest.php index 0bf5ac8ddd..e9a9cd32d5 100644 --- a/tests/phpunit/CRM/Financial/Form/PaymentEditTest.php +++ b/tests/phpunit/CRM/Financial/Form/PaymentEditTest.php @@ -87,7 +87,7 @@ class CRM_Financial_Form_PaymentEditTest extends CiviUnitTestCase { $expectedPaymentParams = array( array( 'total_amount' => 50.00, - 'financial_type' => 'Donation,Donation,Donation', + 'financial_type' => 'Donation', 'payment_instrument' => 'Check', 'status' => 'Completed', 'receive_date' => '2015-04-21 23:27:00', @@ -95,7 +95,7 @@ class CRM_Financial_Form_PaymentEditTest extends CiviUnitTestCase { ), array( 'total_amount' => -50.00, - 'financial_type' => NULL, + 'financial_type' => 'Donation', 'payment_instrument' => 'Check', 'status' => 'Completed', 'receive_date' => $params['trxn_date'], @@ -103,7 +103,7 @@ class CRM_Financial_Form_PaymentEditTest extends CiviUnitTestCase { ), array( 'total_amount' => 50.00, - 'financial_type' => NULL, + 'financial_type' => 'Donation', 'payment_instrument' => sprintf('Credit Card (Visa: %s)', $params['pan_truncation']), 'status' => 'Completed', 'receive_date' => $params['trxn_date'], -- 2.25.1