-- CRM-15848, fixed code to point civicrm_financial_item to latest financial trxn
authorPradeep Nayak <pradpnayak@gmail.com>
Tue, 31 Mar 2015 14:07:46 +0000 (19:37 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Tue, 31 Mar 2015 14:07:46 +0000 (19:37 +0530)
----------------------------------------
* CRM-15848: Civiaccounts inconsistent with spec when adding partial event payment
  https://issues.civicrm.org/jira/browse/CRM-15848

CRM/Event/BAO/Participant.php

index ec1baa59cb120bd44755db6d2ab45d018312b372..ea4e7e521d89a705a2b322f1a2e0c1bdf1a41d16 100644 (file)
@@ -1922,16 +1922,15 @@ GROUP BY li.entity_table, li.entity_id, price_field_value_id
         if (!in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] != 0) {
           // INSERT negative financial_items
           $updateFinancialItemInfoValues['amount'] = -$updateFinancialItemInfoValues['amount'];
-          CRM_Financial_BAO_FinancialItem::create($updateFinancialItemInfoValues, NULL, $trxnId);
-          // INSERT negative financial_items for tax amount
           if ($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']) {
-            $updateFinancialItemInfoValues['amount'] = -($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']);
-            $updateFinancialItemInfoValues['description'] = $taxTerm;
+            $updateFinancialItemInfoValues['tax']['amount'] = -($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']);
+            $updateFinancialItemInfoValues['tax']['description'] = $taxTerm;
             if ($updateFinancialItemInfoValues['financial_type_id']) {
-              $updateFinancialItemInfoValues['financial_account_id'] = CRM_Contribute_BAO_Contribution::getFinancialAccountId($updateFinancialItemInfoValues['financial_type_id']);
+              $updateFinancialItemInfoValues['tax']['financial_account_id'] = CRM_Contribute_BAO_Contribution::getFinancialAccountId($updateFinancialItemInfoValues['financial_type_id']);
             }
-            CRM_Financial_BAO_FinancialItem::create($updateFinancialItemInfoValues, NULL, $trxnId);
           }
+          // INSERT negative financial_items for tax amount
+          $financialItemsArray[] = $updateFinancialItemInfoValues;
         }
         // if submitted and difference is 0 add a positive entry again
         elseif (in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] == 0) {