VAT-414 The system public pages should be updated to show the VAT/Tax breakdown for...
authorParag Bhilkar <parag.bhilkar@webaccessglobal.com>
Thu, 26 Jun 2014 06:50:36 +0000 (12:20 +0530)
committerParag Bhilkar <parag.bhilkar@webaccessglobal.com>
Thu, 26 Jun 2014 06:50:36 +0000 (12:20 +0530)
16 files changed:
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Contribution/ThankYou.php
CRM/Contribute/Form/ContributionView.php
CRM/Event/Form/EventFees.php
CRM/Event/Form/ParticipantView.php
CRM/Event/Form/Registration/ThankYou.php
CRM/Price/Page/Field.php
CRM/Price/Page/Option.php
templates/CRM/Contribute/Form/Contribution/Confirm.tpl
templates/CRM/Contribute/Form/Contribution/ThankYou.tpl
templates/CRM/Contribute/Page/PaymentInfo.tpl
templates/CRM/Event/Form/Registration/Confirm.tpl
templates/CRM/Event/Form/Registration/ThankYou.tpl
templates/CRM/Price/Page/Field.tpl
templates/CRM/Price/Page/LineItem.tpl
templates/CRM/Price/Page/Option.tpl

index f8afdec141d839e6ca8663c3d84b478964401fc8..f80f9ebd2857727eb924d0040183b89ee3611c7a 100644 (file)
@@ -504,6 +504,12 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
 
     // 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']))
     ) {
@@ -1019,6 +1025,21 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       }
     }
 
+    // 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);
index 1597730d54e4e69559ca8cbab05a479b8271642b..c8b0895bbbd9ba9c9d829a5a20162a3320aadbe7 100644 (file)
@@ -119,6 +119,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
     $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);
index 23e08dd5b85a94940c29cc646fdeb2177cb065b8..34a011edfa1881fc8f44f485096c97bc879660ca 100644 (file)
@@ -144,6 +144,9 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
 
     // 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);
index 753417c8091d1c99cf3296ddf0b6587af0045977..f81f3dc2b959de44d63b7345eb87b9815ade03f1 100644 (file)
@@ -380,9 +380,14 @@ SELECT  id, html_type
       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'])) {
index 0f4faa706a61d63e9a76bb94d204eee59b9f0951..815a4ead2440d0065d945716ae224e22fb1c71b3 100644 (file)
@@ -179,11 +179,14 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form {
     $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);
     }
index 7c9fc60705c39f7e0524b2cdf7bf15c6f2102734..eabe6d4cbf7815ae1d1a94bb6d28b1b12efe34f5 100644 (file)
@@ -98,18 +98,34 @@ class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration {
     }
     $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');
index fb5453e592fa7d3e5e680fd2b717a9d01d4c8479..495ca2476e310de9cadf98db63b101bc1e879eba 100644 (file)
@@ -132,6 +132,8 @@ class CRM_Price_Page_Field extends CRM_Core_Page {
     $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]);
@@ -143,7 +145,16 @@ class CRM_Price_Page_Field extends CRM_Core_Page {
 
         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()));
@@ -185,6 +196,7 @@ class CRM_Price_Page_Field extends CRM_Core_Page {
         'PriceField',
         $priceFieldBAO->id
       );
+      $this->assign('getTaxDetails', $getTaxDetails);
     }
 
     $returnURL = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}");
index 78a0bb7c59b7bc54ddc7b850f038c31f7810971e..fdcab22b32a5de73a8ec26775ed93b3d6f8bff5a 100644 (file)
@@ -133,8 +133,19 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
     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']];
       }
@@ -177,6 +188,7 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
       'id', $returnURL, $filter
     );
 
+    $this->assign('getTaxDetails', $getTaxDetails);
     $this->assign('customOption', $customOption);
     $this->assign('sid', $this->_sid);
   }
index f773ff4e5133fe04db799e1a9ee22156dcdb8937..435fcc0ac6d2b1b5eb865092488d5b5933154954 100644 (file)
@@ -79,6 +79,9 @@
                     {$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}
index 955413da87238c6b7b738df4e8bc38e685bae810..fa39cf4f9bfac8cbebbd90b84700e845057a8e75 100644 (file)
             <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}
index 812233877a0283d739d056402316950947327f59..3cfc2d10ee409b73865d7c3d97c4424dfd59e64b 100644 (file)
@@ -37,7 +37,13 @@ CRM.$(function($) {
       }
     });
 
-    cj('.total_amount-section').remove();
+    var taxAmount = "{$totalTaxAmount}";
+    if (taxAmount) {
+      cj('.total_amount-section').show();
+    }
+    else {
+      cj('.total_amount-section').remove();
+    }
   }
 });
 </script>
index 9fafdc53bfeebc290ed0ba90b4debe50571d0c52..435a508d7b854553e54d1f9f51d472341ef8d7d8 100644 (file)
                   <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}:&nbsp;&nbsp;{$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}:&nbsp;&nbsp;{$totalAmount|crmMoney}</div>
index 1e27523e313365c40575c7d09bc19a2135a60430..e55d507ac6cfff0fe504a6aeb794686702503031 100644 (file)
                   <div class="clear"></div>
                     {/foreach}
                 </div>
+                {if $totalTaxAmount}
+                  <div class="content bold">{ts}Tax Total{/ts}:&nbsp;&nbsp;{$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}:&nbsp;&nbsp;{$totalAmount|crmMoney}</div>
index 84159ad0cea29a5c53abec2e29bff6ac248b7dc9..d10ebc6a30755e0fed40a6a1d16118ae0b27c25e 100644 (file)
             <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>
index feacbc347d159d726cbe01d2715428176a77e83b..a66a55108aa4b8e99b60c54659c6c1c5f393a578 100644 (file)
                 {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}
index 7419811118cf6f00444c8cec3291c46eb6a0073d..b532489dbd3af1a4a84d508bfa9de16d11d9fea1 100644 (file)
           <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>