// build price set form.
$buildPriceSet = FALSE;
+
+ // showing tax amount on edit contribution page
+ if ($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']))
) {
}
}
+ // assign dataArray for contribution receipts
+ $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);
+ }
+ else {
+ $dataArray[$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);
$this->assign('useForMember', $this->get('useForMember'));
$params = $this->_params;
+ $this->assign('totalTaxAmount', $params['tax_amount']);
if ($this->_honor_block_is_active && !empty($params['soft_credit_type_id'])) {
$honorName = null;
$softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
// assign values to the template
$this->assign($values);
+ if (isset($values['tax_amount'])) {
+ $this->assign('totalTaxAmount', $values['tax_amount']);
+ }
$displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
$this->assign('displayName', $displayName);
CRM_Event_Form_Registration::initEventFee($form, $event['id']);
CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId);
$lineItem = array();
+ $totalTaxAmount = 0;
if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) {
$lineItem[] = $form->_values['line_items'];
+ foreach ($form->_values['line_items'] as $key => $value) {
+ $totalTaxAmount = $value['tax_amount'] + $totalTaxAmount;
+ }
}
+ $form->assign('totalTaxAmount', $totalTaxAmount);
$form->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
$discounts = array();
if (!empty($form->_values['discount'])) {
$displayName = CRM_Contact_BAO_Contact::displayName($values[$participantID]['contact_id']);
$participantCount = array();
+ $totalTaxAmount = 0;
foreach ($lineItem as $k => $v) {
if (CRM_Utils_Array::value('participant_count', $lineItem[$k]) > 0) {
$participantCount[] = $lineItem[$k]['participant_count'];
}
+ $totalTaxAmount = $v['tax_amount'] + $totalTaxAmount;
}
+ $this->assign('totalTaxAmount', $totalTaxAmount);
if ($participantCount) {
$this->assign('pricesetFieldsCount', $participantCount);
}
}
$this->assignToTemplate();
+ $taxAmount = 0;
if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$lineItemForTemplate = array();
foreach ($this->_lineItem as $key => $value) {
if (!empty($value)) {
$lineItemForTemplate[$key] = $value;
+ foreach ($value as $v) {
+ if (isset($v['tax_amount'])) {
+ $taxAmount += $v['tax_amount'];
+ }
+ }
}
}
if (!empty($lineItemForTemplate)) {
$this->assign('lineItem', $lineItemForTemplate);
}
}
+ else {
+ foreach ($this->_lineItem as $lineItemKey => $lineItemValue) {
+ foreach ($lineItemValue as $v) {
+ if (isset($v['tax_amount'])) {
+ $taxAmount += $v['tax_amount'];
+ }
+ }
+ }
+ }
+ $this->assign('totalTaxAmount', $taxAmount);
$this->assign('totalAmount', $this->_totalAmount);
$hookDiscount = $this->get('hookDiscount');
$priceFieldBAO->orderBy('weight, label');
$priceFieldBAO->find();
+ $getTaxDetails = FALSE;
+ $taxRate = CRM_Core_PseudoConstant::getTaxRates();
while ($priceFieldBAO->fetch()) {
$priceField[$priceFieldBAO->id] = array();
CRM_Core_DAO::storeValues($priceFieldBAO, $priceField[$priceFieldBAO->id]);
CRM_Price_BAO_PriceFieldValue::retrieve($params, $optionValues);
+ $financialTypeId = $optionValues['financial_type_id'];
$priceField[$priceFieldBAO->id]['price'] = CRM_Utils_Array::value('amount', $optionValues);
+ if (isset($taxRate[$financialTypeId])) {
+ $priceField[$priceFieldBAO->id]['tax_rate'] = $taxRate[$financialTypeId];
+ $getTaxDetails = TRUE;
+ }
+ if (isset($priceField[$priceFieldBAO->id]['tax_rate'])) {
+ $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($priceField[$priceFieldBAO->id]['price'], $priceField[$priceFieldBAO->id]['tax_rate']);
+ $priceField[$priceFieldBAO->id]['tax_amount'] = $taxAmount['tax_amount'];
+ }
}
$action = array_sum(array_keys($this->actionLinks()));
'PriceField',
$priceFieldBAO->id
);
+ $this->assign('getTaxDetails', $getTaxDetails);
}
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}");
CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption);
$config = CRM_Core_Config::singleton();
$financialType = CRM_Contribute_PseudoConstant::financialType();
+ $taxRate = CRM_Core_PseudoConstant::getTaxRates();
+ $getTaxDetails = FALSE;
foreach ($customOption as $id => $values) {
$action = array_sum(array_keys($this->actionLinks()));
+ // Adding the required fields in the array
+ if (isset($taxRate[$values['financial_type_id']])) {
+ $customOption[$id]['tax_rate'] = $taxRate[$values['financial_type_id']];
+ if (isset($customOption[$id]['tax_rate'])) {
+ $getTaxDetails = TRUE;
+ }
+ $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($customOption[$id]['amount'], $customOption[$id]['tax_rate']);
+ $customOption[$id]['tax_amount'] = $taxAmount['tax_amount'];
+ }
if (!empty($values['financial_type_id'])){
$customOption[$id]['financial_type_id'] = $financialType[$values['financial_type_id']];
}
'id', $returnURL, $filter
);
+ $this->assign('getTaxDetails', $getTaxDetails);
$this->assign('customOption', $customOption);
$this->assign('sid', $this->_sid);
}
{$membership_name} {ts}Membership{/ts}: <strong>{$minimum_fee|crmMoney}</strong>
{/if}
{else}
+ {if $totalTaxAmount }
+ {ts}Total Tax Amount{/ts}: <strong>{$totalTaxAmount|crmMoney} </strong><br />
+ {/if}
{if $amount }
{ts}Total Amount{/ts}: <strong>{$amount|crmMoney} {if $amount_level } - {$amount_level} {/if}</strong>
{else}
<strong> -------------------------------------------</strong><br />
{ts}Total{/ts}: <strong>{$amount+$membership_amount|crmMoney}</strong><br />
{else}
+ {if $totalTaxAmount}
+ {ts}Tax Amount{/ts}: <strong>{$totalTaxAmount|crmMoney}</strong><br />
+ {/if}
{ts}Amount{/ts}: <strong>{$amount|crmMoney} {if $amount_level} - {$amount_level} {/if}</strong><br />
{/if}
{/if}
}
});
- cj('.total_amount-section').remove();
+ var taxAmount = "{$totalTaxAmount}";
+ if (taxAmount) {
+ cj('.total_amount-section').show();
+ }
+ else {
+ cj('.total_amount-section').remove();
+ }
}
});
</script>
<div class="clear"></div>
{/foreach}
</div>
+ {if $totalTaxAmount}
+ <div class="crm-section no-label total-amount-section">
+ <div class="content bold">{ts}Total Tax Amount{/ts}: {$totalTaxAmount|crmMoney}</div>
+ <div class="clear"></div>
+ </div>
+ {/if}
{if $totalAmount}
<div class="crm-section no-label total-amount-section">
<div class="content bold">{ts}Total Amount{/ts}: {$totalAmount|crmMoney}</div>
<div class="clear"></div>
{/foreach}
</div>
+ {if $totalTaxAmount}
+ <div class="content bold">{ts}Tax Total{/ts}: {$totalTaxAmount|crmMoney}</div>
+ <div class="clear"></div>
+ {/if}
{if $totalAmount}
<div class="crm-section no-label total-amount-section">
<div class="content bold">{ts}Event Total{/ts}: {$totalAmount|crmMoney}</div>
<th>{ts}Active On{/ts}</th>
<th>{ts}Expire On{/ts}</th>
<th id="nosort">{ts}Price{/ts}</th>
+ {if $getTaxDetails}
+ <th>{ts}Tax Label{/ts}</th>
+ <th>{ts}Tax Amount{/ts}</th>
+ {/if}
<th></th>
<th class="hiddenElement"></th>
</tr>
<td>{if $row.active_on}{$row.active_on|date_format:"%Y-%m-%d %T"}{/if}</td>
<td>{if $row.expire_on}{$row.expire_on|date_format:"%Y-%m-%d %T"}{/if}</td>
<td>{if $row.html_type eq "Text / Numeric Quantity"}{$row.price|crmMoney}{else}<a href="{crmURL p="civicrm/admin/price/field/option" q="action=browse&reset=1&sid=$sid&fid=$fid"}">{if $isReserved}{ts}View Price Options{/ts}{else}{ts}Edit Price Options{/ts}{/if}</a>{/if}</td>
+ {if $getTaxDetails}
+ <td>{if $row.tax_rate != '' && $row.html_type eq "Text / Numeric Quantity"}
+ {if $row.tax_rate == 0.00}
+ VAT(Exempt)
+ {else}
+ VAT({$row.tax_rate|string_format:"%.2f"}%)
+ {/if}
+ {/if}</td>
+ <td>{if $row.html_type eq "Text / Numeric Quantity" }{$row.tax_amount|crmMoney}{/if}</td>
+ {/if}
<td class="field-action">{$row.action|replace:'xx':$row.id}</td>
<td class="order hiddenElement">{$row.weight}</td>
</tr>
{else}
<th class="right">{ts}Qty{/ts}</th>
<th class="right">{ts}Unit Price{/ts}</th>
- <th class="right">{ts}Total Price{/ts}</th>
- {/if}
+ {if !$totalTaxAmount}
+ <th class="right">{ts}Total Price{/ts}</th>
+ {/if}
+ {/if}
+
+ {if $totalTaxAmount}
+ <th class="right">{ts}Subtotal{/ts}</th>
+ <th class="right">{ts}Tax Rate{/ts}</th>
+ <th class="right">{ts}Tax Amount{/ts}</th>
+ <th class="right">{ts}Total Amount{/ts}</th>
+ {/if}
{if $pricesetFieldsCount}
<th class="right">{ts}Total Participants{/ts}</th>{/if}
{if $context NEQ "Membership"}
<td class="right">{$line.qty}</td>
<td class="right">{$line.unit_price|crmMoney}</td>
- {/if}
+ {else}
<td class="right">{$line.line_total|crmMoney}</td>
+{/if}
+ {if !$totalTaxAmount && $context NEQ "Membership"}
+ <td class="right">{$line.line_total|crmMoney}</td>
+ {/if}
+ {if $totalTaxAmount}
+ <td class="right">{$line.line_total-$line.tax_amount|crmMoney}</td>
+ {if $line.tax_rate != ""}
+ {if $line.tax_rate == 0}
+ <td class="right">VAT(exempt)</td>
+ {else}
+ <td class="right">VAT({$line.tax_rate|string_format:"%.2f"}%)</td>
+ {/if}
+ <td class="right">{$line.tax_amount|crmMoney}</td>
+ {elseif $line.tax_amount != ''}
+ <td class="right">VAT(exempt)</td>
+ <td class="right">{$line.tax_amount|crmMoney}</td>
+ {else}
+ <td></td>
+ <td></td>
+ {/if}
+ <td class="right">{$line.line_total|crmMoney}</td>
+ {/if}
{if $pricesetFieldsCount}<td class="right">{$line.participant_count}</td> {/if}
</tr>
{/foreach}
<div class="crm-section no-label total_amount-section">
<div class="content bold">
+ {if $totalTaxAmount}
+ {ts}Total Tax Amount{/ts}: {$totalTaxAmount|crmMoney}<br />
+ {/if}
{if $context EQ "Contribution"}
{ts}Contribution Total{/ts}:
{elseif $context EQ "Event"}
- {ts}Event Total{/ts}:
+ {if $totalTaxAmount}
+ {ts}Event SubTotal: {$totalAmount-$totalTaxAmount|crmMoney}{/ts}<br />
+ {/if}
+ {ts}Total{/ts}:
{elseif $context EQ "Membership"}
{ts}Membership Fee Total{/ts}:
{else}
<th>{ts}Default{/ts}</th>
<th>{ts}Financial Type{/ts}</th>
<th id="order" class="sortable">{ts}Order{/ts}</th>
+ {if $getTaxDetails}
+ <th>{ts}Tax Label{/ts}</th>
+ <th>{ts}Tax Amount{/ts}</th>
+ {/if}
<th>{ts}Enabled?{/ts}</th>
<th></th>
<th class="hiddenElement"></th>
<td class="crm-price-option-is_default">{if $row.is_default}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" />{/if}</td>
<td class="nowrap crm-price-option-financial-type-id">{$row.financial_type_id}</td>
<td class="nowrap crm-price-option-order">{$row.weight}</td>
+ {if $getTaxDetails}
+ <td>{if $row.tax_rate != '' }
+ {if $row.tax_rate == 0.00}
+ VAT(Exempt)
+ {else}
+ VAT({$row.tax_rate|string_format:"%.2f"}%)
+ {/if}
+ {/if}</td>
+ <td>{$row.tax_amount|crmMoney}</td>
+ {/if}
<td id="row_{$row.id}_status" class="crm-price-option-is_active">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
<td>{$row.action|replace:'xx':$row.id}</td>
<td class="order hiddenElement">{$row.weight}</td>