classyllama / ClassyLlama_AvaTax

This extension has been deprecated in favor of https://github.com/avadev/Avalara-AvaTax-for-Magento2
Open Software License 3.0
23 stars 15 forks source link

Fatal Error in Helper/TaxClass.php #104

Closed TonyDeStefano closed 6 years ago

TonyDeStefano commented 6 years ago

Preconditions

  1. Magento 2.1.8
  2. nginx / php-fpm / MySql
  3. Package version 1.3.0 / Module version 1.0.0

Steps to reproduce

  1. Run cron process if it's not setup in crontab (bin/magento cron:run)
  2. Check the cron_schedule table for the avatax_processqueue job
  3. Re-run cron at the scheduled_at time

Expected result

  1. No errors

Actual result

  1. The following fatal error:

Fatal error: Uncaught TypeError: Argument 1 passed to ClassyLlama\AvaTax\Helper\TaxClass::getItemCodeOverride() must be an instance of Magento\Catalog\Model\Product, null given, called in /var/www/html/magento/app/code/ClassyLlama/AvaTax/Framework/Interaction/Line.php on line 218 and defined in /var/www/html/magento/app/code/ClassyLlama/AvaTax/Helper/TaxClass.php on line 139

TonyDeStefano commented 6 years ago

Hi there. This issue actually doesn't involve the pull request I did earlier. They are separate issues I believe. The PR I did was a pretty simple fix. I'm not so sure about this one, so I didn't want to take a stab at it without letting you know about it first. Thanks!

rsisco commented 6 years ago

@TonyDeStefano - Thank you for the clarification.

rsisco commented 6 years ago

@TonyDeStefano - I've been able to reproduce this issue with the following steps:

Essentially, the problem occurs because the AvaTax queue process is trying to load a product that no longer exists. I'm refactoring the code to attempt to load an order item's associated product, but when that fails to produce a product, we will just use null values instead. This will prevent an error and still include the item on the AvaTax request and keep the sales tax as accurate as possible.

One situation where this will result in a tax discrepancy is when a product in Magento was assigned a specific tax class at the time the order and invoice were created; because once the product is deleted, the tax code will use the default assigned by Avalara for tax calculation.

rsisco commented 6 years ago

@TonyDeStefano - This issue has been addressed as of release 1.3.2. Please upgrade your installation (in a dev/stage environment for testing first of course).

Closing this issue.