// 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 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;
}
}
+ // 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);
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;
}
}
}
-