emelectrol Posted July 13, 2016 Share Posted July 13, 2016 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 Link to comment Share on other sites More sharing options...
Daniel Patilea Posted July 13, 2016 Share Posted July 13, 2016 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/ Link to comment Share on other sites More sharing options...
emelectrol Posted July 13, 2016 Author Share Posted July 13, 2016 Thank you for your interest, but I think my problem is different. I don't have problem in front office I just need to generate invoices in £ Link to comment Share on other sites More sharing options...
emelectrol Posted July 14, 2016 Author Share Posted July 14, 2016 (edited) 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 July 14, 2016 by emelectrol (see edit history) Link to comment Share on other sites More sharing options...
Daniel Patilea Posted July 15, 2016 Share Posted July 15, 2016 Take a look in Localisation > Localisation > set your preffered defaults Also navigate to Localisation > Country > Your country > Edit > set your currency Link to comment Share on other sites More sharing options...
emelectrol Posted July 15, 2016 Author Share Posted July 15, 2016 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 Link to comment Share on other sites More sharing options...
rocky Posted July 18, 2016 Share Posted July 18, 2016 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. Link to comment Share on other sites More sharing options...
emelectrol Posted July 18, 2016 Author Share Posted July 18, 2016 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 Link to comment Share on other sites More sharing options...
rocky Posted July 18, 2016 Share Posted July 18, 2016 Oops, looks like you'll need to recalculate all the prices too. That will require additional code in the override. Link to comment Share on other sites More sharing options...
emelectrol Posted July 18, 2016 Author Share Posted July 18, 2016 Oops, looks like you'll need to recalculate all the prices too. That will require additional code in the override. Indeed, if someone knows how to do it is welcome Link to comment Share on other sites More sharing options...
rocky Posted July 19, 2016 Share Posted July 19, 2016 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. 1 Link to comment Share on other sites More sharing options...
emelectrol Posted July 19, 2016 Author Share Posted July 19, 2016 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 1 Link to comment Share on other sites More sharing options...
rocky Posted July 20, 2016 Share Posted July 20, 2016 I'm happy it works for you. Link to comment Share on other sites More sharing options...
emelectrol Posted August 4, 2016 Author Share Posted August 4, 2016 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? Link to comment Share on other sites More sharing options...
rocky Posted August 5, 2016 Share Posted August 5, 2016 I not sure that I fully understand. Can't you just remove the *$order->conversion_rate from that variable only in the invoice code? Link to comment Share on other sites More sharing options...
emelectrol Posted August 5, 2016 Author Share Posted August 5, 2016 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? Link to comment Share on other sites More sharing options...
rocky Posted August 5, 2016 Share Posted August 5, 2016 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. Link to comment Share on other sites More sharing options...
emelectrol Posted August 8, 2016 Author Share Posted August 8, 2016 (edited) 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 August 8, 2016 by emelectrol (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted August 8, 2016 Share Posted August 8, 2016 Can you take a screenshot of what part is wrong? Link to comment Share on other sites More sharing options...
emelectrol Posted August 9, 2016 Author Share Posted August 9, 2016 Link to comment Share on other sites More sharing options...
rocky Posted August 10, 2016 Share Posted August 10, 2016 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. Link to comment Share on other sites More sharing options...
emelectrol Posted August 10, 2016 Author Share Posted August 10, 2016 It works! Thanks a lot for your help Link to comment Share on other sites More sharing options...
rocky Posted August 10, 2016 Share Posted August 10, 2016 You're welcome. I'm happy it works now. Link to comment Share on other sites More sharing options...
ptemmerman Posted November 18, 2016 Share Posted November 18, 2016 (edited) 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 November 18, 2016 by ptemmerman (see edit history) Link to comment Share on other sites More sharing options...
attila729 Posted February 1, 2017 Share Posted February 1, 2017 Hi, i have that problem with value in £ i am ltd UK and my invoice must be english with £.. my presta is 1.6.1.11 and can you help me? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now