add vat to message.tpl in checkoutemail module

parkiet

Joined: 2006-03-16
Posts: 22
Posted: Thu, 2007-09-06 08:24

Can anybody help me to add vat to the enail message in the checkout module? On line 187 in Message.tpl there is {$total}. I want to didvide this {$total) by 119 and then multiply it by 19 in a next line to show the costumer the amound of the VAT. Although it may be simple, I cannot find how to do that. So, a little help would be great.
Parkiet

 
Andreas Thyholdt

Joined: 2007-06-29
Posts: 54
Posted: Thu, 2007-09-06 09:59

You could do something like this:

    <tr>
      {if $paper[0] !=""}
        <td colspan="4" align="right">{g->text text="Total excl. VAT"}:</td>
      {else}
        <td colspan="3" align="right">{g->text text="Total excl. VAT"}:</td>
      {/if}
      <td align="right"><strong>{$csymbol}{math equation="round(value,2)" value=$total/1.19}</strong></td>
    </tr>
    <tr>
      {if $paper[0] !=""}
        <td colspan="4" align="right">{g->text text="VAT"}:</td>
      {else}
        <td colspan="3" align="right">{g->text text="VAT"}:</td>   
      {/if}        
      <td align="right"><strong>{$csymbol}{math equation="round(value,2)" value=$total-$total/1.19}</strong></td>
    </tr>

Just insert this where your want it to appear in the table structure.

Cheers,

Andreas

 
parkiet

Joined: 2006-03-16
Posts: 22
Posted: Thu, 2007-09-06 18:37

Hallo Andreas,

Many thanks for your great and fast help. I have done as you told and tested it thoroughly and it works great!

Kind Regards,

Parkiet

 
Andreas Thyholdt

Joined: 2007-06-29
Posts: 54
Posted: Thu, 2007-09-06 19:04

OK, glad to help.

One thing. I forgot to mention that you as a general rule should not edit template files directly, but rather make a subdirectory in the templates folder called local and put a copy of message.tpl in there to edit.

That way you will preserve your version even after an upgrade. Otherwise it could potentially be overwritten.

Files in the local subdirectory takes presendence over the originals when the module is loaded.

Cheers,

Andreas

 
parkiet

Joined: 2006-03-16
Posts: 22
Posted: Fri, 2007-09-07 06:57

Thanks. I already did that.

Kind Regards

Parkiet

 
parkiet

Joined: 2006-03-16
Posts: 22
Posted: Sun, 2007-09-09 09:48

Dear Andreas,

Although I am very happy with your solution, there is still one minor problem. If the outcome has only one decimal, it also writes only one decimal. For example: € 1.20 becomes € 1.2 . In my side I have used NUMBER_FORMAT, but I do not know how to implement that in this occasion. Is there a way to have the outcomes written with two decimals?

Kind Regards,

Parkiet

 
Andreas Thyholdt

Joined: 2007-06-29
Posts: 54
Posted: Sun, 2007-09-09 13:08

This should work:

      {assign var="number" value=math equation="round(value,2)" value=$total/1.19} 
      <td align="right"><strong>{$csymbol}{$number|string_format:"%01.2f"}</strong></td>

Cheers,

Andreas

 
parkiet

Joined: 2006-03-16
Posts: 22
Posted: Sun, 2007-09-09 14:43

Thanks again for your really unbelievable quick help. I have implemented it and tested it. And it works really great!

Kind Regards,

Parkiet