Version Notes
* Fix child item quantity calculation for bundle items when parent quantity is > 1.
Download this release
Release Info
| Developer | TaxJar |
| Extension | Taxjar_Salestaxautomation |
| Version | 2.3.3 |
| Comparing to | |
| See all releases | |
Code changes from version 2.3.2 to 2.3.3
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Backup.php +3 -3
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Enabled.php +3 -3
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Multiselect.php +2 -2
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Class/Edit/Form.php +4 -4
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Class/Grid.php +2 -2
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus.php +2 -2
- app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus/Edit/Form.php +9 -9
- app/code/community/Taxjar/SalesTax/Helper/Data.php +2 -2
- app/code/community/Taxjar/SalesTax/Model/Calculation.php +1 -1
- app/code/community/Taxjar/SalesTax/Model/Categories.php +4 -4
- app/code/community/Taxjar/SalesTax/Model/Client.php +10 -10
- app/code/community/Taxjar/SalesTax/Model/Comment.php +13 -13
- app/code/community/Taxjar/SalesTax/Model/Configuration.php +3 -3
- app/code/community/Taxjar/SalesTax/Model/Debug.php +1 -1
- app/code/community/Taxjar/SalesTax/Model/Import/Comment.php +8 -8
- app/code/community/Taxjar/SalesTax/Model/Import/Rate.php +2 -2
- app/code/community/Taxjar/SalesTax/Model/Observer/AdminMenuItems.php +2 -2
- app/code/community/Taxjar/SalesTax/Model/Observer/ConfigChanged.php +6 -6
- app/code/community/Taxjar/SalesTax/Model/Observer/ConfigReview.php +6 -6
- app/code/community/Taxjar/SalesTax/Model/Observer/ImportCategories.php +4 -4
- app/code/community/Taxjar/SalesTax/Model/Observer/ImportData.php +5 -5
- app/code/community/Taxjar/SalesTax/Model/Observer/ImportRates.php +16 -16
- app/code/community/Taxjar/SalesTax/Model/Sales/Order/Api/V2.php +2 -2
- app/code/community/Taxjar/SalesTax/Model/Sales/Total/Quote/Tax.php +4 -4
- app/code/community/Taxjar/SalesTax/Model/Smartcalcs.php +30 -22
- app/code/community/Taxjar/SalesTax/Model/Tax/Nexus.php +13 -13
- app/code/community/Taxjar/SalesTax/controllers/Adminhtml/Tax/NexusController.php +17 -17
- app/code/community/Taxjar/SalesTax/controllers/Adminhtml/TaxjarController.php +11 -11
- app/code/community/Taxjar/SalesTax/etc/adminhtml.xml +1 -1
- app/code/community/Taxjar/SalesTax/etc/config.xml +1 -1
- app/code/community/Taxjar/SalesTax/etc/system.xml +1 -1
- app/code/community/Taxjar/SalesTax/etc/wsdl.xml +1 -1
- app/code/community/Taxjar/SalesTax/sql/salestax_setup/install-1.6.0.php +1 -1
- app/code/community/Taxjar/SalesTax/sql/salestax_setup/upgrade-2.0.1-2.1.0.php +2 -2
- app/etc/modules/Taxjar_SalesTax.xml +1 -1
- package.xml +5 -5
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Backup.php
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
<?php
|
| 2 |
/**
|
| 3 |
* Taxjar_SalesTax
|
| 4 |
*
|
|
@@ -24,14 +24,14 @@ class Taxjar_SalesTax_Block_Adminhtml_Backup extends Mage_Adminhtml_Block_System
|
|
| 24 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 25 |
{
|
| 26 |
$apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 27 |
-
|
| 28 |
if ($apiKey) {
|
| 29 |
$this->_cacheElementValue($element);
|
| 30 |
}
|
| 31 |
|
| 32 |
return parent::_getElementHtml($element);
|
| 33 |
}
|
| 34 |
-
|
| 35 |
protected function _cacheElementValue(Varien_Data_Form_Element_Abstract $element)
|
| 36 |
{
|
| 37 |
$elementValue = (string) $element->getValue();
|
| 1 |
+
<?php
|
| 2 |
/**
|
| 3 |
* Taxjar_SalesTax
|
| 4 |
*
|
| 24 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 25 |
{
|
| 26 |
$apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 27 |
+
|
| 28 |
if ($apiKey) {
|
| 29 |
$this->_cacheElementValue($element);
|
| 30 |
}
|
| 31 |
|
| 32 |
return parent::_getElementHtml($element);
|
| 33 |
}
|
| 34 |
+
|
| 35 |
protected function _cacheElementValue(Varien_Data_Form_Element_Abstract $element)
|
| 36 |
{
|
| 37 |
$elementValue = (string) $element->getValue();
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Enabled.php
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
<?php
|
| 2 |
/**
|
| 3 |
* Taxjar_SalesTax
|
| 4 |
*
|
|
@@ -24,7 +24,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Enabled extends Mage_Adminhtml_Block_Syste
|
|
| 24 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 25 |
{
|
| 26 |
$apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 27 |
-
|
| 28 |
if (!$apiKey) {
|
| 29 |
$element->setDisabled('disabled');
|
| 30 |
} else {
|
|
@@ -33,7 +33,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Enabled extends Mage_Adminhtml_Block_Syste
|
|
| 33 |
|
| 34 |
return parent::_getElementHtml($element);
|
| 35 |
}
|
| 36 |
-
|
| 37 |
protected function _cacheElementValue(Varien_Data_Form_Element_Abstract $element)
|
| 38 |
{
|
| 39 |
$elementValue = (string) $element->getValue();
|
| 1 |
+
<?php
|
| 2 |
/**
|
| 3 |
* Taxjar_SalesTax
|
| 4 |
*
|
| 24 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 25 |
{
|
| 26 |
$apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 27 |
+
|
| 28 |
if (!$apiKey) {
|
| 29 |
$element->setDisabled('disabled');
|
| 30 |
} else {
|
| 33 |
|
| 34 |
return parent::_getElementHtml($element);
|
| 35 |
}
|
| 36 |
+
|
| 37 |
protected function _cacheElementValue(Varien_Data_Form_Element_Abstract $element)
|
| 38 |
{
|
| 39 |
$elementValue = (string) $element->getValue();
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Multiselect.php
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
<?php
|
| 2 |
/**
|
| 3 |
* Taxjar_SalesTax
|
| 4 |
*
|
|
@@ -26,4 +26,4 @@ class Taxjar_SalesTax_Block_Adminhtml_Multiselect extends Mage_Adminhtml_Block_S
|
|
| 26 |
$element->setSize(4);
|
| 27 |
return parent::_getElementHtml($element);
|
| 28 |
}
|
| 29 |
-
}
|
| 1 |
+
<?php
|
| 2 |
/**
|
| 3 |
* Taxjar_SalesTax
|
| 4 |
*
|
| 26 |
$element->setSize(4);
|
| 27 |
return parent::_getElementHtml($element);
|
| 28 |
}
|
| 29 |
+
}
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Class/Edit/Form.php
CHANGED
|
@@ -24,7 +24,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Class_Edit_Form extends Mage_Adminhtml
|
|
| 24 |
$connected = Mage::getStoreConfig('tax/taxjar/connected');
|
| 25 |
$fieldset = $this->getForm()->getElement('base_fieldset');
|
| 26 |
$currentClass = Mage::registry('tax_class');
|
| 27 |
-
|
| 28 |
if ($connected && $this->getClassType() == 'PRODUCT') {
|
| 29 |
$fieldset->addField(
|
| 30 |
'tj_salestax_code', 'select', array(
|
|
@@ -33,9 +33,9 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Class_Edit_Form extends Mage_Adminhtml
|
|
| 33 |
'value' => $currentClass->getTjSalestaxCode(),
|
| 34 |
'values' => Mage::getModel('taxjar/categories')->toOptionArray()
|
| 35 |
)
|
| 36 |
-
);
|
| 37 |
}
|
| 38 |
-
|
| 39 |
if ($connected && $this->getClassType() == 'CUSTOMER') {
|
| 40 |
$fieldset->addField(
|
| 41 |
'tj_salestax_code', 'select', array(
|
|
@@ -47,7 +47,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Class_Edit_Form extends Mage_Adminhtml
|
|
| 47 |
'' => 'No'
|
| 48 |
)
|
| 49 |
)
|
| 50 |
-
);
|
| 51 |
}
|
| 52 |
|
| 53 |
return $this;
|
| 24 |
$connected = Mage::getStoreConfig('tax/taxjar/connected');
|
| 25 |
$fieldset = $this->getForm()->getElement('base_fieldset');
|
| 26 |
$currentClass = Mage::registry('tax_class');
|
| 27 |
+
|
| 28 |
if ($connected && $this->getClassType() == 'PRODUCT') {
|
| 29 |
$fieldset->addField(
|
| 30 |
'tj_salestax_code', 'select', array(
|
| 33 |
'value' => $currentClass->getTjSalestaxCode(),
|
| 34 |
'values' => Mage::getModel('taxjar/categories')->toOptionArray()
|
| 35 |
)
|
| 36 |
+
);
|
| 37 |
}
|
| 38 |
+
|
| 39 |
if ($connected && $this->getClassType() == 'CUSTOMER') {
|
| 40 |
$fieldset->addField(
|
| 41 |
'tj_salestax_code', 'select', array(
|
| 47 |
'' => 'No'
|
| 48 |
)
|
| 49 |
)
|
| 50 |
+
);
|
| 51 |
}
|
| 52 |
|
| 53 |
return $this;
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Class/Grid.php
CHANGED
|
@@ -19,7 +19,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Class_Grid extends Mage_Adminhtml_Bloc
|
|
| 19 |
{
|
| 20 |
protected function _prepareColumns()
|
| 21 |
{
|
| 22 |
-
parent::_prepareColumns();
|
| 23 |
|
| 24 |
$connected = Mage::getStoreConfig('tax/taxjar/connected');
|
| 25 |
|
|
@@ -34,7 +34,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Class_Grid extends Mage_Adminhtml_Bloc
|
|
| 34 |
)
|
| 35 |
);
|
| 36 |
}
|
| 37 |
-
|
| 38 |
if ($connected && $this->getClassType() == 'CUSTOMER') {
|
| 39 |
$this->addColumn(
|
| 40 |
'tj_salestax_code', array(
|
| 19 |
{
|
| 20 |
protected function _prepareColumns()
|
| 21 |
{
|
| 22 |
+
parent::_prepareColumns();
|
| 23 |
|
| 24 |
$connected = Mage::getStoreConfig('tax/taxjar/connected');
|
| 25 |
|
| 34 |
)
|
| 35 |
);
|
| 36 |
}
|
| 37 |
+
|
| 38 |
if ($connected && $this->getClassType() == 'CUSTOMER') {
|
| 39 |
$this->addColumn(
|
| 40 |
'tj_salestax_code', array(
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus.php
CHANGED
|
@@ -23,9 +23,9 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus extends Mage_Adminhtml_Block_Wid
|
|
| 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')}')",
|
| 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')}')",
|
app/code/community/Taxjar/SalesTax/Block/Adminhtml/Tax/Nexus/Edit/Form.php
CHANGED
|
@@ -33,10 +33,10 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml
|
|
| 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 |
}
|
|
@@ -44,7 +44,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml
|
|
| 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 |
|
|
@@ -53,7 +53,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml
|
|
| 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',
|
|
@@ -64,7 +64,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml
|
|
| 64 |
'name' => 'api_id',
|
| 65 |
'value' => $model->getApiId()
|
| 66 |
));
|
| 67 |
-
|
| 68 |
$fieldset->addField('region', 'hidden', array(
|
| 69 |
'name' => 'region',
|
| 70 |
'value' => $model->getRegion()
|
|
@@ -80,7 +80,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml
|
|
| 80 |
'required' => true
|
| 81 |
)
|
| 82 |
);
|
| 83 |
-
|
| 84 |
$fieldset->addField('city', 'text',
|
| 85 |
array(
|
| 86 |
'name' => 'city',
|
|
@@ -90,7 +90,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml
|
|
| 90 |
'required' => true
|
| 91 |
)
|
| 92 |
);
|
| 93 |
-
|
| 94 |
$fieldset->addField('country_id', 'select',
|
| 95 |
array(
|
| 96 |
'name' => 'country_id',
|
|
@@ -109,7 +109,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml
|
|
| 109 |
'values' => $regions
|
| 110 |
)
|
| 111 |
);
|
| 112 |
-
|
| 113 |
$fieldset->addField('postcode', 'text',
|
| 114 |
array(
|
| 115 |
'name' => 'postcode',
|
|
@@ -123,7 +123,7 @@ class Taxjar_SalesTax_Block_Adminhtml_Tax_Nexus_Edit_Form extends Mage_Adminhtml
|
|
| 123 |
$form->setAction($this->getUrl('*/tax_nexus/save'));
|
| 124 |
$form->setUseContainer(true);
|
| 125 |
$form->setMethod('post');
|
| 126 |
-
|
| 127 |
$nexusData = $model->getData();
|
| 128 |
$form->setValues($nexusData);
|
| 129 |
$this->setForm($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 |
}
|
| 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 |
|
| 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',
|
| 64 |
'name' => 'api_id',
|
| 65 |
'value' => $model->getApiId()
|
| 66 |
));
|
| 67 |
+
|
| 68 |
$fieldset->addField('region', 'hidden', array(
|
| 69 |
'name' => 'region',
|
| 70 |
'value' => $model->getRegion()
|
| 80 |
'required' => true
|
| 81 |
)
|
| 82 |
);
|
| 83 |
+
|
| 84 |
$fieldset->addField('city', 'text',
|
| 85 |
array(
|
| 86 |
'name' => 'city',
|
| 90 |
'required' => true
|
| 91 |
)
|
| 92 |
);
|
| 93 |
+
|
| 94 |
$fieldset->addField('country_id', 'select',
|
| 95 |
array(
|
| 96 |
'name' => 'country_id',
|
| 109 |
'values' => $regions
|
| 110 |
)
|
| 111 |
);
|
| 112 |
+
|
| 113 |
$fieldset->addField('postcode', 'text',
|
| 114 |
array(
|
| 115 |
'name' => 'postcode',
|
| 123 |
$form->setAction($this->getUrl('*/tax_nexus/save'));
|
| 124 |
$form->setUseContainer(true);
|
| 125 |
$form->setMethod('post');
|
| 126 |
+
|
| 127 |
$nexusData = $model->getData();
|
| 128 |
$form->setValues($nexusData);
|
| 129 |
$this->setForm($form);
|
app/code/community/Taxjar/SalesTax/Helper/Data.php
CHANGED
|
@@ -36,7 +36,7 @@ class Taxjar_SalesTax_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 36 |
if (function_exists('array_column')) {
|
| 37 |
return array_column($input, $columnKey, $indexKey);
|
| 38 |
}
|
| 39 |
-
|
| 40 |
// Using func_get_args() in order to check for proper number of
|
| 41 |
// parameters and trigger errors exactly as the built-in array_column()
|
| 42 |
// does in PHP 5.5.
|
|
@@ -106,7 +106,7 @@ class Taxjar_SalesTax_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 106 |
}
|
| 107 |
return $resultArray;
|
| 108 |
}
|
| 109 |
-
|
| 110 |
/**
|
| 111 |
* Sort a multidimensional array by key
|
| 112 |
*
|
| 36 |
if (function_exists('array_column')) {
|
| 37 |
return array_column($input, $columnKey, $indexKey);
|
| 38 |
}
|
| 39 |
+
|
| 40 |
// Using func_get_args() in order to check for proper number of
|
| 41 |
// parameters and trigger errors exactly as the built-in array_column()
|
| 42 |
// does in PHP 5.5.
|
| 106 |
}
|
| 107 |
return $resultArray;
|
| 108 |
}
|
| 109 |
+
|
| 110 |
/**
|
| 111 |
* Sort a multidimensional array by key
|
| 112 |
*
|
app/code/community/Taxjar/SalesTax/Model/Calculation.php
CHANGED
|
@@ -18,7 +18,7 @@
|
|
| 18 |
/**
|
| 19 |
* Calculation Model
|
| 20 |
* TaxJar Zip+4 Rate Calculation Support for US
|
| 21 |
-
|
| 22 |
class Taxjar_SalesTax_Model_Calculation extends Mage_Tax_Model_Resource_Calculation
|
| 23 |
{
|
| 24 |
/**
|
| 18 |
/**
|
| 19 |
* Calculation Model
|
| 20 |
* TaxJar Zip+4 Rate Calculation Support for US
|
| 21 |
+
*/
|
| 22 |
class Taxjar_SalesTax_Model_Calculation extends Mage_Tax_Model_Resource_Calculation
|
| 23 |
{
|
| 24 |
/**
|
app/code/community/Taxjar/SalesTax/Model/Categories.php
CHANGED
|
@@ -15,10 +15,10 @@
|
|
| 15 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
*/
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
class Taxjar_SalesTax_Model_Categories
|
| 23 |
{
|
| 24 |
/**
|
| 15 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
*/
|
| 17 |
|
| 18 |
+
/**
|
| 19 |
+
* TaxJar Categories Model
|
| 20 |
+
* Populates tax category dropdown under
|
| 21 |
+
*/
|
| 22 |
class Taxjar_SalesTax_Model_Categories
|
| 23 |
{
|
| 24 |
/**
|
app/code/community/Taxjar/SalesTax/Model/Client.php
CHANGED
|
@@ -31,7 +31,7 @@ class Taxjar_SalesTax_Model_Client
|
|
| 31 |
$this->_storeZip = trim(Mage::getStoreConfig('shipping/origin/postcode'));
|
| 32 |
$this->_storeRegionCode = Mage::getModel('directory/region')->load(Mage::getStoreConfig('shipping/origin/region_id'))->getCode();
|
| 33 |
}
|
| 34 |
-
|
| 35 |
/**
|
| 36 |
* Perform a GET request
|
| 37 |
*
|
|
@@ -61,7 +61,7 @@ class Taxjar_SalesTax_Model_Client
|
|
| 61 |
$client->setRawData(json_encode($data), 'application/json');
|
| 62 |
return $this->_getRequest($client, $errors);
|
| 63 |
}
|
| 64 |
-
|
| 65 |
/**
|
| 66 |
* Perform a PUT request
|
| 67 |
*
|
|
@@ -78,7 +78,7 @@ class Taxjar_SalesTax_Model_Client
|
|
| 78 |
$client->setRawData(json_encode($data), 'application/json');
|
| 79 |
return $this->_getRequest($client, $errors);
|
| 80 |
}
|
| 81 |
-
|
| 82 |
/**
|
| 83 |
* Perform a DELETE request
|
| 84 |
*
|
|
@@ -109,7 +109,7 @@ class Taxjar_SalesTax_Model_Client
|
|
| 109 |
|
| 110 |
return $client;
|
| 111 |
}
|
| 112 |
-
|
| 113 |
/**
|
| 114 |
* Get HTTP request
|
| 115 |
*
|
|
@@ -121,7 +121,7 @@ class Taxjar_SalesTax_Model_Client
|
|
| 121 |
{
|
| 122 |
try {
|
| 123 |
$response = $client->request();
|
| 124 |
-
|
| 125 |
if ($response->isSuccessful()) {
|
| 126 |
$json = $response->getBody();
|
| 127 |
return json_decode($json, true);
|
|
@@ -132,7 +132,7 @@ class Taxjar_SalesTax_Model_Client
|
|
| 132 |
Mage::throwException(Mage::helper('taxjar')->__('Could not connect to TaxJar.'));
|
| 133 |
}
|
| 134 |
}
|
| 135 |
-
|
| 136 |
/**
|
| 137 |
* Get SmartCalcs API URL
|
| 138 |
*
|
|
@@ -157,10 +157,10 @@ class Taxjar_SalesTax_Model_Client
|
|
| 157 |
$apiUrl .= '/nexus/addresses';
|
| 158 |
break;
|
| 159 |
}
|
| 160 |
-
|
| 161 |
return $apiUrl;
|
| 162 |
}
|
| 163 |
-
|
| 164 |
/**
|
| 165 |
* Handle API errors and throw exception
|
| 166 |
*
|
|
@@ -171,14 +171,14 @@ class Taxjar_SalesTax_Model_Client
|
|
| 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 |
*
|
| 31 |
$this->_storeZip = trim(Mage::getStoreConfig('shipping/origin/postcode'));
|
| 32 |
$this->_storeRegionCode = Mage::getModel('directory/region')->load(Mage::getStoreConfig('shipping/origin/region_id'))->getCode();
|
| 33 |
}
|
| 34 |
+
|
| 35 |
/**
|
| 36 |
* Perform a GET request
|
| 37 |
*
|
| 61 |
$client->setRawData(json_encode($data), 'application/json');
|
| 62 |
return $this->_getRequest($client, $errors);
|
| 63 |
}
|
| 64 |
+
|
| 65 |
/**
|
| 66 |
* Perform a PUT request
|
| 67 |
*
|
| 78 |
$client->setRawData(json_encode($data), 'application/json');
|
| 79 |
return $this->_getRequest($client, $errors);
|
| 80 |
}
|
| 81 |
+
|
| 82 |
/**
|
| 83 |
* Perform a DELETE request
|
| 84 |
*
|
| 109 |
|
| 110 |
return $client;
|
| 111 |
}
|
| 112 |
+
|
| 113 |
/**
|
| 114 |
* Get HTTP request
|
| 115 |
*
|
| 121 |
{
|
| 122 |
try {
|
| 123 |
$response = $client->request();
|
| 124 |
+
|
| 125 |
if ($response->isSuccessful()) {
|
| 126 |
$json = $response->getBody();
|
| 127 |
return json_decode($json, true);
|
| 132 |
Mage::throwException(Mage::helper('taxjar')->__('Could not connect to TaxJar.'));
|
| 133 |
}
|
| 134 |
}
|
| 135 |
+
|
| 136 |
/**
|
| 137 |
* Get SmartCalcs API URL
|
| 138 |
*
|
| 157 |
$apiUrl .= '/nexus/addresses';
|
| 158 |
break;
|
| 159 |
}
|
| 160 |
+
|
| 161 |
return $apiUrl;
|
| 162 |
}
|
| 163 |
+
|
| 164 |
/**
|
| 165 |
* Handle API errors and throw exception
|
| 166 |
*
|
| 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 |
*
|
app/code/community/Taxjar/SalesTax/Model/Comment.php
CHANGED
|
@@ -23,7 +23,7 @@ class Taxjar_SalesTax_Model_Comment
|
|
| 23 |
{
|
| 24 |
private $_apiKey;
|
| 25 |
private $_apiEmail;
|
| 26 |
-
|
| 27 |
/**
|
| 28 |
* Display Nexus states loaded and API Key setting
|
| 29 |
*
|
|
@@ -41,7 +41,7 @@ class Taxjar_SalesTax_Model_Comment
|
|
| 41 |
return $this->_buildDisconnectedHtml();
|
| 42 |
}
|
| 43 |
}
|
| 44 |
-
|
| 45 |
/**
|
| 46 |
* Build connected HTML
|
| 47 |
*
|
|
@@ -70,7 +70,7 @@ EOT;
|
|
| 70 |
|
| 71 |
return $htmlString;
|
| 72 |
}
|
| 73 |
-
|
| 74 |
/**
|
| 75 |
* Build disconnected HTML
|
| 76 |
*
|
|
@@ -83,7 +83,7 @@ EOT;
|
|
| 83 |
$htmlString .= $this->_buildConnectionHtml();
|
| 84 |
return $htmlString;
|
| 85 |
}
|
| 86 |
-
|
| 87 |
/**
|
| 88 |
* Build HTML for connect/disconnect buttons
|
| 89 |
*
|
|
@@ -98,13 +98,13 @@ EOT;
|
|
| 98 |
$connectUrl = Mage::helper('adminhtml')->getUrl('adminhtml/taxjar/connect');
|
| 99 |
$connectUrl .= (parse_url($connectUrl, PHP_URL_QUERY) ? '&' : '?');
|
| 100 |
$pluginVersion = Mage::getConfig()->getModuleConfig('Taxjar_SalesTax')->version;
|
| 101 |
-
|
| 102 |
if ($this->_getStoreGeneralEmail()) {
|
| 103 |
$popupUrl .= '&email=' . urlencode($this->_getStoreGeneralEmail());
|
| 104 |
}
|
| 105 |
-
|
| 106 |
$popupUrl .= '&plugin=magento&version=' . $pluginVersion;
|
| 107 |
-
|
| 108 |
$htmlString = <<<EOT
|
| 109 |
<br/><p><button type='button' class='scalable' onclick='openConnectPopup("{$popupUrl}", "Connect to TaxJar", 400, 500)'><span>Connect to TaxJar</span></button> <button type='button' class='scalable' onclick='window.open("{$guideUrl}", "_blank")'><span>Learn More</span></button></p>
|
| 110 |
<script>
|
|
@@ -115,16 +115,16 @@ EOT;
|
|
| 115 |
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
|
| 116 |
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
|
| 117 |
var top = ((height / 2) - (h / 2)) + dualScreenTop;
|
| 118 |
-
|
| 119 |
window.connectPopup = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
|
| 120 |
|
| 121 |
if (window.focus) window.connectPopup.focus();
|
| 122 |
}
|
| 123 |
-
|
| 124 |
window.addEventListener('message', function(e) {
|
| 125 |
if (e.origin !== '{$authUrl}')
|
| 126 |
return;
|
| 127 |
-
|
| 128 |
try {
|
| 129 |
var data = JSON.parse(e.data);
|
| 130 |
if (data.api_token && data.email) {
|
|
@@ -132,7 +132,7 @@ EOT;
|
|
| 132 |
window.location = encodeURI('{$connectUrl}api_key=' + data.api_token + '&api_email=' + data.email);
|
| 133 |
} else {
|
| 134 |
throw 'Invalid data';
|
| 135 |
-
}
|
| 136 |
} catch(e) {
|
| 137 |
alert('Invalid API token or email provided. Please try connecting to TaxJar again or contact support@taxjar.com.');
|
| 138 |
}
|
|
@@ -142,7 +142,7 @@ EOT;
|
|
| 142 |
|
| 143 |
return $htmlString;
|
| 144 |
}
|
| 145 |
-
|
| 146 |
/**
|
| 147 |
* Get current store origin
|
| 148 |
*
|
|
@@ -154,7 +154,7 @@ EOT;
|
|
| 154 |
$protocol = Mage::app()->getRequest()->isSecure() ? 'https://' : 'http://';
|
| 155 |
return $protocol . $_SERVER['HTTP_HOST'];
|
| 156 |
}
|
| 157 |
-
|
| 158 |
/**
|
| 159 |
* Get store general contact email if non-default
|
| 160 |
*
|
| 23 |
{
|
| 24 |
private $_apiKey;
|
| 25 |
private $_apiEmail;
|
| 26 |
+
|
| 27 |
/**
|
| 28 |
* Display Nexus states loaded and API Key setting
|
| 29 |
*
|
| 41 |
return $this->_buildDisconnectedHtml();
|
| 42 |
}
|
| 43 |
}
|
| 44 |
+
|
| 45 |
/**
|
| 46 |
* Build connected HTML
|
| 47 |
*
|
| 70 |
|
| 71 |
return $htmlString;
|
| 72 |
}
|
| 73 |
+
|
| 74 |
/**
|
| 75 |
* Build disconnected HTML
|
| 76 |
*
|
| 83 |
$htmlString .= $this->_buildConnectionHtml();
|
| 84 |
return $htmlString;
|
| 85 |
}
|
| 86 |
+
|
| 87 |
/**
|
| 88 |
* Build HTML for connect/disconnect buttons
|
| 89 |
*
|
| 98 |
$connectUrl = Mage::helper('adminhtml')->getUrl('adminhtml/taxjar/connect');
|
| 99 |
$connectUrl .= (parse_url($connectUrl, PHP_URL_QUERY) ? '&' : '?');
|
| 100 |
$pluginVersion = Mage::getConfig()->getModuleConfig('Taxjar_SalesTax')->version;
|
| 101 |
+
|
| 102 |
if ($this->_getStoreGeneralEmail()) {
|
| 103 |
$popupUrl .= '&email=' . urlencode($this->_getStoreGeneralEmail());
|
| 104 |
}
|
| 105 |
+
|
| 106 |
$popupUrl .= '&plugin=magento&version=' . $pluginVersion;
|
| 107 |
+
|
| 108 |
$htmlString = <<<EOT
|
| 109 |
<br/><p><button type='button' class='scalable' onclick='openConnectPopup("{$popupUrl}", "Connect to TaxJar", 400, 500)'><span>Connect to TaxJar</span></button> <button type='button' class='scalable' onclick='window.open("{$guideUrl}", "_blank")'><span>Learn More</span></button></p>
|
| 110 |
<script>
|
| 115 |
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
|
| 116 |
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
|
| 117 |
var top = ((height / 2) - (h / 2)) + dualScreenTop;
|
| 118 |
+
|
| 119 |
window.connectPopup = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
|
| 120 |
|
| 121 |
if (window.focus) window.connectPopup.focus();
|
| 122 |
}
|
| 123 |
+
|
| 124 |
window.addEventListener('message', function(e) {
|
| 125 |
if (e.origin !== '{$authUrl}')
|
| 126 |
return;
|
| 127 |
+
|
| 128 |
try {
|
| 129 |
var data = JSON.parse(e.data);
|
| 130 |
if (data.api_token && data.email) {
|
| 132 |
window.location = encodeURI('{$connectUrl}api_key=' + data.api_token + '&api_email=' + data.email);
|
| 133 |
} else {
|
| 134 |
throw 'Invalid data';
|
| 135 |
+
}
|
| 136 |
} catch(e) {
|
| 137 |
alert('Invalid API token or email provided. Please try connecting to TaxJar again or contact support@taxjar.com.');
|
| 138 |
}
|
| 142 |
|
| 143 |
return $htmlString;
|
| 144 |
}
|
| 145 |
+
|
| 146 |
/**
|
| 147 |
* Get current store origin
|
| 148 |
*
|
| 154 |
$protocol = Mage::app()->getRequest()->isSecure() ? 'https://' : 'http://';
|
| 155 |
return $protocol . $_SERVER['HTTP_HOST'];
|
| 156 |
}
|
| 157 |
+
|
| 158 |
/**
|
| 159 |
* Get store general contact email if non-default
|
| 160 |
*
|
app/code/community/Taxjar/SalesTax/Model/Configuration.php
CHANGED
|
@@ -64,8 +64,8 @@ class Taxjar_SalesTax_Model_Configuration
|
|
| 64 |
public function setDisplaySettings()
|
| 65 |
{
|
| 66 |
$settings = array(
|
| 67 |
-
'tax/display/type',
|
| 68 |
-
'tax/display/shipping',
|
| 69 |
'tax/cart_display/price',
|
| 70 |
'tax/cart_display/subtotal',
|
| 71 |
'tax/cart_display/shipping'
|
|
@@ -164,7 +164,7 @@ class Taxjar_SalesTax_Model_Configuration
|
|
| 164 |
$apiUser->setIsActive(1);
|
| 165 |
$apiUser->save();
|
| 166 |
|
| 167 |
-
return $apiUser->getUserId();
|
| 168 |
}
|
| 169 |
|
| 170 |
/**
|
| 64 |
public function setDisplaySettings()
|
| 65 |
{
|
| 66 |
$settings = array(
|
| 67 |
+
'tax/display/type',
|
| 68 |
+
'tax/display/shipping',
|
| 69 |
'tax/cart_display/price',
|
| 70 |
'tax/cart_display/subtotal',
|
| 71 |
'tax/cart_display/shipping'
|
| 164 |
$apiUser->setIsActive(1);
|
| 165 |
$apiUser->save();
|
| 166 |
|
| 167 |
+
return $apiUser->getUserId();
|
| 168 |
}
|
| 169 |
|
| 170 |
/**
|
app/code/community/Taxjar/SalesTax/Model/Debug.php
CHANGED
|
@@ -53,7 +53,7 @@ class Taxjar_SalesTax_Model_Debug
|
|
| 53 |
$phpVersion = @phpversion();
|
| 54 |
$magentoVersion = Mage::getVersion();
|
| 55 |
$lastUpdated = Mage::getStoreConfig('tax/taxjar/last_update');
|
| 56 |
-
|
| 57 |
if (!empty($states)) {
|
| 58 |
$states = implode(',', $states);
|
| 59 |
}
|
| 53 |
$phpVersion = @phpversion();
|
| 54 |
$magentoVersion = Mage::getVersion();
|
| 55 |
$lastUpdated = Mage::getStoreConfig('tax/taxjar/last_update');
|
| 56 |
+
|
| 57 |
if (!empty($states)) {
|
| 58 |
$states = implode(',', $states);
|
| 59 |
}
|
app/code/community/Taxjar/SalesTax/Model/Import/Comment.php
CHANGED
|
@@ -22,7 +22,7 @@
|
|
| 22 |
class Taxjar_SalesTax_Model_Import_Comment
|
| 23 |
{
|
| 24 |
protected $_regionCode;
|
| 25 |
-
|
| 26 |
/**
|
| 27 |
* Display Nexus states loaded and API Key setting
|
| 28 |
*
|
|
@@ -31,7 +31,7 @@ class Taxjar_SalesTax_Model_Import_Comment
|
|
| 31 |
*/
|
| 32 |
public function getCommentText()
|
| 33 |
{
|
| 34 |
-
$isEnabled = Mage::getStoreConfig('tax/taxjar/backup');
|
| 35 |
$regionId = Mage::getStoreConfig('shipping/origin/region_id');
|
| 36 |
$this->_regionCode = Mage::getModel('directory/region')->load($regionId)->getCode();
|
| 37 |
|
|
@@ -61,7 +61,7 @@ class Taxjar_SalesTax_Model_Import_Comment
|
|
| 61 |
}
|
| 62 |
|
| 63 |
$rateCalcs = array(
|
| 64 |
-
'total_rates' => array_sum($ratesByState),
|
| 65 |
'rates_loaded' => Mage::getModel('taxjar/import_rate')->getExistingRates()->getSize(),
|
| 66 |
'rates_by_state' => $ratesByState
|
| 67 |
);
|
|
@@ -90,11 +90,11 @@ class Taxjar_SalesTax_Model_Import_Comment
|
|
| 90 |
{
|
| 91 |
$states = unserialize(Mage::getStoreConfig('tax/taxjar/states'));
|
| 92 |
$htmlString = "<p class='note'><span>Download zip-based rates from TaxJar as a fallback. TaxJar uses your shipping origin and nexus addresses to sync rates rach month.</span></p><br/>";
|
| 93 |
-
|
| 94 |
if (!empty($states)) {
|
| 95 |
$htmlString .= "<ul class='messages'>" . $this->buildStatesHtml($states) . "</ul>";
|
| 96 |
}
|
| 97 |
-
|
| 98 |
$htmlString .= $this->buildSyncHtml();
|
| 99 |
|
| 100 |
return $htmlString;
|
|
@@ -142,7 +142,7 @@ class Taxjar_SalesTax_Model_Import_Comment
|
|
| 142 |
$totalForState = $taxRatesByState['rates_by_state'][$state] . ' rates';
|
| 143 |
}
|
| 144 |
|
| 145 |
-
$statesHtml .= '<li class="' . $class . '-msg"><ul><li style="line-height: 1.9em"><span style="font-size: 1.4em">' . $stateName . '</span>: ' . $totalForState . '</li></ul></li>';
|
| 146 |
}
|
| 147 |
}
|
| 148 |
|
|
@@ -155,7 +155,7 @@ class Taxjar_SalesTax_Model_Import_Comment
|
|
| 155 |
$statesHtml .= '<p class="' . $matches . '-msg" style="background: none !important;"><small> ' . $taxRatesByState['total_rates'] . ' of ' . $taxRatesByState['rates_loaded'] . ' expected rates loaded.</small></p>';
|
| 156 |
$statesHtml .= '<p class="' . $matches . '-msg" style="background: none !important;"><small> ' . 'Last synced on ' . $lastUpdate . '</small></p><br/>';
|
| 157 |
|
| 158 |
-
return $statesHtml;
|
| 159 |
}
|
| 160 |
|
| 161 |
/**
|
|
@@ -176,7 +176,7 @@ class Taxjar_SalesTax_Model_Import_Comment
|
|
| 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 |
}
|
| 22 |
class Taxjar_SalesTax_Model_Import_Comment
|
| 23 |
{
|
| 24 |
protected $_regionCode;
|
| 25 |
+
|
| 26 |
/**
|
| 27 |
* Display Nexus states loaded and API Key setting
|
| 28 |
*
|
| 31 |
*/
|
| 32 |
public function getCommentText()
|
| 33 |
{
|
| 34 |
+
$isEnabled = Mage::getStoreConfig('tax/taxjar/backup');
|
| 35 |
$regionId = Mage::getStoreConfig('shipping/origin/region_id');
|
| 36 |
$this->_regionCode = Mage::getModel('directory/region')->load($regionId)->getCode();
|
| 37 |
|
| 61 |
}
|
| 62 |
|
| 63 |
$rateCalcs = array(
|
| 64 |
+
'total_rates' => array_sum($ratesByState),
|
| 65 |
'rates_loaded' => Mage::getModel('taxjar/import_rate')->getExistingRates()->getSize(),
|
| 66 |
'rates_by_state' => $ratesByState
|
| 67 |
);
|
| 90 |
{
|
| 91 |
$states = unserialize(Mage::getStoreConfig('tax/taxjar/states'));
|
| 92 |
$htmlString = "<p class='note'><span>Download zip-based rates from TaxJar as a fallback. TaxJar uses your shipping origin and nexus addresses to sync rates rach month.</span></p><br/>";
|
| 93 |
+
|
| 94 |
if (!empty($states)) {
|
| 95 |
$htmlString .= "<ul class='messages'>" . $this->buildStatesHtml($states) . "</ul>";
|
| 96 |
}
|
| 97 |
+
|
| 98 |
$htmlString .= $this->buildSyncHtml();
|
| 99 |
|
| 100 |
return $htmlString;
|
| 142 |
$totalForState = $taxRatesByState['rates_by_state'][$state] . ' rates';
|
| 143 |
}
|
| 144 |
|
| 145 |
+
$statesHtml .= '<li class="' . $class . '-msg"><ul><li style="line-height: 1.9em"><span style="font-size: 1.4em">' . $stateName . '</span>: ' . $totalForState . '</li></ul></li>';
|
| 146 |
}
|
| 147 |
}
|
| 148 |
|
| 155 |
$statesHtml .= '<p class="' . $matches . '-msg" style="background: none !important;"><small> ' . $taxRatesByState['total_rates'] . ' of ' . $taxRatesByState['rates_loaded'] . ' expected rates loaded.</small></p>';
|
| 156 |
$statesHtml .= '<p class="' . $matches . '-msg" style="background: none !important;"><small> ' . 'Last synced on ' . $lastUpdate . '</small></p><br/>';
|
| 157 |
|
| 158 |
+
return $statesHtml;
|
| 159 |
}
|
| 160 |
|
| 161 |
/**
|
| 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/Import/Rate.php
CHANGED
|
@@ -77,7 +77,7 @@ class Taxjar_SalesTax_Model_Import_Rate
|
|
| 77 |
return;
|
| 78 |
}
|
| 79 |
}
|
| 80 |
-
|
| 81 |
/**
|
| 82 |
* Get existing TaxJar rates based on configuration states
|
| 83 |
*
|
|
@@ -90,7 +90,7 @@ class Taxjar_SalesTax_Model_Import_Rate
|
|
| 90 |
->getCollection()
|
| 91 |
->addFieldToFilter('tax_region_id', $this->getRegionFilter());
|
| 92 |
}
|
| 93 |
-
|
| 94 |
/**
|
| 95 |
* Get existing TaxJar rule calculations based on the rate ID
|
| 96 |
*
|
| 77 |
return;
|
| 78 |
}
|
| 79 |
}
|
| 80 |
+
|
| 81 |
/**
|
| 82 |
* Get existing TaxJar rates based on configuration states
|
| 83 |
*
|
| 90 |
->getCollection()
|
| 91 |
->addFieldToFilter('tax_region_id', $this->getRegionFilter());
|
| 92 |
}
|
| 93 |
+
|
| 94 |
/**
|
| 95 |
* Get existing TaxJar rule calculations based on the rate ID
|
| 96 |
*
|
app/code/community/Taxjar/SalesTax/Model/Observer/AdminMenuItems.php
CHANGED
|
@@ -20,13 +20,13 @@ class TaxJar_SalesTax_Model_Observer_AdminMenuItems
|
|
| 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 |
}
|
| 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
|
@@ -22,27 +22,27 @@ class Taxjar_SalesTax_Model_Observer_ConfigChanged
|
|
| 22 |
$this->_updateSmartcalcs();
|
| 23 |
$this->_updateBackupRates();
|
| 24 |
}
|
| 25 |
-
|
| 26 |
private function _updateSmartcalcs()
|
| 27 |
{
|
| 28 |
-
$enabled = Mage::getStoreConfig('tax/taxjar/enabled');
|
| 29 |
$prevEnabled = Mage::app()->getCache()->load('taxjar_salestax_config_enabled');
|
| 30 |
|
| 31 |
if (isset($prevEnabled)) {
|
| 32 |
-
if($prevEnabled != $enabled && $enabled == 1) {
|
| 33 |
Mage::dispatchEvent('taxjar_salestax_import_categories');
|
| 34 |
Mage::dispatchEvent('taxjar_salestax_import_data');
|
| 35 |
}
|
| 36 |
}
|
| 37 |
}
|
| 38 |
-
|
| 39 |
private function _updateBackupRates()
|
| 40 |
{
|
| 41 |
-
$enabled = Mage::getStoreConfig('tax/taxjar/backup');
|
| 42 |
$prevEnabled = Mage::app()->getCache()->load('taxjar_salestax_config_backup');
|
| 43 |
|
| 44 |
if (isset($prevEnabled)) {
|
| 45 |
-
if($prevEnabled != $enabled) {
|
| 46 |
Mage::dispatchEvent('taxjar_salestax_import_categories');
|
| 47 |
Mage::dispatchEvent('taxjar_salestax_import_data');
|
| 48 |
Mage::dispatchEvent('taxjar_salestax_import_rates');
|
| 22 |
$this->_updateSmartcalcs();
|
| 23 |
$this->_updateBackupRates();
|
| 24 |
}
|
| 25 |
+
|
| 26 |
private function _updateSmartcalcs()
|
| 27 |
{
|
| 28 |
+
$enabled = Mage::getStoreConfig('tax/taxjar/enabled');
|
| 29 |
$prevEnabled = Mage::app()->getCache()->load('taxjar_salestax_config_enabled');
|
| 30 |
|
| 31 |
if (isset($prevEnabled)) {
|
| 32 |
+
if ($prevEnabled != $enabled && $enabled == 1) {
|
| 33 |
Mage::dispatchEvent('taxjar_salestax_import_categories');
|
| 34 |
Mage::dispatchEvent('taxjar_salestax_import_data');
|
| 35 |
}
|
| 36 |
}
|
| 37 |
}
|
| 38 |
+
|
| 39 |
private function _updateBackupRates()
|
| 40 |
{
|
| 41 |
+
$enabled = Mage::getStoreConfig('tax/taxjar/backup');
|
| 42 |
$prevEnabled = Mage::app()->getCache()->load('taxjar_salestax_config_backup');
|
| 43 |
|
| 44 |
if (isset($prevEnabled)) {
|
| 45 |
+
if ($prevEnabled != $enabled) {
|
| 46 |
Mage::dispatchEvent('taxjar_salestax_import_categories');
|
| 47 |
Mage::dispatchEvent('taxjar_salestax_import_data');
|
| 48 |
Mage::dispatchEvent('taxjar_salestax_import_rates');
|
app/code/community/Taxjar/SalesTax/Model/Observer/ConfigReview.php
CHANGED
|
@@ -20,24 +20,24 @@ class TaxJar_SalesTax_Model_Observer_ConfigReview
|
|
| 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 |
}
|
| 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/ImportCategories.php
CHANGED
|
@@ -19,17 +19,17 @@ class Taxjar_SalesTax_Model_Observer_ImportCategories
|
|
| 19 |
{
|
| 20 |
protected $_apiKey;
|
| 21 |
protected $_client;
|
| 22 |
-
|
| 23 |
public function execute(Varien_Event_Observer $observer)
|
| 24 |
{
|
| 25 |
$this->_apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 26 |
-
|
| 27 |
if ($this->_apiKey) {
|
| 28 |
$this->_client = Mage::getModel('taxjar/client');
|
| 29 |
$this->_importCategories();
|
| 30 |
}
|
| 31 |
}
|
| 32 |
-
|
| 33 |
/**
|
| 34 |
* Get TaxJar product categories
|
| 35 |
*
|
|
@@ -41,7 +41,7 @@ class Taxjar_SalesTax_Model_Observer_ImportCategories
|
|
| 41 |
$categoryJson = $this->_client->getResource($this->_apiKey, 'categories');
|
| 42 |
return $categoryJson['categories'];
|
| 43 |
}
|
| 44 |
-
|
| 45 |
/**
|
| 46 |
* Import TaxJar product categories
|
| 47 |
*
|
| 19 |
{
|
| 20 |
protected $_apiKey;
|
| 21 |
protected $_client;
|
| 22 |
+
|
| 23 |
public function execute(Varien_Event_Observer $observer)
|
| 24 |
{
|
| 25 |
$this->_apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 26 |
+
|
| 27 |
if ($this->_apiKey) {
|
| 28 |
$this->_client = Mage::getModel('taxjar/client');
|
| 29 |
$this->_importCategories();
|
| 30 |
}
|
| 31 |
}
|
| 32 |
+
|
| 33 |
/**
|
| 34 |
* Get TaxJar product categories
|
| 35 |
*
|
| 41 |
$categoryJson = $this->_client->getResource($this->_apiKey, 'categories');
|
| 42 |
return $categoryJson['categories'];
|
| 43 |
}
|
| 44 |
+
|
| 45 |
/**
|
| 46 |
* Import TaxJar product categories
|
| 47 |
*
|
app/code/community/Taxjar/SalesTax/Model/Observer/ImportData.php
CHANGED
|
@@ -19,15 +19,15 @@ class Taxjar_SalesTax_Model_Observer_ImportData
|
|
| 19 |
{
|
| 20 |
protected $_apiKey;
|
| 21 |
protected $_client;
|
| 22 |
-
|
| 23 |
public function execute(Varien_Event_Observer $observer)
|
| 24 |
{
|
| 25 |
$this->_apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 26 |
$storeRegionCode = Mage::getModel('directory/region')->load(Mage::getStoreConfig('shipping/origin/region_id'))->getCode();
|
| 27 |
-
|
| 28 |
if ($this->_apiKey) {
|
| 29 |
$this->_client = Mage::getModel('taxjar/client');
|
| 30 |
-
|
| 31 |
if (isset($storeRegionCode)) {
|
| 32 |
$this->_setConfiguration();
|
| 33 |
} else {
|
|
@@ -35,7 +35,7 @@ class Taxjar_SalesTax_Model_Observer_ImportData
|
|
| 35 |
}
|
| 36 |
}
|
| 37 |
}
|
| 38 |
-
|
| 39 |
/**
|
| 40 |
* Get TaxJar user account configuration
|
| 41 |
*
|
|
@@ -47,7 +47,7 @@ class Taxjar_SalesTax_Model_Observer_ImportData
|
|
| 47 |
$configJson = $this->_client->getResource($this->_apiKey, 'config');
|
| 48 |
return $configJson['configuration'];
|
| 49 |
}
|
| 50 |
-
|
| 51 |
/**
|
| 52 |
* Set TaxJar config
|
| 53 |
*
|
| 19 |
{
|
| 20 |
protected $_apiKey;
|
| 21 |
protected $_client;
|
| 22 |
+
|
| 23 |
public function execute(Varien_Event_Observer $observer)
|
| 24 |
{
|
| 25 |
$this->_apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 26 |
$storeRegionCode = Mage::getModel('directory/region')->load(Mage::getStoreConfig('shipping/origin/region_id'))->getCode();
|
| 27 |
+
|
| 28 |
if ($this->_apiKey) {
|
| 29 |
$this->_client = Mage::getModel('taxjar/client');
|
| 30 |
+
|
| 31 |
if (isset($storeRegionCode)) {
|
| 32 |
$this->_setConfiguration();
|
| 33 |
} else {
|
| 35 |
}
|
| 36 |
}
|
| 37 |
}
|
| 38 |
+
|
| 39 |
/**
|
| 40 |
* Get TaxJar user account configuration
|
| 41 |
*
|
| 47 |
$configJson = $this->_client->getResource($this->_apiKey, 'config');
|
| 48 |
return $configJson['configuration'];
|
| 49 |
}
|
| 50 |
+
|
| 51 |
/**
|
| 52 |
* Set TaxJar config
|
| 53 |
*
|
app/code/community/Taxjar/SalesTax/Model/Observer/ImportRates.php
CHANGED
|
@@ -25,12 +25,12 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 25 |
protected $_productTaxClasses;
|
| 26 |
protected $_newRates = array();
|
| 27 |
protected $_newShippingRates = array();
|
| 28 |
-
|
| 29 |
public function execute(Varien_Event_Observer $observer)
|
| 30 |
{
|
| 31 |
$isEnabled = Mage::getStoreConfig('tax/taxjar/backup');
|
| 32 |
$this->_apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 33 |
-
|
| 34 |
if ($isEnabled && $this->_apiKey) {
|
| 35 |
$this->_client = Mage::getModel('taxjar/client');
|
| 36 |
$this->_storeZip = trim(Mage::getStoreConfig('shipping/origin/postcode'));
|
|
@@ -40,7 +40,7 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 40 |
$this->_importRates();
|
| 41 |
} else {
|
| 42 |
$states = unserialize(Mage::getStoreConfig('tax/taxjar/states'));
|
| 43 |
-
|
| 44 |
if (!empty($states)) {
|
| 45 |
$this->_purgeRates();
|
| 46 |
}
|
|
@@ -49,11 +49,11 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 49 |
Mage::getConfig()->saveConfig('taxjar/smartcalcs/backup', 0);
|
| 50 |
Mage::getSingleton('core/session')->addNotice('TaxJar has been uninstalled. All tax rates imported by TaxJar have been removed.');
|
| 51 |
}
|
| 52 |
-
|
| 53 |
// Clear the cache to avoid UI elements not loading
|
| 54 |
Mage::app()->getCacheInstance()->flush();
|
| 55 |
}
|
| 56 |
-
|
| 57 |
/**
|
| 58 |
* Import tax rates from TaxJar
|
| 59 |
*
|
|
@@ -74,7 +74,7 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 74 |
} else {
|
| 75 |
Mage::throwException('Please check that your zip code is a valid US zip code in Shipping Settings.');
|
| 76 |
}
|
| 77 |
-
|
| 78 |
if (!count($this->_productTaxClasses) || !count($this->_customerTaxClasses)) {
|
| 79 |
Mage::throwException('Please select at least one product tax class and one customer tax class to import backup rates from TaxJar.');
|
| 80 |
}
|
|
@@ -86,7 +86,7 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 86 |
// This process can take awhile
|
| 87 |
@set_time_limit(0);
|
| 88 |
@ignore_user_abort(true);
|
| 89 |
-
|
| 90 |
$filename = $this->_getTempRatesFileName();
|
| 91 |
$ratesJson = unserialize(file_get_contents($filename));
|
| 92 |
|
|
@@ -103,7 +103,7 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 103 |
Mage::throwException('Could not write to your Magento temp directory. Please check permissions for ' . Mage::getBaseDir('tmp') . '.');
|
| 104 |
}
|
| 105 |
}
|
| 106 |
-
|
| 107 |
/**
|
| 108 |
* Create new tax rates
|
| 109 |
*
|
|
@@ -126,7 +126,7 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 126 |
}
|
| 127 |
}
|
| 128 |
}
|
| 129 |
-
|
| 130 |
/**
|
| 131 |
* Create or update existing tax rules with new rates
|
| 132 |
*
|
|
@@ -139,18 +139,18 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 139 |
$productTaxClasses = $this->_productTaxClasses;
|
| 140 |
$shippingClass = Mage::getStoreConfig('tax/classes/shipping_tax_class');
|
| 141 |
$backupShipping = in_array($shippingClass, $productTaxClasses);
|
| 142 |
-
|
| 143 |
if ($backupShipping) {
|
| 144 |
$productTaxClasses = array_diff($productTaxClasses, array($shippingClass));
|
| 145 |
}
|
| 146 |
|
| 147 |
$rule->create('TaxJar Backup Rates', $this->_customerTaxClasses, $productTaxClasses, 1, $this->_newRates);
|
| 148 |
-
|
| 149 |
if ($backupShipping) {
|
| 150 |
-
$rule->create('TaxJar Backup Rates (Shipping)', $this->_customerTaxClasses, array($shippingClass), 2, $this->_newShippingRates);
|
| 151 |
}
|
| 152 |
}
|
| 153 |
-
|
| 154 |
/**
|
| 155 |
* Purge existing rule calculations and rates
|
| 156 |
*
|
|
@@ -163,7 +163,7 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 163 |
|
| 164 |
foreach ($rates as $rate) {
|
| 165 |
$calculations = Mage::getModel('taxjar/import_rate')->getCalculationsByRateId($rate->getId())->load();
|
| 166 |
-
|
| 167 |
try {
|
| 168 |
foreach ($calculations as $calculation) {
|
| 169 |
$calculation->delete();
|
|
@@ -179,7 +179,7 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 179 |
}
|
| 180 |
}
|
| 181 |
}
|
| 182 |
-
|
| 183 |
/**
|
| 184 |
* Get TaxJar backup rates
|
| 185 |
*
|
|
@@ -204,7 +204,7 @@ class Taxjar_SalesTax_Model_Observer_ImportRates
|
|
| 204 |
{
|
| 205 |
return Mage::getBaseDir('tmp') . DS . 'tj_tmp.dat';
|
| 206 |
}
|
| 207 |
-
|
| 208 |
/**
|
| 209 |
* Set the last updated date
|
| 210 |
*
|
| 25 |
protected $_productTaxClasses;
|
| 26 |
protected $_newRates = array();
|
| 27 |
protected $_newShippingRates = array();
|
| 28 |
+
|
| 29 |
public function execute(Varien_Event_Observer $observer)
|
| 30 |
{
|
| 31 |
$isEnabled = Mage::getStoreConfig('tax/taxjar/backup');
|
| 32 |
$this->_apiKey = trim(Mage::getStoreConfig('tax/taxjar/apikey'));
|
| 33 |
+
|
| 34 |
if ($isEnabled && $this->_apiKey) {
|
| 35 |
$this->_client = Mage::getModel('taxjar/client');
|
| 36 |
$this->_storeZip = trim(Mage::getStoreConfig('shipping/origin/postcode'));
|
| 40 |
$this->_importRates();
|
| 41 |
} else {
|
| 42 |
$states = unserialize(Mage::getStoreConfig('tax/taxjar/states'));
|
| 43 |
+
|
| 44 |
if (!empty($states)) {
|
| 45 |
$this->_purgeRates();
|
| 46 |
}
|
| 49 |
Mage::getConfig()->saveConfig('taxjar/smartcalcs/backup', 0);
|
| 50 |
Mage::getSingleton('core/session')->addNotice('TaxJar has been uninstalled. All tax rates imported by TaxJar have been removed.');
|
| 51 |
}
|
| 52 |
+
|
| 53 |
// Clear the cache to avoid UI elements not loading
|
| 54 |
Mage::app()->getCacheInstance()->flush();
|
| 55 |
}
|
| 56 |
+
|
| 57 |
/**
|
| 58 |
* Import tax rates from TaxJar
|
| 59 |
*
|
| 74 |
} else {
|
| 75 |
Mage::throwException('Please check that your zip code is a valid US zip code in Shipping Settings.');
|
| 76 |
}
|
| 77 |
+
|
| 78 |
if (!count($this->_productTaxClasses) || !count($this->_customerTaxClasses)) {
|
| 79 |
Mage::throwException('Please select at least one product tax class and one customer tax class to import backup rates from TaxJar.');
|
| 80 |
}
|
| 86 |
// This process can take awhile
|
| 87 |
@set_time_limit(0);
|
| 88 |
@ignore_user_abort(true);
|
| 89 |
+
|
| 90 |
$filename = $this->_getTempRatesFileName();
|
| 91 |
$ratesJson = unserialize(file_get_contents($filename));
|
| 92 |
|
| 103 |
Mage::throwException('Could not write to your Magento temp directory. Please check permissions for ' . Mage::getBaseDir('tmp') . '.');
|
| 104 |
}
|
| 105 |
}
|
| 106 |
+
|
| 107 |
/**
|
| 108 |
* Create new tax rates
|
| 109 |
*
|
| 126 |
}
|
| 127 |
}
|
| 128 |
}
|
| 129 |
+
|
| 130 |
/**
|
| 131 |
* Create or update existing tax rules with new rates
|
| 132 |
*
|
| 139 |
$productTaxClasses = $this->_productTaxClasses;
|
| 140 |
$shippingClass = Mage::getStoreConfig('tax/classes/shipping_tax_class');
|
| 141 |
$backupShipping = in_array($shippingClass, $productTaxClasses);
|
| 142 |
+
|
| 143 |
if ($backupShipping) {
|
| 144 |
$productTaxClasses = array_diff($productTaxClasses, array($shippingClass));
|
| 145 |
}
|
| 146 |
|
| 147 |
$rule->create('TaxJar Backup Rates', $this->_customerTaxClasses, $productTaxClasses, 1, $this->_newRates);
|
| 148 |
+
|
| 149 |
if ($backupShipping) {
|
| 150 |
+
$rule->create('TaxJar Backup Rates (Shipping)', $this->_customerTaxClasses, array($shippingClass), 2, $this->_newShippingRates);
|
| 151 |
}
|
| 152 |
}
|
| 153 |
+
|
| 154 |
/**
|
| 155 |
* Purge existing rule calculations and rates
|
| 156 |
*
|
| 163 |
|
| 164 |
foreach ($rates as $rate) {
|
| 165 |
$calculations = Mage::getModel('taxjar/import_rate')->getCalculationsByRateId($rate->getId())->load();
|
| 166 |
+
|
| 167 |
try {
|
| 168 |
foreach ($calculations as $calculation) {
|
| 169 |
$calculation->delete();
|
| 179 |
}
|
| 180 |
}
|
| 181 |
}
|
| 182 |
+
|
| 183 |
/**
|
| 184 |
* Get TaxJar backup rates
|
| 185 |
*
|
| 204 |
{
|
| 205 |
return Mage::getBaseDir('tmp') . DS . 'tj_tmp.dat';
|
| 206 |
}
|
| 207 |
+
|
| 208 |
/**
|
| 209 |
* Set the last updated date
|
| 210 |
*
|
app/code/community/Taxjar/SalesTax/Model/Sales/Order/Api/V2.php
CHANGED
|
@@ -31,12 +31,12 @@ class Taxjar_SalesTax_Model_Sales_Order_Api_V2 extends Mage_Sales_Model_Order_Ap
|
|
| 31 |
{
|
| 32 |
$result = parent::info($orderIncrementId);
|
| 33 |
$order = parent::_initOrder($orderIncrementId);
|
| 34 |
-
|
| 35 |
foreach ($order->getAllItems() as $itemIndex => $item) {
|
| 36 |
$taxClass = Mage::getModel('tax/class')->load($item->getProduct()->getTaxClassId());
|
| 37 |
$result['items'][$itemIndex]['product_tax_code'] = $taxClass->getTjSalestaxCode();
|
| 38 |
}
|
| 39 |
-
|
| 40 |
return $result;
|
| 41 |
}
|
| 42 |
}
|
| 31 |
{
|
| 32 |
$result = parent::info($orderIncrementId);
|
| 33 |
$order = parent::_initOrder($orderIncrementId);
|
| 34 |
+
|
| 35 |
foreach ($order->getAllItems() as $itemIndex => $item) {
|
| 36 |
$taxClass = Mage::getModel('tax/class')->load($item->getProduct()->getTaxClassId());
|
| 37 |
$result['items'][$itemIndex]['product_tax_code'] = $taxClass->getTjSalestaxCode();
|
| 38 |
}
|
| 39 |
+
|
| 40 |
return $result;
|
| 41 |
}
|
| 42 |
}
|
app/code/community/Taxjar/SalesTax/Model/Sales/Total/Quote/Tax.php
CHANGED
|
@@ -44,7 +44,7 @@ class Taxjar_SalesTax_Model_Sales_Total_Quote_Tax extends Mage_Tax_Model_Sales_T
|
|
| 44 |
$store = $address->getQuote()->getStore();
|
| 45 |
$items = $this->_getAddressItems($address);
|
| 46 |
$rates = $smartCalcsResponse['body']['tax'];
|
| 47 |
-
|
| 48 |
if (isset($rates['breakdown']['shipping']['tax_collectable'])) {
|
| 49 |
$shippingTaxAmount = $rates['breakdown']['shipping']['tax_collectable'];
|
| 50 |
} else {
|
|
@@ -56,11 +56,11 @@ class Taxjar_SalesTax_Model_Sales_Total_Quote_Tax extends Mage_Tax_Model_Sales_T
|
|
| 56 |
|
| 57 |
$address->setShippingTaxAmount($store->convertPrice($shippingTaxAmount));
|
| 58 |
$address->setBaseShippingTaxAmount($shippingTaxAmount);
|
| 59 |
-
|
| 60 |
if (count($items) > 0) {
|
| 61 |
foreach ($items as $item) {
|
| 62 |
$itemTax = $smartCalcs->getResponseLineItem($item->getId());
|
| 63 |
-
|
| 64 |
if (isset($itemTax)) {
|
| 65 |
$this->_addAmount($store->convertPrice($itemTax['tax_collectable']));
|
| 66 |
$this->_addBaseAmount($itemTax['tax_collectable']);
|
|
@@ -68,7 +68,7 @@ class Taxjar_SalesTax_Model_Sales_Total_Quote_Tax extends Mage_Tax_Model_Sales_T
|
|
| 68 |
$item->setTaxAmount($store->convertPrice($itemTax['tax_collectable']));
|
| 69 |
$item->setBaseTaxAmount($itemTax['tax_collectable']);
|
| 70 |
}
|
| 71 |
-
}
|
| 72 |
}
|
| 73 |
} else {
|
| 74 |
return parent::collect($address);
|
| 44 |
$store = $address->getQuote()->getStore();
|
| 45 |
$items = $this->_getAddressItems($address);
|
| 46 |
$rates = $smartCalcsResponse['body']['tax'];
|
| 47 |
+
|
| 48 |
if (isset($rates['breakdown']['shipping']['tax_collectable'])) {
|
| 49 |
$shippingTaxAmount = $rates['breakdown']['shipping']['tax_collectable'];
|
| 50 |
} else {
|
| 56 |
|
| 57 |
$address->setShippingTaxAmount($store->convertPrice($shippingTaxAmount));
|
| 58 |
$address->setBaseShippingTaxAmount($shippingTaxAmount);
|
| 59 |
+
|
| 60 |
if (count($items) > 0) {
|
| 61 |
foreach ($items as $item) {
|
| 62 |
$itemTax = $smartCalcs->getResponseLineItem($item->getId());
|
| 63 |
+
|
| 64 |
if (isset($itemTax)) {
|
| 65 |
$this->_addAmount($store->convertPrice($itemTax['tax_collectable']));
|
| 66 |
$this->_addBaseAmount($itemTax['tax_collectable']);
|
| 68 |
$item->setTaxAmount($store->convertPrice($itemTax['tax_collectable']));
|
| 69 |
$item->setBaseTaxAmount($itemTax['tax_collectable']);
|
| 70 |
}
|
| 71 |
+
}
|
| 72 |
}
|
| 73 |
} else {
|
| 74 |
return parent::collect($address);
|
app/code/community/Taxjar/SalesTax/Model/Smartcalcs.php
CHANGED
|
@@ -54,7 +54,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 54 |
if (!count($address->getAllItems())) {
|
| 55 |
return;
|
| 56 |
}
|
| 57 |
-
|
| 58 |
if ($this->_isCustomerExempt($address)) {
|
| 59 |
return;
|
| 60 |
}
|
|
@@ -86,7 +86,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 86 |
$client = new Zend_Http_Client('https://api.taxjar.com/v2/magento/taxes');
|
| 87 |
$client->setHeaders('Authorization', 'Bearer ' . $apiKey);
|
| 88 |
$client->setRawData(json_encode($order), 'application/json');
|
| 89 |
-
|
| 90 |
$this->_setSessionData('order', json_encode($order));
|
| 91 |
|
| 92 |
try {
|
|
@@ -100,7 +100,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 100 |
}
|
| 101 |
} else {
|
| 102 |
$sessionResponse = $this->_getSessionData('response');
|
| 103 |
-
|
| 104 |
if (isset($sessionResponse)) {
|
| 105 |
$this->_response = $sessionResponse;
|
| 106 |
}
|
|
@@ -127,7 +127,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 127 |
);
|
| 128 |
}
|
| 129 |
}
|
| 130 |
-
|
| 131 |
/**
|
| 132 |
* Get a specific line item breakdown from a SmartCalcs API response
|
| 133 |
* Also builds a combined rate based on returned sales tax rates
|
|
@@ -135,14 +135,14 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 135 |
* @return array
|
| 136 |
*/
|
| 137 |
public function getResponseLineItem($id)
|
| 138 |
-
{
|
| 139 |
if ($this->_response) {
|
| 140 |
$responseBody = json_decode($this->_response->getBody(), true);
|
| 141 |
|
| 142 |
if (isset($responseBody['tax']['breakdown']['line_items'])) {
|
| 143 |
$lineItems = $responseBody['tax']['breakdown']['line_items'];
|
| 144 |
$matchedKey = array_search($id, Mage::helper('taxjar')->array_column($lineItems, 'id'));
|
| 145 |
-
|
| 146 |
if (isset($lineItems[$matchedKey]) && $matchedKey !== false) {
|
| 147 |
return $lineItems[$matchedKey];
|
| 148 |
}
|
|
@@ -160,24 +160,24 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 160 |
private function _hasNexus($regionCode, $country)
|
| 161 |
{
|
| 162 |
$nexusCollection = Mage::getModel('taxjar/tax_nexus')->getCollection();
|
| 163 |
-
|
| 164 |
if ($country == 'US') {
|
| 165 |
$nexusInRegion = $nexusCollection->addFieldToFilter('region_code', $regionCode);
|
| 166 |
-
|
| 167 |
if ($nexusInRegion->getSize()) {
|
| 168 |
return true;
|
| 169 |
}
|
| 170 |
} else {
|
| 171 |
$nexusInCountry = $nexusCollection->addFieldToFilter('country_id', $country);
|
| 172 |
-
|
| 173 |
if ($nexusInCountry->getSize()) {
|
| 174 |
return true;
|
| 175 |
}
|
| 176 |
}
|
| 177 |
-
|
| 178 |
return false;
|
| 179 |
}
|
| 180 |
-
|
| 181 |
/**
|
| 182 |
* Verify if customer is exempt from sales tax
|
| 183 |
*
|
|
@@ -188,11 +188,11 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 188 |
{
|
| 189 |
$customerTaxClass = Mage::getModel('tax/class')->load($address->getQuote()->getCustomerTaxClassId());
|
| 190 |
$customerTaxCode = $customerTaxClass->getTjSalestaxCode();
|
| 191 |
-
|
| 192 |
if ($customerTaxCode == '99999') {
|
| 193 |
return true;
|
| 194 |
}
|
| 195 |
-
|
| 196 |
return false;
|
| 197 |
}
|
| 198 |
|
|
@@ -208,8 +208,11 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 208 |
$items = $address->getAllItems();
|
| 209 |
|
| 210 |
if (count($items) > 0) {
|
|
|
|
|
|
|
| 211 |
foreach ($items as $item) {
|
| 212 |
$id = $item->getId();
|
|
|
|
| 213 |
$quantity = $item->getQty();
|
| 214 |
$taxClass = Mage::getModel('tax/class')->load($item->getProduct()->getTaxClassId());
|
| 215 |
$taxCode = $taxClass->getTjSalestaxCode();
|
|
@@ -217,15 +220,20 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 217 |
$discount = (float) $item->getDiscountAmount();
|
| 218 |
|
| 219 |
if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
|
|
|
| 220 |
continue;
|
| 221 |
}
|
| 222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
if (Mage::getEdition() == 'Enterprise') {
|
| 224 |
if ($item->getProductType() == Enterprise_GiftCard_Model_Catalog_Product_Type_Giftcard::TYPE_GIFTCARD) {
|
| 225 |
$giftTaxClassId = Mage::getStoreConfig('tax/classes/wrapping_tax_class');
|
| 226 |
$giftTaxClass = Mage::getModel('tax/class')->load($giftTaxClassId);
|
| 227 |
$giftTaxClassCode = $giftTaxClass->getTjSalestaxCode();
|
| 228 |
-
|
| 229 |
if ($giftTaxClassCode) {
|
| 230 |
$taxCode = $giftTaxClassCode;
|
| 231 |
} else {
|
|
@@ -241,14 +249,14 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 241 |
'product_tax_code' => $taxCode,
|
| 242 |
'unit_price' => $unitPrice,
|
| 243 |
'discount' => $discount,
|
| 244 |
-
));
|
| 245 |
}
|
| 246 |
}
|
| 247 |
}
|
| 248 |
|
| 249 |
return $lineItems;
|
| 250 |
}
|
| 251 |
-
|
| 252 |
/**
|
| 253 |
* Get nexus addresses for `nexus_addresses` param
|
| 254 |
*
|
|
@@ -258,7 +266,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 258 |
{
|
| 259 |
$nexusAddresses = Mage::getModel('taxjar/tax_nexus')->getCollection();
|
| 260 |
$addresses = array();
|
| 261 |
-
|
| 262 |
foreach($nexusAddresses as $nexusAddress) {
|
| 263 |
$addresses[] = array(
|
| 264 |
'id' => $nexusAddress->getId(),
|
|
@@ -269,7 +277,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 269 |
'street' => $nexusAddress->getStreet()
|
| 270 |
);
|
| 271 |
}
|
| 272 |
-
|
| 273 |
return $addresses;
|
| 274 |
}
|
| 275 |
|
|
@@ -289,7 +297,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 289 |
return true;
|
| 290 |
}
|
| 291 |
}
|
| 292 |
-
|
| 293 |
/**
|
| 294 |
* Get prefixed session data from checkout/session
|
| 295 |
*
|
|
@@ -300,7 +308,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 300 |
{
|
| 301 |
return Mage::getModel('checkout/session')->getData('taxjar_salestax_' . $key);
|
| 302 |
}
|
| 303 |
-
|
| 304 |
/**
|
| 305 |
* Set prefixed session data in checkout/session
|
| 306 |
*
|
|
@@ -312,7 +320,7 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 312 |
{
|
| 313 |
return Mage::getModel('checkout/session')->setData('taxjar_salestax_' . $key, $val);
|
| 314 |
}
|
| 315 |
-
|
| 316 |
/**
|
| 317 |
* Unset prefixed session data in checkout/session
|
| 318 |
*
|
|
@@ -323,4 +331,4 @@ class Taxjar_SalesTax_Model_Smartcalcs
|
|
| 323 |
{
|
| 324 |
return Mage::getModel('checkout/session')->unsetData('taxjar_salestax_' . $key);
|
| 325 |
}
|
| 326 |
-
}
|
| 54 |
if (!count($address->getAllItems())) {
|
| 55 |
return;
|
| 56 |
}
|
| 57 |
+
|
| 58 |
if ($this->_isCustomerExempt($address)) {
|
| 59 |
return;
|
| 60 |
}
|
| 86 |
$client = new Zend_Http_Client('https://api.taxjar.com/v2/magento/taxes');
|
| 87 |
$client->setHeaders('Authorization', 'Bearer ' . $apiKey);
|
| 88 |
$client->setRawData(json_encode($order), 'application/json');
|
| 89 |
+
|
| 90 |
$this->_setSessionData('order', json_encode($order));
|
| 91 |
|
| 92 |
try {
|
| 100 |
}
|
| 101 |
} else {
|
| 102 |
$sessionResponse = $this->_getSessionData('response');
|
| 103 |
+
|
| 104 |
if (isset($sessionResponse)) {
|
| 105 |
$this->_response = $sessionResponse;
|
| 106 |
}
|
| 127 |
);
|
| 128 |
}
|
| 129 |
}
|
| 130 |
+
|
| 131 |
/**
|
| 132 |
* Get a specific line item breakdown from a SmartCalcs API response
|
| 133 |
* Also builds a combined rate based on returned sales tax rates
|
| 135 |
* @return array
|
| 136 |
*/
|
| 137 |
public function getResponseLineItem($id)
|
| 138 |
+
{
|
| 139 |
if ($this->_response) {
|
| 140 |
$responseBody = json_decode($this->_response->getBody(), true);
|
| 141 |
|
| 142 |
if (isset($responseBody['tax']['breakdown']['line_items'])) {
|
| 143 |
$lineItems = $responseBody['tax']['breakdown']['line_items'];
|
| 144 |
$matchedKey = array_search($id, Mage::helper('taxjar')->array_column($lineItems, 'id'));
|
| 145 |
+
|
| 146 |
if (isset($lineItems[$matchedKey]) && $matchedKey !== false) {
|
| 147 |
return $lineItems[$matchedKey];
|
| 148 |
}
|
| 160 |
private function _hasNexus($regionCode, $country)
|
| 161 |
{
|
| 162 |
$nexusCollection = Mage::getModel('taxjar/tax_nexus')->getCollection();
|
| 163 |
+
|
| 164 |
if ($country == 'US') {
|
| 165 |
$nexusInRegion = $nexusCollection->addFieldToFilter('region_code', $regionCode);
|
| 166 |
+
|
| 167 |
if ($nexusInRegion->getSize()) {
|
| 168 |
return true;
|
| 169 |
}
|
| 170 |
} else {
|
| 171 |
$nexusInCountry = $nexusCollection->addFieldToFilter('country_id', $country);
|
| 172 |
+
|
| 173 |
if ($nexusInCountry->getSize()) {
|
| 174 |
return true;
|
| 175 |
}
|
| 176 |
}
|
| 177 |
+
|
| 178 |
return false;
|
| 179 |
}
|
| 180 |
+
|
| 181 |
/**
|
| 182 |
* Verify if customer is exempt from sales tax
|
| 183 |
*
|
| 188 |
{
|
| 189 |
$customerTaxClass = Mage::getModel('tax/class')->load($address->getQuote()->getCustomerTaxClassId());
|
| 190 |
$customerTaxCode = $customerTaxClass->getTjSalestaxCode();
|
| 191 |
+
|
| 192 |
if ($customerTaxCode == '99999') {
|
| 193 |
return true;
|
| 194 |
}
|
| 195 |
+
|
| 196 |
return false;
|
| 197 |
}
|
| 198 |
|
| 208 |
$items = $address->getAllItems();
|
| 209 |
|
| 210 |
if (count($items) > 0) {
|
| 211 |
+
$parentQuantities = array();
|
| 212 |
+
|
| 213 |
foreach ($items as $item) {
|
| 214 |
$id = $item->getId();
|
| 215 |
+
$parentId = $item->getParentItemId();
|
| 216 |
$quantity = $item->getQty();
|
| 217 |
$taxClass = Mage::getModel('tax/class')->load($item->getProduct()->getTaxClassId());
|
| 218 |
$taxCode = $taxClass->getTjSalestaxCode();
|
| 220 |
$discount = (float) $item->getDiscountAmount();
|
| 221 |
|
| 222 |
if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
| 223 |
+
$parentQuantities[$id] = $quantity;
|
| 224 |
continue;
|
| 225 |
}
|
| 226 |
|
| 227 |
+
if ($parentId) {
|
| 228 |
+
$quantity *= $parentQuantities[$parentId];
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
if (Mage::getEdition() == 'Enterprise') {
|
| 232 |
if ($item->getProductType() == Enterprise_GiftCard_Model_Catalog_Product_Type_Giftcard::TYPE_GIFTCARD) {
|
| 233 |
$giftTaxClassId = Mage::getStoreConfig('tax/classes/wrapping_tax_class');
|
| 234 |
$giftTaxClass = Mage::getModel('tax/class')->load($giftTaxClassId);
|
| 235 |
$giftTaxClassCode = $giftTaxClass->getTjSalestaxCode();
|
| 236 |
+
|
| 237 |
if ($giftTaxClassCode) {
|
| 238 |
$taxCode = $giftTaxClassCode;
|
| 239 |
} else {
|
| 249 |
'product_tax_code' => $taxCode,
|
| 250 |
'unit_price' => $unitPrice,
|
| 251 |
'discount' => $discount,
|
| 252 |
+
));
|
| 253 |
}
|
| 254 |
}
|
| 255 |
}
|
| 256 |
|
| 257 |
return $lineItems;
|
| 258 |
}
|
| 259 |
+
|
| 260 |
/**
|
| 261 |
* Get nexus addresses for `nexus_addresses` param
|
| 262 |
*
|
| 266 |
{
|
| 267 |
$nexusAddresses = Mage::getModel('taxjar/tax_nexus')->getCollection();
|
| 268 |
$addresses = array();
|
| 269 |
+
|
| 270 |
foreach($nexusAddresses as $nexusAddress) {
|
| 271 |
$addresses[] = array(
|
| 272 |
'id' => $nexusAddress->getId(),
|
| 277 |
'street' => $nexusAddress->getStreet()
|
| 278 |
);
|
| 279 |
}
|
| 280 |
+
|
| 281 |
return $addresses;
|
| 282 |
}
|
| 283 |
|
| 297 |
return true;
|
| 298 |
}
|
| 299 |
}
|
| 300 |
+
|
| 301 |
/**
|
| 302 |
* Get prefixed session data from checkout/session
|
| 303 |
*
|
| 308 |
{
|
| 309 |
return Mage::getModel('checkout/session')->getData('taxjar_salestax_' . $key);
|
| 310 |
}
|
| 311 |
+
|
| 312 |
/**
|
| 313 |
* Set prefixed session data in checkout/session
|
| 314 |
*
|
| 320 |
{
|
| 321 |
return Mage::getModel('checkout/session')->setData('taxjar_salestax_' . $key, $val);
|
| 322 |
}
|
| 323 |
+
|
| 324 |
/**
|
| 325 |
* Unset prefixed session data in checkout/session
|
| 326 |
*
|
| 331 |
{
|
| 332 |
return Mage::getModel('checkout/session')->unsetData('taxjar_salestax_' . $key);
|
| 333 |
}
|
| 334 |
+
}
|
app/code/community/Taxjar/SalesTax/Model/Tax/Nexus.php
CHANGED
|
@@ -21,7 +21,7 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 21 |
{
|
| 22 |
$this->_init('taxjar/tax_nexus');
|
| 23 |
}
|
| 24 |
-
|
| 25 |
/**
|
| 26 |
* Create or update nexus address in TaxJar
|
| 27 |
*
|
|
@@ -39,14 +39,14 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 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 {
|
|
@@ -55,7 +55,7 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 55 |
$this->save();
|
| 56 |
}
|
| 57 |
}
|
| 58 |
-
|
| 59 |
/**
|
| 60 |
* Delete nexus address in TaxJar
|
| 61 |
*
|
|
@@ -65,7 +65,7 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 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.')
|
|
@@ -75,7 +75,7 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 75 |
$client->deleteResource($apiKey, 'nexus', $this->getApiId(), $responseErrors);
|
| 76 |
}
|
| 77 |
}
|
| 78 |
-
|
| 79 |
/**
|
| 80 |
* Sync nexus addresses from TaxJar -> Magento
|
| 81 |
*
|
|
@@ -94,14 +94,14 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 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'],
|
|
@@ -130,7 +130,7 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 130 |
}
|
| 131 |
}
|
| 132 |
}
|
| 133 |
-
|
| 134 |
/**
|
| 135 |
* Validate nexus address
|
| 136 |
*
|
|
@@ -140,11 +140,11 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 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 |
}
|
|
@@ -152,11 +152,11 @@ class Taxjar_SalesTax_Model_Tax_Nexus extends Mage_Core_Model_Abstract
|
|
| 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->getPostcode(), 'NotEmpty')) {
|
| 157 |
$errors[] = Mage::helper('taxjar')->__('Zip/Post Code can\'t be empty');
|
| 158 |
}
|
| 159 |
-
|
| 160 |
if (!$this->getId()) {
|
| 161 |
$countryAddresses = $nexusModel->getCollection()->addFieldToFilter('country_id', $this->getCountryId());
|
| 162 |
|
| 21 |
{
|
| 22 |
$this->_init('taxjar/tax_nexus');
|
| 23 |
}
|
| 24 |
+
|
| 25 |
/**
|
| 26 |
* Create or update nexus address in TaxJar
|
| 27 |
*
|
| 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 {
|
| 55 |
$this->save();
|
| 56 |
}
|
| 57 |
}
|
| 58 |
+
|
| 59 |
/**
|
| 60 |
* Delete nexus address in TaxJar
|
| 61 |
*
|
| 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.')
|
| 75 |
$client->deleteResource($apiKey, 'nexus', $this->getApiId(), $responseErrors);
|
| 76 |
}
|
| 77 |
}
|
| 78 |
+
|
| 79 |
/**
|
| 80 |
* Sync nexus addresses from TaxJar -> Magento
|
| 81 |
*
|
| 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'],
|
| 130 |
}
|
| 131 |
}
|
| 132 |
}
|
| 133 |
+
|
| 134 |
/**
|
| 135 |
* Validate nexus address
|
| 136 |
*
|
| 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 |
}
|
| 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->getPostcode(), 'NotEmpty')) {
|
| 157 |
$errors[] = Mage::helper('taxjar')->__('Zip/Post Code can\'t be empty');
|
| 158 |
}
|
| 159 |
+
|
| 160 |
if (!$this->getId()) {
|
| 161 |
$countryAddresses = $nexusModel->getCollection()->addFieldToFilter('country_id', $this->getCountryId());
|
| 162 |
|
app/code/community/Taxjar/SalesTax/controllers/Adminhtml/Tax/NexusController.php
CHANGED
|
@@ -14,7 +14,7 @@
|
|
| 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
|
|
@@ -33,24 +33,24 @@ class Taxjar_SalesTax_Adminhtml_Tax_NexusController extends Mage_Adminhtml_Contr
|
|
| 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'))
|
|
@@ -91,7 +91,7 @@ class Taxjar_SalesTax_Adminhtml_Tax_NexusController extends Mage_Adminhtml_Contr
|
|
| 91 |
)
|
| 92 |
->renderLayout();
|
| 93 |
}
|
| 94 |
-
|
| 95 |
public function saveAction()
|
| 96 |
{
|
| 97 |
$nexusPost = $this->getRequest()->getPost();
|
|
@@ -109,7 +109,7 @@ class Taxjar_SalesTax_Adminhtml_Tax_NexusController extends Mage_Adminhtml_Contr
|
|
| 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 |
|
|
@@ -120,7 +120,7 @@ class Taxjar_SalesTax_Adminhtml_Tax_NexusController extends Mage_Adminhtml_Contr
|
|
| 120 |
$this->_redirectReferer();
|
| 121 |
return;
|
| 122 |
}
|
| 123 |
-
|
| 124 |
try {
|
| 125 |
if ($nexusModel->getCountryId() == 'US') {
|
| 126 |
$nexusModel->sync();
|
|
@@ -146,7 +146,7 @@ class Taxjar_SalesTax_Adminhtml_Tax_NexusController extends Mage_Adminhtml_Contr
|
|
| 146 |
|
| 147 |
$this->getResponse()->setRedirect($this->getUrl('*/tax_nexus'));
|
| 148 |
}
|
| 149 |
-
|
| 150 |
public function deleteAction()
|
| 151 |
{
|
| 152 |
if ($nexusId = $this->getRequest()->getParam('id')) {
|
|
@@ -180,7 +180,7 @@ class Taxjar_SalesTax_Adminhtml_Tax_NexusController extends Mage_Adminhtml_Contr
|
|
| 180 |
}
|
| 181 |
}
|
| 182 |
}
|
| 183 |
-
|
| 184 |
protected function _initAction()
|
| 185 |
{
|
| 186 |
$this->loadLayout()
|
|
@@ -188,26 +188,26 @@ class Taxjar_SalesTax_Adminhtml_Tax_NexusController extends Mage_Adminhtml_Contr
|
|
| 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 |
-
}
|
| 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
|
| 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'))
|
| 91 |
)
|
| 92 |
->renderLayout();
|
| 93 |
}
|
| 94 |
+
|
| 95 |
public function saveAction()
|
| 96 |
{
|
| 97 |
$nexusPost = $this->getRequest()->getPost();
|
| 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 |
|
| 120 |
$this->_redirectReferer();
|
| 121 |
return;
|
| 122 |
}
|
| 123 |
+
|
| 124 |
try {
|
| 125 |
if ($nexusModel->getCountryId() == 'US') {
|
| 126 |
$nexusModel->sync();
|
| 146 |
|
| 147 |
$this->getResponse()->setRedirect($this->getUrl('*/tax_nexus'));
|
| 148 |
}
|
| 149 |
+
|
| 150 |
public function deleteAction()
|
| 151 |
{
|
| 152 |
if ($nexusId = $this->getRequest()->getParam('id')) {
|
| 180 |
}
|
| 181 |
}
|
| 182 |
}
|
| 183 |
+
|
| 184 |
protected function _initAction()
|
| 185 |
{
|
| 186 |
$this->loadLayout()
|
| 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
|
@@ -14,7 +14,7 @@
|
|
| 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
|
|
@@ -28,16 +28,16 @@ class Taxjar_SalesTax_Adminhtml_TaxjarController extends Mage_Adminhtml_Controll
|
|
| 28 |
{
|
| 29 |
$apiKey = (string) $this->getRequest()->getParam('api_key');
|
| 30 |
$apiEmail = (string) $this->getRequest()->getParam('api_email');
|
| 31 |
-
|
| 32 |
if ($apiKey && $apiEmail) {
|
| 33 |
Mage::getConfig()->saveConfig('tax/taxjar/apikey', $apiKey);
|
| 34 |
Mage::getConfig()->saveConfig('tax/taxjar/email', $apiEmail);
|
| 35 |
Mage::getConfig()->saveConfig('tax/taxjar/connected', 1);
|
| 36 |
Mage::getConfig()->reinit();
|
| 37 |
-
|
| 38 |
$configuration = Mage::getModel('taxjar/configuration');
|
| 39 |
$configuration->setApiSettings($apiKey);
|
| 40 |
-
|
| 41 |
Mage::getSingleton('core/session')->addSuccess('TaxJar account for ' . $apiEmail . ' is now connected.');
|
| 42 |
Mage::dispatchEvent('taxjar_salestax_import_categories');
|
| 43 |
} else {
|
|
@@ -46,7 +46,7 @@ class Taxjar_SalesTax_Adminhtml_TaxjarController extends Mage_Adminhtml_Controll
|
|
| 46 |
|
| 47 |
$this->_redirect('adminhtml/system_config/edit/section/tax');
|
| 48 |
}
|
| 49 |
-
|
| 50 |
/**
|
| 51 |
* Disconnect from TaxJar
|
| 52 |
*/
|
|
@@ -58,15 +58,15 @@ class Taxjar_SalesTax_Adminhtml_TaxjarController extends Mage_Adminhtml_Controll
|
|
| 58 |
Mage::getConfig()->saveConfig('tax/taxjar/enabled', 0);
|
| 59 |
Mage::getConfig()->saveConfig('tax/taxjar/backup', 0);
|
| 60 |
Mage::getConfig()->reinit();
|
| 61 |
-
|
| 62 |
$this->_purgeNexusAddresses();
|
| 63 |
|
| 64 |
Mage::getSingleton('core/session')->addSuccess('Your TaxJar account has been disconnected.');
|
| 65 |
Mage::dispatchEvent('taxjar_salestax_import_rates');
|
| 66 |
-
|
| 67 |
$this->_redirect('adminhtml/system_config/edit/section/tax');
|
| 68 |
}
|
| 69 |
-
|
| 70 |
/**
|
| 71 |
* Sync backup rates from TaxJar
|
| 72 |
*/
|
|
@@ -80,7 +80,7 @@ class Taxjar_SalesTax_Adminhtml_TaxjarController extends Mage_Adminhtml_Controll
|
|
| 80 |
Mage::getSingleton('core/session')->addError($e->getMessage());
|
| 81 |
}
|
| 82 |
}
|
| 83 |
-
|
| 84 |
/**
|
| 85 |
* Purge nexus addresses on disconnect
|
| 86 |
*/
|
|
@@ -91,9 +91,9 @@ class Taxjar_SalesTax_Adminhtml_TaxjarController extends Mage_Adminhtml_Controll
|
|
| 91 |
$nexusAddress->delete();
|
| 92 |
}
|
| 93 |
}
|
| 94 |
-
|
| 95 |
protected function _isAllowed()
|
| 96 |
{
|
| 97 |
return Mage::getSingleton('admin/session')->isAllowed('system/config/tax');
|
| 98 |
}
|
| 99 |
-
}
|
| 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
|
| 28 |
{
|
| 29 |
$apiKey = (string) $this->getRequest()->getParam('api_key');
|
| 30 |
$apiEmail = (string) $this->getRequest()->getParam('api_email');
|
| 31 |
+
|
| 32 |
if ($apiKey && $apiEmail) {
|
| 33 |
Mage::getConfig()->saveConfig('tax/taxjar/apikey', $apiKey);
|
| 34 |
Mage::getConfig()->saveConfig('tax/taxjar/email', $apiEmail);
|
| 35 |
Mage::getConfig()->saveConfig('tax/taxjar/connected', 1);
|
| 36 |
Mage::getConfig()->reinit();
|
| 37 |
+
|
| 38 |
$configuration = Mage::getModel('taxjar/configuration');
|
| 39 |
$configuration->setApiSettings($apiKey);
|
| 40 |
+
|
| 41 |
Mage::getSingleton('core/session')->addSuccess('TaxJar account for ' . $apiEmail . ' is now connected.');
|
| 42 |
Mage::dispatchEvent('taxjar_salestax_import_categories');
|
| 43 |
} else {
|
| 46 |
|
| 47 |
$this->_redirect('adminhtml/system_config/edit/section/tax');
|
| 48 |
}
|
| 49 |
+
|
| 50 |
/**
|
| 51 |
* Disconnect from TaxJar
|
| 52 |
*/
|
| 58 |
Mage::getConfig()->saveConfig('tax/taxjar/enabled', 0);
|
| 59 |
Mage::getConfig()->saveConfig('tax/taxjar/backup', 0);
|
| 60 |
Mage::getConfig()->reinit();
|
| 61 |
+
|
| 62 |
$this->_purgeNexusAddresses();
|
| 63 |
|
| 64 |
Mage::getSingleton('core/session')->addSuccess('Your TaxJar account has been disconnected.');
|
| 65 |
Mage::dispatchEvent('taxjar_salestax_import_rates');
|
| 66 |
+
|
| 67 |
$this->_redirect('adminhtml/system_config/edit/section/tax');
|
| 68 |
}
|
| 69 |
+
|
| 70 |
/**
|
| 71 |
* Sync backup rates from TaxJar
|
| 72 |
*/
|
| 80 |
Mage::getSingleton('core/session')->addError($e->getMessage());
|
| 81 |
}
|
| 82 |
}
|
| 83 |
+
|
| 84 |
/**
|
| 85 |
* Purge nexus addresses on disconnect
|
| 86 |
*/
|
| 91 |
$nexusAddress->delete();
|
| 92 |
}
|
| 93 |
}
|
| 94 |
+
|
| 95 |
protected function _isAllowed()
|
| 96 |
{
|
| 97 |
return Mage::getSingleton('admin/session')->isAllowed('system/config/tax');
|
| 98 |
}
|
| 99 |
+
}
|
app/code/community/Taxjar/SalesTax/etc/adminhtml.xml
CHANGED
|
@@ -51,4 +51,4 @@
|
|
| 51 |
</admin>
|
| 52 |
</resources>
|
| 53 |
</acl>
|
| 54 |
-
</config>
|
| 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.3.
|
| 23 |
</Taxjar_SalesTax>
|
| 24 |
</modules>
|
| 25 |
<global>
|
| 19 |
<config>
|
| 20 |
<modules>
|
| 21 |
<Taxjar_SalesTax>
|
| 22 |
+
<version>2.3.3</version>
|
| 23 |
</Taxjar_SalesTax>
|
| 24 |
</modules>
|
| 25 |
<global>
|
app/code/community/Taxjar/SalesTax/etc/system.xml
CHANGED
|
@@ -106,7 +106,7 @@
|
|
| 106 |
</depends>
|
| 107 |
</apikey>
|
| 108 |
</fields>
|
| 109 |
-
</taxjar>
|
| 110 |
</groups>
|
| 111 |
</tax>
|
| 112 |
</sections>
|
| 106 |
</depends>
|
| 107 |
</apikey>
|
| 108 |
</fields>
|
| 109 |
+
</taxjar>
|
| 110 |
</groups>
|
| 111 |
</tax>
|
| 112 |
</sections>
|
app/code/community/Taxjar/SalesTax/etc/wsdl.xml
CHANGED
|
@@ -35,4 +35,4 @@
|
|
| 35 |
</complexType>
|
| 36 |
</schema>
|
| 37 |
</types>
|
| 38 |
-
</definitions>
|
| 35 |
</complexType>
|
| 36 |
</schema>
|
| 37 |
</types>
|
| 38 |
+
</definitions>
|
app/code/community/Taxjar/SalesTax/sql/salestax_setup/install-1.6.0.php
CHANGED
|
@@ -32,4 +32,4 @@ try {
|
|
| 32 |
Mage::logException($e);
|
| 33 |
}
|
| 34 |
|
| 35 |
-
$installer->endSetup();
|
| 32 |
Mage::logException($e);
|
| 33 |
}
|
| 34 |
|
| 35 |
+
$installer->endSetup();
|
app/code/community/Taxjar/SalesTax/sql/salestax_setup/upgrade-2.0.1-2.1.0.php
CHANGED
|
@@ -56,11 +56,11 @@ try {
|
|
| 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();
|
| 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();
|
app/etc/modules/Taxjar_SalesTax.xml
CHANGED
|
@@ -23,4 +23,4 @@
|
|
| 23 |
<codePool>community</codePool>
|
| 24 |
</Taxjar_SalesTax>
|
| 25 |
</modules>
|
| 26 |
-
</config>
|
| 23 |
<codePool>community</codePool>
|
| 24 |
</Taxjar_SalesTax>
|
| 25 |
</modules>
|
| 26 |
+
</config>
|
package.xml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Taxjar_Salestaxautomation</name>
|
| 4 |
-
<version>2.3.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL-3.0</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 |
<authors><author><name>TaxJar</name><user>taxjar</user><email>support@taxjar.com</email></author></authors>
|
| 13 |
-
<date>2017-
|
| 14 |
-
<time>23:
|
| 15 |
-
<contents><target name="magecommunity"><dir name="Taxjar"><dir name="SalesTax"><dir name="Block"><dir name="Adminhtml"><file name="Backup.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Taxjar_Salestaxautomation</name>
|
| 4 |
+
<version>2.3.3</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL-3.0</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>* Fix child item quantity calculation for bundle items when parent quantity is > 1.</notes>
|
| 12 |
<authors><author><name>TaxJar</name><user>taxjar</user><email>support@taxjar.com</email></author></authors>
|
| 13 |
+
<date>2017-02-17</date>
|
| 14 |
+
<time>23:31:14</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Taxjar"><dir name="SalesTax"><dir name="Block"><dir name="Adminhtml"><file name="Backup.php" hash="f39a9f3edb1335b28d4be0ce95a07e98"/><file name="Enabled.php" hash="bd0fab35f1dc97eb663312da39bf36e4"/><file name="Multiselect.php" hash="82ed56f5b82e4578f0080fc5639cc0d0"/><dir name="Tax"><dir name="Class"><dir name="Edit"><file name="Form.php" hash="0f94d07830d96e892aa5967af5735d0b"/></dir><dir name="Grid"><dir name="Renderer"><file name="Exempt.php" hash="d6b842595707f4afaab0af0b0926c42d"/></dir></dir><file name="Grid.php" hash="b43394570558d1542ac6d48a14dde37c"/></dir><dir name="Nexus"><dir name="Edit"><file name="Form.php" hash="9f2a167182b1ae3dd73b2ae01c5111fc"/></dir><file name="Edit.php" hash="e8bffbb5bc4ff17c368543c2508c00a5"/><file name="Grid.php" hash="ccb748472a7a20ae0f5f0e3df58d5edf"/></dir><file name="Nexus.php" hash="ded4c4d35a79c7ca8ca393f65ea7f04c"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ce5b4453ff985146f0d49ce5e0bcc29a"/></dir><dir name="Model"><file name="Calculation.php" hash="2694a417e573f1b67866c4669c67333c"/><file name="Categories.php" hash="c2d7a4fb57ebc2081773075d8bc2a485"/><file name="Client.php" hash="9f917a21e8f07052466e0d747d476324"/><file name="Comment.php" hash="4e3bfe99cd74055c5714861be48b8ae3"/><file name="Configuration.php" hash="7200a77a626c47f0ce3aa706a7f193ef"/><file name="Debug.php" hash="941631b36855a99f853b071236778f2f"/><dir name="Import"><file name="Comment.php" hash="959874242cf3e8226dfcdc0fef5b7429"/><file name="Rate.php" hash="18305b25f55b102d7b3fe3ddd1a07e08"/><file name="Rule.php" hash="597ff0e337b4e04e43660b4d4f05d0e0"/></dir><dir name="Observer"><file name="AdminMenuItems.php" hash="e4770aa8daa34ce3233d9a4a2483d398"/><file name="AdminNotifications.php" hash="f6279c889aaf4a47d768ff8974d69781"/><file name="ConfigChanged.php" hash="53d5dbc5547537dc17049414ae53b7d0"/><file name="ConfigReview.php" hash="e8314eb6958ef68768e114c297df7511"/><file name="ImportCategories.php" hash="ce93f72fb99d941b032792eb232a494f"/><file name="ImportData.php" hash="532e91a85ed36c6c08e88cc1e568e86d"/><file name="ImportRates.php" hash="769092a271a0a0866aab7c52fafb2c5d"/><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="Order"><dir name="Api"><file name="V2.php" hash="add798c63160d8eda5303632f7725da9"/></dir></dir><dir name="Total"><dir name="Quote"><file name="Tax.php" hash="12d6259240afcfd2e5d3ed0e15bc0615"/></dir></dir></dir><file name="Smartcalcs.php" hash="2928e96720e1f19e2c2f05de759f79be"/><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="8dbc99f73efe139bda443a79e5ddec06"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Tax"><file name="NexusController.php" hash="c11069cc6f3909ca785de3515b64f149"/></dir><file name="TaxjarController.php" hash="5b867b4d311374a39889029a0ef286be"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="626c4f445fa504b6f2f53841314b959e"/><file name="config.xml" hash="d88395a329c413fd0253058d3b721426"/><file name="system.xml" hash="9b05863801f431a87e4d87df42bc987c"/><file name="wsdl.xml" hash="0b58a445dcde7efcafb1ba0d0127f487"/></dir><dir name="sql"><dir name="salestax_setup"><file name="install-1.6.0.php" hash="0e01caa22c709131f87f4fb4991b5a5f"/><file name="upgrade-2.0.1-2.1.0.php" hash="8541cddb28b34ba7d867cb9665d0a408"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Taxjar_SalesTax.xml" hash="e568c7b0e9ec79d9f32db68e90402856"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="taxjar"><dir name="nexus"><file name="form.phtml" hash="e5b3ac4950aa351f9bd0876f3adcf136"/></dir></dir></dir></dir></dir></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
