Jump to content

[SOLVED] PDF invoice modification


Recommended Posts

Hi every body,

 

I need to make a simple modification on the invoice PDF files to show some extra info.

 

Now the invoice PDF file is showing the following info as summary costs:

 

- Total products (tax excluded)

- Total products (tax included)

- Shipping

- Total Taxes

- Total order

 

And we would like to show it this way:

 

- Total products (tax excluded)

- Total Taxes

- Total products (tax included)

- Shipping

- Total order

 

So we just need to exchange the position of the fields Total product (tax included) and Total Taxes

 

As I have seen, the file to modify is invoice.tpl (at the PDF folder) and the lines that I must modify are these ones:

<table style="width: 100%">
                {if (($order_invoice->total_paid_tax_incl - $order_invoice->total_paid_tax_excl) > 0)}
                <tr style="line-height:5px;">
                    <td style="width: 83%; text-align: right; font-weight: bold">{l s='Product Total (Tax Excl.)' pdf='true'}</td>
                    <td style="width: 17%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_products}</td>
                </tr>

                <tr style="line-height:5px;">
                    <td style="width: 83%; text-align: right; font-weight: bold">{l s='Product Total (Tax Incl.)' pdf='true'}</td>
                    <td style="width: 17%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_products_wt}</td>
                </tr>
                {else}
                <tr style="line-height:5px;">
                    <td style="width: 83%; text-align: right; font-weight: bold">{l s='Product Total' pdf='true'}</td>
                    <td style="width: 17%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_products}</td>
                </tr>
                {/if}

                {if $order_invoice->total_discount_tax_incl > 0}
                <tr style="line-height:5px;">
                    <td style="text-align: right; font-weight: bold">{l s='Total Vouchers' pdf='true'}</td>
                    <td style="width: 17%; text-align: right;">-{displayPrice currency=$order->id_currency price=($order_invoice->total_discount_tax_incl)}</td>
                </tr>
                {/if}

                {if $order_invoice->total_wrapping_tax_incl > 0}
                <tr style="line-height:5px;">
                    <td style="text-align: right; font-weight: bold">{l s='Wrapping Cost' pdf='true'}</td>
                    <td style="width: 17%; text-align: right;">
                    {if $tax_excluded_display}
                        {displayPrice currency=$order->id_currency price=$order_invoice->total_wrapping_tax_excl}
                    {else}
                        {displayPrice currency=$order->id_currency price=$order_invoice->total_wrapping_tax_incl}
                    {/if}
                    </td>
                </tr>
                {/if}

                {if $order_invoice->total_shipping_tax_incl > 0}
                <tr style="line-height:5px;">
                    <td style="text-align: right; font-weight: bold">{l s='Shipping Cost' pdf='true'}</td>
                    <td style="width: 17%; text-align: right;">
                        {if $tax_excluded_display}
                            {displayPrice currency=$order->id_currency price=$order_invoice->total_shipping_tax_excl}
                            {else}
                            {displayPrice currency=$order->id_currency price=$order_invoice->total_shipping_tax_incl}
                        {/if}
                    </td>
                </tr>
                {/if}

                {if ($order_invoice->total_paid_tax_incl - $order_invoice->total_paid_tax_excl) > 0}
                <tr style="line-height:5px;">
                    <td style="text-align: right; font-weight: bold">{l s='Total Tax' pdf='true'}</td>
                    <td style="width: 17%; text-align: right;">{displayPrice currency=$order->id_currency price=($order_invoice->total_paid_tax_incl - $order_invoice->total_paid_tax_excl)}</td>
                </tr>
                {/if}

                <tr style="line-height:5px;">
                    <td style="text-align: right; font-weight: bold">{l s='Total' pdf='true'}</td>
                    <td style="width: 17%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_paid_tax_incl}</td>
                </tr>

            </table>

Taking a closer look to the code I saw that this is the part I must modify:

<tr style="line-height:5px;">
<td style="width: 83%; text-align: right; font-weight: bold">{l s='Product Total (Tax Incl.)' pdf='true'}</td>
<td style="width: 17%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_products_wt}</td>
</tr>

To change the field title from "Total Product (Tax incl.)" to "Total Taxes" I have modified this part:

{l s='Product Total (Tax Incl.)' pdf='true'}

and I've changed it by:

{l s='Total Tax' pdf='true'}

That was the easy part...

 

Now it's time to change the value of the field... and here is where I get stuck :( :( :(

<td style="width: 17%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_products_wt}

Where you see total_products_wt it indicates the value that will be shown, so I've tried to change it by "total_tax", "total_taxes", etc. but nothing works.... :angry: I just want to show the amount of the total tax but it seems imposible!

 

Please could somebody tell me what should I set in that part of the code to show "total taxes"?

 

Thanks in advance :)

Edited by Antakarana (see edit history)
Link to comment
Share on other sites

Hi,

 

I've found the solution at the same invoice.tpl file... There is no specific field at the data base for the taxes so they must be calculated by a simple formula...

 

Then I release that looking at the bottom of the code at the file invoice.tpl there is a part where it calculates the total taxes:

{if ($order_invoice->total_paid_tax_incl - $order_invoice->total_paid_tax_excl) > 0}
        <tr style="line-height:5px;">
           <td style="text-align: right; font-weight: bold">{l s='Total Tax' pdf='true'}</td>
           <td style="width: 17%; text-align: right;">{displayPrice currency=$order->id_currency price=($order_invoice->total_paid_tax_incl - $order_invoice->total_paid_tax_excl)}</td>
        </tr>
 {/if}

I hope it helps!

 

https://www.prestashop.com/forums/topic/594313-solucionado-modificar-posici%C3%B3n-campos-pdf-factura/?do=findComment&comment=2508561

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...