Display tax amount in receipts for membership and event offline contribution with...
authorParag Bhilkar <parag.bhilkar@webaccessglobal.com>
Tue, 19 Aug 2014 16:13:40 +0000 (21:43 +0530)
committerParag Bhilkar <parag.bhilkar@webaccessglobal.com>
Tue, 19 Aug 2014 16:13:40 +0000 (21:43 +0530)
CRM/Contribute/Form/Contribution.php
CRM/Event/Form/Participant.php
CRM/Member/Form/Membership.php
CRM/Upgrade/4.5.beta5.msg_template/message_templates/contribution_offline_receipt_html.tpl
CRM/Upgrade/4.5.beta5.msg_template/message_templates/contribution_offline_receipt_text.tpl
CRM/Upgrade/4.5.beta5.msg_template/message_templates/membership_offline_receipt_html.tpl
CRM/Upgrade/4.5.beta5.msg_template/message_templates/membership_offline_receipt_text.tpl
xml/templates/message_templates/contribution_offline_receipt_html.tpl
xml/templates/message_templates/contribution_offline_receipt_text.tpl
xml/templates/message_templates/membership_offline_receipt_html.tpl
xml/templates/message_templates/membership_offline_receipt_text.tpl

index 2c5e91cd05897128a51b724163686982ab0ad7c3..93c5de014564a0c6d29aeb05d75602d908c10c26 100644 (file)
@@ -1352,7 +1352,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       $getTaxDetails = FALSE;
       $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings');
       $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
-      $this->assign('invoicing', $invoicing);
       if ($invoicing) {
         if ($this->_action & CRM_Core_Action::ADD) {
           $line = $lineItem;
@@ -1374,9 +1373,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
           }
         }
       }
-      else {
-        $taxRate = array($submittedValues['tax_amount']);
-      }
        
       if ($invoicing) {
         if ($this->_action & CRM_Core_Action::UPDATE) {
@@ -1394,6 +1390,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
             $this->assign('totalTaxAmount', $submittedValues['tax_amount']);
             $this->assign('getTaxDetails', $getTaxDetails);
             $this->assign('dataArray', $taxRate);
+            $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
           }
           else {
             $this->assign('totalTaxAmount', CRM_Utils_Array::value('tax_amount', $submittedValues));
index 87f877781b38b65c11f8fdfcdce398bcd895800d..2e5c7801e43cc834f57e2ba173c4718f8d5dbfd2 100644 (file)
@@ -1711,6 +1711,7 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
               }
             }
             $this->assign('totalTaxAmount', $totalTaxAmount);
+            $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
             $this->assign('dataArray', $dataArray);
           }
           if (!empty($additionalParticipantDetails)) {
index 1866add14d802db3243f87eff76bd55210b47980..a18814cb8e5361cd267956cc846724e377519008 100644 (file)
@@ -1655,6 +1655,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
     if (!empty($lineItem[$priceSetId])) {
       $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings');
       $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
+      $taxAmount = FALSE;
       $totalTaxAmount = 0;
       foreach ($lineItem[$priceSetId] as & $priceFieldOp) {
         if (!empty($priceFieldOp['membership_type_id'])) {
@@ -1666,6 +1667,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
           $priceFieldOp['start_date'] = $priceFieldOp['end_date'] = 'N/A';
         }
         if ($invoicing && isset($priceFieldOp['tax_amount'])) {
+          $taxAmount = TRUE;
           $totalTaxAmount += $priceFieldOp['tax_amount'];
         }
       }
@@ -1680,7 +1682,10 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
             }
           } 
         }
-        $this->assign('totalTaxAmount', $totalTaxAmount);
+        if ($taxAmount) {
+          $this->assign('totalTaxAmount', $totalTaxAmount);
+          $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
+        }
         $this->assign('dataArray', $dataArray);
       }
     }
index 264e0fee8710b86c00776c7bef657e0c29e1510d..f24045b0dca700787aa53482e52b8a79848bcbfa 100644 (file)
@@ -82,7 +82,7 @@
               </td>
               {if $line.tax_rate != "" || $line.tax_amount != ""}
                 <td>
-                  {$line.tax_rate}%
+                  {$line.tax_rate|string_format:"%.2f"}%
                 </td>
                 <td>
                   {$line.tax_amount|crmMoney:$currency}
       {/foreach}
      {/if}
 
-     {if $getTaxDetails && $totalTaxAmount !== 'null'}
+     {if isset($totalTaxAmount) && $totalTaxAmount !== 'null'}
       <tr>
         <td {$labelStyle}>
           {ts}Total Tax Amount{/ts}
index 7eacb63d834f8662031b005a7d53a962c974bd98..fe202d4d6b622a5f5b75744e324d1e643e078c9e 100644 (file)
@@ -25,7 +25,7 @@
 {$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {if $getTaxDetails} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate} {$ts_taxAmount|string_format:"%10s"} {/if} {$ts_total|string_format:"%10s"}
 ----------------------------------------------------------
 {foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $getTaxDetails}{$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate != "" || $line.tax_amount != ""} {$line.tax_rate} %   {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if} {/if}   {$line.line_total+$line.tax_amount|crmMoney:$currency|string_format:"%10s"}
