Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Cannot parse "-2.8421709430404E-14" to Money error with tax rate of 0 #3822

Open
JodebaDigitalPulse opened this issue Dec 18, 2024 · 1 comment

Comments

@JodebaDigitalPulse
Copy link

What happened?

Description

Getting an error "Cannot parse "-2.8421709430404E-14" to Money "

Traced back to this location in the code
craft\commerce\adjusters::_getTaxAmount() called from https://github.com/craftcms/commerce/blob/744dd561b7e6763a369465e31d98fecb6885ad09/src/adjusters/Tax.php#L263C22-L263C30

The result is a float, close to zero, but not 0

Steps to reproduce

  1. product with taxrate of 0
  2. trigger commerce/cart/update-cart from frontend

stacktrace

{"trace":["#0 /application/vendor/moneyphp/money/src/Teller.php(394): Money\\Parser\\DecimalMoneyParser->parse()","#1 /application/vendor/craftcms/commerce/src/helpers/Currency.php(117): Money\\Teller->convertToMoney()","#2 /application/vendor/craftcms/commerce/src/behaviors/CurrencyAttributeBehavior.php(187): craft\\commerce\\helpers\\Currency::formatAsCurrency()","#3 /application/vendor/yiisoft/yii2/base/ArrayableTrait.php(126): craft\\commerce\\behaviors\\CurrencyAttributeBehavior->craft\\commerce\\behaviors\\{closure}()","#4 /application/vendor/yiisoft/yii2/base/ArrayableTrait.php(139): yii\\base\\Model->toArray()","#5 [internal function]: yii\\base\\Model->yii\\base\\{closure}()","#6 /application/vendor/yiisoft/yii2/base/ArrayableTrait.php(136): array_map()","#7 /application/vendor/yiisoft/yii2/base/ArrayableTrait.php(139): yii\\base\\Model->toArray()","#8 [internal function]: craft\\base\\Element->yii\\base\\{closure}()","#9 /application/vendor/yiisoft/yii2/base/ArrayableTrait.php(136): array_map()","#10 /application/vendor/craftcms/cms/src/base/Element.php(2659): craft\\base\\Element->traitToArray()","#11 /application/vendor/craftcms/commerce/src/controllers/BaseFrontEndController.php(59): craft\\base\\Element->toArray()","#12 /application/vendor/craftcms/commerce/src/controllers/CartController.php(566): craft\\commerce\\controllers\\BaseFrontEndController->cartArray()","#13 /application/vendor/craftcms/commerce/src/controllers/CartController.php(331): craft\\commerce\\controllers\\CartController->_returnCart()","#14 [internal function]: craft\\commerce\\controllers\\CartController->actionUpdateCart()","#15 /application/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()","#16 /application/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams()","#17 /application/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction()","#18 /application/vendor/craftcms/cms/src/web/Application.php(350): yii\\base\\Module->runAction()","#19 /application/vendor/putyourlightson/craft-sprig-core/src/controllers/ComponentsController.php(109): craft\\web\\Application->runAction()","#20 /application/vendor/putyourlightson/craft-sprig-core/src/controllers/ComponentsController.php(66): putyourlightson\\sprig\\controllers\\ComponentsController->runActionInternal()","#21 [internal function]: putyourlightson\\sprig\\controllers\\ComponentsController->actionRender()","#22 /application/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()","#23 /application/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams()","#24 /application/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction()","#25 /application/vendor/craftcms/cms/src/web/Application.php(350): yii\\base\\Module->runAction()","#26 /application/vendor/craftcms/cms/src/web/Application.php(649): craft\\web\\Application->runAction()","#27 /application/vendor/craftcms/cms/src/web/Application.php(312): craft\\web\\Application->_processActionRequest()","#28 /application/vendor/yiisoft/yii2/base/Application.php(384): craft\\web\\Application->handleRequest()","#29 /application/web/index.php(12): yii\\base\\Application->run()","#30 {main}"],"memory":22700744,"exception":"[object] (Money\\Exception\\ParserException(code: 0): Cannot parse \"-2.8421709430404E-14\" to Money. at /application/vendor/moneyphp/money/src/Parser/DecimalMoneyParser.php:46)"}

Craft CMS version

5.5.6.1

Craft Commerce version

5.2.9.1

PHP version

8.3.14

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant