onepica / avatax

One Pica Magento extension for sales tax calculation performed by Avatax
http://www.magentocommerce.com/magento-connect/6760.html
29 stars 34 forks source link

Dates formatted incorrectly, API rejecting malformed dates in DocDate field #273

Open AndresInSpace opened 6 years ago

AndresInSpace commented 6 years ago

Platform 1.9.x CE Lang/Locale fr_CA && en_CA Issue: API Request Fails due to malformed dates [DocDate:GetTaxRequest:private] => 00002018-MMMMMM-dddd This is incorrectly formatted according to https://developer.avalara.com/api-reference/avatax/soap/models/GetTaxRequest/ DocDate should be yyyy-mm-dd format.

Cause: OnePica\AvaTax\Model\Service\Abstract\Tools.php

protected function _convertGmtDate($gmt, $storeId) { return $this->_getHelper() ->storeDate($storeId, $gmt, false, Varien_Date::DATETIME_INTERNAL_FORMAT) ->toString(Varien_Date::DATE_INTERNAL_FORMAT); }

FIX: Change to protected function _convertGmtDate($gmt, $storeId) { return Mage::getModel('core/date')->date('Y-m-d', strtotime($gmt)); }

Magentos date object already accounts for store time zones and locale. Tested on en_US , fr_CA and en_CA locales and seems to work fine now.