# How to handle units the right way with price decimal digits more than currency

Hello,

we need help for a ugly problem.
On start we set price_decimal = 2.

Now we have some suppliers with “price per hundred”(pph) or “price per thousand”(ppt).
On purchases with ppt 123.45€ when bought lower then 1000 pieces we ran in the problem.

We create UOM with hecto unit and kilo unit, works but looks not great.

We test to set price_decimal = 4 and the next problem come.

On sale and invoices we don’t want and need 4 decimal points at the unit price.

Is there a way to round unit price on sale and invoices(not in reports, accounting goes wrong)?
Or is there a way to handle it the right way?

Max

The number of decimal for unit price is global for all the system because the same price may be copied between different record like from sale line to stock move and invoice line and purchase line to stock move and invoice line.

But what would be the problem to have higher precision ?

Thats good and needfully.

Other software have a mechanic there can set “price per hundred”(hecto) or “price per thousand”(kilo).

Our customers don’t need more than 2 decimal_points and unit prices with 12345.1234€ are not that fine.

This is the unit of measures.

Then I do not understand your question.

Hi Max,

My pragmatical solution was that I modified the Invoice template.

In the “Unit Price” column I removed the “digits=” parameter

``````[...], digits=line.__class__.unit_price.digits[1])
``````

So the resulting variable is

``````format_currency(line.unit_price, invoice.party.lang, invoice.currency)
``````

like in the “Amount” column.

This may not be the cleanest solution, but it works for me, as I know that I will never need more than two digits precision on a customer invoice’s unit price.

Why not create a unit named x1000 of type unit with a factor of 1000, where unit has 1.
So then you can buy 1 unit x1000 and set the price.
Then you can use/consume/sell the product by unit.

Like this you can leave decimal digits at 2, you can buy at the right price and you don’t need to modify anything.

1 Like

Hello,

Sorry for my question i want the right (tryton) way. There a many UOM pre defined, but pph and ppt on unit not.
I think we are on the right way with hecto and kilo units for tryton.

That is why i wrote not in report.
If you have auto calculated products you run in problems, there are no rounding function in pricelist.
P.S. you can set it like digits=2 or what you want, but on accounting site you got problems, the rounding is only on reports.

that is what we actual have, hecto = 100, kilo = 1000.

Conclusion, we are on the right way.

Thanks all.

I would see no problem on sale to reduce the number of digits for unit price as long as the `Product.get_sale_price` is extended to round its result correctly.

I do not think it is good to create unit of measure to get around the precision is right because you will still need at some point to store the actual unit price.

That is our pain.

That is a good idea, we will give it a try.
Invoices got that unit price from sales and there are no calculation from tryton on invoices.
In reports set round with two digits and there are all done.

I don’t know, is in project a similar rounding?
I didn’t find anything quickly.