Jacek Es Posted yesterday at 04:29 PM Share Posted yesterday at 04:29 PM (edited) Hi, PS 8.1.7 While not intending to change currency decimal for the entire shop (Localization > Currencies > Decimals) is it possible to increase the decimals of the Unit Price on the invoice? I have now currency decimals set to 2 but would like to have product unit price displayed with 4 decimals because when the quantity discount is applied the price often has more decimals than 2. I believe this is the part on the invoice (invoice.product-tab.tpl) {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl_including_ecotax} I tried changing it to: {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl_including_ecotax|sprintf:"%.4f"} and {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl_including_ecotax precision=4} but no effect. Is it possible somehow? Edited yesterday at 04:30 PM by Jacek Es (see edit history) Link to comment Share on other sites More sharing options...
Prestashop Addict Posted yesterday at 05:02 PM Share Posted yesterday at 05:02 PM Hi, unfortunately no, because if you don't change global decimals settings, the value is stored with 2 decimals in database. Link to comment Share on other sites More sharing options...
Jacek Es Posted 10 hours ago Author Share Posted 10 hours ago Hi, It seems the Unit Price value (with % discount added) is stored with all decimals or calculated on the fly when needed. Please see below screenshot of invoice generated when the shop currency is set to 2 Decimals (left) and 4 Decimals (right). Order was placed when currency decimals was set to 2: What I am trying to achieve is to change how the calculations are presented. With the 2 Decimals it shows as: £0.21 * 1000 = £207.00 which isn't correct This is because the discounted Unit Price is in fact £0.207. Prestashop 8 rounds the display to £0.21 but for the calculations uses £207.00 How can I address this? Link to comment Share on other sites More sharing options...
Prestashop Addict Posted 9 hours ago Share Posted 9 hours ago Did you try to change method calculation by line instead of product? Link to comment Share on other sites More sharing options...
Jacek Es Posted 8 hours ago Author Share Posted 8 hours ago (edited) Yes. The screenshot in the above post was actually from 'Round on each line' method. 'Round on total' method displays the same as 'Round on each line' in this example. 'Round on each item' is different but the way it's done doesn't serve us because everything is rounded, tax added per item and rounded and at the end multiplied by quantities . The calculations are as follows: Rounding mode: Round on each item Product base price: £0.30 Discount applied at 1000pc: -31% Price after discount excl. VAT: £0.207, rounded to £0.21 20% VAT applied to each item: £0.21 * 0.20 = 0.042, rounded to £0.04 Item price, incl. VAT: £0.21 + £0.04 = £0.25 Total for 1000pcs: £0.25 * 1000 = £250 Edited 8 hours ago by Jacek Es (see edit history) Link to comment Share on other sites More sharing options...
Jacek Es Posted 5 hours ago Author Share Posted 5 hours ago To simplify... The issue comes from a fact (should be considered as bug) that PrestaShop 8.1 rounds Unit Price value but uses unrounded value for further calculations. This makes the calculations wrong. Example: Product base price: £0.30 Discount from 1000pcs: 31% Product price with discount applied: £0.207 PrestaShop 8.1, rounding method: Round on each line or Round on total makes the following calculations: £0.21 * 1000 cannot be £207.00 The problem is that rounded Unit Price with discount is displayed (£0.21) but unrounded value is taken to the calculations (£0.207) In PrestaShop 1.6 with Classical rounding mode the calculations were made correct - the rounded value was displayed and used for the calculations: Possible approaches to resolve this: 1. Display rounded value and use it for further calculations (as it was in PrestaShop 1.6): £0.21 * 1000 = £210.00 2. Display unrounded value and use it for further calculations: £0.207 * 1000 = £207.00 Is there another way of resolving this? Can this bug be taken to the developers somehow? 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