-- CRM-15188, fixed code to provide line item ref to correct component id
authorPradeep Nayak <pradeep.nayak@webaccess.co.in>
Sat, 30 Aug 2014 13:59:46 +0000 (19:29 +0530)
committerPradeep Nayak <pradeep.nayak@webaccess.co.in>
Wed, 3 Sep 2014 09:27:18 +0000 (14:57 +0530)
----------------------------------------
* CRM-15188: line_item entity refs to membership rather than contrib on non-membership lines of membership price sets
  https://issues.civicrm.org/jira/browse/CRM-15188

CRM/Price/BAO/LineItem.php

index 4d18eeae9b880dabf64fe73a18b541cce8923906..f87af912552ed8497b1d7f703185f6c4a3b2f233 100644 (file)
@@ -341,17 +341,15 @@ AND li.entity_id = {$entityId}
         $line['entity_table'] = $entityTable;
         $line['entity_id'] = $entityId;
         if(!empty($line['membership_type_id'])) {
-          $entityTable == 'civicrm_membership';
-          $line['contribution_id'] = $contributionDetails->id;
-        }
-        if ($entityTable == 'civicrm_contribution') {
-          $line['contribution_id'] = $entityId;
+          $line['entity_table'] = 'civicrm_membership';
         }
-        else {
-          if (!empty($contributionDetails->id)) {
-            $line['contribution_id'] = $contributionDetails->id;
+        if (!empty($contributionDetails->id)) {
+          $line['contribution_id'] = $contributionDetails->id;
+          if ($line['entity_table'] == 'civicrm_contribution') {
+            $line['entity_id'] = $contributionDetails->id;
           }
         }
+        
         // if financial type is not set and if price field value is NOT NULL
         // get financial type id of price field value
         if (!empty($line['price_field_value_id']) && empty($line['financial_type_id'])) {
@@ -431,7 +429,7 @@ AND li.entity_id = {$entityId}
    * @return void
    * @static
    */
-  static function getLineItemArray(&$params, $entityId = NULL, $entityTable = 'contribution') {
+  static function getLineItemArray(&$params, $entityId = NULL, $entityTable = 'contribution', $isRelatedID = FALSE) {
 
     if (!$entityId) {
       $priceSetDetails = CRM_Price_BAO_PriceSet::getDefaultPriceSet();
@@ -451,7 +449,7 @@ AND li.entity_id = {$entityId}
       $setID = NULL;
       $totalEntityId = count($entityId);
       foreach ($entityId as $id) {
-        $lineItems = CRM_Price_BAO_LineItem::getLineItems($id, $entityTable);
+        $lineItems = CRM_Price_BAO_LineItem::getLineItems($id, $entityTable, NULL, TRUE, $isRelatedID);
         foreach ($lineItems as $key => $values) {
           if (!$setID && $values['price_field_id']) {
             $setID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $values['price_field_id'], 'price_set_id');