surprisehighway / craft-avatax

Calculate and add sales tax to an order's base tax using Avalara's AvaTax service with Craft Commerce 5.
MIT License
7 stars 11 forks source link

Error if the order is saved through console command in 2.1.7 version #42

Closed ivarsbariss-solspace closed 3 years ago

ivarsbariss-solspace commented 3 years ago

Hi,

We updated the plugin to 2.1.7 version and when order is saved through a console command the Avatax plugin causes this error Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: craft\console\Request::getParam()' in /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/base/Component.php:301

Stack trace:

Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: craft\console\Request::getParam()'
in /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/base/Component.php:301
Stack trace:
#0 /home/forge/solspace.magna-power.com/vendor/surprisehighway/craft-avatax/src/services/SalesTaxService.php(787): yii\base\Component->__call()
#1 /home/forge/solspace.magna-power.com/vendor/surprisehighway/craft-avatax/src/services/SalesTaxService.php(106): surprisehighway\avatax\services\SalesTaxService->parseOverrideParam()
#2 /home/forge/solspace.magna-power.com/vendor/surprisehighway/craft-avatax/src/adjusters/AvataxTaxAdjuster.php(24): surprisehighway\avatax\services\SalesTaxService->createSalesOrder()
#3 /home/forge/solspace.magna-power.com/vendor/craftcms/commerce/src/elements/Order.php(1828): surprisehighway\avatax\adjusters\AvataxTaxAdjuster->adjust()
#4 /home/forge/solspace.magna-power.com/plugins/magnapowerbusinessfunctions/src/MagnaPowerBusinessFunctions.php(210): craft\commerce\elements\Order->recalculate()
#5 [internal function]: solspace\magnapowerbusinessfunctions\MagnaPowerBusinessFunctions->solspace\magnapowerbusinessfunctions{closure}()
#6 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#7 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/base/Component.php(637): yii\base\Event::trigger()
#8 /home/forge/solspace.magna-power.com/vendor/craftcms/cms/src/base/Element.php(4102): yii\base\Component->trigger()
#9 /home/forge/solspace.magna-power.com/vendor/craftcms/commerce/src/elements/Order.php(2071): craft\base\Element->afterSave()
#10 /home/forge/solspace.magna-power.com/vendor/craftcms/cms/src/services/Elements.php(2687): craft\commerce\elements\Order->afterSave()
#11 /home/forge/solspace.magna-power.com/vendor/craftcms/cms/src/services/Elements.php(783): craft\services\Elements->_saveElementInternal()
#12 /home/forge/solspace.magna-power.com/plugins/magnapowerbusinessfunctions/src/services/Data.php(589): craft\services\Elements->saveElement()
#13 /home/forge/solspace.magna-power.com/plugins/magnapowerbusinessfunctions/src/services/Data.php(478): solspace\magnapowerbusinessfunctions\services\Data->processOrderFile()
#14 /home/forge/solspace.magna-power.com/plugins/magnapowerbusinessfunctions/src/console/controllers/DataController.php(56): solspace\magnapowerbusinessfunctions\services\Data->processInbox()
#15 [internal function]: solspace\magnapowerbusinessfunctions\console\controllers\DataController->actionProcessInbox()
#16 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#17 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams()
#18 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/console/Controller.php(184): yii\base\Controller->runAction()
#19 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/base/Module.php(534): yii\console\Controller->runAction()
#20 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/console/Application.php(181): yii\base\Module->runAction()
#21 /home/forge/solspace.magna-power.com/vendor/craftcms/cms/src/console/Application.php(89): yii\console\Application->runAction()
#22 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/console/Application.php(148): craft\console\Application->runAction()
#23 /home/forge/solspace.magna-power.com/vendor/yiisoft/yii2/base/Application.php(392): yii\console\Application->handleRequest()
#24 /home/forge/solspace.magna-power.com/craft(22): yii\base\Application->run()
#25 {main}

It seems like that with 2.1.7 a bug was introduced for a console environment where the Avatax plugin tries to call a getParam() from a request which isn't possible for the console environment.

imagehat commented 3 years ago

@ivarsbariss-solspace - thanks for catching this. I just bumped the version to 2.1.8 with a fix.