Version Notes
* Nexus addresses can now be managed in Magento under Sales > Tax > Nexus Addresses. If upgrading from a previous version and using checkout calculations, make sure you sync your existing addresses from TaxJar or set up a new address. Your addresses will automatically sync with TaxJar when added or changed.
* International support for SmartCalcs checkout calculations. One nexus address per country outside of US/CA is currently supported for more than 30 countries.
* Review nexus addresses for missing data and set up observer to report tax configuration issues.
* Report errors when using AJAX sync backup rate button in the TaxJar configuration.
Download this release
Release Info
| Developer | TaxJar |
| Extension | Taxjar_Salestaxautomation |
| Version | 2.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0.1 to 2.1.0
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Backup.php +1 -1
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Enabled.php +1 -1
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus.php +34 -0
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus/Edit.php +52 -0
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus/Edit/Form.php +135 -0
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus/Grid.php +80 -0
- app/code/community/Taxjar/SalesTax/Model/Client.php +117 -21
- app/code/community/Taxjar/SalesTax/Model/Comment.php +1 -1
- app/code/community/Taxjar/SalesTax/Model/Debug.php +1 -1
- app/code/community/Taxjar/SalesTax/Model/Import/Comment.php +2 -2
- app/code/community/Taxjar/SalesTax/Model/Observer/AdminMenuItems.php +32 -0
- app/code/community/Taxjar/SalesTax/Model/Observer/ConfigChanged.php +1 -1
- app/code/community/Taxjar/SalesTax/Model/Observer/ConfigReview.php +43 -0
- app/code/community/Taxjar/SalesTax/Model/Observer/ImportRates.php +3 -1
- app/code/community/Taxjar/SalesTax/Model/Resource/Tax/Nexus.php +42 -0
- app/code/community/Taxjar/SalesTax/Model/Resource/Tax/Nexus/Collection.php +47 -0
- app/code/community/Taxjar/SalesTax/Model/Smartcalcs.php +28 -3
- app/code/community/Taxjar/SalesTax/Model/Tax/Nexus.php +178 -0
- app/code/community/Taxjar/SalesTax/controllers/Adminhtml/Tax/NexusController.php +213 -0
- app/code/community/Taxjar/SalesTax/controllers/Adminhtml/TaxjarController.php +7 -3
- app/code/community/Taxjar/SalesTax/etc/adminhtml.xml +54 -0
- app/code/community/Taxjar/SalesTax/etc/config.xml +28 -1
- app/code/community/Taxjar/SalesTax/sql/salestax_setup/upgrade-2.0.0-2.1.0.php +66 -0
- package.xml +8 -7
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Backup.php
CHANGED
|
@@ -32,7 +32,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Backup extends Mage_Adminhtml_Block_System
|
|
| 32 |
return parent::_getElementHtml($element);
|
| 33 |
}
|
| 34 |
|
| 35 |
-
protected function _cacheElementValue($element)
|
| 36 |
{
|
| 37 |
$elementValue = (string) $element->getValue();
|
| 38 |
Mage::app()->getCache()->save($elementValue, 'taxjar_salestax_config_backup', array('TAXJAR_SALESTAX_BACKUP'), null);
|
| 32 |
return parent::_getElementHtml($element);
|
| 33 |
}
|
| 34 |
|
| 35 |
+
protected function _cacheElementValue(Varien_Data_Form_Element_Abstract $element)
|
| 36 |
{
|
| 37 |
$elementValue = (string) $element->getValue();
|
| 38 |
Mage::app()->getCache()->save($elementValue, 'taxjar_salestax_config_backup', array('TAXJAR_SALESTAX_BACKUP'), null);
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Enabled.php
CHANGED
|
@@ -34,7 +34,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Enabled extends Mage_Adminhtml_Block_Syste
|
|
| 34 |
return parent::_getElementHtml($element);
|
| 35 |
}
|
| 36 |
|
| 37 |
-
protected function _cacheElementValue($element)
|
| 38 |
{
|
| 39 |
$elementValue = (string) $element->getValue();
|
| 40 |
Mage::app()->getCache()->save($elementValue, 'taxjar_salestax_config_enabled', array('TAXJAR_SALESTAX_ENABLED'), null);
|
| 34 |
return parent::_getElementHtml($element);
|
| 35 |
}
|
| 36 |
|
| 37 |
+
protected function _cacheElementValue(Varien_Data_Form_Element_Abstract $element)
|
| 38 |
{
|
| 39 |
$elementValue = (string) $element->getValue();
|
| 40 |
Mage::app()->getCache()->save($elementValue, 'taxjar_salestax_config_enabled', array('TAXJAR_SALESTAX_ENABLED'), null);
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus.php
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 19 |
+
{
|
| 20 |
+
public function __construct()
|
| 21 |
+
{
|
| 22 |
+
$this->_blockGroup = 'taxjar';
|
| 23 |
+
$this->_controller = 'adminhtml_tax_nexus';
|
| 24 |
+
$this->_headerText = Mage::helper('taxjar')->__('Nexus Addresses');
|
| 25 |
+
$this->_addButtonLabel = Mage::helper('taxjar')->__('Add New Nexus Address');
|
| 26 |
+
|
| 27 |
+
parent::__construct();
|
| 28 |
+
|
| 29 |
+
$this->_addButton('sync', array(
|
| 30 |
+
'label' => Mage::helper('taxjar')->__('Sync from TaxJar'),
|
| 31 |
+
'onclick' => "setLocation('{$this->getUrl('*/tax_nexus/sync')}')",
|
| 32 |
+
), 0, -1);
|
| 33 |
+
}
|
| 34 |
+
}
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus/Edit.php
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 19 |
+
{
|
| 20 |
+
public function __construct()
|
| 21 |
+
{
|
| 22 |
+
$this->_objectId = 'id';
|
| 23 |
+
$this->_blockGroup = 'taxjar';
|
| 24 |
+
$this->_controller = 'adminhtml_tax_nexus';
|
| 25 |
+
|
| 26 |
+
parent::__construct();
|
| 27 |
+
|
| 28 |
+
$this->_updateButton('save', 'label', Mage::helper('taxjar')->__('Save Nexus Address'));
|
| 29 |
+
$this->_updateButton('delete', 'label', Mage::helper('taxjar')->__('Delete Nexus Address'));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
public function getHeaderText()
|
| 33 |
+
{
|
| 34 |
+
if (Mage::registry('taxjar/tax_nexus')->getId()) {
|
| 35 |
+
$region = Mage::registry('taxjar/tax_nexus')->getRegion();
|
| 36 |
+
$countryId = Mage::registry('taxjar/tax_nexus')->getCountryId();
|
| 37 |
+
$country = Mage::getModel('directory/country')->load($countryId)->getName();
|
| 38 |
+
$location = isset($region) ? $this->escapeHtml($region) : $this->escapeHtml($country);
|
| 39 |
+
|
| 40 |
+
return Mage::helper('taxjar')->__("Edit Nexus Address for %s", $location);
|
| 41 |
+
}
|
| 42 |
+
else {
|
| 43 |
+
return Mage::helper('taxjar')->__('New Nexus Address');
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
public function setClassType($classType)
|
| 48 |
+
{
|
| 49 |
+
$this->getChild('form')->setClassType($classType);
|
| 50 |
+
return $this;
|
| 51 |
+
}
|
| 52 |
+
}
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus/Edit/Form.php
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 19 |
+
{
|
| 20 |
+
public function __construct()
|
| 21 |
+
{
|
| 22 |
+
parent::__construct();
|
| 23 |
+
|
| 24 |
+
$this->setId('nexus_form');
|
| 25 |
+
$this->setTemplate('taxjar/nexus/form.phtml');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
protected function _prepareForm()
|
| 29 |
+
{
|
| 30 |
+
$model = Mage::registry('taxjar/tax_nexus');
|
| 31 |
+
$form = new Varien_Data_Form(array(
|
| 32 |
+
'id' => 'edit_form',
|
| 33 |
+
'action' => $this->getData('action'),
|
| 34 |
+
'method' => 'post'
|
| 35 |
+
));
|
| 36 |
+
|
| 37 |
+
$countries = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray();
|
| 38 |
+
unset($countries[0]);
|
| 39 |
+
|
| 40 |
+
if (!$model->hasCountryId()) {
|
| 41 |
+
$model->setCountryId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_COUNTRY));
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
if (!$model->hasRegionId()) {
|
| 45 |
+
$model->setRegionId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_REGION));
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
$regionCollection = Mage::getModel('directory/region')->getCollection()->addCountryFilter($model->getCountryId());
|
| 49 |
+
$regions = $regionCollection->toOptionArray();
|
| 50 |
+
|
| 51 |
+
$this->setTitle('Nexus Address Information');
|
| 52 |
+
|
| 53 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
| 54 |
+
'legend' => 'Nexus Address Information'
|
| 55 |
+
));
|
| 56 |
+
|
| 57 |
+
if ($model->getId() > 0) {
|
| 58 |
+
$fieldset->addField('id', 'hidden', array(
|
| 59 |
+
'name' => 'id',
|
| 60 |
+
'value' => $model->getId()
|
| 61 |
+
));
|
| 62 |
+
|
| 63 |
+
$fieldset->addField('api_id', 'hidden', array(
|
| 64 |
+
'name' => 'api_id',
|
| 65 |
+
'value' => $model->getApiId()
|
| 66 |
+
));
|
| 67 |
+
|
| 68 |
+
$fieldset->addField('region', 'hidden', array(
|
| 69 |
+
'name' => 'region',
|
| 70 |
+
'value' => $model->getRegion()
|
| 71 |
+
));
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
$fieldset->addField('street', 'text',
|
| 75 |
+
array(
|
| 76 |
+
'name' => 'street',
|
| 77 |
+
'label' => Mage::helper('taxjar')->__('Street Address'),
|
| 78 |
+
'class' => 'required-entry',
|
| 79 |
+
'value' => $model->getStreet(),
|
| 80 |
+
'required' => true
|
| 81 |
+
)
|
| 82 |
+
);
|
| 83 |
+
|
| 84 |
+
$fieldset->addField('city', 'text',
|
| 85 |
+
array(
|
| 86 |
+
'name' => 'city',
|
| 87 |
+
'label' => Mage::helper('taxjar')->__('City'),
|
| 88 |
+
'class' => 'required-entry',
|
| 89 |
+
'value' => $model->getCity(),
|
| 90 |
+
'required' => true
|
| 91 |
+
)
|
| 92 |
+
);
|
| 93 |
+
|
| 94 |
+
$fieldset->addField('country_id', 'select',
|
| 95 |
+
array(
|
| 96 |
+
'name' => 'country_id',
|
| 97 |
+
'label' => Mage::helper('taxjar')->__('Country'),
|
| 98 |
+
'class' => 'required-entry',
|
| 99 |
+
'values' => $countries,
|
| 100 |
+
'required' => true,
|
| 101 |
+
'after_element_html' => '<p class="note"><span>TaxJar provides sales tax calculations for <a href="http://developers.taxjar.com/api/reference/#countries" target="_blank">more than 30 countries</a> around the world. Sales tax reporting and filing is currently offered in the US.</span></p>'
|
| 102 |
+
)
|
| 103 |
+
);
|
| 104 |
+
|
| 105 |
+
$fieldset->addField('region_id', 'select',
|
| 106 |
+
array(
|
| 107 |
+
'name' => 'region_id',
|
| 108 |
+
'label' => Mage::helper('taxjar')->__('State/Region'),
|
| 109 |
+
'class' => 'required-entry',
|
| 110 |
+
'values' => $regions,
|
| 111 |
+
'required' => true
|
| 112 |
+
)
|
| 113 |
+
);
|
| 114 |
+
|
| 115 |
+
$fieldset->addField('postcode', 'text',
|
| 116 |
+
array(
|
| 117 |
+
'name' => 'postcode',
|
| 118 |
+
'label' => Mage::helper('taxjar')->__('Zip/Post Code'),
|
| 119 |
+
'class' => 'required-entry',
|
| 120 |
+
'value' => $model->getPostcode(),
|
| 121 |
+
'required' => true
|
| 122 |
+
)
|
| 123 |
+
);
|
| 124 |
+
|
| 125 |
+
$form->setAction($this->getUrl('*/tax_nexus/save'));
|
| 126 |
+
$form->setUseContainer(true);
|
| 127 |
+
$form->setMethod('post');
|
| 128 |
+
|
| 129 |
+
$nexusData = $model->getData();
|
| 130 |
+
$form->setValues($nexusData);
|
| 131 |
+
$this->setForm($form);
|
| 132 |
+
|
| 133 |
+
return parent::_prepareForm();
|
| 134 |
+
}
|
| 135 |
+
}
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus/Grid.php
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 19 |
+
{
|
| 20 |
+
public function __construct()
|
| 21 |
+
{
|
| 22 |
+
parent::__construct();
|
| 23 |
+
$this->setId('nexus_grid');
|
| 24 |
+
$this->setDefaultSort('region');
|
| 25 |
+
$this->setDefaultDir('ASC');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
protected function _prepareCollection()
|
| 29 |
+
{
|
| 30 |
+
$collection = Mage::getModel('taxjar/tax_nexus')->getCollection();
|
| 31 |
+
$this->setCollection($collection);
|
| 32 |
+
return parent::_prepareCollection();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
protected function _prepareColumns()
|
| 36 |
+
{
|
| 37 |
+
$this->addColumn('street', array(
|
| 38 |
+
'header' => Mage::helper('taxjar')->__('Street Address'),
|
| 39 |
+
'align' => 'left',
|
| 40 |
+
'index' => 'street',
|
| 41 |
+
'filter_index' => 'main_table.street',
|
| 42 |
+
));
|
| 43 |
+
|
| 44 |
+
$this->addColumn('city', array(
|
| 45 |
+
'header' => Mage::helper('taxjar')->__('City'),
|
| 46 |
+
'align' => 'left',
|
| 47 |
+
'index' => 'city',
|
| 48 |
+
'filter_index' => 'main_table.city'
|
| 49 |
+
));
|
| 50 |
+
|
| 51 |
+
$this->addColumn('region', array(
|
| 52 |
+
'header' => Mage::helper('taxjar')->__('State/Region'),
|
| 53 |
+
'align' => 'left',
|
| 54 |
+
'index' => 'region',
|
| 55 |
+
'filter_index' => 'main_table.region'
|
| 56 |
+
));
|
| 57 |
+
|
| 58 |
+
$this->addColumn('country_id', array(
|
| 59 |
+
'header' => Mage::helper('taxjar')->__('Country'),
|
| 60 |
+
'type' => 'country',
|
| 61 |
+
'align' => 'left',
|
| 62 |
+
'index' => 'country_id',
|
| 63 |
+
'filter_index' => 'main_table.country_id',
|
| 64 |
+
'sortable' => false
|
| 65 |
+
));
|
| 66 |
+
|
| 67 |
+
$this->addColumn('postcode', array(
|
| 68 |
+
'header' => Mage::helper('taxjar')->__('Zip/Post Code'),
|
| 69 |
+
'align' => 'left',
|
| 70 |
+
'index' => 'postcode'
|
| 71 |
+
));
|
| 72 |
+
|
| 73 |
+
return parent::_prepareColumns();
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
public function getRowUrl($row)
|
| 77 |
+
{
|
| 78 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 79 |
+
}
|
| 80 |
+
}
|
app/code/community/Taxjar/SalesTax/Model/Client.php
CHANGED
|
@@ -33,44 +33,106 @@ class Taxjar_SalesTax_Model_Client
|
|
| 33 |
}
|
| 34 |
|
| 35 |
/**
|
| 36 |
-
*
|
| 37 |
*
|
| 38 |
* @param string $apiKey
|
| 39 |
* @param string $url
|
| 40 |
-
* @
|
|
|
|
| 41 |
*/
|
| 42 |
-
public function getResource($apiKey, $resource)
|
| 43 |
{
|
| 44 |
-
$
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
/**
|
| 59 |
-
*
|
| 60 |
*
|
| 61 |
* @param string $apiKey
|
| 62 |
* @param string $url
|
| 63 |
-
* @return
|
| 64 |
*/
|
| 65 |
-
private function _getClient($apiKey, $url)
|
| 66 |
{
|
| 67 |
-
$client = new
|
| 68 |
-
$client->setMethod(
|
| 69 |
-
$client->setHeaders('Authorization', '
|
| 70 |
|
| 71 |
return $client;
|
| 72 |
}
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
/**
|
| 75 |
* Get SmartCalcs API URL
|
| 76 |
*
|
|
@@ -91,8 +153,42 @@ class Taxjar_SalesTax_Model_Client
|
|
| 91 |
case 'categories':
|
| 92 |
$apiUrl .= '/categories';
|
| 93 |
break;
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
return $apiUrl;
|
| 97 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
}
|
| 33 |
}
|
| 34 |
|
| 35 |
/**
|
| 36 |
+
* Perform a GET request
|
| 37 |
*
|
| 38 |
* @param string $apiKey
|
| 39 |
* @param string $url
|
| 40 |
+
* @param array $errors
|
| 41 |
+
* @return array
|
| 42 |
*/
|
| 43 |
+
public function getResource($apiKey, $resource, $errors = array())
|
| 44 |
{
|
| 45 |
+
$client = $this->_getClient($apiKey, $this->_getApiUrl($resource));
|
| 46 |
+
return $this->_getRequest($client, $errors);
|
| 47 |
+
}
|
| 48 |
|
| 49 |
+
/**
|
| 50 |
+
* Perform a POST request
|
| 51 |
+
*
|
| 52 |
+
* @param string $apiKey
|
| 53 |
+
* @param string $resource
|
| 54 |
+
* @param array $data
|
| 55 |
+
* @param array $errors
|
| 56 |
+
* @return array
|
| 57 |
+
*/
|
| 58 |
+
public function postResource($apiKey, $resource, $data, $errors = array())
|
| 59 |
+
{
|
| 60 |
+
$client = $this->_getClient($apiKey, $this->_getApiUrl($resource), Zend_Http_Client::POST);
|
| 61 |
+
$client->setRawData(json_encode($data), 'application/json');
|
| 62 |
+
return $this->_getRequest($client, $errors);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Perform a PUT request
|
| 67 |
+
*
|
| 68 |
+
* @param string $apiKey
|
| 69 |
+
* @param string $resource
|
| 70 |
+
* @param array $data
|
| 71 |
+
* @param array $errors
|
| 72 |
+
* @return array
|
| 73 |
+
*/
|
| 74 |
+
public function putResource($apiKey, $resource, $resourceId, $data, $errors = array())
|
| 75 |
+
{
|
| 76 |
+
$resourceUrl = $this->_getApiUrl($resource) . '/' . $resourceId;
|
| 77 |
+
$client = $this->_getClient($apiKey, $resourceUrl, Zend_Http_Client::PUT);
|
| 78 |
+
$client->setRawData(json_encode($data), 'application/json');
|
| 79 |
+
return $this->_getRequest($client, $errors);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Perform a DELETE request
|
| 84 |
+
*
|
| 85 |
+
* @param string $apiKey
|
| 86 |
+
* @param string $resource
|
| 87 |
+
* @param array $errors
|
| 88 |
+
* @return array
|
| 89 |
+
*/
|
| 90 |
+
public function deleteResource($apiKey, $resource, $resourceId, $errors = array())
|
| 91 |
+
{
|
| 92 |
+
$resourceUrl = $this->_getApiUrl($resource) . '/' . $resourceId;
|
| 93 |
+
$client = $this->_getClient($apiKey, $resourceUrl, Zend_Http_Client::DELETE);
|
| 94 |
+
return $this->_getRequest($client, $errors);
|
| 95 |
+
}
|
| 96 |
|
| 97 |
/**
|
| 98 |
+
* Get HTTP Client
|
| 99 |
*
|
| 100 |
* @param string $apiKey
|
| 101 |
* @param string $url
|
| 102 |
+
* @return Zend_Http_Client $response
|
| 103 |
*/
|
| 104 |
+
private function _getClient($apiKey, $url, $method = Zend_Http_Client::GET)
|
| 105 |
{
|
| 106 |
+
$client = new Zend_Http_Client($url);
|
| 107 |
+
$client->setMethod($method);
|
| 108 |
+
$client->setHeaders('Authorization', 'Bearer ' . $apiKey);
|
| 109 |
|
| 110 |
return $client;
|
| 111 |
}
|
| 112 |
|
| 113 |
+
/**
|
| 114 |
+
* Get HTTP request
|
| 115 |
+
*
|
| 116 |
+
* @param Zend_Http_Client $client
|
| 117 |
+
* @param array $errors
|
| 118 |
+
* @return array
|
| 119 |
+
*/
|
| 120 |
+
private function _getRequest($client, $errors = array())
|
| 121 |
+
{
|
| 122 |
+
try {
|
| 123 |
+
$response = $client->request();
|
| 124 |
+
|
| 125 |
+
if ($response->isSuccessful()) {
|
| 126 |
+
$json = $response->getBody();
|
| 127 |
+
return json_decode($json, true);
|
| 128 |
+
} else {
|
| 129 |
+
$this->_handleError($errors, $response->getStatus());
|
| 130 |
+
}
|
| 131 |
+
} catch (Zend_Http_Client_Exception $e) {
|
| 132 |
+
Mage::throwException(Mage::helper('taxjar')->__('Could not connect to TaxJar.'));
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
/**
|
| 137 |
* Get SmartCalcs API URL
|
| 138 |
*
|
| 153 |
case 'categories':
|
| 154 |
$apiUrl .= '/categories';
|
| 155 |
break;
|
| 156 |
+
case 'nexus':
|
| 157 |
+
$apiUrl .= '/nexus/addresses';
|
| 158 |
+
break;
|
| 159 |
}
|
| 160 |
|
| 161 |
return $apiUrl;
|
| 162 |
}
|
| 163 |
+
|
| 164 |
+
/**
|
| 165 |
+
* Handle API errors and throw exception
|
| 166 |
+
*
|
| 167 |
+
* @param array $customErrors
|
| 168 |
+
* @param string $statusCode
|
| 169 |
+
* @return string
|
| 170 |
+
*/
|
| 171 |
+
private function _handleError($customErrors, $statusCode)
|
| 172 |
+
{
|
| 173 |
+
$errors = $this->_defaultErrors() + $customErrors;
|
| 174 |
+
|
| 175 |
+
if ($errors[$statusCode]) {
|
| 176 |
+
Mage::throwException($errors[$statusCode]);
|
| 177 |
+
} else {
|
| 178 |
+
Mage::throwException($errors['default']);
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Return default API errors
|
| 184 |
+
*
|
| 185 |
+
* @return array
|
| 186 |
+
*/
|
| 187 |
+
private function _defaultErrors()
|
| 188 |
+
{
|
| 189 |
+
return array(
|
| 190 |
+
'401' => Mage::helper('taxjar')->__('Your TaxJar API token is invalid. Please review your TaxJar account at https://app.taxjar.com.'),
|
| 191 |
+
'default' => Mage::helper('taxjar')->__('Could not connect to TaxJar.')
|
| 192 |
+
);
|
| 193 |
+
}
|
| 194 |
}
|
app/code/community/Taxjar/SalesTax/Model/Comment.php
CHANGED
|
@@ -54,7 +54,7 @@ class Taxjar_SalesTax_Model_Comment
|
|
| 54 |
$htmlString .= "<p class='note'><span>TaxJar Account</span></p>";
|
| 55 |
$htmlString .= "<ul class='messages'><li class='success-msg'><span style='font-size: 1.4em'>" . $this->_apiEmail . "</span></li></ul>";
|
| 56 |
$htmlString .= "<p class='note'><span>Getting Started</span></p><p></p>";
|
| 57 |
-
|
| 58 |
$htmlString .= "<p><a href='" . Mage::helper('adminhtml')->getUrl('adminhtml/tax_class_product/index') . "'>Product Tax Classes</a><br/><span style='font-size: 0.9em'>If some of your products are tax-exempt, assign a TaxJar category tax code for new or existing product tax classes.</span></p>";
|
| 59 |
$htmlString .= "<p><a href='http://www.taxjar.com/contact/' target='_blank'>Help & Support</a><br/><span style='font-size: 0.9em'>Need help setting up SmartCalcs? Get in touch with our Magento sales tax experts.</span></p><br/>";
|
| 60 |
$htmlString .= $this->_buildConnectionHtml();
|
| 54 |
$htmlString .= "<p class='note'><span>TaxJar Account</span></p>";
|
| 55 |
$htmlString .= "<ul class='messages'><li class='success-msg'><span style='font-size: 1.4em'>" . $this->_apiEmail . "</span></li></ul>";
|
| 56 |
$htmlString .= "<p class='note'><span>Getting Started</span></p><p></p>";
|
| 57 |
+
$htmlString .= "<p><a href='" . Mage::helper('adminhtml')->getUrl('adminhtml/tax_nexus/index') . "'>Nexus Addresses</a><br/><span style='font-size: 0.9em'>Before enabling SmartCalcs, set up your nexus addresses so TaxJar knows where to collect sales tax.</span></p>";
|
| 58 |
$htmlString .= "<p><a href='" . Mage::helper('adminhtml')->getUrl('adminhtml/tax_class_product/index') . "'>Product Tax Classes</a><br/><span style='font-size: 0.9em'>If some of your products are tax-exempt, assign a TaxJar category tax code for new or existing product tax classes.</span></p>";
|
| 59 |
$htmlString .= "<p><a href='http://www.taxjar.com/contact/' target='_blank'>Help & Support</a><br/><span style='font-size: 0.9em'>Need help setting up SmartCalcs? Get in touch with our Magento sales tax experts.</span></p><br/>";
|
| 60 |
$htmlString .= $this->_buildConnectionHtml();
|
app/code/community/Taxjar/SalesTax/Model/Debug.php
CHANGED
|
@@ -49,7 +49,7 @@ class Taxjar_SalesTax_Model_Debug
|
|
| 49 |
$states = unserialize(Mage::getStoreConfig('tax/taxjar/states'));
|
| 50 |
$apiUser = Mage::getModel('api/user');
|
| 51 |
$existingUserId = $apiUser->load('taxjar', 'username')->getUserId();
|
| 52 |
-
$pluginVersion = '2.0
|
| 53 |
$phpMemory = @ini_get('memory_limit');
|
| 54 |
$phpVersion = @phpversion();
|
| 55 |
$magentoVersion = Mage::getVersion();
|
| 49 |
$states = unserialize(Mage::getStoreConfig('tax/taxjar/states'));
|
| 50 |
$apiUser = Mage::getModel('api/user');
|
| 51 |
$existingUserId = $apiUser->load('taxjar', 'username')->getUserId();
|
| 52 |
+
$pluginVersion = '2.1.0';
|
| 53 |
$phpMemory = @ini_get('memory_limit');
|
| 54 |
$phpVersion = @phpversion();
|
| 55 |
$magentoVersion = Mage::getVersion();
|
app/code/community/Taxjar/SalesTax/Model/Import/Comment.php
CHANGED
|
@@ -136,7 +136,7 @@ class Taxjar_SalesTax_Model_Import_Comment
|
|
| 136 |
$class = 'success';
|
| 137 |
} elseif ($taxRatesByState['rates_by_state'][$state] == 0 && ($taxRatesByState['rates_loaded'] == $taxRatesByState['total_rates'])) {
|
| 138 |
$class = 'error';
|
| 139 |
-
$totalForState = '<a href="
|
| 140 |
} else {
|
| 141 |
$class = 'success';
|
| 142 |
$totalForState = $taxRatesByState['rates_by_state'][$state] . ' rates';
|
|
@@ -176,7 +176,7 @@ class Taxjar_SalesTax_Model_Import_Comment
|
|
| 176 |
onCreate: function(request) {
|
| 177 |
varienLoaderHandler.handler.onCreate({options: {loaderArea: true}});
|
| 178 |
},
|
| 179 |
-
|
| 180 |
varienLoaderHandler.handler.onComplete();
|
| 181 |
window.location = '{$redirectUrl}';
|
| 182 |
}
|
| 136 |
$class = 'success';
|
| 137 |
} elseif ($taxRatesByState['rates_by_state'][$state] == 0 && ($taxRatesByState['rates_loaded'] == $taxRatesByState['total_rates'])) {
|
| 138 |
$class = 'error';
|
| 139 |
+
$totalForState = '<a href="' . Mage::helper('adminhtml')->getUrl('adminhtml/tax_nexus/index') . '">Click here</a> and add a zip code for this state to load rates.';
|
| 140 |
} else {
|
| 141 |
$class = 'success';
|
| 142 |
$totalForState = $taxRatesByState['rates_by_state'][$state] . ' rates';
|
| 176 |
onCreate: function(request) {
|
| 177 |
varienLoaderHandler.handler.onCreate({options: {loaderArea: true}});
|
| 178 |
},
|
| 179 |
+
onComplete: function(data) {
|
| 180 |
varienLoaderHandler.handler.onComplete();
|
| 181 |
window.location = '{$redirectUrl}';
|
| 182 |
}
|
app/code/community/Taxjar/SalesTax/Model/Observer/AdminMenuItems.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class TaxJar_SalesTax_Model_Observer_AdminMenuItems
|
| 19 |
+
{
|
| 20 |
+
public function execute(Varien_Event_Observer $observer)
|
| 21 |
+
{
|
| 22 |
+
$connected = Mage::getStoreConfig('tax/taxjar/connected');
|
| 23 |
+
|
| 24 |
+
if (!$connected) {
|
| 25 |
+
$config = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode();
|
| 26 |
+
unset($config->menu->sales->children->tax->children->taxjar_salestax_nexus);
|
| 27 |
+
Mage::getSingleton('admin/config')->getAdminhtmlConfig()->setXml($config);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
return $this;
|
| 31 |
+
}
|
| 32 |
+
}
|
app/code/community/Taxjar/SalesTax/Model/Observer/ConfigChanged.php
CHANGED
|
@@ -17,7 +17,7 @@
|
|
| 17 |
|
| 18 |
class Taxjar_SalesTax_Model_Observer_ConfigChanged
|
| 19 |
{
|
| 20 |
-
public function execute($observer)
|
| 21 |
{
|
| 22 |
$this->_updateSmartcalcs();
|
| 23 |
$this->_updateBackupRates();
|
| 17 |
|
| 18 |
class Taxjar_SalesTax_Model_Observer_ConfigChanged
|
| 19 |
{
|
| 20 |
+
public function execute(Varien_Event_Observer $observer)
|
| 21 |
{
|
| 22 |
$this->_updateSmartcalcs();
|
| 23 |
$this->_updateBackupRates();
|
app/code/community/Taxjar/SalesTax/Model/Observer/ConfigReview.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class TaxJar_SalesTax_Model_Observer_ConfigReview
|
| 19 |
+
{
|
| 20 |
+
public function execute(Varien_Event_Observer $observer)
|
| 21 |
+
{
|
| 22 |
+
$configSection = Mage::app()->getRequest()->getParam('section');
|
| 23 |
+
|
| 24 |
+
if ($configSection == 'tax') {
|
| 25 |
+
$enabled = Mage::getStoreConfig('tax/taxjar/enabled');
|
| 26 |
+
|
| 27 |
+
if ($enabled) {
|
| 28 |
+
$this->_reviewNexusAddresses();
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
return $this;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
protected function _reviewNexusAddresses()
|
| 36 |
+
{
|
| 37 |
+
$nexusAddresses = Mage::getModel('taxjar/tax_nexus')->getCollection();
|
| 38 |
+
|
| 39 |
+
if (!$nexusAddresses->getSize()) {
|
| 40 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('taxjar')->__('You have no nexus addresses loaded in Magento. Go to Sales > Tax > Nexus Addresses to sync from your TaxJar account or add a new address.'));
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
}
|
app/code/community/Taxjar/SalesTax/Model/Observer/ImportRates.php
CHANGED
|
@@ -188,7 +188,9 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 188 |
*/
|
| 189 |
private function _getRatesJson()
|
| 190 |
{
|
| 191 |
-
$ratesJson = $this->_client->getResource($this->_apiKey, 'rates'
|
|
|
|
|
|
|
| 192 |
return $ratesJson;
|
| 193 |
}
|
| 194 |
|
| 188 |
*/
|
| 189 |
private function _getRatesJson()
|
| 190 |
{
|
| 191 |
+
$ratesJson = $this->_client->getResource($this->_apiKey, 'rates', array(
|
| 192 |
+
'403' => Mage::helper('taxjar')->__('Your last backup rate sync from TaxJar was too recent. Please wait at least 5 minutes and try again.')
|
| 193 |
+
));
|
| 194 |
return $ratesJson;
|
| 195 |
}
|
| 196 |
|
app/code/community/Taxjar/SalesTax/Model/Resource/Tax/Nexus.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Taxjar_SalesTax_Model_Resource_Tax_Nexus extends Mage_Core_Model_Resource_Db_Abstract
|
| 19 |
+
{
|
| 20 |
+
/**
|
| 21 |
+
* Resource initialization
|
| 22 |
+
*
|
| 23 |
+
*/
|
| 24 |
+
public function _construct()
|
| 25 |
+
{
|
| 26 |
+
$this->_init('taxjar/tax_nexus', 'id');
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Initialize unique fields
|
| 31 |
+
*
|
| 32 |
+
* @return Mage_Tax_Model_Resource_Class
|
| 33 |
+
*/
|
| 34 |
+
protected function _initUniqueFields()
|
| 35 |
+
{
|
| 36 |
+
$this->_uniqueFields = array(array(
|
| 37 |
+
'field' => array('region_id'),
|
| 38 |
+
'title' => Mage::helper('taxjar')->__('An error occurred while saving this nexus address. An address with the same region'),
|
| 39 |
+
));
|
| 40 |
+
return $this;
|
| 41 |
+
}
|
| 42 |
+
}
|
app/code/community/Taxjar/SalesTax/Model/Resource/Tax/Nexus/Collection.php
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Taxjar_SalesTax_Model_Resource_Tax_Nexus_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
| 19 |
+
{
|
| 20 |
+
/**
|
| 21 |
+
* Resource initialization
|
| 22 |
+
*/
|
| 23 |
+
public function _construct()
|
| 24 |
+
{
|
| 25 |
+
$this->_init('taxjar/tax_nexus');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Retrieve option array
|
| 30 |
+
*
|
| 31 |
+
* @return array
|
| 32 |
+
*/
|
| 33 |
+
public function toOptionArray()
|
| 34 |
+
{
|
| 35 |
+
return $this->_toOptionArray('id', 'region');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Retrieve option hash
|
| 40 |
+
*
|
| 41 |
+
* @return array
|
| 42 |
+
*/
|
| 43 |
+
public function toOptionHash()
|
| 44 |
+
{
|
| 45 |
+
return $this->_toOptionHash('id', 'region');
|
| 46 |
+
}
|
| 47 |
+
}
|
app/code/community/Taxjar/SalesTax/Model/Smartcalcs.php
CHANGED
|
@@ -75,10 +75,11 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 75 |
'amount' => (float) $address->getSubtotal(),
|
| 76 |
'shipping' => (float) $address->getShippingAmount(),
|
| 77 |
'line_items' => $this->_getLineItems($address),
|
|
|
|
| 78 |
));
|
| 79 |
|
| 80 |
if ($this->_orderChanged($order)) {
|
| 81 |
-
$client = new
|
| 82 |
$client->setHeaders('Authorization', 'Bearer ' . $apiKey);
|
| 83 |
$client->setRawData(json_encode($order), 'application/json');
|
| 84 |
|
|
@@ -153,9 +154,9 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 153 |
*/
|
| 154 |
private function _hasNexus($regionCode)
|
| 155 |
{
|
| 156 |
-
$
|
| 157 |
|
| 158 |
-
if (
|
| 159 |
return true;
|
| 160 |
} else {
|
| 161 |
return false;
|
|
@@ -194,6 +195,30 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 194 |
|
| 195 |
return $lineItems;
|
| 196 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
/**
|
| 199 |
* Verify if the order changed compared to session
|
| 75 |
'amount' => (float) $address->getSubtotal(),
|
| 76 |
'shipping' => (float) $address->getShippingAmount(),
|
| 77 |
'line_items' => $this->_getLineItems($address),
|
| 78 |
+
'nexus_addresses' => $this->_getNexusAddresses()
|
| 79 |
));
|
| 80 |
|
| 81 |
if ($this->_orderChanged($order)) {
|
| 82 |
+
$client = new Zend_Http_Client('https://api.taxjar.com/v2/taxes');
|
| 83 |
$client->setHeaders('Authorization', 'Bearer ' . $apiKey);
|
| 84 |
$client->setRawData(json_encode($order), 'application/json');
|
| 85 |
|
| 154 |
*/
|
| 155 |
private function _hasNexus($regionCode)
|
| 156 |
{
|
| 157 |
+
$nexusInRegion = Mage::getModel('taxjar/tax_nexus')->getCollection()->addFieldToFilter('region_code', $regionCode);
|
| 158 |
|
| 159 |
+
if ($nexusInRegion->getSize()) {
|
| 160 |
return true;
|
| 161 |
} else {
|
| 162 |
return false;
|
| 195 |
|
| 196 |
return $lineItems;
|
| 197 |
}
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* Get nexus addresses for `nexus_addresses` param
|
| 201 |
+
*
|
| 202 |
+
* @return array
|
| 203 |
+
*/
|
| 204 |
+
private function _getNexusAddresses()
|
| 205 |
+
{
|
| 206 |
+
$nexusAddresses = Mage::getModel('taxjar/tax_nexus')->getCollection();
|
| 207 |
+
$addresses = array();
|
| 208 |
+
|
| 209 |
+
foreach($nexusAddresses as $nexusAddress) {
|
| 210 |
+
$addresses[] = array(
|
| 211 |
+
'id' => $nexusAddress->getId(),
|
| 212 |
+
'country' => $nexusAddress->getCountryId(),
|
| 213 |
+
'zip' => $nexusAddress->getPostcode(),
|
| 214 |
+
'state' => $nexusAddress->getRegionCode(),
|
| 215 |
+
'city' => $nexusAddress->getCity(),
|
| 216 |
+
'street' => $nexusAddress->getStreet()
|
| 217 |
+
);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
return $addresses;
|
| 221 |
+
}
|
| 222 |
|
| 223 |
/**
|
| 224 |
* Verify if the order changed compared to session
|
app/code/community/Taxjar/SalesTax/Model/Tax/Nexus.php
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
| 19 |
+
{
|
| 20 |
+
public function _construct()
|
| 21 |
+
{
|
| 22 |
+
$this->_init('taxjar/tax_nexus');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Create or update nexus address in TaxJar
|
| 27 |
+
*
|
| 28 |
+
* @return void
|
| 29 |
+
*/
|
| 30 |
+
public function sync()
|
| 31 |
+
{
|
| 32 |
+
$client = Mage::getModel('taxjar/client');
|
| 33 |
+
$apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 34 |
+
|
| 35 |
+
$data = array(
|
| 36 |
+
'street' => $this->getStreet(),
|
| 37 |
+
'city' => $this->getCity(),
|
| 38 |
+
'state' => $this->getRegionCode(),
|
| 39 |
+
'zip' => $this->getPostcode(),
|
| 40 |
+
'country' => $this->getCountryId()
|
| 41 |
+
);
|
| 42 |
+
|
| 43 |
+
$responseErrors = array(
|
| 44 |
+
'400' => Mage::helper('taxjar')->__('Your nexus address contains invalid data. Please verify the address in order to sync with TaxJar.'),
|
| 45 |
+
'409' => Mage::helper('taxjar')->__('A nexus address already exists for this state/region. TaxJar currently supports one address per region.'),
|
| 46 |
+
'422' => Mage::helper('taxjar')->__('Your nexus address is missing one or more required fields. Please verify the address in order to sync with TaxJar.'),
|
| 47 |
+
'500' => Mage::helper('taxjar')->__('Something went wrong while syncing your address with TaxJar. Please verify the address and contact support@taxjar.com if the problem persists.')
|
| 48 |
+
);
|
| 49 |
+
|
| 50 |
+
if ($this->getId()) {
|
| 51 |
+
$client->putResource($apiKey, 'nexus', $this->getApiId(), $data, $responseErrors);
|
| 52 |
+
} else {
|
| 53 |
+
$savedAddress = $client->postResource($apiKey, 'nexus', $data, $responseErrors);
|
| 54 |
+
$this->setApiId($savedAddress['id']);
|
| 55 |
+
$this->save();
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Delete nexus address in TaxJar
|
| 61 |
+
*
|
| 62 |
+
* @return void
|
| 63 |
+
*/
|
| 64 |
+
public function syncDelete()
|
| 65 |
+
{
|
| 66 |
+
$client = Mage::getModel('taxjar/client');
|
| 67 |
+
$apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 68 |
+
|
| 69 |
+
$responseErrors = array(
|
| 70 |
+
'409' => Mage::helper('taxjar')->__('A nexus address with this ID could not be found in TaxJar.'),
|
| 71 |
+
'500' => Mage::helper('taxjar')->__('Something went wrong while deleting your address in TaxJar. Please contact support@taxjar.com if the problem persists.')
|
| 72 |
+
);
|
| 73 |
+
|
| 74 |
+
if ($this->getId()) {
|
| 75 |
+
$client->deleteResource($apiKey, 'nexus', $this->getApiId(), $responseErrors);
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Sync nexus addresses from TaxJar -> Magento
|
| 81 |
+
*
|
| 82 |
+
* @return void
|
| 83 |
+
*/
|
| 84 |
+
public function syncCollection()
|
| 85 |
+
{
|
| 86 |
+
$client = Mage::getModel('taxjar/client');
|
| 87 |
+
$apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 88 |
+
$nexusJson = $client->getResource($apiKey, 'nexus');
|
| 89 |
+
|
| 90 |
+
if ($nexusJson['addresses']) {
|
| 91 |
+
$addresses = $nexusJson['addresses'];
|
| 92 |
+
|
| 93 |
+
foreach($addresses as $address) {
|
| 94 |
+
$addressRegion = Mage::getModel('directory/region')->loadByCode($address['state'], $address['country']);
|
| 95 |
+
$addressCountry = Mage::getModel('directory/country')->loadByCode($address['country']);
|
| 96 |
+
$addressCollection = Mage::getModel('taxjar/tax_nexus')->getCollection();
|
| 97 |
+
|
| 98 |
+
// Find existing address by region if US, otherwise country
|
| 99 |
+
if ($address['country'] == 'US') {
|
| 100 |
+
$existingAddress = $addressCollection->addFieldToFilter('region_id', $addressRegion->getId())->getFirstItem();
|
| 101 |
+
} else {
|
| 102 |
+
$existingAddress = $addressCollection->addFieldToFilter('country_id', $addressCountry->getId())->getFirstItem();
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
if ($existingAddress->getId()) {
|
| 106 |
+
$existingAddress->addData(array(
|
| 107 |
+
'api_id' => $address['id'],
|
| 108 |
+
'street' => $address['street'],
|
| 109 |
+
'city' => $address['city'],
|
| 110 |
+
'postcode' => $address['zip'],
|
| 111 |
+
'updated_at' => now()
|
| 112 |
+
));
|
| 113 |
+
$existingAddress->save();
|
| 114 |
+
} else {
|
| 115 |
+
$newAddress = Mage::getModel('taxjar/tax_nexus');
|
| 116 |
+
$newAddress->setData(array(
|
| 117 |
+
'api_id' => $address['id'],
|
| 118 |
+
'street' => $address['street'],
|
| 119 |
+
'city' => $address['city'],
|
| 120 |
+
'country_id' => $addressCountry->getId(),
|
| 121 |
+
'region' => $addressRegion->getName(),
|
| 122 |
+
'region_id' => $addressRegion->getId(),
|
| 123 |
+
'region_code' => $addressRegion->getCode(),
|
| 124 |
+
'postcode' => $address['zip'],
|
| 125 |
+
'created_at' => now(),
|
| 126 |
+
'updated_at' => now()
|
| 127 |
+
));
|
| 128 |
+
$newAddress->save();
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* Validate nexus address
|
| 136 |
+
*
|
| 137 |
+
* @return array
|
| 138 |
+
*/
|
| 139 |
+
public function validate()
|
| 140 |
+
{
|
| 141 |
+
$errors = array();
|
| 142 |
+
$nexusModel = Mage::getModel('taxjar/tax_nexus');
|
| 143 |
+
|
| 144 |
+
if (!Zend_Validate::is($this->getStreet(), 'NotEmpty')) {
|
| 145 |
+
$errors[] = Mage::helper('taxjar')->__('Street address can\'t be empty');
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
if (!Zend_Validate::is($this->getCity(), 'NotEmpty')) {
|
| 149 |
+
$errors[] = Mage::helper('taxjar')->__('City can\'t be empty');
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
if (!Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
|
| 153 |
+
$errors[] = Mage::helper('taxjar')->__('Country can\'t be empty');
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
if (!Zend_Validate::is($this->getRegionId(), 'NotEmpty')) {
|
| 157 |
+
$errors[] = Mage::helper('taxjar')->__('State/region can\'t be empty');
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
if (!Zend_Validate::is($this->getPostcode(), 'NotEmpty')) {
|
| 161 |
+
$errors[] = Mage::helper('taxjar')->__('Zip/Post Code can\'t be empty');
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
if (!$this->getId()) {
|
| 165 |
+
$countryAddresses = $nexusModel->getCollection()->addFieldToFilter('country_id', $this->getCountryId());
|
| 166 |
+
|
| 167 |
+
if ($countryAddresses->getSize() && $this->getCountryId() != 'US' && $this->getCountryId() != 'CA') {
|
| 168 |
+
$errors[] = Mage::helper('taxjar')->__('Only one address per country (outside of US/CA) is currently supported.');
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
if (empty($errors)) {
|
| 173 |
+
return true;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
return $errors;
|
| 177 |
+
}
|
| 178 |
+
}
|
app/code/community/Taxjar/SalesTax/controllers/Adminhtml/Tax/NexusController.php
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* TaxJar Admin Router
|
| 20 |
+
* Connect and disconnect TaxJar accounts
|
| 21 |
+
*/
|
| 22 |
+
class Taxjar_SalesTax_Adminhtml_Tax_NexusController extends Mage_Adminhtml_Controller_Action
|
| 23 |
+
{
|
| 24 |
+
public function indexAction()
|
| 25 |
+
{
|
| 26 |
+
$this->_title($this->__('Sales'))
|
| 27 |
+
->_title($this->__('Tax'))
|
| 28 |
+
->_title($this->__('Nexus Addresses'));
|
| 29 |
+
|
| 30 |
+
$this->_reviewAddresses();
|
| 31 |
+
|
| 32 |
+
$this->_initAction()
|
| 33 |
+
->_addContent($this->getLayout()->createBlock('taxjar/adminhtml_tax_nexus'))
|
| 34 |
+
->renderLayout();
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
public function syncAction()
|
| 38 |
+
{
|
| 39 |
+
try {
|
| 40 |
+
Mage::getModel('taxjar/tax_nexus')->syncCollection();
|
| 41 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('taxjar')->__('Your nexus addresses have been synced from TaxJar.'));
|
| 42 |
+
} catch (Mage_Core_Exception $e) {
|
| 43 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
$this->_redirect('*/*/');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function newAction()
|
| 50 |
+
{
|
| 51 |
+
$this->_forward('edit');
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
public function editAction()
|
| 55 |
+
{
|
| 56 |
+
$this->_title($this->__('Sales'))
|
| 57 |
+
->_title($this->__('Tax'))
|
| 58 |
+
->_title($this->__('Nexus Addresses'));
|
| 59 |
+
|
| 60 |
+
$nexusId = $this->getRequest()->getParam('id');
|
| 61 |
+
$model = Mage::getModel('taxjar/tax_nexus');
|
| 62 |
+
|
| 63 |
+
if ($nexusId) {
|
| 64 |
+
$model->load($nexusId);
|
| 65 |
+
if (!$model->getId()) {
|
| 66 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
| 67 |
+
Mage::helper('taxjar')->__('This nexus address no longer exists.')
|
| 68 |
+
);
|
| 69 |
+
$this->_redirect('*/*/');
|
| 70 |
+
return;
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
$this->_title($nexusId ? $model->getRegion() : $this->__('New Nexus Address'));
|
| 75 |
+
|
| 76 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
| 77 |
+
if (!empty($data)) {
|
| 78 |
+
$model->setData($data);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
Mage::register('taxjar/tax_nexus', $model);
|
| 82 |
+
|
| 83 |
+
$this->_initAction()
|
| 84 |
+
->_addBreadcrumb(
|
| 85 |
+
$nexusId ? Mage::helper('taxjar')->__('Edit Nexus Address') : Mage::helper('taxjar')->__('New Nexus Address'),
|
| 86 |
+
$nexusId ? Mage::helper('taxjar')->__('Edit Nexus Address') : Mage::helper('taxjar')->__('New Nexus Address')
|
| 87 |
+
)
|
| 88 |
+
->_addContent(
|
| 89 |
+
$this->getLayout()->createBlock('taxjar/adminhtml_tax_nexus_edit')
|
| 90 |
+
->setData('action', $this->getUrl('*/tax_nexus/save'))
|
| 91 |
+
)
|
| 92 |
+
->renderLayout();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
public function saveAction()
|
| 96 |
+
{
|
| 97 |
+
$nexusPost = $this->getRequest()->getPost();
|
| 98 |
+
|
| 99 |
+
if ($nexusPost) {
|
| 100 |
+
$nexusId = $this->getRequest()->getParam('id');
|
| 101 |
+
|
| 102 |
+
if ($nexusId) {
|
| 103 |
+
$nexusModel = Mage::getSingleton('taxjar/tax_nexus')->load($nexusId);
|
| 104 |
+
|
| 105 |
+
if (!$nexusModel->getId()) {
|
| 106 |
+
unset($nexusPost['id']);
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
$nexusModel = Mage::getModel('taxjar/tax_nexus')->setData($nexusPost);
|
| 111 |
+
$regionModel = Mage::getModel('directory/region')->load($nexusModel->getRegionId());
|
| 112 |
+
|
| 113 |
+
$nexusModel->setRegion($regionModel->getName());
|
| 114 |
+
$nexusModel->setRegionCode($regionModel->getCode());
|
| 115 |
+
|
| 116 |
+
try {
|
| 117 |
+
if (is_array($errors = $nexusModel->validate())) {
|
| 118 |
+
Mage::getSingleton('adminhtml/session')->setFormData($nexusPost);
|
| 119 |
+
Mage::getSingleton('adminhtml/session')->addError($errors[0]);
|
| 120 |
+
$this->_redirectReferer();
|
| 121 |
+
return;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
try {
|
| 125 |
+
if ($nexusModel->getCountryId() == 'US') {
|
| 126 |
+
$nexusModel->sync();
|
| 127 |
+
}
|
| 128 |
+
$nexusModel->save();
|
| 129 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('taxjar')->__('The nexus address has been saved.'));
|
| 130 |
+
$this->getResponse()->setRedirect($this->getUrl("*/*/"));
|
| 131 |
+
return true;
|
| 132 |
+
} catch (Mage_Core_Exception $e) {
|
| 133 |
+
Mage::getSingleton('adminhtml/session')->setFormData($nexusPost);
|
| 134 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 135 |
+
}
|
| 136 |
+
} catch (Mage_Core_Exception $e) {
|
| 137 |
+
Mage::getSingleton('adminhtml/session')->setFormData($nexusPost);
|
| 138 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 139 |
+
} catch (Exception $e) {
|
| 140 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
$this->_redirectReferer();
|
| 144 |
+
return;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
$this->getResponse()->setRedirect($this->getUrl('*/tax_nexus'));
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
public function deleteAction()
|
| 151 |
+
{
|
| 152 |
+
if ($nexusId = $this->getRequest()->getParam('id')) {
|
| 153 |
+
$nexusModel = Mage::getModel('taxjar/tax_nexus')->load($nexusId);
|
| 154 |
+
if ($nexusModel->getId()) {
|
| 155 |
+
try {
|
| 156 |
+
if ($nexusModel->getCountryId() == 'US') {
|
| 157 |
+
$nexusModel->syncDelete();
|
| 158 |
+
}
|
| 159 |
+
$nexusModel->delete();
|
| 160 |
+
|
| 161 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('taxjar')->__('The nexus address has been deleted.'));
|
| 162 |
+
$this->getResponse()->setRedirect($this->getUrl("*/*/"));
|
| 163 |
+
return true;
|
| 164 |
+
}
|
| 165 |
+
catch (Mage_Core_Exception $e) {
|
| 166 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 167 |
+
}
|
| 168 |
+
catch (Exception $e) {
|
| 169 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('taxjar')->__('An error occurred while deleting this nexus address.'));
|
| 170 |
+
}
|
| 171 |
+
if ($referer = $this->getRequest()->getServer('HTTP_REFERER')) {
|
| 172 |
+
$this->getResponse()->setRedirect($referer);
|
| 173 |
+
}
|
| 174 |
+
else {
|
| 175 |
+
$this->getResponse()->setRedirect($this->getUrl("*/*/"));
|
| 176 |
+
}
|
| 177 |
+
} else {
|
| 178 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('taxjar')->__('An error occurred while deleting this nexus address. Incorrect nexus ID.'));
|
| 179 |
+
$this->getResponse()->setRedirect($this->getUrl('*/*/'));
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
protected function _initAction()
|
| 185 |
+
{
|
| 186 |
+
$this->loadLayout()
|
| 187 |
+
->_setActiveMenu('sales/tax/taxjar_salestax_nexus')
|
| 188 |
+
->_addBreadcrumb(Mage::helper('taxjar')->__('Tax'), Mage::helper('taxjar')->__('Tax'))
|
| 189 |
+
->_addBreadcrumb(Mage::helper('taxjar')->__('Nexus Addresses'), Mage::helper('taxjar')->__('Nexus Addresses'))
|
| 190 |
+
;
|
| 191 |
+
return $this;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
protected function _isAllowed()
|
| 195 |
+
{
|
| 196 |
+
$connected = Mage::getStoreConfig('tax/taxjar/connected');
|
| 197 |
+
|
| 198 |
+
if (!$connected) {
|
| 199 |
+
return false;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
return Mage::getSingleton('admin/session')->isAllowed('sales/tax/taxjar_salestax_nexus');
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
protected function _reviewAddresses()
|
| 206 |
+
{
|
| 207 |
+
$nexusMissingPostcode = Mage::getModel('taxjar/tax_nexus')->getCollection()->addFieldToFilter('postcode', array('null' => true));
|
| 208 |
+
|
| 209 |
+
if ($nexusMissingPostcode->getSize()) {
|
| 210 |
+
return Mage::getSingleton('core/session')->addNotice(Mage::helper('taxjar')->__('One or more of your nexus addresses are missing a zip/post code. Please provide accurate data for each nexus address.'));
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
}
|
app/code/community/Taxjar/SalesTax/controllers/Adminhtml/TaxjarController.php
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
* Connect and disconnect TaxJar accounts
|
| 21 |
*/
|
| 22 |
class Taxjar_SalesTax_Adminhtml_TaxjarController extends Mage_Adminhtml_Controller_Action
|
| 23 |
-
{
|
| 24 |
/**
|
| 25 |
* Connect to TaxJar
|
| 26 |
*/
|
|
@@ -65,8 +65,12 @@ class Taxjar_SalesTax_Adminhtml_TaxjarController extends Mage_Adminhtml_Controll
|
|
| 65 |
*/
|
| 66 |
public function sync_ratesAction()
|
| 67 |
{
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
protected function _isAllowed()
|
| 20 |
* Connect and disconnect TaxJar accounts
|
| 21 |
*/
|
| 22 |
class Taxjar_SalesTax_Adminhtml_TaxjarController extends Mage_Adminhtml_Controller_Action
|
| 23 |
+
{
|
| 24 |
/**
|
| 25 |
* Connect to TaxJar
|
| 26 |
*/
|
| 65 |
*/
|
| 66 |
public function sync_ratesAction()
|
| 67 |
{
|
| 68 |
+
try {
|
| 69 |
+
Mage::dispatchEvent('taxjar_salestax_import_data');
|
| 70 |
+
Mage::dispatchEvent('taxjar_salestax_import_rates');
|
| 71 |
+
} catch (Exception $e) {
|
| 72 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
| 73 |
+
}
|
| 74 |
}
|
| 75 |
|
| 76 |
protected function _isAllowed()
|
app/code/community/Taxjar/SalesTax/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Taxjar_SalesTax
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
*
|
| 13 |
+
* @category Taxjar
|
| 14 |
+
* @package Taxjar_SalesTax
|
| 15 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
-->
|
| 19 |
+
<config>
|
| 20 |
+
<menu>
|
| 21 |
+
<sales>
|
| 22 |
+
<children>
|
| 23 |
+
<tax>
|
| 24 |
+
<children>
|
| 25 |
+
<taxjar_salestax_nexus translate="title" module="taxjar">
|
| 26 |
+
<title>Nexus Addresses</title>
|
| 27 |
+
<action>adminhtml/tax_nexus</action>
|
| 28 |
+
<sort_order>10</sort_order>
|
| 29 |
+
</taxjar_salestax_nexus>
|
| 30 |
+
</children>
|
| 31 |
+
</tax>
|
| 32 |
+
</children>
|
| 33 |
+
</sales>
|
| 34 |
+
</menu>
|
| 35 |
+
<acl>
|
| 36 |
+
<resources>
|
| 37 |
+
<admin>
|
| 38 |
+
<children>
|
| 39 |
+
<sales>
|
| 40 |
+
<children>
|
| 41 |
+
<tax>
|
| 42 |
+
<children>
|
| 43 |
+
<taxjar_salestax_nexus>
|
| 44 |
+
<title>Nexus Addresses</title>
|
| 45 |
+
</taxjar_salestax_nexus>
|
| 46 |
+
</children>
|
| 47 |
+
</tax>
|
| 48 |
+
</children>
|
| 49 |
+
</sales>
|
| 50 |
+
</children>
|
| 51 |
+
</admin>
|
| 52 |
+
</resources>
|
| 53 |
+
</acl>
|
| 54 |
+
</config>
|
app/code/community/Taxjar/SalesTax/etc/config.xml
CHANGED
|
@@ -19,7 +19,7 @@
|
|
| 19 |
<config>
|
| 20 |
<modules>
|
| 21 |
<Taxjar_SalesTax>
|
| 22 |
-
<version>2.0
|
| 23 |
</Taxjar_SalesTax>
|
| 24 |
</modules>
|
| 25 |
<global>
|
|
@@ -42,7 +42,16 @@
|
|
| 42 |
<models>
|
| 43 |
<taxjar>
|
| 44 |
<class>Taxjar_SalesTax_Model</class>
|
|
|
|
| 45 |
</taxjar>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
<tax_resource>
|
| 47 |
<rewrite>
|
| 48 |
<calculation>Taxjar_SalesTax_Model_Calculation</calculation>
|
|
@@ -66,6 +75,15 @@
|
|
| 66 |
</taxjar>
|
| 67 |
</observers>
|
| 68 |
</admin_system_config_changed_section_tax>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
<taxjar_salestax_import_data>
|
| 70 |
<observers>
|
| 71 |
<taxjar>
|
|
@@ -102,6 +120,15 @@
|
|
| 102 |
</taxjar>
|
| 103 |
</observers>
|
| 104 |
</controller_action_predispatch>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
</events>
|
| 106 |
</global>
|
| 107 |
<admin>
|
| 19 |
<config>
|
| 20 |
<modules>
|
| 21 |
<Taxjar_SalesTax>
|
| 22 |
+
<version>2.1.0</version>
|
| 23 |
</Taxjar_SalesTax>
|
| 24 |
</modules>
|
| 25 |
<global>
|
| 42 |
<models>
|
| 43 |
<taxjar>
|
| 44 |
<class>Taxjar_SalesTax_Model</class>
|
| 45 |
+
<resourceModel>taxjar_resource</resourceModel>
|
| 46 |
</taxjar>
|
| 47 |
+
<taxjar_resource>
|
| 48 |
+
<class>Taxjar_SalesTax_Model_Resource</class>
|
| 49 |
+
<entities>
|
| 50 |
+
<tax_nexus>
|
| 51 |
+
<table>tax_nexus</table>
|
| 52 |
+
</tax_nexus>
|
| 53 |
+
</entities>
|
| 54 |
+
</taxjar_resource>
|
| 55 |
<tax_resource>
|
| 56 |
<rewrite>
|
| 57 |
<calculation>Taxjar_SalesTax_Model_Calculation</calculation>
|
| 75 |
</taxjar>
|
| 76 |
</observers>
|
| 77 |
</admin_system_config_changed_section_tax>
|
| 78 |
+
<controller_action_predispatch_adminhtml_system_config_edit>
|
| 79 |
+
<observers>
|
| 80 |
+
<taxjar>
|
| 81 |
+
<type>singleton</type>
|
| 82 |
+
<class>taxjar/observer_configReview</class>
|
| 83 |
+
<method>execute</method>
|
| 84 |
+
</taxjar>
|
| 85 |
+
</observers>
|
| 86 |
+
</controller_action_predispatch_adminhtml_system_config_edit>
|
| 87 |
<taxjar_salestax_import_data>
|
| 88 |
<observers>
|
| 89 |
<taxjar>
|
| 120 |
</taxjar>
|
| 121 |
</observers>
|
| 122 |
</controller_action_predispatch>
|
| 123 |
+
<controller_action_layout_render_before>
|
| 124 |
+
<observers>
|
| 125 |
+
<taxjar>
|
| 126 |
+
<type>singleton</type>
|
| 127 |
+
<class>taxjar/observer_adminMenuItems</class>
|
| 128 |
+
<method>execute</method>
|
| 129 |
+
</taxjar>
|
| 130 |
+
</observers>
|
| 131 |
+
</controller_action_layout_render_before>
|
| 132 |
</events>
|
| 133 |
</global>
|
| 134 |
<admin>
|
app/code/community/Taxjar/SalesTax/sql/salestax_setup/upgrade-2.0.0-2.1.0.php
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Taxjar_SalesTax
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
*
|
| 12 |
+
* @category Taxjar
|
| 13 |
+
* @package Taxjar_SalesTax
|
| 14 |
+
* @copyright Copyright (c) 2016 TaxJar. TaxJar is a trademark of TPS Unlimited, Inc. (http://www.taxjar.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
$installer = $this;
|
| 19 |
+
$installer->startSetup();
|
| 20 |
+
|
| 21 |
+
try {
|
| 22 |
+
$table = $installer->getConnection()
|
| 23 |
+
->newTable($installer->getTable('taxjar/tax_nexus'))
|
| 24 |
+
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 25 |
+
'identity' => true,
|
| 26 |
+
'unsigned' => true,
|
| 27 |
+
'nullable' => false,
|
| 28 |
+
'primary' => true
|
| 29 |
+
), 'ID')
|
| 30 |
+
->addColumn('api_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 31 |
+
'unsigned' => true,
|
| 32 |
+
), 'API ID')
|
| 33 |
+
->addColumn('street', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 34 |
+
), 'Street')
|
| 35 |
+
->addColumn('city', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 36 |
+
), 'City')
|
| 37 |
+
->addColumn('country_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 38 |
+
), 'Country Id')
|
| 39 |
+
->addColumn('region', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 40 |
+
), 'Region')
|
| 41 |
+
->addColumn('region_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 42 |
+
'unsigned' => true,
|
| 43 |
+
), 'Region Id')
|
| 44 |
+
->addColumn('region_code', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 45 |
+
), 'Region Code')
|
| 46 |
+
->addColumn('postcode', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 47 |
+
), 'Postcode')
|
| 48 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
| 49 |
+
), 'Creation Time')
|
| 50 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
| 51 |
+
), 'Update Time')
|
| 52 |
+
->addIndex($installer->getIdxName('taxjar/tax_nexus', array('country_id')),
|
| 53 |
+
array('country_id'))
|
| 54 |
+
->addIndex($installer->getIdxName('taxjar/tax_nexus', array('region_id')),
|
| 55 |
+
array('region_id'))
|
| 56 |
+
->addIndex($installer->getIdxName('taxjar/tax_nexus', array('region_code')),
|
| 57 |
+
array('region_code'))
|
| 58 |
+
->setComment('TaxJar Nexus Address');
|
| 59 |
+
|
| 60 |
+
$installer->getConnection()->createTable($table);
|
| 61 |
+
|
| 62 |
+
} catch (Exception $e) {
|
| 63 |
+
Mage::logException($e);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
$installer->endSetup();
|
package.xml
CHANGED
|
@@ -1,20 +1,21 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Taxjar_Salestaxautomation</name>
|
| 4 |
-
<version>2.0
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>MIT</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Easily collect sales tax without altering your Magento store’s checkout experience or performance.</summary>
|
| 10 |
<description>TaxJar for Magento allows you to quickly calculate sales tax at checkout using our SmartCalcs API and zip-based rates as a backup.</description>
|
| 11 |
-
<notes>*
|
| 12 |
-
*
|
| 13 |
-
*
|
|
|
|
| 14 |
<authors><author><name>TaxJar</name><user>taxjar</user><email>support@taxjar.com</email></author></authors>
|
| 15 |
-
<date>2016-
|
| 16 |
-
<time>
|
| 17 |
-
<contents><target name="magecommunity"><dir name="Taxjar"><dir name="SalesTax"><dir name="Block"><dir name="Adminhtml"><file name="Backup.php" hash="
|
| 18 |
<compatible/>
|
| 19 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Taxjar_Salestaxautomation</name>
|
| 4 |
+
<version>2.1.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>MIT</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Easily collect sales tax without altering your Magento store’s checkout experience or performance.</summary>
|
| 10 |
<description>TaxJar for Magento allows you to quickly calculate sales tax at checkout using our SmartCalcs API and zip-based rates as a backup.</description>
|
| 11 |
+
<notes>* Nexus addresses can now be managed in Magento under Sales > Tax > Nexus Addresses. If upgrading from a previous version and using checkout calculations, make sure you sync your existing addresses from TaxJar or set up a new address. Your addresses will automatically sync with TaxJar when added or changed.
|
| 12 |
+
* International support for SmartCalcs checkout calculations. One nexus address per country outside of US/CA is currently supported for more than 30 countries.
|
| 13 |
+
* Review nexus addresses for missing data and set up observer to report tax configuration issues.
|
| 14 |
+
* Report errors when using AJAX sync backup rate button in the TaxJar configuration.</notes>
|
| 15 |
<authors><author><name>TaxJar</name><user>taxjar</user><email>support@taxjar.com</email></author></authors>
|
| 16 |
+
<date>2016-06-10</date>
|
| 17 |
+
<time>22:24:15</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="Taxjar"><dir name="SalesTax"><dir name="Block"><dir name="Adminhtml"><file name="Backup.php" hash="97933cb0f04c30baab4af5af24412f8d"/><file name="Enabled.php" hash="29462c876c8ea67c21a6f4d799b53925"/><file name="Multiselect.php" hash="a1a7ea16e85cbc27b3014a2cc7d24c95"/><dir name="Tax"><dir name="Class"><dir name="Edit"><file name="Form.php" hash="655e276e44ad233b055eee8965391088"/></dir><file name="Grid.php" hash="a52bbe41bc9255bf54720ab4142bfaa7"/></dir><dir name="Nexus"><dir name="Edit"><file name="Form.php" hash="d4f40eea98055fe60409863066c72454"/></dir><file name="Edit.php" hash="e8bffbb5bc4ff17c368543c2508c00a5"/><file name="Grid.php" hash="ccb748472a7a20ae0f5f0e3df58d5edf"/></dir><file name="Nexus.php" hash="65d93fb5dbfa747b2d59a5f521863fc6"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="d19f2af9ff020d2e0d31369cf43eac50"/></dir><dir name="Model"><file name="Calculation.php" hash="89c05ee42f8316563ea610f11b53a26d"/><file name="Categories.php" hash="934947240f1a1c7ae7b9ba323aacabd6"/><file name="Client.php" hash="1bda5172a54d2f7c7ef290a9d71a8f37"/><file name="Comment.php" hash="07bf5fbd4fe084233f11dc64a3b6de43"/><file name="Configuration.php" hash="c59b69931392eb896e4d0c46b7d2e38b"/><file name="Debug.php" hash="5bb3e0a4ccaf7532cbdd63ce55275d84"/><dir name="Import"><file name="Comment.php" hash="958de1f883a6f67f1fa1c26d5d67e3ec"/><file name="Rate.php" hash="00ad69812c8d2f31915cac959483c1eb"/><file name="Rule.php" hash="597ff0e337b4e04e43660b4d4f05d0e0"/></dir><dir name="Observer"><file name="AdminMenuItems.php" hash="f62dbedd59e82f6b556c832064859ded"/><file name="AdminNotifications.php" hash="462c1210a649d81a2a49db7c03d7f293"/><file name="ConfigChanged.php" hash="9a916f26f223c22cda229c2e61a3d119"/><file name="ConfigReview.php" hash="d1ae83a4e074e034440f3074724bdefb"/><file name="ImportData.php" hash="ca21015ca41f8352fe015b4a82fc428d"/><file name="ImportRates.php" hash="95cbcd73ed1914bdfc3459631308d35d"/><file name="SalesQuoteCollectTotalsBefore.php" hash="37c28ddaf8a27d548bf463fff1aa7da1"/></dir><dir name="Resource"><dir name="Tax"><dir name="Nexus"><file name="Collection.php" hash="75cae3600991518db909a08d5031ff6a"/></dir><file name="Nexus.php" hash="b43e437c89ed549c9ec20af2841dfb1b"/></dir></dir><dir name="Sales"><dir name="Total"><dir name="Quote"><file name="Tax.php" hash="71399362c1f7d057626f6658f15bbe38"/></dir></dir></dir><file name="Smartcalcs.php" hash="f997c65ecd55042e4f3b23d7c47738d0"/><dir name="Tax"><dir name="Class"><dir name="Source"><file name="Customer.php" hash="9f2941032dc80219f9def35de5c5afc8"/><file name="Product.php" hash="3e0d0826d3d43e8a7c63f2e2e44b810a"/></dir></dir><file name="Nexus.php" hash="7e559a59d41feb796c6a19550badb6c6"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Tax"><file name="NexusController.php" hash="cc61d7e6dd1adc53996513d549c757bd"/></dir><file name="TaxjarController.php" hash="bd38d253864ff98a0ece6d5bcea36486"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b88bc6bfb95dfbd8f5343ae0128dbe11"/><file name="config.xml" hash="0053260a22d8fd15708508abed104fad"/><file name="system.xml" hash="7307753f550f490112ded20317c1a07d"/></dir><dir name="sql"><dir name="salestax_setup"><file name="install-1.6.0.php" hash="9d400004ec642113a8cc907fe5d33960"/><file name="upgrade-2.0.0-2.1.0.php" hash="f4571be5edfe2a7d6a54a0e239792907"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Taxjar_SalesTax.xml" hash="552596be5ec12440753bf69ed6005747"/></dir></target></contents>
|
| 19 |
<compatible/>
|
| 20 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 21 |
</package>
|
