WHMCSModuleNetworks Posted April 4, 2017 Share Posted April 4, 2017 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% 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 4, 2017 Share Posted April 4, 2017 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+. 0 Quote Link to comment Share on other sites More sharing options...
WHMCSModuleNetworks Posted April 5, 2017 Author Share Posted April 5, 2017 @brian! What code it will be for invoicepdf.tpl can you share that as well 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 5, 2017 Share Posted April 5, 2017 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>'; } 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.