Skip to content
This repository has been archived by the owner on Apr 22, 2019. It is now read-only.

Fatal Error in Helper/TaxClass.php #104

Closed
TonyDeStefano opened this issue Jan 11, 2018 · 4 comments
Closed

Fatal Error in Helper/TaxClass.php #104

TonyDeStefano opened this issue Jan 11, 2018 · 4 comments

Comments

@TonyDeStefano
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link

rsisco commented Jan 22, 2018

@TonyDeStefano - Thank you for the clarification.

@rsisco
Copy link

rsisco commented Jan 31, 2018

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

  • Create an order
  • Create an invoice for that order
  • Delete a product on that invoice from Magento
  • Process the AvaTax queue

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
Copy link

rsisco commented Feb 8, 2018

@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.

@rsisco rsisco closed this as completed Feb 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants