Jump to content

ViewInvoice Tax Splitting


Recommended Posts

Hello,

 

I want to split taxrate of an invoice into 3 parts as we can not add multiple tax rules for an invoice for tax1. Say if i am adding 2 tax1 rules then invoice shows last one so i want to show like this:

 

Tax Rules added of 15% and in viewinvoice i want it to be 14%, 0.5%, 0.5% as image attached for this i am changed as:

 

{if $taxrate}
                                   <tr>
                                       <td class="total-row text-right"><strong>{$taxrate - 1}% Service Tax</strong></td>
                                       <td class="total-row text-center">{$tax * 0.9333}</td>
                                   </tr>
                               <tr>
                                       <td class="total-row text-right"><strong>{$taxrate - 14.50}% Swachh Bharat Cess</strong></td>
                                       <td class="total-row text-center">{$tax * 0.0333}</td>
                                   </tr>
                               <tr>
                                       <td class="total-row text-right"><strong>{$taxrate - 14.50}% Krishi Kalyan Cess</strong></td>
                                       <td class="total-row text-center">{$tax * 0.0333}</td>
                                   </tr>
                               {/if}

 

But it shows me blank if i add $tax it shows 15%

whmcstax.png

Link to comment
Share on other sites

Tax Rules added of 15% and in viewinvoice i want it to be 14%, 0.5%, 0.5% as image attached for this i am changed as:

But it shows me blank if i add $tax it shows 15%

the problem you have is that {$tax} isn't a number, it's a string, e.g it's value is "€1.50EUR" and therefore you can't do any calculations with it.

 

the only way you could would be to strip the prefix/suffix (€/EUR) from the string, then you'd be left with a number - that would work, but it would then be difficult to add the prefix/suffix back.

 

if you are using v7.1, you should be able to use this...

 

                                {if $taxrate}
                                   {assign currencyprefix {$tax->toPrefixed()|replace:$tax->toNumeric():''}}
                                   {assign currencysuffix {$tax->toSuffixed()|replace:$tax->toNumeric():''}}
                                   <tr>
                                       <td class="total-row text-right"><strong>{$taxrate - 1}% Service Tax</strong></td>
                                       <td class="total-row text-center">{$currencyprefix}{($tax->toNumeric() * 0.9333)|number_format:2}{$currencysuffix}</td>
                                   </tr>
                                   <tr>
                                       <td class="total-row text-right"><strong>{$taxrate - 14.50}% Swachh Bharat Cess</strong></td>
                                       <td class="total-row text-center">{$currencyprefix}{($tax->toNumeric() * 0.0333)|number_format:2}{$currencysuffix}</td>
                                   </tr>
                                   <tr>
                                       <td class="total-row text-right"><strong>{$taxrate - 14.50}% Krishi Kalyan Cess</strong></td>
                                       <td class="total-row text-center">{$currencyprefix}{($tax->toNumeric() * 0.0333)|number_format:2}{$currencysuffix}</td>
                                   </tr> 
                               {/if}

it would probably have been easier to do this as an action hook and then pass the results back to the template, but the above Smarty code should work if you're using v7.1+. :idea:

Link to comment
Share on other sites

it should be virtually the same - but just converted from Smarty to PHP...

 

$currencyprefix = str_replace($tax->toNumeric(),"",$tax->toPrefixed());
$currencysuffix = str_replace($tax->toNumeric(),"",$tax->toSuffixed());

if ($taxname) {
   $tblhtml .= '
   <tr height="30" bgcolor="#efefef" style="font-weight:bold;">
       <td align="right">' . ($taxrate-1) . '% Service Tax</td>
       <td align="center">' . $currencyprefix . number_format(($tax->toNumeric() * 0.9333),2) . $currencysuffix . '</td>
   </tr>
   <tr height="30" bgcolor="#efefef" style="font-weight:bold;">
       <td align="right">' . ($taxrate-14.5) . '% Swachh Bharat Cess</td>
       <td align="center">' . $currencyprefix . number_format(($tax->toNumeric() * 0.0333),2) . $currencysuffix . '</td>
   </tr>    
   <tr height="30" bgcolor="#efefef" style="font-weight:bold;">
       <td align="right">' . ($taxrate-14.5) . '% Krishi Kalyan Cess</td>
       <td align="center">' . $currencyprefix . number_format(($tax->toNumeric() * 0.0333),2) . $currencysuffix . '</td>
   </tr>';    
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated