From: Pradeep Nayak Date: Sat, 30 Aug 2014 14:01:04 +0000 (+0530) Subject: -- CRM-15055, create line item for membership wne no contribution is recorded X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d5b95619b7ab9afa123b3db635128294514ea2ef;p=civicrm-core.git -- CRM-15055, create line item for membership wne no contribution is recorded ---------------------------------------- * 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 d900d6f28e..3c99d44e3a 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -316,12 +316,19 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { 'membership_id' ); } - + + $params['skipLineItem'] = TRUE; + $params['contribution'] = NULL; + //record contribution for this membership if (!empty($params['contribution_status_id']) && empty($params['relate_contribution_id'])) { $memInfo = array_merge($params, array('membership_id' => $membership->id)); $params['contribution'] = self::recordMembershipContribution($memInfo, $ids); } + + if (CRM_Utils_Array::value('lineItems', $params) && empty($params['contributionId'])) { + CRM_Price_BAO_LineItem::processPriceSet($membership->id, $params['lineItems'], $params['contribution']); + } //insert payment record for this membership if (!empty($params['relate_contribution_id'])) { @@ -2804,7 +2811,7 @@ WHERE civicrm_membership.is_test = 0"; 'contact_id', 'total_amount', 'receive_date', 'financial_type_id', 'payment_instrument_id', 'trxn_id', 'invoice_id', 'is_test', 'contribution_status_id', 'check_number', 'campaign_id', 'is_pay_later', - 'membership_id', + 'membership_id', 'skipLineItem' ); foreach ($recordContribution as $f) { $contributionParams[$f] = CRM_Utils_Array::value($f, $params); diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 7b01f96c0d..2137d44847 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -271,6 +271,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $this->setPageTitle(ts('Membership')); + parent::preProcess(); } @@ -1243,6 +1244,12 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; } $membershipType = implode(', ', $membershipTypes); + + //do cleanup line items if membership edit the Membership Fee. + $params['contributionId'] = CRM_Utils_Array::value('contribution_id', $this->_defaultValues); + if (empty($params['contributionId']) && $this->_id) { + CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_membership'); + } // Retrieve the name and email of the current user - this will be the FROM for the receipt email list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($ids['userId']); @@ -1624,6 +1631,7 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; } $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids); + unset($params['lineItems']); $this->_membershipIDs[] = $membership->id; $createdMemberships[$memType] = $membership;