// build price set form.
$buildPriceSet = FALSE;
+ $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings');
+ $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
- // showing tax amount on edit contribution page
- if ($this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) {
+ // display tax amount on edit contribution page
+ if ($invoicing && $this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) {
$this->assign('totalTaxAmount', $this->_values['tax_amount']);
}
$softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields, $errors, $self);
- if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) {
- $sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
- if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
+ // If we have a net amount or fee amount that is NOT set to 0.00, then ensure
+ // that the net_amount + the fee_amount is equal to the total amount.
+ $total_amount = NULL;
+ if(!empty($fields['total_amount']) && $fields['total_amount'] != '0.00') {
+ $total_amount = $fields['total_amount'];
+ }
+ $fee_amount = NULL;
+ if(!empty($fields['fee_amount']) && $fields['fee_amount'] != '0.00') {
+ $fee_amount = $fields['fee_amount'];
+ }
+ $net_amount = NULL;
+ if(!empty($fields['net_amount']) && $fields['net_amount'] != '0.00') {
+ $net_amount = $fields['net_amount'];
+ }
+ if ($total_amount && ($net_amount || $fee_amount)) {
+ $sum = CRM_Utils_Rule::cleanMoney($net_amount) + CRM_Utils_Rule::cleanMoney($fee_amount);
+ if (CRM_Utils_Rule::cleanMoney($total_amount) != $sum) {
$errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount');
}
}
$dataArray = array();
foreach ($this->_lineItems as $key => $value) {
foreach ($value as $v) {
- if (isset($dataArray[$v['tax_rate']])) {
- $dataArray[$v['tax_rate']] = $dataArray[$v['tax_rate']] + CRM_Utils_Array::value('tax_amount', $v);
+ if (isset($dataArray[(string)$v['tax_rate']])) {
+ $dataArray[(string)$v['tax_rate']] = $dataArray[(string)$v['tax_rate']] + CRM_Utils_Array::value('tax_amount', $v);
}
else {
- $dataArray[$v['tax_rate']] = CRM_Utils_Array::value('tax_amount', $v);
+ $dataArray[(string)$v['tax_rate']] = CRM_Utils_Array::value('tax_amount', $v);
}
}
}
);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
- $this->_lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
+ $this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
}
else {
}
// Set is_pay_later flag for back-office offline Pending status contributions CRM-8996
+ // else if contribution_status is changed to Completed is_pay_later flag is changed to 0, CRM-15041
if ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name')) {
$params['is_pay_later'] = 1;
}
+ elseif ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
+ $params['is_pay_later'] = 0;
+ }
$ids['contribution'] = $params['id'] = $this->_id;
unset($submittedValues[$key]);
}
}
-
+ $isTest = ($this->_mode == 'test') ? 1 : 0;
// CRM-12680 set $_lineItem if its not set
if (empty($this->_lineItem) && !empty($lineItem)) {
$this->_lineItem = $lineItem;
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
- $result = NULL;
-
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor, CRM-7115
if (!empty($paymentParams['is_recur'])) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this,
$this->_params,
- $result,
+ NULL,
$this->_contactID,
$contributionType,
- FALSE,
TRUE,
- FALSE
+ FALSE,
+ $isTest,
+ $this->_lineItem
);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
-
+ $result = NULL;
if ($paymentParams['amount'] > 0.0) {
// force a re-get of the payment processor in case the form changed it, CRM-7179
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this, TRUE);
$result,
$this->_contactID,
$contributionType,
- FALSE, FALSE, FALSE
+ FALSE, FALSE,
+ $isTest,
+ $this->_lineItem
);
}
}
}
}
-