Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.27k stars 2.73k forks source link

Error on supplier order with multi-currency #30452

Open altairis-benjamin opened 2 months ago

altairis-benjamin commented 2 months ago

Bug

When we add a product with a buying price in another currency to a supplier order, the price in original currency is wrongly calcultated in most cases.

Dolibarr Version

18.0 and more (at least)

Environment PHP

7.4 and 8.1

Environment Database

MariaDB 11.4.2

Steps to reproduce the behavior and expected behavior

On my side, I created a supplier whose currency is Japan Yen with a rate defined at 167. I created a product called Issue with a price with this supplier defined at 23000 Japan Yen (first and second screenshot)

I created a new supplier order in Japan Yen, and added this product with a quantity of 15000.

The result should be the following :

But, with rounded and current calculation method, we get respectively: 137,72455 2 065 868,25 22 999,99985 344 999 997,75

(Thrid screenshot)

It's a small difference here, but in fact it's due to the original currency price calculation: we start from the unit price in euros here, we multiply it by the conversion rate, and because of rounded values, we don't get the good result. Because of that, supplier orders are wrong, and can't be used to send the order to the related supplier.

I just opened this issue because I wanted to give the possibility to discuss that point, but I'm ALREADY working on that point, so could you please assign myself to this issue while I can't do it on my own?

Attached files

image image image

altairis-benjamin commented 2 months ago

It looks like, to make it work correctly, we should return here the unit price devise.

For now, I absolutely ignore how I can get this value. Still working.