Jump to content

Increase currency decimals but only product unit price


Jacek Es

Recommended Posts

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 by Jacek Es (see edit history)
Link to comment
Share on other sites

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:

Screenshot2024-10-30at11_39_25.thumb.png.30eb107f395c6b58ad55be218b344a67.png

 

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

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

Screenshot2024-10-30at13_55_19.thumb.png.22055785a43ac89fac22bf18e0c67720.png

 

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

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:

Screenshot2024-10-30at17_25_49.png.439ed04e865decbabf8fb5843d995714.png

£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:

Screenshot2024-10-30at16_57_29.thumb.png.55f96a23bcb6f3873f85b266da859507.png

 

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

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