Jump to content

Change invoice currencies


Recommended Posts

Hello everybody

 

I have little problem with my invoices: my website main currencies is euro and I want to keep it, but my business address is in UK so I need to make invoice in pounds or at least with both currencies.

 

How can I do that?

 

Regards

Share this post


Link to post
Share on other sites

Hello everybody

 

I have little problem with my invoices: my website main currencies is euro and I want to keep it, but my business address is in UK so I need to make invoice in pounds or at least with both currencies.

 

How can I do that?

 

Regards

Take a look here: https://www.prestashop.com/forums/topic/84971-solved-different-currency-in-front-office-and-back-office/

Share this post


Link to post
Share on other sites

Bump

 

My problem is that I have all product in backoffice in euro only, so in frontoffice is fine because prestashop convert the prices but in backoffice when I print my sales invoices all of them is in Euro and my company is UK based so I have to made that in pounds, is a legal requirement

Edited by emelectrol (see edit history)

Share this post


Link to post
Share on other sites

Take a look in Localisation > Localisation > set your preffered defaults

Also navigate to Localisation > Country > Your country > Edit > set your currency

 

Yes all of that settings is correct

Share this post


Link to post
Share on other sites

The problem is that the currency is stored with the order and order invoice, so you'll need to override it just for the invoice. Try creating override/classes/pdf/HTMLTemplateInvoice.php with the following:

<?php

class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
{
    public function __construct(OrderInvoice $order_invoice, $smarty, $bulk_mode = false)
    {
        parent::__construct($order_invoice, $smarty, $bulk_mode);
        
        $this->order_invoice->id_currency = 2;
        $this->order->id_currency = 2;   
    }
}

Change 2 to the ID of your UK currency. Remember to go to Advanced Parameters > Performance and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

Share this post


Link to post
Share on other sites

The problem is that the currency is stored with the order and order invoice, so you'll need to override it just for the invoice. Try creating override/classes/pdf/HTMLTemplateInvoice.php with the following:

<?php

class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
{
    public function __construct(OrderInvoice $order_invoice, $smarty, $bulk_mode = false)
    {
        parent::__construct($order_invoice, $smarty, $bulk_mode);
        
        $this->order_invoice->id_currency = 2;
        $this->order->id_currency = 2;   
    }
}

Change 2 to the ID of your UK currency. Remember to go to Advanced Parameters > Performance and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

 

Thank you for your help, but this just change the symbol.

For example: € 30.00 in the invoice will be £ 30.00

Share this post


Link to post
Share on other sites

It's tricky, but try:

<?php

class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
{
    public function __construct(OrderInvoice $order_invoice, $smarty, $bulk_mode = false)
    {
        parent::__construct($order_invoice, $smarty, $bulk_mode);

        if ($this->order->id_currency != 2) {
            $old_currency = Currency::getCurrency((int)$this->order->id_currency);
            $new_currency = Currency::getCurrency(2);
                      
            $conversion_rate = (float)$new_currency['conversion_rate'] / (float)$old_currency['conversion_rate'];
    
            $this->order_invoice->id_currency = (int)$new_currency['id_currency'];
            $this->order->id_currency = (int)$new_currency['id_currency'];

            $this->order->conversion_rate = $conversion_rate;
        }
    }
}

Then override all the invoice TPL files and add *$order->conversion_rate after every price. For example, copy pdf/invoice.payment-tab.tpl if necessary, then change line 33 of themes/<your_theme>/pdf/invoice.payment-tab.tpl from:

						<td class="right small">{displayPrice currency=$payment->id_currency price=$payment->amount}</td>

to:

						<td class="right small">{displayPrice currency=$payment->id_currency price=$payment->amount*$order->conversion_rate}</td>

Unfortunately, there's a lot to TPL files to override and change, but multiplying all prices by the conversion rate should work.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for your help

 

In order I have made changes at this 3 files:

 

invoice.total-tab.tpl

invoice.product-tab.tpl

invoice.tax-tab.tpl

 

situated in pdf folder.

I had *$order->conversion_rate in some lines

 

also I had override/classes/pdf/HTMLTemplateInvoice.php

 

and then cleared the cache

 

it works!

 

thanks again for your help

  • Like 1

Share this post


Link to post
Share on other sites
  • 3 weeks later...

I'm happy it works for you. :)

 

There is another problem now, with your method also the payment that I receive in £ are recalculated. So for example also a payment of 20£ now appear on the invoice as 16.80£

 

Any suggestion?

Share this post


Link to post
Share on other sites
I not sure that I fully understand. Can't you just remove the *$order->conversion_rate from that variable only in the invoice code?

Share this post


Link to post
Share on other sites

 

I not sure that I fully understand. Can't you just remove the *$order->conversion_rate from that variable only in the invoice code?

 

 

I have the backup of every files, but if I replace it I'm at the starting point again.

 

With your method we are telling prestashop to multiplicate the price value for the eur/gpb exchange rate (that is 0.837600 at the moment).

 

The problem is that also the payement that I receive in pounds now are multiplicated, so I get wrong value.

 

Is there a way for tell prestashop to multiplicate only the eur value for the exchange rate?

Share this post


Link to post
Share on other sites
Do you mean pdf/invoice-payment-tab.tpl? If you want that amount displayed differently, you'll need to modify line 33:
						<td class="right small">{displayPrice currency=$payment->id_currency price=$payment->amount}</td>

Since it's already using the payment currency and amount, not the order currency, no conversion is needed, so remove any *$order->conversion_rate you have there.

Share this post


Link to post
Share on other sites

Thank you for your help

 

In order I have made changes at this 3 files:

 

invoice.total-tab.tpl

invoice.product-tab.tpl

invoice.tax-tab.tpl

 

situated in pdf folder.

I had *$order->conversion_rate in some lines

 

also I had override/classes/pdf/HTMLTemplateInvoice.php

 

and then cleared the cache

 

it works!

 

thanks again for your help

 

This is the files that I have modified previously, so I don't have changed nothing in pdf/invoice-payment-tab.tpl

Edited by emelectrol (see edit history)

Share this post


Link to post
Share on other sites

So it's working when the currencies are different, but not when the currencies are the same? In that case, try:

<?php

class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
{
    public function __construct(OrderInvoice $order_invoice, $smarty, $bulk_mode = false)
    {
        parent::__construct($order_invoice, $smarty, $bulk_mode);

        if ($this->order->id_currency != 2) {
            $old_currency = Currency::getCurrency((int)$this->order->id_currency);
            $new_currency = Currency::getCurrency(2);
                      
            $conversion_rate = (float)$new_currency['conversion_rate'] / (float)$old_currency['conversion_rate'];
    
            $this->order_invoice->id_currency = (int)$new_currency['id_currency'];
            $this->order->id_currency = (int)$new_currency['id_currency'];

            $this->order->conversion_rate = $conversion_rate;
        } else {
            $this->order->conversion_rate = 1;
        }
    }
}

This should set the conversion rate to 1 if the order currency has an ID of 2, which should hopefully make no change to the prices.

Share this post


Link to post
Share on other sites
  • 3 months later...

Hi,

 

Great topic!

I need exactly the same, but just the other way around.

 

Just one question:

 

On the backend I want the invoices to always be generated in EUR, however customers in UK should be able to get their invoice in GPB. Is that still possible with this modification?

 

 

Thanks in advance.

Edited by ptemmerman (see edit history)

Share this post


Link to post
Share on other sites
  • 2 months later...

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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More