// fix the display of the monetary value, CRM-4038
if (isset($defaults['total_amount'])) {
- $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'], NULL, '%a');
+ if (!empty($defaults['tax_amount'])) {
+ $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'] - $defaults['tax_amount'], NULL, '%a');
+ }
+ else {
+ $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'], NULL, '%a');
+ }
}
if (isset($defaults['non_deductible_amount'])) {
return;
}
$allPanes = array();
+ //tax rate from financialType
+ $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
+ $this->assign('currencies', json_encode(CRM_Core_OptionGroup::values('currencies_enabled')));
// 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);
+
+ // 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']);
+ }
+
if (empty($this->_lineItems) &&
($this->_priceSetId || !empty($_POST['price_set_id']))
) {
$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');
}
}
}
}
+ // assign dataArray for contribution receipts
+ $dataArray = array();
+ foreach ($this->_lineItems as $key => $value) {
+ foreach ($value as $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[(string)$v['tax_rate']] = CRM_Utils_Array::value('tax_amount', $v);
+ }
+ }
+ }
+ $smarty = CRM_Core_Smarty::singleton();
+ $smarty->assign('dataArray', $dataArray);
+
// process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
);
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 {
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
+ // Update line total and total amount with tax on edit
+ if ($lineItems[$itemId]['tax_amount']) {
+ $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney($lineItems[$itemId]['line_total'] + $lineItems[$itemId]['tax_amount']);
+ $submittedValues['total_amount'] = $lineItems[$itemId]['line_total'];
+ }
}
// 10117 update th line items for participants
if (!empty($lineItems[$itemId]['price_field_id'])) {
}
// 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;
}
$params['line_item'] = $lineItem;
$params['payment_processor_id'] = $params['payment_processor'] = CRM_Utils_Array::value('id', $this->_paymentProcessor);
+ if (CRM_Utils_Array::value('tax_amount', $submittedValues)) {
+ $params['tax_amount'] = $submittedValues['tax_amount'];
+ }
//create contribution.
if ($isQuickConfig) {
$params['is_quick_config'] = 1;
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
);
}
}
}
}
-