VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: jessedyck on November 30, 2018, 18:16:59 PM

Title: AvaTax Frieght Tax Code Fix
Post by: jessedyck on November 30, 2018, 18:16:59 PM
I've discovered the Frieght Tax Code (set in the Tax and Calculation Rules) isn't being sent to AvaTax due to a bug in the code, thus the freight tax code is not working.

In avalara.php, line 955, the code is getting the taxfrieghtcode index from $calc as an object, but $calc is an array. It's treated as an array throughout this file.

https://dev.virtuemart.net/projects/virtuemart/repository/entry/trunk/virtuemart/plugins/vmcalculation/avalara/avalara.php#L955

Change this:

if(!empty($product['shipment'])){
        if(!empty($calc->taxfreightcode)) $line->setTaxCode($calc->taxfreightcode);
}


To this:

if(!empty($product['shipment'])){
        if(!empty($calc['taxfreightcode'])) $line->setTaxCode($calc['taxfreightcode']);
}


Should be all that's needed; that fixed it for me using NT as the freight tax code (for no tax).
Title: Re: AvaTax Frieght Tax Code Fix
Post by: Milbo on December 02, 2018, 23:08:34 PM
Thank you.

I use now

if(is_object($calc)){
if(!empty($calc->taxfreightcode)) $line->setTaxCode($calc->taxfreightcode);
} else {
if(!empty($calc['taxfreightcode'])) $line->setTaxCode($calc['taxfreightcode']);
}


to be sure.