* @static
*/
static function recordFinancialAccounts(&$params, $financialTrxnValues = NULL) {
- $skipRecords = $update = $return = FALSE;
+ $skipRecords = $update = $return = $isRelatedId = FALSE;
$additionalParticipantId = array();
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$entityTable = 'civicrm_contribution';
}
+ if (CRM_Utils_Array::value('contribution_mode', $params) == 'membership') {
+ $isRelatedId = TRUE;
+ }
+
$entityID[] = $entityId;
if (!empty($additionalParticipantId)) {
$entityID += $additionalParticipantId;
// build line item array if its not set in $params
if (empty($params['line_item']) || $additionalParticipantId) {
- CRM_Price_BAO_LineItem::getLineItemArray($params, $entityID, str_replace('civicrm_', '', $entityTable));
+ CRM_Price_BAO_LineItem::getLineItemArray($params, $entityID, str_replace('civicrm_', '', $entityTable), $isRelatedId);
}
if (CRM_Utils_Array::value('contribution_status_id', $params) != array_search('Failed', $contributionStatuses) &&
*/
public function postProcess() {
$session = CRM_Core_Session::singleton();
- $sendReceipt = $pId = $contribution = FALSE;
+ $sendReceipt = $pId = $contribution = $isRelatedId = FALSE;
$softParams = $softIDs =array();
if ($this->_action & CRM_Core_Action::DELETE) {
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
- //CRM-10964
- $pId = ($this->_compId && $this->_context == 'participant') ? $this->_compId : CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
+ if ($this->_compId) {
+ if ($this->_context == 'participant') {
+ $pId = $this->_compId;
+ }
+ elseif ($this->_context == 'membership') {
+ $isRelatedId = TRUE;
+ }
+ }
+ else {
+ $contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
+ if (array_key_exists('membership', $contributionDetails)) {
+ $isRelatedId = TRUE;
+ }
+ elseif (array_key_exists('participant', $contributionDetails)) {
+ $pId = current($contributionDetails['participant']);
+ }
+ }
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// 10117 update th line items for participants
$entityID = $this->_id;
}
- $lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable);
+ $lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$params['participant_id'] = $pId;
$params['skipLineItem'] = 1;
}
+ elseif ($isRelatedId) {
+ $params['contribution_mode'] = 'membership';
+ }
$params['line_item'] = $lineItem;
$params['payment_processor_id'] = $params['payment_processor'] = CRM_Utils_Array::value('id', $this->_paymentProcessor);
//create contribution.