Skip to content

Commit

Permalink
CIVICRM-1148: Setting line item values correctly for multiple members…
Browse files Browse the repository at this point in the history
…hip terms.
  • Loading branch information
agilewarealok authored and agileware-dev committed Feb 26, 2019
1 parent 21ece9c commit 6222067
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CRM/Price/BAO/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public static function format($fid, $params, $fields, &$values, $amount_override
'auto_renew' => CRM_Utils_Array::value('auto_renew', $options[$oid]),
'html_type' => $fields['html_type'],
'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $options[$oid]),
'tax_amount' => CRM_Utils_Array::value('tax_amount', $options[$oid]),
'tax_amount' => (CRM_Utils_Array::value('tax_amount', $options[$oid]) * $qty),
'non_deductible_amount' => CRM_Utils_Array::value('non_deductible_amount', $options[$oid]),
);

Expand Down
27 changes: 24 additions & 3 deletions CRM/Price/BAO/PriceSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,19 @@ public static function initSet(&$form, $id, $entityTable = 'civicrm_event', $val
return FALSE;
}

/**
* Get number of membership terms from Params.
* @param $params
* @return int
*/
private static function getMembershipTerms($params) {
$numTerms = 1;
if (isset($params['num_terms'])) {
$numTerms = $params['num_terms'];
}
return $numTerms;
}

/**
* Get line item purchase information.
*
Expand Down Expand Up @@ -739,7 +752,11 @@ public static function processAmount($fields, &$params, &$lineItem, $component =
if ($params["price_{$id}"] <= 0) {
break;
}
$params["price_{$id}"] = array($params["price_{$id}"] => 1);
$terms = self::getMembershipTerms($params);
if ($amount_override == $params['total_amount']) {
$amount_override = NULL;
}
$params["price_{$id}"] = array($params["price_{$id}"] => $terms);
$optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);

CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem, $amount_override);
Expand All @@ -762,10 +779,14 @@ public static function processAmount($fields, &$params, &$lineItem, $component =
break;

case 'Select':
$params["price_{$id}"] = array($params["price_{$id}"] => 1);
$terms = self::getMembershipTerms($params);
if ($amount_override == $params['total_amount']) {
$amount_override = NULL;
}
$params["price_{$id}"] = array($params["price_{$id}"] => $terms);
$optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);

CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem, CRM_Utils_Array::value('partial_payment_total', $params));
CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem, $amount_override);
if (CRM_Utils_Array::value('tax_rate', $field['options'][$optionValueId])) {
$lineItem = self::setLineItem($field, $lineItem, $optionValueId, $totalTax);
}
Expand Down

0 comments on commit 6222067

Please sign in to comment.