+{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $getTaxDetails}{$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate != "" || $line.tax_amount != ""} {$line.tax_rate|string_format:"%.2f"} %   {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if} {/if}   {$line.line_total+$line.tax_amount|crmMoney:$currency|string_format:"%10s"}
 {/foreach}
 {/foreach}
 {/if}
@@ -42,7 +42,7 @@
 {/foreach}
 {/if}
 
-{if $getTaxDetails && $totalTaxAmount !== 'null'}
+{if isset($totalTaxAmount) && $totalTaxAmount !== 'null'}
 {ts}Total Tax Amount{/ts} : {$totalTaxAmount|crmMoney:$currency}
 {/if}
 {ts}Total Amount{/ts} : {$formValues.total_amount|crmMoney:$currency}
index 17fdb8f66048b3cc1dd6efec09a3137b5268c10b..45f339420fd2a64676029f2f4c7d36516040bbc5 100644 (file)
        {/foreach}
       {/if}
       {/if}
-      {if $totalTaxAmount}
+      {if isset($totalTaxAmount)}
         <tr>
          <td {$labelStyle}>
           {ts}Total Tax Amount{/ts}
index 072957de86388a0e7bba54846400f84d1a88355e..6e4348993896bc46db5f16bf4cc76609364edd6b 100644 (file)
@@ -63,7 +63,7 @@
 --------------------------------------------------------------------------------------------------
 {/if}
 
-{if $totalTaxAmount}
+{if isset($totalTaxAmount)}
 {ts}Total Tax Amount{/ts}: {$totalTaxAmount|crmMoney:$currency}
 {/if}
 
index 264e0fee8710b86c00776c7bef657e0c29e1510d..f24045b0dca700787aa53482e52b8a79848bcbfa 100644 (file)
@@ -82,7 +82,7 @@
               </td>
               {if $line.tax_rate != "" || $line.tax_amount != ""}
                 <td>
-                  {$line.tax_rate}%
+                  {$line.tax_rate|string_format:"%.2f"}%
                 </td>
                 <td>
                   {$line.tax_amount|crmMoney:$currency}
       {/foreach}
      {/if}
 
-     {if $getTaxDetails && $totalTaxAmount !== 'null'}
+     {if isset($totalTaxAmount) && $totalTaxAmount !== 'null'}
       <tr>
         <td {$labelStyle}>
           {ts}Total Tax Amount{/ts}
index 7eacb63d834f8662031b005a7d53a962c974bd98..fe202d4d6b622a5f5b75744e324d1e643e078c9e 100644 (file)
@@ -25,7 +25,7 @@
 {$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {if $getTaxDetails} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate} {$ts_taxAmount|string_format:"%10s"} {/if} {$ts_total|string_format:"%10s"}
 ----------------------------------------------------------
 {foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $getTaxDetails}{$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate != "" || $line.tax_amount != ""} {$line.tax_rate} %   {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if} {/if}   {$line.line_total+$line.tax_amount|crmMoney:$currency|string_format:"%10s"}
+{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $getTaxDetails}{$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate != "" || $line.tax_amount != ""} {$line.tax_rate|string_format:"%.2f"} %   {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if} {/if}   {$line.line_total+$line.tax_amount|crmMoney:$currency|string_format:"%10s"}
 {/foreach}
 {/foreach}
 {/if}
@@ -42,7 +42,7 @@
 {/foreach}
 {/if}
 
-{if $getTaxDetails && $totalTaxAmount !== 'null'}
+{if isset($totalTaxAmount) && $totalTaxAmount !== 'null'}
 {ts}Total Tax Amount{/ts} : {$totalTaxAmount|crmMoney:$currency}
 {/if}
 {ts}Total Amount{/ts} : {$formValues.total_amount|crmMoney:$currency}
index 17fdb8f66048b3cc1dd6efec09a3137b5268c10b..45f339420fd2a64676029f2f4c7d36516040bbc5 100644 (file)
        {/foreach}
       {/if}
       {/if}
-      {if $totalTaxAmount}
+      {if isset($totalTaxAmount)}
         <tr>
          <td {$labelStyle}>
           {ts}Total Tax Amount{/ts}
index 072957de86388a0e7bba54846400f84d1a88355e..6e4348993896bc46db5f16bf4cc76609364edd6b 100644 (file)
@@ -63,7 +63,7 @@
 --------------------------------------------------------------------------------------------------
 {/if}
 
-{if $totalTaxAmount}
+{if isset($totalTaxAmount)}
 {ts}Total Tax Amount{/ts}: {$totalTaxAmount|crmMoney:$currency}
 {/if}