Version Notes
Maurisource Canada tax setup
Download this release
Release Info
Developer | Manesh Sonah |
Extension | maurisou-setup |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
app/code/local/Maurisource/Setup/Helper/Data.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: Parvesh
|
5 |
+
* Date: 12/2/15
|
6 |
+
* Time: 10:30 PM
|
7 |
+
*/
|
8 |
+
class Maurisource_Setup_Helper_Data extends Mage_Core_Helper_Abstract {
|
9 |
+
|
10 |
+
}
|
app/code/local/Maurisource/Setup/etc/config.xml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Maurisource_Setup>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Maurisource_Setup>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<maurisource_setup>
|
11 |
+
<class>Maurisource_Setup_Model</class>
|
12 |
+
<resourceModel>maurisource_setup_resource</resourceModel>
|
13 |
+
</maurisource_setup>
|
14 |
+
<maurisource_setup_resource>
|
15 |
+
<class>Maurisource_Setup_Model_Resource</class>
|
16 |
+
</maurisource_setup_resource>
|
17 |
+
</models>
|
18 |
+
<blocks>
|
19 |
+
<maurisource_setup>
|
20 |
+
<class>Maurisource_Setup_Block</class>
|
21 |
+
</maurisource_setup>
|
22 |
+
</blocks>
|
23 |
+
<helpers>
|
24 |
+
<maurisource_setup>
|
25 |
+
<class>Maurisource_Setup_Helper</class>
|
26 |
+
</maurisource_setup>
|
27 |
+
</helpers>
|
28 |
+
<resources>
|
29 |
+
<maurisource_setup_setup>
|
30 |
+
<setup>
|
31 |
+
<module>Maurisource_Setup</module>
|
32 |
+
</setup>
|
33 |
+
</maurisource_setup_setup>
|
34 |
+
</resources>
|
35 |
+
</global>
|
36 |
+
</config>
|
app/code/local/Maurisource/Setup/sql/maurisource_setup_setup/install-0.1.0.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: Parvesh
|
5 |
+
* Date: 12/2/15
|
6 |
+
* Time: 10:30 PM
|
7 |
+
*/
|
8 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
9 |
+
$installer = $this;
|
10 |
+
|
11 |
+
$installer->startSetup();
|
12 |
+
$countryCode = 'CA';
|
13 |
+
//truncate tax tables
|
14 |
+
$connectionObject = $installer->getConnection();
|
15 |
+
$connectionObject->truncateTable($installer->getTable('tax_calculation_rate'));
|
16 |
+
$connectionObject->truncateTable($installer->getTable('tax_calculation_rule'));
|
17 |
+
|
18 |
+
//get the product tax class
|
19 |
+
$productTaxClass = Mage::getModel('tax/class')
|
20 |
+
->getCollection()
|
21 |
+
->addFieldToFilter('class_name', 'Taxable Goods')
|
22 |
+
->load()
|
23 |
+
->getFirstItem();
|
24 |
+
|
25 |
+
$productTaxShippingClass = Mage::getModel('tax/class')
|
26 |
+
->getCollection()
|
27 |
+
->addFieldToFilter('class_name', 'Shipping')
|
28 |
+
->load()
|
29 |
+
->getFirstItem();
|
30 |
+
|
31 |
+
//get the customer tax class
|
32 |
+
$customerTaxClass = Mage::getModel('tax/class')
|
33 |
+
->getCollection()
|
34 |
+
->addFieldToFilter('class_name', 'Retail Customer')
|
35 |
+
->load()
|
36 |
+
->getFirstItem();
|
37 |
+
|
38 |
+
$regionData = array();
|
39 |
+
$regionArray = Mage::getModel('directory/region_api')->items($countryCode);
|
40 |
+
foreach($regionArray as $region){
|
41 |
+
$regionData[$region['region_id']] = $region['code'];
|
42 |
+
}
|
43 |
+
|
44 |
+
$correctedRegionData = array_flip($regionData);
|
45 |
+
|
46 |
+
$taxRates = array(
|
47 |
+
array("GST","CA","*","*",5.00),
|
48 |
+
array("PST-BC","CA",$correctedRegionData["BC"],"*",7.00),
|
49 |
+
array("PST-MB","CA",$correctedRegionData["MB"],"*",8.0),
|
50 |
+
array("HST-NB","CA",$correctedRegionData["NB"],"*",8.00),
|
51 |
+
array("HST-NF","CA",$correctedRegionData["NL"],"*",8.00),
|
52 |
+
array("HST-NS","CA",$correctedRegionData["NS"],"*",10.00),
|
53 |
+
array("PST-ON","CA",$correctedRegionData["ON"],"*",8.00),
|
54 |
+
array("HST-PEI","CA",$correctedRegionData["PE"],"*",9.00),
|
55 |
+
array("TVQ","CA",$correctedRegionData["QC"],"*",9.975),
|
56 |
+
array("PST-SAS","CA",$correctedRegionData["SK"],"*",5.00),
|
57 |
+
);
|
58 |
+
|
59 |
+
|
60 |
+
$taxRateArray = array();
|
61 |
+
|
62 |
+
foreach($taxRates as $taxRate){
|
63 |
+
$taxCalculationRateId = Mage::getModel('tax/calculation_rate')
|
64 |
+
->setData(array(
|
65 |
+
"code" => $taxRate[0],
|
66 |
+
"tax_country_id" => $taxRate[1],
|
67 |
+
"tax_region_id" => $taxRate[2],
|
68 |
+
"tax_postcode" => $taxRate[3],
|
69 |
+
"rate" => $taxRate[4],
|
70 |
+
))->save()->getId();
|
71 |
+
|
72 |
+
$taxRateArray[$taxCalculationRateId] = $taxRate[0];
|
73 |
+
}
|
74 |
+
|
75 |
+
$correctedTaxArray = array_flip($taxRateArray);
|
76 |
+
|
77 |
+
$taxRules = array(
|
78 |
+
array("Taxable Goods Canada", $customerTaxClass->getId(), array($productTaxClass->getId(), $productTaxShippingClass->getId()), array($correctedTaxArray["GST"],$correctedTaxArray["HST-NB"],$correctedTaxArray["HST-NF"], $correctedTaxArray["HST-NS"], $correctedTaxArray["HST-PEI"]), 1, null, 1),
|
79 |
+
array("Taxable Goods PST Ontario", $customerTaxClass->getId(), array($productTaxClass->getId()), array($correctedTaxArray["PST-ON"]), 1, null, 2),
|
80 |
+
array("Taxable Goods PST MB", $customerTaxClass->getId(), array($productTaxClass->getId()), array($correctedTaxArray["PST-MB"]), 1, null, 4),
|
81 |
+
array("Taxable Goods PST BC", $customerTaxClass->getId(), array($productTaxClass->getId()), array($correctedTaxArray["PST-BC"]), 1, null, 6),
|
82 |
+
array("Taxable Goods PST SAS", $customerTaxClass->getId(), array($productTaxClass->getId()), array($correctedTaxArray["PST-SAS"]), 1, null, 8),
|
83 |
+
array("Taxable Goods PST Quebec", $customerTaxClass->getId(), array($productTaxClass->getId(), $productTaxShippingClass->getId()), array($correctedTaxArray["TVQ"]), 2, 1, 3)
|
84 |
+
);
|
85 |
+
|
86 |
+
|
87 |
+
foreach($taxRules as $taxRule){
|
88 |
+
$ruleModel = Mage::getModel('tax/calculation_rule')->setData(array(
|
89 |
+
'code' => $taxRule[0],
|
90 |
+
'priority' => $taxRule[4],
|
91 |
+
'position' => $taxRule[6],
|
92 |
+
'tax_customer_class' => array($taxRule[1]),
|
93 |
+
'tax_product_class' => $taxRule[2],
|
94 |
+
'tax_rate' => $taxRule[3],
|
95 |
+
'calculate_subtotal' => $taxRule[5]
|
96 |
+
))->save();
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
$installer->endSetup();
|
app/etc/modules/Maurisource_Setup.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Maurisource_Setup>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Maurisource_Setup>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Maurisource_Setup</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>ASL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Maurisource Canada tax setup</summary>
|
10 |
+
<description>Maurisource Canada tax setup</description>
|
11 |
+
<notes>Maurisource Canada tax setup</notes>
|
12 |
+
<authors><author><name>Manesh Sonah</name><user>maneso</user><email>maurisource.seo@gmail.com</email></author></authors>
|
13 |
+
<date>2015-12-03</date>
|
14 |
+
<time>18:50:06</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Maurisource"><dir name="Setup"><dir name="Helper"><file name="Data.php" hash="05556ee3e8030420720df1fb029cb25a"/></dir><dir name="etc"><file name="config.xml" hash="6ece1ae30e0333cf11d1975c4cc024a5"/></dir><dir name="sql"><dir name="maurisource_setup_setup"><file name="install-0.1.0.php" hash="38ae4ac81cd2f940cc2184f376abe840"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Maurisource_Setup.xml" hash="7410c75441af290ef878b90befbe57f3"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.0.0</min><max>5.7.0</max></php></required></dependencies>
|
18 |
+
</package>
|