craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
219 stars 170 forks source link

[4.x]: Various floating point number comparison issues #3403

Open lukeholder opened 6 months ago

lukeholder commented 6 months ago

What happened?

Description

Please put any information on any floating point number comparison issues in the comments below.

Related issues:

https://github.com/craftcms/commerce/issues/1836

Related PRs:

https://github.com/craftcms/commerce/pull/3385

Craft CMS version

4.x

Craft Commerce version

4.x

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

adrum commented 6 months ago

@lukeholder On our non-Craft Commerce projects, we use https://github.com/moneyphp/money which helps abstract away most of the logic. It still takes careful consideration across the board when working with money, as usual.

lukeholder commented 6 months ago

@adrum Thanks, we are using Money in Commerce 5 and it's new Teller class for managing floating point number comparisons until we move to Money objects for all values. I will look to backport these changes to Commerce 4.

adrum commented 4 months ago

@lukeholder Have you given any more attention to this particular issue? We came across an issue in production where this caused an order to be "partially paid" when it should've been just "paid", and wasn't sure what to expect on this front.