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

Invoices sent to AvaTax do not properly handle orders with custom totals #207

Closed ctadlock closed 5 years ago

ctadlock commented 5 years ago

We use this extension to charge fees to customers based on their payment methods. These fees show up in Magento as a custom order total. When the transactions are pushed to AvaTax, the fee is not pushed over. https://store.fooman.co.nz/extensions/magento2/magento-extension-payment-surcharge-m2.html

This issue is not specific to the Fooman extension, but to ANY extension that modifies the order totals in a similar manner.

Preconditions

  1. Magento 2.2.6
  2. AvaTax 1.4.8
  3. Fooman Payment Surcharge

Steps to reproduce

  1. Create an order with a payment fee
  2. Export to AvaTax

Expected result

  1. AvaTax transaction should include a line item for the fee

Actual result

  1. AvaTax has now awareness of the fee
Xero
magento
AvaTax
avatax
fooman commented 5 years ago

Feel free to get in touch with us directly (support@fooman.co.nz) if there are any questions around the custom total. I am guessing it would require similar treatment to how the Enterprise custom totals are handled here https://github.com/classyllama/ClassyLlama_AvaTax/blob/develop/Model/Tax/Sales/Total/Quote/Tax.php#L464

erikhansen commented 5 years ago

@fooman or @ctadlock Are either of you able to submit a PR to implement this functionality? I didn't look into the details of what the Fooman extension is doing, but I'm thinking it would involve adding an event to the method that @fooman linked to that a custom extension could observe and pass in additional details.

ctadlock commented 5 years ago

@erikhansen No. We pay Avalara enough already. Im not about to spend the hours needed to learn their code just to make one change. They know their code, they should make the change.

ctadlock commented 5 years ago

After further testing there is an even deeper problem here with this code. It incorrectly assumes that any order with an extra taxable is using Magento Enterprise addition.

In the above Fooman extension, the payment surcharge is mapped to a product class that is taxable (which is required by US law), then the error below occurs at checkout. This is because it is looking at the items to see if they have gift wrapping; but that is a Magento EE only feature so the class isnt found.

The workaround is to either comment out this section of the code, or not map the payment surcharge to a tax item and then explain that to the tax man.

https://new.store.gototags.com/rest/default/V1/carts/mine/estimate-shipping-methods-by-address-id

{
    "messages": {
        "error": [
            {
                "code": 500,
                "message": "Fatal Error: 'Uncaught Error: Class 'Magento\\GiftWrapping\\Model\\Total\\Quote\\Tax\\Giftwrapping' not found in \/data\/Store4\/src\/web\/vendor\/classyllama\/module-avatax\/Model\/Tax\/Sales\/Total\/Quote\/Tax.php:464\nStack trace:\n#0 \/data\/Store4\/src\/web\/generated\/code\/ClassyLlama\/AvaTax\/Model\/Tax\/Sales\/Total\/Quote\/Tax\/Interceptor.php(63): ClassyLlama\\AvaTax\\Model\\Tax\\Sales\\Total\\Quote\\Tax->mapQuoteExtraTaxables(Object(Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterfaceFactory), Object(Magento\\Quote\\Model\\Quote\\Address\\Interceptor), false)\n#1 \/data\/Store4\/src\/web\/vendor\/classyllama\/module-avatax\/Model\/Tax\/Sales\/Total\/Quote\/Tax.php(272): ClassyLlama\\AvaTax\\Model\\Tax\\Sales\\Total\\Quote\\Tax\\Interceptor->mapQuoteExtraTaxables(Object(Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterfaceFactory), Object(Magento\\Quote\\Model\\Quote\\Address\\Interceptor), false)\n#2 \/data\/Store4\/src\/web\/vendor\/classyllama\/module-avatax\/Model\/Tax\/Sales\/Total\/Quote\/Tax.php(186): ClassyLlama\\AvaTax\\Model\\Tax\\Sales\\Total\\Quote\\Tax->getTaxQuoteDetails(Object(Magento\\Quote\\Model\\Shippin' in '\/data\/Store4\/src\/web\/vendor\/classyllama\/module-avatax\/Model\/Tax\/Sales\/Total\/Quote\/Tax.php' on line 464",
                "trace": "Trace is not available."
            }
        ]
    }
}

image

ctadlock commented 5 years ago

@erikhansen Any update on this?

erikhansen commented 5 years ago

@rsisco Can you let Craig know how soon you or SB will be able to look into this?

@fooman Can you email me a copy of the https://store.fooman.co.nz/extensions/magento2/magento-extension-payment-surcharge-m2.html extension so we can verify our fix? erik@<Classy Llama's domain>

fooman commented 5 years ago

Thanks @erikhansen - email is on its way.

erikhansen commented 5 years ago

@fooman Thanks. I've posted your email and the extension in our internal task tracking system and we'll provide an update once we have an ETA for this task.

erikhansen commented 5 years ago

@ctadlock We spent a significant amount of time in December, looking at how to implement this in the extension. We have an outstanding PR were we have a draft implementation of this. However it adds about ~1,500 lines of code to the extension and adds a lot of technical complexity. And it's looking like it will take an additional ~20 hours to finish implementing and testing the changes.

I'm going to be discussing this issue with Avalara to determine how we're going to move forward.

Can you confirm with me that you're still needing this feature? Or have you come up with an alternative solution?

erikhansen commented 5 years ago

Update: Avalara is no longer having Classy Llama support this connector. The internal conversation with Avalara about whether to move forward with supporting this use case was never resolved. If you'd like to move this forward, please contact Avalara's support and reference this Github issue.