CRM-15374 fix - Contribution FEES are affecting Balance and Total Paid incorrectly
authormonishdeb <monish.deb@webaccessglobal.com>
Wed, 1 Oct 2014 20:44:39 +0000 (02:14 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Wed, 1 Oct 2014 20:44:39 +0000 (02:14 +0530)
https://issues.civicrm.org/jira/browse/CRM-15374

CRM/Contribute/Form/Contribution.php
CRM/Core/BAO/FinancialTrxn.php

index b6b88e1a01ce995548f09e7e096a99c6a9971678..211d2e445d913cf48b059cb0ff0507d8118935c4 100644 (file)
@@ -1045,14 +1045,21 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
         }
         elseif (array_key_exists('participant', $contributionDetails)) {
           $pId = current($contributionDetails['participant']);
-        }        
+        }
       }
     }
+
+    $isQuickConfig = 0;
+    if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
+      $isQuickConfig = 1;
+    }
+
     if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
       // 10117 update th line items for participants
       if ($pId) {
         $entityTable = 'participant';
         $entityID = $pId;
+        $isRelatedId = FALSE;
         $participantParams = array(
           'fee_amount' => $submittedValues['total_amount'],
           'id' => $entityID
@@ -1067,7 +1074,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
         $entityID = $this->_id;
       }
 
-      $lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, NULL, TRUE, $isRelatedId);
+      $lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, $isQuickConfig, $isRelatedId);
       foreach (array_keys($lineItems) as $id) {
         $lineItems[$id]['id'] = $id;
       }
@@ -1084,10 +1091,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
         $lineItem[$this->_priceSetId] = $lineItems;
       }
     }
-    $isQuickConfig = 0;
-    if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
-      $isQuickConfig = 1;
-    }
+
     //CRM-11529 for quick config back office transactions
     //when financial_type_id is passed in form, update the
     //line items with the financial type selected in form
index 7008bf9607d6447ee964d671aefd9b53de32b8e1..063050c6594a2bb15e8f919b3bf76ee660ea7bba 100644 (file)
@@ -385,7 +385,12 @@ WHERE ceft.entity_id = %1";
     $expenseTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
     $domainId = CRM_Core_Config::domainID();
     $amount = 0;
+    $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     if (!empty($params['prevContribution'])) {
+      if ($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatuses) ||
+        $params['contribution']->contribution_status_id == array_search('Refund', $contributionStatuses)) {
+        return FALSE;
+      }
       $amount = $params['prevContribution']->fee_amount;
     }
     $amount = $params['fee_amount'] - $amount;