Version Notes
* Adds support for zip plus four rate calculations to Magento.
* Rates may now only be installed on one Magento installation at a time.
Download this release
Release Info
| Developer | TaxJar |
| Extension | Taxjar_Salestaxautomation |
| Version | 1.3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.2.2 to 1.3.0
- app/code/community/Taxjar/.DS_Store +0 -0
- app/code/community/Taxjar/SalesTax/Model/Calculation.php +40 -0
- app/code/community/Taxjar/SalesTax/Model/Comment.php +2 -2
- app/code/community/Taxjar/SalesTax/Model/Debug.php +1 -1
- app/code/community/Taxjar/SalesTax/Model/Observer.php +1 -1
- app/code/community/Taxjar/SalesTax/Model/Rate.php +31 -24
- app/code/community/Taxjar/SalesTax/etc/config.xml +7 -2
- package.xml +8 -8
app/code/community/Taxjar/.DS_Store
DELETED
|
Binary file
|
app/code/community/Taxjar/SalesTax/Model/Calculation.php
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* TaxJar Zip+4 Rate Calculation Support for US
|
| 5 |
+
*
|
| 6 |
+
* @author Taxjar (support@taxjar.com)
|
| 7 |
+
*/
|
| 8 |
+
class Taxjar_SalesTax_Model_Calculation extends Mage_Tax_Model_Resource_Calculation {
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Returns tax rates for request and when US only uses five digit zip code lookups
|
| 12 |
+
*
|
| 13 |
+
* @param Varien_Object $request
|
| 14 |
+
* @return array
|
| 15 |
+
*/
|
| 16 |
+
protected function _getRates( $request ) {
|
| 17 |
+
// Grab each current value
|
| 18 |
+
$countryId = $request->getCountryId();
|
| 19 |
+
$currentPostcode = $request->getPostcode();
|
| 20 |
+
if( $countryId == 'US' ) {
|
| 21 |
+
// Trim whitespace
|
| 22 |
+
$newPostcode = preg_replace('/\s+/', '', $request->getPostcode());
|
| 23 |
+
// Snatch only the first five characters
|
| 24 |
+
$newPostcode = substr($newPostcode, 0, 5);
|
| 25 |
+
// Replace the request's zip code with one that now has 5 digits
|
| 26 |
+
$request->setPostcode($newPostcode);
|
| 27 |
+
// Find rates by the new 5-digit zip
|
| 28 |
+
$rates = parent::_getRates($request);
|
| 29 |
+
// Reset the request's postcode to what it was
|
| 30 |
+
$request->setPostcode($currentPostcode);
|
| 31 |
+
}
|
| 32 |
+
else {
|
| 33 |
+
// Non-US should just work normally
|
| 34 |
+
$rates = parent::_getRates($request);
|
| 35 |
+
}
|
| 36 |
+
return $rates;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
}
|
| 40 |
+
?>
|
app/code/community/Taxjar/SalesTax/Model/Comment.php
CHANGED
|
@@ -72,7 +72,7 @@ class Taxjar_SalesTax_Model_Comment {
|
|
| 72 |
* @return $string
|
| 73 |
*/
|
| 74 |
private function buildInstalledHtml( $statesHtml, $lastUpdate ) {
|
| 75 |
-
$htmlString = "<p class='note'><span>TaxJar is installed. Check the Manage Tax Rules section to verify all installed states.</span></p><br/><p>TaxJar has <em>automatically</em> added rates for the following states to your Magento installation:<br/><ul class='messages'>". $statesHtml . "</ul>To manage your TaxJar states <a href='https://app.taxjar.com/account#states' target='_blank'>click here</a>.</p><p>Your sales tax rates were last updated on: <ul class='messages'><li class='info-msg'><ul><li><span style='font-size: 1.4em;'>" . $lastUpdate . "</span></li></ul></li></ul><small>Rates may be automatically or manually updated again once per month. Contact support@taxjar.com with the email address registered to your TaxJar account if you need assistance.</small></p><p><small>If you would like to uninstall TaxJar, remove the API Token from the box above, then save the config. This will remove all tax rates in your Magento store. You can then uninstall in the Magento Connect Manager.<small></p>";
|
| 76 |
return $htmlString;
|
| 77 |
}
|
| 78 |
|
|
@@ -83,7 +83,7 @@ class Taxjar_SalesTax_Model_Comment {
|
|
| 83 |
* @return $string
|
| 84 |
*/
|
| 85 |
private function buildNotYetInstalledHtml( $regionName ) {
|
| 86 |
-
$htmlString = "<p class='note'><span>Enter your TaxJar API Token</span></p><br/><p>Enter your TaxJar API Token to import current sales tax rates for all zip codes in " . $regionName . ", your state of origin as set in Shipping Settings. We will also retrieve all other states from your TaxJar account. To get an API Token, go to <a href='https://app.taxjar.com/account' target='_blank'>TaxJar's Account Screen.</a></p><p>For more information on how your tax settings are changed, <a href='http://taxjar.com/magento/tax-settings' target='_blank'>click here</a>.</p>";
|
| 87 |
return $htmlString;
|
| 88 |
}
|
| 89 |
|
| 72 |
* @return $string
|
| 73 |
*/
|
| 74 |
private function buildInstalledHtml( $statesHtml, $lastUpdate ) {
|
| 75 |
+
$htmlString = "<p class='note'><span>TaxJar is installed. Check the Manage Tax Rules section to verify all installed states.</span></p><br/><p>TaxJar has <em>automatically</em> added rates for the following states to your Magento installation:<br/><ul class='messages'>". $statesHtml . "</ul>To manage your TaxJar states <a href='https://app.taxjar.com/account#states' target='_blank'>click here</a>.</p><p>Your sales tax rates were last updated on: <ul class='messages'><li class='info-msg'><ul><li><span style='font-size: 1.4em;'>" . $lastUpdate . "</span></li></ul></li></ul><small>Rates may be automatically or manually updated again once per month. Contact support@taxjar.com with the email address registered to your TaxJar account if you need assistance.</small></p><p><small>If you would like to uninstall TaxJar, remove the API Token from the box above, then save the config. This will remove all tax rates in your Magento store. You can then uninstall in the Magento Connect Manager.<small></p><p><strong>Important Notice</strong>: Your API key may be used to install rates on only <em>one</em> Magento installation at a time.</p>";
|
| 76 |
return $htmlString;
|
| 77 |
}
|
| 78 |
|
| 83 |
* @return $string
|
| 84 |
*/
|
| 85 |
private function buildNotYetInstalledHtml( $regionName ) {
|
| 86 |
+
$htmlString = "<p class='note'><span>Enter your TaxJar API Token</span></p><br/><p>Enter your TaxJar API Token to import current sales tax rates for all zip codes in " . $regionName . ", your state of origin as set in Shipping Settings. We will also retrieve all other states from your TaxJar account. To get an API Token, go to <a href='https://app.taxjar.com/account' target='_blank'>TaxJar's Account Screen.</a></p><p>For more information on how your tax settings are changed, <a href='http://taxjar.com/magento/tax-settings' target='_blank'>click here</a>.</p><p><small><strong>Important Notice</strong>: Your API key may be used to install rates on only <em>one</em> Magento installation at a time.</small></p>";
|
| 87 |
return $htmlString;
|
| 88 |
}
|
| 89 |
|
app/code/community/Taxjar/SalesTax/Model/Debug.php
CHANGED
|
@@ -34,7 +34,7 @@ class Taxjar_SalesTax_Model_Debug {
|
|
| 34 |
$states = implode( ',', unserialize( Mage::getStoreConfig('taxjar/config/states') ) );
|
| 35 |
$apiUser = Mage::getModel('api/user');
|
| 36 |
$existingUserId = $apiUser->load('taxjar', 'username')->getUserId();
|
| 37 |
-
$pluginVersion = '1.
|
| 38 |
$phpMemory = @ini_get('memory_limit');
|
| 39 |
$phpVersion = @phpversion();
|
| 40 |
$magentoVersion = Mage::getVersion();
|
| 34 |
$states = implode( ',', unserialize( Mage::getStoreConfig('taxjar/config/states') ) );
|
| 35 |
$apiUser = Mage::getModel('api/user');
|
| 36 |
$existingUserId = $apiUser->load('taxjar', 'username')->getUserId();
|
| 37 |
+
$pluginVersion = '1.3.0';
|
| 38 |
$phpMemory = @ini_get('memory_limit');
|
| 39 |
$phpVersion = @phpversion();
|
| 40 |
$magentoVersion = Mage::getVersion();
|
app/code/community/Taxjar/SalesTax/Model/Observer.php
CHANGED
|
@@ -43,7 +43,7 @@ class Taxjar_SalesTax_Model_Observer {
|
|
| 43 |
|
| 44 |
if( ! $configJson['allow_update'] ) {
|
| 45 |
$dateUpdated = Mage::getStoreConfig('taxjar/config/last_update');
|
| 46 |
-
Mage::getSingleton('core/session')->addNotice("Your
|
| 47 |
return;
|
| 48 |
}
|
| 49 |
|
| 43 |
|
| 44 |
if( ! $configJson['allow_update'] ) {
|
| 45 |
$dateUpdated = Mage::getStoreConfig('taxjar/config/last_update');
|
| 46 |
+
Mage::getSingleton('core/session')->addNotice("Your last rate update was too recent. Please wait at least 5 minutes and try again.");
|
| 47 |
return;
|
| 48 |
}
|
| 49 |
|
app/code/community/Taxjar/SalesTax/Model/Rate.php
CHANGED
|
@@ -8,41 +8,48 @@
|
|
| 8 |
class Taxjar_SalesTax_Model_Rate {
|
| 9 |
|
| 10 |
/**
|
| 11 |
-
*
|
| 12 |
*
|
| 13 |
* @param JSON $string
|
| 14 |
* @return array
|
| 15 |
*/
|
| 16 |
public function create( $rateJson ) {
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
-
|
| 42 |
-
$
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
-
|
| 45 |
-
return array( $rateModel->getId(), $shippingRateId );
|
| 46 |
}
|
| 47 |
|
| 48 |
}
|
| 8 |
class Taxjar_SalesTax_Model_Rate {
|
| 9 |
|
| 10 |
/**
|
| 11 |
+
* Try to create the rate
|
| 12 |
*
|
| 13 |
* @param JSON $string
|
| 14 |
* @return array
|
| 15 |
*/
|
| 16 |
public function create( $rateJson ) {
|
| 17 |
+
try {
|
| 18 |
+
$zip = $rateJson['zip'];
|
| 19 |
+
$regionCode = $rateJson['state'];
|
| 20 |
+
$rate = $rateJson['rate'];
|
| 21 |
|
| 22 |
+
if ( isset( $rateJson['country'] ) ) {
|
| 23 |
+
$countryCode = $rateJson['country'];
|
| 24 |
+
}
|
| 25 |
+
else {
|
| 26 |
+
$countryCode = 'US';
|
| 27 |
+
}
|
| 28 |
|
| 29 |
+
$regionId = Mage::getModel('directory/region')->loadByCode($regionCode, $countryCode)->getId();
|
| 30 |
+
$rateModel = Mage::getModel('tax/calculation_rate');
|
| 31 |
|
| 32 |
+
$rateModel->setTaxCountryId($countryCode);
|
| 33 |
+
$rateModel->setTaxRegionId($regionId);
|
| 34 |
+
$rateModel->setTaxPostcode($zip);
|
| 35 |
+
$rateModel->setCode($countryCode . '-' . $regionCode . '-' . $zip);
|
| 36 |
+
$rateModel->setRate($rate);
|
| 37 |
+
$rateModel->save();
|
| 38 |
|
| 39 |
+
if ( $rateJson['freight_taxable'] ) {
|
| 40 |
+
$shippingRateId = $rateModel->getId();
|
| 41 |
+
}
|
| 42 |
+
else {
|
| 43 |
+
$shippingRateId = 0;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return array( $rateModel->getId(), $shippingRateId );
|
| 47 |
}
|
| 48 |
+
catch ( Exception $e ) {
|
| 49 |
+
Mage::getSingleton('core/session')->addNotice("There was an error encountered while loading rate with code " . $rateModel->getCode() . ". This is most likely due to duplicate codes and can be safely ignored if lots of other rates were loaded. If the error persists, email support@taxjar.com with a screenshot of any Magento errors displayed." );
|
| 50 |
+
unset( $rateModel );
|
| 51 |
+
return;
|
| 52 |
}
|
|
|
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
}
|
app/code/community/Taxjar/SalesTax/etc/config.xml
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
-->
|
| 7 |
<config>
|
| 8 |
<modules>
|
| 9 |
-
<Taxjar_SalesTax><version>1.
|
| 10 |
</modules>
|
| 11 |
<global>
|
| 12 |
<helpers>
|
|
@@ -17,7 +17,12 @@
|
|
| 17 |
<models>
|
| 18 |
<taxjar>
|
| 19 |
<class>Taxjar_SalesTax_Model</class>
|
| 20 |
-
</taxjar>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
</models>
|
| 22 |
<blocks>
|
| 23 |
<taxjar>
|
| 6 |
-->
|
| 7 |
<config>
|
| 8 |
<modules>
|
| 9 |
+
<Taxjar_SalesTax><version>1.3.0</version></Taxjar_SalesTax>
|
| 10 |
</modules>
|
| 11 |
<global>
|
| 12 |
<helpers>
|
| 17 |
<models>
|
| 18 |
<taxjar>
|
| 19 |
<class>Taxjar_SalesTax_Model</class>
|
| 20 |
+
</taxjar>
|
| 21 |
+
<tax_resource>
|
| 22 |
+
<rewrite>
|
| 23 |
+
<calculation>Taxjar_SalesTax_Model_Calculation</calculation>
|
| 24 |
+
</rewrite>
|
| 25 |
+
</tax_resource>
|
| 26 |
</models>
|
| 27 |
<blocks>
|
| 28 |
<taxjar>
|
package.xml
CHANGED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Taxjar_Salestaxautomation</name>
|
| 4 |
-
<version>1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
-
<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>
|
| 11 |
-
<notes
|
| 12 |
-
|
| 13 |
<authors><author><name>TaxJar</name><user>taxjar</user><email>support@taxjar.com</email></author></authors>
|
| 14 |
-
<date>
|
| 15 |
-
<time>
|
| 16 |
-
<contents><target name="magecommunity"><dir name="Taxjar"><dir name="SalesTax"><dir name="Helper"><file name="Data.php" hash="565812e7d6927df4c91bfb69b79b1b09"/></dir><dir name="Model"><file name="Client.php" hash="6c3339bcc33670b0d41ded468b72e77b"/><file name="Comment.php" hash="
|
| 17 |
<compatible/>
|
| 18 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 19 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Taxjar_Salestaxautomation</name>
|
| 4 |
+
<version>1.3.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
+
<license>MIT</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Easily collect sales tax without altering your Magento store’s checkout experience or performance.</summary>
|
| 10 |
+
<description>TaxJar for Magento allows you to install rates for multiple origin or destination-based states without affecting your store's checkout experience.</description>
|
| 11 |
+
<notes>* Adds support for zip plus four rate calculations to Magento.
|
| 12 |
+
* Rates may now only be installed on one Magento installation at a time.</notes>
|
| 13 |
<authors><author><name>TaxJar</name><user>taxjar</user><email>support@taxjar.com</email></author></authors>
|
| 14 |
+
<date>2015-03-10</date>
|
| 15 |
+
<time>13:48:00</time>
|
| 16 |
+
<contents><target name="magecommunity"><dir name="Taxjar"><dir name="SalesTax"><dir name="Helper"><file name="Data.php" hash="565812e7d6927df4c91bfb69b79b1b09"/></dir><dir name="Model"><file name="Calculation.php" hash="170fd255c7bdf2d3d7cfa258e08dcc91"/><file name="Client.php" hash="6c3339bcc33670b0d41ded468b72e77b"/><file name="Comment.php" hash="b02f877f10934f3596215fbc6a4ce08e"/><file name="Configuration.php" hash="1ed6e9467ac8c5ca6e906753071a9161"/><file name="Debug.php" hash="096b1fb2e45e808845d50f2ad371953a"/><file name="Observer.php" hash="fd0a35937096c2d8b6eb97405eb54460"/><file name="Rate.php" hash="30b07e73624405c5acba6965c0f6b2f6"/><file name="Rule.php" hash="ae33149080b3182e62b56607f7b30da4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4ea028ad6b00688d99531597e8d3c404"/><file name="config.xml" hash="60802c2569b2a5b7178d527e35d43175"/><file name="system.xml" hash="8dc55519eef0349d487f4039eabda164"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Taxjar_SalesTax.xml" hash="60b211e28d8b9d4cc49d1dd746d4aa46"/></dir></target></contents>
|
| 17 |
<compatible/>
|
| 18 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 19 |
</package>
|
