$lineItem = array($this->_priceSetId => array());
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'],
- $formValues, $lineItem[$this->_priceSetId]);
+ $formValues, $lineItem[$this->_priceSetId], NULL, $this->_priceSetId);
if (CRM_Utils_Array::value('tax_amount', $formValues)) {
$params['tax_amount'] = $formValues['tax_amount'];
$lineItem = array();
$this->_params = $this->setPriceSetParameters($this->_params);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'],
- $this->_params, $lineItem[$this->_priceSetId]
+ $this->_params, $lineItem[$this->_priceSetId], NULL, $this->_priceSetId
);
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
* @param array $params
* Reference to form values.
* @param array $fields
- * Array of fields belonging.
- * to the price set used for particular event
+ * Array of fields belonging to the price set used for particular event
* @param array $values
* Reference to the values array(.
* this is
* lineItem array)
+ * @param string $amount_override
*/
- public static function format($fid, $params, $fields, &$values) {
+ public static function format($fid, $params, $fields, &$values, $amount_override = NULL) {
if (empty($params["price_{$fid}"])) {
return;
}
}
foreach ($params["price_{$fid}"] as $oid => $qty) {
- $price = $options[$oid]['amount'];
+ $price = $amount_override === NULL ? $options[$oid]['amount'] : $amount_override;
// lets clean the price in case it is not yet cleant
// CRM-10974
* This parameter appears to only be relevant to determining whether memberships should be auto-renewed.
* (and is effectively a boolean for 'is_membership' which could be calculated from the line items.)
*/
- public static function processAmount($fields, &$params, &$lineItem, $component = '') {
+ public static function processAmount($fields, &$params, &$lineItem, $component = '', $priceSetID = NULL) {
// using price set
$totalPrice = $totalTax = 0;
+ // CRM-18701 Sometimes the amount in the price set is overridden by the amount on the form.
+ // This is notably the case with memberships and we need to put this amount
+ // on the line item rather than the calculated amount.
+ // This seems to only affect radio link items as that is the use case for the 'quick config'
+ // set up (which allows a free form field).
+ $amount_override = NULL;
if ($component) {
$autoRenew = array();
$autoRenew[0] = $autoRenew[1] = $autoRenew[2] = 0;
}
+ if ($priceSetID) {
+ $priceFields = self::filterPriceFieldsFromParams($priceSetID, $params);
+ if (count($priceFields) == 1 && !empty($params['total_amount'])) {
+ $amount_override = $params['total_amount'];
+ }
+ }
foreach ($fields as $id => $field) {
if (empty($params["price_{$id}"]) ||
(empty($params["price_{$id}"]) && $params["price_{$id}"] == NULL)
$params["price_{$id}"] = array($params["price_{$id}"] => 1);
$optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);
- CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
+ 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 += $field['options'][$optionValueId]['tax_amount'];
'entity_table' => 'civicrm_membership',
'contribution_id' => $contribution['id'],
), 1);
+ $this->_checkFinancialRecords(array('id' => $contribution['id'], 'total_amount' => 50, 'financial_account_id' => 2), 'online');
}
/**
'entity_table' => 'civicrm_membership',
'contribution_id' => $contribution['id'],
), 1);
+
+ $this->_checkFinancialRecords(array('id' => $contribution['id'], 'total_amount' => 50, 'financial_account_id' => 2), 'online');
$this->mut->checkMailLog(array(
'50',
'Receipt text',
$compareParams = array(
'amount' => CRM_Utils_Array::value('total_amount', $params, 100),
'status_id' => 1,
- 'financial_account_id' => 1,
+ 'financial_account_id' => CRM_Utils_Array::value('financial_account_id', $params, 1),
);
if ($context == 'payLater') {
$compareParams = array(
'amount' => CRM_Utils_Array::value('total_amount', $params, 100),
'status_id' => 3,
- 'financial_account_id' => 1,
+ 'financial_account_id' => CRM_Utils_Array::value('financial_account_id', $params, 1),
);
}
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $fitemParams, $compareParams);