From: Pradeep Nayak Date: Sat, 30 Aug 2014 14:01:40 +0000 (+0530) Subject: -- CRM-15055, fixed for multiple membership X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3e228d818f764391bc5e08c6aa894423773d9b08;p=civicrm-core.git -- CRM-15055, fixed for multiple membership ---------------------------------------- * CRM-15055: Line item for membership entity should be created even when Record Payment is not checked https://issues.civicrm.org/jira/browse/CRM-15055 --- diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 3c99d44e3a..d8735c4f21 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -318,7 +318,6 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { } $params['skipLineItem'] = TRUE; - $params['contribution'] = NULL; //record contribution for this membership if (!empty($params['contribution_status_id']) && empty($params['relate_contribution_id'])) { @@ -327,7 +326,7 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { } if (CRM_Utils_Array::value('lineItems', $params) && empty($params['contributionId'])) { - CRM_Price_BAO_LineItem::processPriceSet($membership->id, $params['lineItems'], $params['contribution']); + CRM_Price_BAO_LineItem::processPriceSet($membership->id, $params['lineItems'], CRM_Utils_Array::value('contribution', $params)); } //insert payment record for this membership diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 2137d44847..c199493976 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1303,7 +1303,13 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; $formValues['financial_type_id'] ); } - + $membershipLineItems = array(); + foreach ($lineItem[$this->_priceSetId] as $key => $value) { + if (!empty($value['membership_type_id'])) { + $membershipLineItems[$value['membership_type_id']] = $value; + unset($lineItem[$this->_priceSetId][$key]); + } + } // process line items, until no previous line items. if (!empty($lineItem)) { $params['lineItems'] = $lineItem; @@ -1529,8 +1535,10 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; } $membershipParams = array_merge($membershipTypeValues[$memType], $params); + $membershipParams['lineItems'][$this->_priceSetId][] = $membershipLineItems[$memType]; $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids); - + $params['contribution'] = CRM_Utils_Array::value('contribution', $membershipParams); + unset($params['lineItems']); $this->_membershipIDs[] = $membership->id; $createdMemberships[$memType] = $membership; $count++; @@ -1629,8 +1637,10 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; if (!empty($softParams)) { $membershipParams['soft_credit'] = $softParams; } - + + $membershipParams['lineItems'][$this->_priceSetId][] = $membershipLineItems[$memType]; $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids); + $params['contribution'] = CRM_Utils_Array::value('contribution', $membershipParams); unset($params['lineItems']); $this->_membershipIDs[] = $membership->id; @@ -1645,6 +1655,7 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; if (!empty($priceFieldOp['membership_type_id'])) { $priceFieldOp['start_date'] = $membershipTypeValues[$priceFieldOp['membership_type_id']]['start_date'] ? CRM_Utils_Date::customFormat($membershipTypeValues[$priceFieldOp['membership_type_id']]['start_date'], '%d%f %b, %Y') : '-'; + $priceFieldOp['end_date'] = $membershipTypeValues[$priceFieldOp['membership_type_id']]['end_date'] ? CRM_Utils_Date::customFormat($membershipTypeValues[$priceFieldOp['membership_type_id']]['end_date'], '%d%f %b, %Y') : '-'; } else {