Fix mis-allocation of financial transactions
authoreileen <emcnaughton@wikimedia.org>
Tue, 3 Jul 2018 23:52:22 +0000 (11:52 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 4 Jul 2018 05:51:37 +0000 (17:51 +1200)
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
tests/phpunit/CRM/Financial/Form/PaymentEditTest.php

index 68d0398c51b8dd81fad07e66692240bf55bbf9d4..3f53f37e8446e9656c3aad68f2c95a92f64d2567 100644 (file)
@@ -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 {
index 0bf5ac8dddf351dbd305193a83fb489ec1d1caa2..e9a9cd32d57ca77e7eb95b9458d69afe47102412 100644 (file)
@@ -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'],