From 5ebee3756d52e9e730c3e59ecd415d0ce45dcf92 Mon Sep 17 00:00:00 2001 From: dpradeep Date: Fri, 4 Jul 2014 16:02:11 +0530 Subject: [PATCH] VAT-568 [Tax Term] use on contribution and event registration page. --- CRM/Price/BAO/PriceField.php | 37 ++++++++----------- templates/CRM/Event/Form/ManageEvent/Fee.tpl | 2 +- .../CRM/Financial/Form/FinancialAccount.tpl | 4 +- templates/CRM/Price/Form/PriceSet.tpl | 9 ++--- 4 files changed, 21 insertions(+), 31 deletions(-) diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 4f34da3066..108708415c 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -283,16 +283,18 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { //use value field. $valueFieldName = 'amount'; $seperator = '|'; - $displayOpt = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); - $displayOpt = CRM_Utils_Array::value('tax_display_settings', $displayOpt); + $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); + $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); + $displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings); switch ($field->html_type) { case 'Text': $optionKey = key($customOption); $count = CRM_Utils_Array::value('count', $customOption[$optionKey], ''); $max_value = CRM_Utils_Array::value('max_value', $customOption[$optionKey], ''); $taxAmount = CRM_Utils_Array::value('tax_amount', $customOption[$optionKey]); - if ($taxAmount && $displayOpt) { + if (isset($taxAmount) && $displayOpt) { $qf->assign('displayOpt', $displayOpt); + $qf->assign('taxTerm', $taxTerm); } $priceVal = implode($seperator, array($customOption[$optionKey][$valueFieldName] + $taxAmount, $count, $max_value)); @@ -355,24 +357,21 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); if ($field->is_display_amounts) { $opt['label'] = !empty($opt['label']) ? $opt['label'] : ''; - if ($taxAmount) { + if (isset($taxAmount)) { if ($displayOpt == 'Do_not_show') { $opt['label'] = '' . CRM_Utils_Money::format($opt[$valueFieldName] + $taxAmount) . ' ' . $opt['label'] . ''; } else if ($displayOpt == 'Inclusive') { $opt['label'] = '' . CRM_Utils_Money::format($opt[$valueFieldName] + $taxAmount) . ' ' . $opt['label'] . ''; - $opt['label'] .= ' (includes '.round($opt['tax_rate'],2).'% VAT - ' . CRM_Utils_Money::format($taxAmount) . ')'; + $opt['label'] .= ' (includes '.round($opt['tax_rate'],2).'% ' . $taxTerm . ' - ' . CRM_Utils_Money::format($taxAmount) . ')'; } else { $opt['label'] = '' . CRM_Utils_Money::format($opt[$valueFieldName]) . ' ' . $opt['label'] . ''; - $opt['label'] .= ' + '.round($opt['tax_rate'],2).'% VAT - ' . CRM_Utils_Money::format($taxAmount) . ''; + $opt['label'] .= ' + '. CRM_Utils_Money::format($opt['tax_amount']) . ' - ' . round($opt['tax_rate'],2).'% ' . $taxTerm . ''; } } else { $opt['label'] = '' . CRM_Utils_Money::format($opt[$valueFieldName]) . ' ' . $opt['label'] . ''; - if (isset($opt['tax_amount']) && $displayOpt != 'Do_not_show') { - $opt['label'] .= ''. ts(' VAT (exempt)') .''; - } } } $count = CRM_Utils_Array::value('count', $opt, ''); @@ -452,14 +451,11 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { if ($field->is_display_amounts) { $opt['label'] .= ' - '; - if ($taxAmount) { - $opt['label'] .= self::getTaxLabel($opt, $valueFieldName, $displayOpt); + if (isset($taxAmount)) { + $opt['label'] .= self::getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm); } else { $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]); - if (isset($opt['tax_amount']) && $displayOpt != 'Do_not_show') { - $opt['label'] .= ''. ts(' VAT (exempt)') .''; - } } } $selectOption[$opt['id']] = $opt['label']; @@ -496,14 +492,11 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { if ($field->is_display_amounts) { $opt['label'] .= ' - '; - if ($taxAmount) { - $opt['label'] .= self::getTaxLabel($opt, $valueFieldName, $displayOpt); + if (isset($taxAmount)) { + $opt['label'] .= self::getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm); } else { $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]); - if (isset($opt['tax_amount']) && $displayOpt != 'Do_not_show') { - $opt['label'] .= ''. ts(' VAT (exempt)') .''; - } } } $priceVal = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value)); @@ -747,17 +740,17 @@ WHERE id IN (" . implode(',', array_keys($priceFields)) . ')'; * @static * */ - public static function getTaxLabel($opt, $valueFieldName, $displayOpt) { + public static function getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm) { if ($displayOpt == 'Do_not_show') { $label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount']); } else if ($displayOpt == 'Inclusive') { $label = CRM_Utils_Money::format($opt[$valueFieldName] + $opt['tax_amount']); - $label .= ' (includes '.round($opt['tax_rate'],2).'% VAT - ' . CRM_Utils_Money::format($opt['tax_amount']) . ')'; + $label .= ' (includes '.round($opt['tax_rate'],2).'% ' . $taxTerm . ' - ' . CRM_Utils_Money::format($opt['tax_amount']) . ')'; } else { $label = CRM_Utils_Money::format($opt[$valueFieldName]); - $label .= ' + '.round($opt['tax_rate'],2).'% VAT - ' . CRM_Utils_Money::format($opt['tax_amount']) . ''; + $label .= ' + '. CRM_Utils_Money::format($opt['tax_amount']) . ' - ' . round($opt['tax_rate'],2).'% ' . $taxTerm . ''; } return $label; diff --git a/templates/CRM/Event/Form/ManageEvent/Fee.tpl b/templates/CRM/Event/Form/ManageEvent/Fee.tpl index 2d4e084205..e8e2a167d4 100644 --- a/templates/CRM/Event/Form/ManageEvent/Fee.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Fee.tpl @@ -127,7 +127,7 @@   - {ts}This financial type will be assigned to payments made by participants when they register online.{/ts} + {ts}This financial type will be assigned to payments made by participants when they register online. If using a price set below note that the contribution record will have this financial type, however line items will be processed using the actual financial type selected for the price set item.{/ts} diff --git a/templates/CRM/Financial/Form/FinancialAccount.tpl b/templates/CRM/Financial/Form/FinancialAccount.tpl index ddc5514cd7..0492fc8a45 100644 --- a/templates/CRM/Financial/Form/FinancialAccount.tpl +++ b/templates/CRM/Financial/Form/FinancialAccount.tpl @@ -77,13 +77,13 @@ {$form.is_tax.label} {$form.is_tax.html}
- {ts}Does this account hold taxes collected? NB: for information only - not used by core CiviCRM.{/ts} + {ts}Does this account hold taxes collected?{/ts} {$form.tax_rate.label} {$form.tax_rate.html}
- {ts}The default rate used to calculate the taxes collected into this account (e.g. for tax rate of 8.27%, enter 8.27). NB: for information only - not used by core CiviCRM.{/ts} + {ts}The default rate used to calculate the taxes collected into this account (e.g. for tax rate of 8.27%, enter 8.27).{/ts} diff --git a/templates/CRM/Price/Form/PriceSet.tpl b/templates/CRM/Price/Form/PriceSet.tpl index ab29bb6f4f..b051f04cde 100644 --- a/templates/CRM/Price/Form/PriceSet.tpl +++ b/templates/CRM/Price/Form/PriceSet.tpl @@ -71,22 +71,19 @@ {if $element.is_display_amounts && $element.html_type eq 'Text'} {foreach item=option from=$element.options} - {if $option.tax_amount && $displayOpt} + {if $option.tax_amount || $option.tax_amount == "0" && $displayOpt} {assign var="amount" value=`$option.amount+$option.tax_amount`} {if $displayOpt == 'Do_not_show'} {$amount|crmMoney} {elseif $displayOpt == 'Inclusive'} {$amount|crmMoney} - (includes {$option.tax_rate|round:2}% VAT - {$option.tax_amount|crmMoney}) + (includes {$option.tax_rate|round:2}% {$taxTerm} - {$option.tax_amount|crmMoney}) {else} {$option.amount|crmMoney} - + {$option.tax_rate|round:2}% VAT - {$option.tax_amount|crmMoney} + + {$option.tax_amount|crmMoney} - {$option.tax_rate|round:2}% {$taxTerm} {/if} {else} {$option.amount|crmMoney} - {if $option.tax_amount == "0" && $displayOpt != 'Do_not_show'} - {ts} VAT (exempt){/ts} - {/if} {/if} {/foreach} -- 2.25.1