Taxify_Sales_Tax_Rates_and_Filing - Version 0.1.0

Version Notes

Initial Public Release

Download this release

Release Info

Developer Vonnda Development
Extension Taxify_Sales_Tax_Rates_and_Filing
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (27) hide show
  1. app/code/local/Vonnda/Taxify/.DS_Store +0 -0
  2. app/code/local/Vonnda/Taxify/Helper/Data.php +5 -0
  3. app/code/local/Vonnda/Taxify/Model/.DS_Store +0 -0
  4. app/code/local/Vonnda/Taxify/Model/Client.php +69 -0
  5. app/code/local/Vonnda/Taxify/Model/Config.php +37 -0
  6. app/code/local/Vonnda/Taxify/Model/Observer.php +48 -0
  7. app/code/local/Vonnda/Taxify/Model/Request/Calculate.php +225 -0
  8. app/code/local/Vonnda/Taxify/Model/Request/Cancel.php +13 -0
  9. app/code/local/Vonnda/Taxify/Model/Request/Commit.php +13 -0
  10. app/code/local/Vonnda/Taxify/Model/Request/Request.php +67 -0
  11. app/code/local/Vonnda/Taxify/Model/Request/Verifyaddress.php +20 -0
  12. app/code/local/Vonnda/Taxify/Model/Request/Version.php +8 -0
  13. app/code/local/Vonnda/Taxify/Model/Sales/.DS_Store +0 -0
  14. app/code/local/Vonnda/Taxify/Model/Sales/Quote/.DS_Store +0 -0
  15. app/code/local/Vonnda/Taxify/Model/Sales/Quote/Address/.DS_Store +0 -0
  16. app/code/local/Vonnda/Taxify/Model/Sales/Quote/Address/Total/Tax.php +213 -0
  17. app/code/local/Vonnda/Taxify/etc/config.xml +56 -0
  18. app/code/local/Vonnda/Taxify/etc/system.xml +70 -0
  19. app/code/local/Vonnda/Taxify/tests/.DS_Store +0 -0
  20. app/code/local/Vonnda/Taxify/tests/Request/CalculateTest.php +101 -0
  21. app/code/local/Vonnda/Taxify/tests/Request/CancelTest.php +14 -0
  22. app/code/local/Vonnda/Taxify/tests/Request/CommitTest.php +14 -0
  23. app/code/local/Vonnda/Taxify/tests/SampleTest.php +12 -0
  24. app/code/local/Vonnda/Taxify/tests/fixtures/calculateMultiSimpleProductSuccess.txt +1 -0
  25. app/code/local/Vonnda/Taxify/tests/fixtures/calculateSuccess.txt +1 -0
  26. app/etc/modules/Vonnda_Taxify.xml +9 -0
  27. package.xml +18 -0
app/code/local/Vonnda/Taxify/.DS_Store ADDED
Binary file
app/code/local/Vonnda/Taxify/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ }
app/code/local/Vonnda/Taxify/Model/.DS_Store ADDED
Binary file
app/code/local/Vonnda/Taxify/Model/Client.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Client extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ public $config;
7
+ public $request = array();
8
+ public $response;
9
+ public $url = '';
10
+ public $soapClient;
11
+ public $logFilename = 'taxify.log';
12
+ const PARTNER_KEY = '275067E9-C359-4BF3-AC6E-2772456F6FAD';
13
+
14
+ public function __construct()
15
+ {
16
+ $this->config = Mage::getModel('taxify/config');
17
+ $this->url = $this->config->getApiUrl(). '?wsdl';
18
+ $this->log('URL:'. $this->url);
19
+
20
+ $this->soapClient = new SoapClient($this->url, array(
21
+ 'trace' => 1,
22
+ 'exception' => 0,
23
+ ));
24
+ }
25
+
26
+ public function log($message)
27
+ {
28
+ Mage::log($message, null, $this->logFilename);
29
+ }
30
+
31
+ public function addSecurityToRequest()
32
+ {
33
+ $this->request['Request']['Security'] = array(
34
+ 'Username' => $this->config->getApiUsername(),
35
+ 'Password' => $this->config->getApiPassword(),
36
+ );
37
+ $this->request['Request']['Security']['PartnerKey'] = self::PARTNER_KEY;
38
+ }
39
+
40
+ public function buildRequest($req)
41
+ {
42
+ $this->request['Request'] = $req;
43
+ $this->addSecurityToRequest();
44
+ }
45
+
46
+ public function logTransaction()
47
+ {
48
+ $this->log('REQUEST:');
49
+ $this->log($this->request);
50
+ $this->log('RESPONSE:');
51
+ $this->log($this->response);
52
+ }
53
+
54
+ public function request($method, $req)
55
+ {
56
+ $this->buildRequest($req);
57
+
58
+ try {
59
+ $this->response = $this->soapClient->$method($this->request);
60
+ } catch (Exception $e) {
61
+ $this->log('ERROR:');
62
+ $this->log($e->getMessage());
63
+ }
64
+
65
+ $this->logTransaction();
66
+
67
+ return $this->response;
68
+ }
69
+ }
app/code/local/Vonnda/Taxify/Model/Config.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Config extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ public function getApiUrl()
7
+ {
8
+ if ($this->isTestMode()) {
9
+ return 'https://ws-dev.shipcompliant.com/taxify/1.0/core/service.asmx';
10
+ }
11
+
12
+ return 'https://ws.taxify.co/taxify/1.0/core/service.asmx';
13
+ }
14
+
15
+ public function isEnabled()
16
+ {
17
+ return Mage::getStoreConfigFlag('tax/taxify/enabled');
18
+ }
19
+
20
+ // This is now the API Key
21
+ public function getApiPassword()
22
+ {
23
+ return Mage::getStoreConfig('tax/taxify/password');
24
+ }
25
+
26
+ public function getApiUsername()
27
+ {
28
+ // We no longer provide username, just api key as password
29
+ return '';
30
+ }
31
+
32
+ public function isTestMode()
33
+ {
34
+ return Mage::getStoreConfigFlag('tax/taxify/test_mode');
35
+ }
36
+
37
+ }
app/code/local/Vonnda/Taxify/Model/Observer.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Observer
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ $this->config = Mage::getModel('taxify/config');
9
+ }
10
+
11
+ public function isEnabled()
12
+ {
13
+ return $this->config->isEnabled();
14
+ }
15
+
16
+ public function quoteCollectTotalsBefore(Varien_Event_Observer $observer)
17
+ {
18
+ if (!$this->isEnabled()) {
19
+ return;
20
+ }
21
+
22
+ Mage::getConfig()->setNode('global/sales/quote/totals/tax/class', 'vonnda_taxify_model_sales_quote_address_total_tax');
23
+ }
24
+
25
+ public function salesOrderPlaceAfter(Varien_Event_Observer $observer)
26
+ {
27
+ if (!$this->isEnabled()) {
28
+ return;
29
+ }
30
+
31
+ $order = $observer->getEvent()->getOrder();
32
+ $commit = Mage::getModel('taxify/request_commit');
33
+ $commit->loadOrder($order);
34
+ $commit->send();
35
+ }
36
+
37
+ public function salesOrderCancelAfter(Varien_Event_Observer $observer)
38
+ {
39
+ if (!$this->isEnabled()) {
40
+ return;
41
+ }
42
+
43
+ $order = $observer->getEvent()->getPayment()->getOrder();
44
+ $cancel = Mage::getModel('taxify/request_cancel');
45
+ $cancel->loadOrder($order);
46
+ $cancel->send();
47
+ }
48
+ }
app/code/local/Vonnda/Taxify/Model/Request/Calculate.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Request_Calculate extends Vonnda_Taxify_Model_Request_Request
4
+ {
5
+
6
+ public $apiMethod = 'CalculateTax';
7
+ public $isCommited = 'false';
8
+
9
+ public function formatCurrency($amount)
10
+ {
11
+ return number_format($amount, 2);
12
+ }
13
+
14
+ public function getShippingAmount()
15
+ {
16
+ $shippingAddr = $this->getMageModel()->getShippingAddress();
17
+ if (!$shippingAddr) {
18
+ return 0.00;
19
+ }
20
+
21
+ return $this->formatCurrency($shippingAddr->getShippingAmount());
22
+ }
23
+
24
+ public function buildDestinationAddress()
25
+ {
26
+ $shippingAddr = $this->getMageModel()->getShippingAddress();
27
+
28
+ $addrParts = $this->splitAddr($shippingAddr->getData('street'));
29
+
30
+ $addr = array();
31
+ $addr['FirstName'] = $shippingAddr->getData('firstname');
32
+ $addr['LastName'] = $shippingAddr->getData('lastname');
33
+ $addr['Company'] = $shippingAddr->getData('company');
34
+ $addr['Street1'] = $addrParts[0];
35
+ $addr['Street2'] = $addrParts[1];
36
+ $addr['City'] = $shippingAddr->getData('city');
37
+ $addr['Region'] = $this->getRegionCode();
38
+ $addr['PostalCode'] = $shippingAddr->getData('postcode');
39
+ $addr['Country'] = $shippingAddr->getData('country_id');
40
+ $addr['Email'] = $shippingAddr->getData('email');
41
+ $addr['Phone'] = $shippingAddr->getData('telephone');
42
+
43
+ $this->request['DestinationAddress'] = $addr;
44
+ }
45
+
46
+ public function getItemTaxabilityCode($item)
47
+ {
48
+ $taxClassId = $item->getProduct()->getTaxClassId();
49
+
50
+ $map = array('0' => 'NON', '6' => 'NON');
51
+
52
+ if (isset($map[$taxClassId])) {
53
+ return $map[$taxClassId];
54
+ }
55
+
56
+ return '';
57
+ }
58
+
59
+ public function createLineFromMageItem($item)
60
+ {
61
+ $line = array();
62
+ $line['LineNumber'] = $item->getItemId();
63
+ $line['ItemKey'] = $item->getSku();
64
+ $line['ActualExtendedPrice'] = number_format($item->getBaseRowTotal(), 2);
65
+ if ($item->getQtyOrdered()) {
66
+ $line['Quantity'] = $item->getQtyOrdered();
67
+ } else {
68
+ $line['Quantity'] = $item->getData('qty');
69
+ }
70
+ $line['ItemDescription'] = $item->getName();
71
+
72
+ // * (blank) : Taxify will assume the item is generally taxable "tangible goods" unless
73
+ // otherwise configured (by ItemKey) in Taxify
74
+ // * "NON" : a generally non taxable item or service
75
+ // * "FR" : Shipping - it is important to identify shipping chrged with this tax code as
76
+ // taxability of shipping differs state to state
77
+ $line['ItemTaxabilityCode'] = $this->getItemTaxabilityCode($item);
78
+
79
+ return $line;
80
+ }
81
+
82
+ public function isRowItemBundle($item)
83
+ {
84
+ if ($item->getProductType() == 'bundle') {
85
+ return true;
86
+ }
87
+
88
+ return false;
89
+ }
90
+
91
+ public function isRowItemFixedBundle($item)
92
+ {
93
+ if (!$this->isRowItemBundle($item)) {
94
+ return false;
95
+ }
96
+
97
+ if ($item->getProduct()->getPriceType() === '1') {
98
+ return true;
99
+ }
100
+
101
+ return false;
102
+ }
103
+
104
+ public function isRowItem($item)
105
+ {
106
+ if ($this->isRowItemBundle($item)) {
107
+ if ($this->isRowItemFixedBundle($item)) {
108
+ return true;
109
+ }
110
+
111
+ return false;
112
+ }
113
+
114
+ if ($item->getData('base_row_total') == 0.00) {
115
+ return false;
116
+ }
117
+
118
+ return true;
119
+ }
120
+
121
+ public function buildShipmentLineItem()
122
+ {
123
+ $line = array();
124
+ $line['LineNumber'] = 0;
125
+ $line['ItemKey'] = 'SHIPPING';
126
+ $line['ActualExtendedPrice'] = $this->getShippingAmount();
127
+ $line['Quantity'] = 1;
128
+ $line['ItemDescription'] = 'Shipping';
129
+ $line['ItemTaxabilityCode'] = 'FR';
130
+
131
+ return $line;
132
+ }
133
+
134
+ public function buildOrderLineItems()
135
+ {
136
+ $lines = array();
137
+ foreach ($this->getMageModel()->getAllItems() as $item) {
138
+ if ($this->isRowItem($item) == false) {
139
+ continue;
140
+ }
141
+
142
+ $lines[] = $this->createLineFromMageItem($item);
143
+ }
144
+ $lines[] = $this->buildShipmentLineItem();
145
+
146
+ $this->request['Lines']['TaxRequestLine'] = $lines;
147
+ }
148
+
149
+ public function build()
150
+ {
151
+ if ($this->order) {
152
+ $this->request['DocumentKey'] = $this->order->getIncrementId();
153
+ } else {
154
+ $this->request['DocumentKey'] = 'q-'. $this->getMageModel()->getId();
155
+ }
156
+
157
+ $originalTimeZone = date_default_timezone_get();
158
+
159
+ date_default_timezone_set('America/Los_Angeles');
160
+ $this->request['TaxDate'] = date('Y-m-d');
161
+ date_default_timezone_set($originalTimeZone);
162
+
163
+ $this->buildOrderLineItems();
164
+ $this->buildDestinationAddress();
165
+ $this->request['IsCommited'] = false;
166
+ $this->request['CustomerKey'] = $this->getMageModel()->getCustomerId();
167
+
168
+ // (blank) : default, consumer
169
+ // "NON" : tax exempt customer – sales tax will not be charged
170
+ // "R" : reseller / wholesale transaction - sales tax will not be charged
171
+ $this->request['CustomerTaxability'] = '';
172
+
173
+ return $this->request;
174
+ }
175
+
176
+ public function convertPercentRate($percent)
177
+ {
178
+ return $percent * 100;
179
+ }
180
+
181
+ public function getTaxByLineNumber($lineNumber)
182
+ {
183
+ $tax = array(
184
+ 'amount' => 0.00,
185
+ 'rate' => '0',
186
+ );
187
+ if (!$this->response) {
188
+ return $tax;
189
+ }
190
+
191
+ if (!isset($this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail)) {
192
+ return $tax;
193
+ }
194
+
195
+ if (is_array($this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail)) {
196
+ foreach ($this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail as $line) {
197
+ if (!isset($line->LineNumber)) {
198
+ continue;
199
+ }
200
+
201
+ if ($line->LineNumber == $lineNumber) {
202
+ $tax['amount'] = $line->SalesTaxAmount;
203
+ $tax['rate'] = $this->convertPercentRate($line->TaxRate);
204
+ }
205
+ }
206
+ }
207
+
208
+ if (isset($this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail->LineNumber)) {
209
+ if ($this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail->LineNumber != $lineNumber) {
210
+ return $tax;
211
+ }
212
+ }
213
+
214
+ if (isset($this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail->TaxRate)) {
215
+ $tax['rate'] = $this->convertPercentRate($this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail->TaxRate);
216
+ }
217
+
218
+ if (isset($this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail->SalesTaxAmount)) {
219
+ $tax['amount'] = $this->response->CalculateTaxResult->TaxLineDetails->TaxLineDetail->SalesTaxAmount;
220
+ }
221
+
222
+ return $tax;
223
+ }
224
+
225
+ }
app/code/local/Vonnda/Taxify/Model/Request/Cancel.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Request_Cancel extends Vonnda_Taxify_Model_Request_Request
4
+ {
5
+
6
+ public $apiMethod = 'CancelTax';
7
+
8
+ public function build()
9
+ {
10
+ $this->request['DocumentKey'] = $this->order->getIncrementId();
11
+ }
12
+
13
+ }
app/code/local/Vonnda/Taxify/Model/Request/Commit.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Request_Commit extends Vonnda_Taxify_Model_Request_Request
4
+ {
5
+
6
+ public $apiMethod = 'CommitTax';
7
+
8
+ public function build()
9
+ {
10
+ $this->request['DocumentKey'] = 'q-'. $this->order->getQuoteId();
11
+ $this->request['CommitedDocumentKey'] = $this->order->getIncrementId();
12
+ }
13
+ }
app/code/local/Vonnda/Taxify/Model/Request/Request.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Request_Request extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ public $order;
7
+ public $request = array();
8
+ public $response;
9
+ public $client;
10
+ public $apiMethod = '';
11
+
12
+ public function __construct()
13
+ {
14
+ $this->client = Mage::getModel('taxify/client');
15
+ }
16
+
17
+ public function loadOrder($order)
18
+ {
19
+ $this->order = $order;
20
+ }
21
+
22
+ public function loadQuote($quote)
23
+ {
24
+ $this->quote = $quote;
25
+ }
26
+
27
+ public function getMageModel()
28
+ {
29
+ if ($this->order) {
30
+ return $this->order;
31
+ } else {
32
+ return $this->quote;
33
+ }
34
+ }
35
+
36
+ public function build()
37
+ {
38
+ }
39
+
40
+ public function send()
41
+ {
42
+ $this->build();
43
+ $this->response = $this->client->request($this->apiMethod, $this->request);
44
+
45
+ return $this->response;
46
+ }
47
+
48
+ public function splitAddr($addr)
49
+ {
50
+ $splitAddr = explode(PHP_EOL, $addr);
51
+ if (!isset($splitAddr[1])) {
52
+ $splitAddr[1] = '';
53
+ }
54
+
55
+ return $splitAddr;
56
+ }
57
+
58
+ public function getRegionCode()
59
+ {
60
+ $shippingAddr = $this->getMageModel()->getShippingAddress();
61
+ $regionId = $shippingAddr->getData('region_id');
62
+ $region = Mage::getModel('directory/region')->load($regionId);
63
+
64
+ return $region->getCode();
65
+ }
66
+
67
+ }
app/code/local/Vonnda/Taxify/Model/Request/Verifyaddress.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Request_Verifyaddress extends Vonnda_Taxify_Model_Request_Request
4
+ {
5
+
6
+ public $apiMethod = 'VerifyAddress';
7
+
8
+ public function build()
9
+ {
10
+ $shippingAddr = $this->order->getShippingAddress();
11
+ $addrParts = $this->splitAddr($shippingAddr->getData('street'));
12
+ $this->request['Street1'] = $addrParts[0];
13
+ $this->request['Street2'] = $addrParts[1];
14
+ $this->request['City'] = $shippingAddr->getData('city');
15
+ $this->request['Region'] = $this->getRegionCode();
16
+ $this->request['PostalCode'] = $shippingAddr->getData('postcode');
17
+ $this->request['Country'] = $shippingAddr->getData('country_id');
18
+ }
19
+
20
+ }
app/code/local/Vonnda/Taxify/Model/Request/Version.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Request_Version extends Vonnda_Taxify_Model_Request_Request
4
+ {
5
+
6
+ public $apiMethod = 'GetVersion';
7
+
8
+ }
app/code/local/Vonnda/Taxify/Model/Sales/.DS_Store ADDED
Binary file
app/code/local/Vonnda/Taxify/Model/Sales/Quote/.DS_Store ADDED
Binary file
app/code/local/Vonnda/Taxify/Model/Sales/Quote/Address/.DS_Store ADDED
Binary file
app/code/local/Vonnda/Taxify/Model/Sales/Quote/Address/Total/Tax.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Vonnda_Taxify_Model_Sales_Quote_Address_Total_Tax extends Mage_Sales_Model_Quote_Address_Total_Tax
4
+ {
5
+ protected $_appliedTaxes = array();
6
+
7
+ public function __construct(){
8
+ $this->setCode('tax');
9
+ }
10
+
11
+ public function collect(Mage_Sales_Model_Quote_Address $address)
12
+ {
13
+ $store = $address->getQuote()->getStore();
14
+
15
+ $address->setTaxAmount(0);
16
+ $address->setBaseTaxAmount(0);
17
+ //$address->setShippingTaxAmount(0);
18
+ //$address->setBaseShippingTaxAmount(0);
19
+ $address->setAppliedTaxes(array());
20
+
21
+ $items = $address->getAllItems();
22
+ if (!count($items)) {
23
+ return $this;
24
+ }
25
+ $custTaxClassId = $address->getQuote()->getCustomerTaxClassId();
26
+
27
+ $taxCalculationModel = Mage::getSingleton('tax/calculation');
28
+ /* @var $taxCalculationModel Mage_Tax_Model_Calculation */
29
+ $request = $taxCalculationModel->getRateRequest(
30
+ $address,
31
+ $address->getQuote()->getBillingAddress(),
32
+ $custTaxClassId,
33
+ $store
34
+ );
35
+
36
+ // Added by Mark Sanborn
37
+ $data = $address->getQuote()->getShippingAddress()->getData();
38
+ if ($data) {
39
+ //if (in_array('street', array_keys($data)) && $data['street'] != '' && in_array('city', array_keys($data))) {
40
+ if (in_array('postcode', array_keys($data)) && $data['postcode'] != '') {
41
+ $calculate = Mage::getModel('taxify/request_calculate');
42
+ $calculate->loadQuote($address->getQuote());
43
+ $calculate->send();
44
+
45
+ } else {
46
+ return $this;
47
+ }
48
+ } else {
49
+ return $this;
50
+ }
51
+
52
+ foreach ($items as $item) {
53
+ $discountBefore = $item->getDiscountAmount();
54
+ $baseDiscountBefore = $item->getBaseDiscountAmount();
55
+
56
+ $rate = $taxCalculationModel->getRate(
57
+ $request->setProductClassId($item->getProduct()->getTaxClassId())
58
+ );
59
+
60
+ // Added by Mark Sanborn
61
+ $lineTax = $calculate->getTaxByLineNumber($item->getId());
62
+ $item->setTaxPercent($lineTax['rate']);
63
+ $item->setTaxAmount($lineTax['amount']);
64
+ //$item->calcTaxAmount();
65
+
66
+ if ($discountBefore != $item->getDiscountAmount()) {
67
+ $address->setDiscountAmount(
68
+ $address->getDiscountAmount() + ($item->getDiscountAmount() - $discountBefore)
69
+ );
70
+ $address->setBaseDiscountAmount(
71
+ $address->getBaseDiscountAmount() + ($item->getBaseDiscountAmount() - $baseDiscountBefore)
72
+ );
73
+
74
+ $address->setGrandTotal(
75
+ $address->getGrandTotal() - ($item->getDiscountAmount() - $discountBefore)
76
+ );
77
+ $address->setBaseGrandTotal(
78
+ $address->getBaseGrandTotal() - ($item->getBaseDiscountAmount() - $baseDiscountBefore)
79
+ );
80
+ }
81
+
82
+ $itemTaxAmount = $item->getTaxAmount() + $item->getDiscountTaxCompensation();
83
+ $address->setTaxAmount($address->getTaxAmount() + $itemTaxAmount);
84
+ $itemBaseTaxAmount = $item->getBaseTaxAmount() + $item->getBaseDiscountTaxCompensation();
85
+ $address->setBaseTaxAmount($address->getBaseTaxAmount() + $itemBaseTaxAmount);
86
+
87
+ $applied = $taxCalculationModel->getAppliedRates($request);
88
+ $this->_saveAppliedTaxes(
89
+ $address,
90
+ $applied,
91
+ $item->getTaxAmount(),
92
+ $item->getBaseTaxAmount(),
93
+ $rate
94
+ );
95
+ }
96
+
97
+
98
+ $shippingTaxClass = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $store);
99
+
100
+ $shippingTax = 0;
101
+ $shippingBaseTax = 0;
102
+
103
+ if ($shippingTaxClass) {
104
+ if ($rate = $taxCalculationModel->getRate($request->setProductClassId($shippingTaxClass))) {
105
+ if (!Mage::helper('tax')->shippingPriceIncludesTax()) {
106
+ $shippingTax = $address->getShippingAmount() * $rate/100;
107
+ $shippingBaseTax= $address->getBaseShippingAmount() * $rate/100;
108
+ } else {
109
+ $shippingTax = $address->getShippingTaxAmount();
110
+ $shippingBaseTax= $address->getBaseShippingTaxAmount();
111
+ }
112
+
113
+ $shippingTax = $store->roundPrice($shippingTax);
114
+ $shippingBaseTax= $store->roundPrice($shippingBaseTax);
115
+
116
+ $address->setTaxAmount($address->getTaxAmount() + $shippingTax);
117
+ $address->setBaseTaxAmount($address->getBaseTaxAmount() + $shippingBaseTax);
118
+
119
+ $this->_saveAppliedTaxes(
120
+ $address,
121
+ $taxCalculationModel->getAppliedRates($request),
122
+ $shippingTax,
123
+ $shippingBaseTax,
124
+ $rate
125
+ );
126
+ }
127
+ }
128
+
129
+ // Added by Mark Sanborn to add shipping tax from Taxify
130
+ // ---------------------------
131
+ $shippingLineItemNumber = 0;
132
+ $lineTax = $calculate->getTaxByLineNumber($shippingLineItemNumber);
133
+ $shippingTax = $lineTax['amount'];
134
+ $shippingBaseTax = $lineTax['amount'];
135
+ $address->setTaxAmount($address->getTaxAmount() + $shippingTax);
136
+ $address->setBaseTaxAmount($address->getBaseTaxAmount() + $shippingBaseTax);
137
+
138
+ $this->_saveAppliedTaxes(
139
+ $address,
140
+ $taxCalculationModel->getAppliedRates($request),
141
+ $shippingTax,
142
+ $shippingBaseTax,
143
+ $rate
144
+ );
145
+ // ---------------------------
146
+
147
+ if (!Mage::helper('tax')->shippingPriceIncludesTax()) {
148
+ $address->setShippingTaxAmount($shippingTax);
149
+ $address->setBaseShippingTaxAmount($shippingBaseTax);
150
+ }
151
+
152
+ $address->setGrandTotal($address->getGrandTotal() + $address->getTaxAmount());
153
+ $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseTaxAmount());
154
+ return $this;
155
+ }
156
+
157
+ protected function _saveAppliedTaxes(Mage_Sales_Model_Quote_Address $address, $applied, $amount, $baseAmount, $rate)
158
+ {
159
+ $previouslyAppliedTaxes = $address->getAppliedTaxes();
160
+ $process = count($previouslyAppliedTaxes);
161
+
162
+ foreach ($applied as $row) {
163
+ if (!isset($previouslyAppliedTaxes[$row['id']])) {
164
+ $row['process'] = $process;
165
+ $row['amount'] = 0;
166
+ $row['base_amount'] = 0;
167
+ $previouslyAppliedTaxes[$row['id']] = $row;
168
+ }
169
+
170
+ if (!is_null($row['percent'])) {
171
+ $row['percent'] = $row['percent'] ? $row['percent'] : 1;
172
+ $rate = $rate ? $rate : 1;
173
+
174
+ $appliedAmount = $amount/$rate*$row['percent'];
175
+ $baseAppliedAmount = $baseAmount/$rate*$row['percent'];
176
+ } else {
177
+ $appliedAmount = 0;
178
+ $baseAppliedAmount = 0;
179
+ foreach ($row['rates'] as $rate) {
180
+ $appliedAmount += $rate['amount'];
181
+ $baseAppliedAmount += $rate['base_amount'];
182
+ }
183
+ }
184
+
185
+
186
+ if ($appliedAmount || $previouslyAppliedTaxes[$row['id']]['amount']) {
187
+ $previouslyAppliedTaxes[$row['id']]['amount'] += $appliedAmount;
188
+ $previouslyAppliedTaxes[$row['id']]['base_amount'] += $baseAppliedAmount;
189
+ } else {
190
+ unset($previouslyAppliedTaxes[$row['id']]);
191
+ }
192
+ }
193
+ $address->setAppliedTaxes($previouslyAppliedTaxes);
194
+ }
195
+
196
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
197
+ {
198
+ $applied = $address->getAppliedTaxes();
199
+ $store = $address->getQuote()->getStore();
200
+ $amount = $address->getTaxAmount();
201
+
202
+ if (($amount!=0) || (Mage::helper('tax')->displayZeroTax($store))) {
203
+ $address->addTotal(array(
204
+ 'code'=>$this->getCode(),
205
+ 'title'=>Mage::helper('sales')->__('Tax'),
206
+ 'full_info'=>$applied ? $applied : array(),
207
+ 'value'=>$amount
208
+ ));
209
+ }
210
+ return $this;
211
+ }
212
+ }
213
+
app/code/local/Vonnda/Taxify/etc/config.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Vonnda_Taxify>
5
+ <version>0.1.0</version>
6
+ </Vonnda_Taxify>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <taxify>
11
+ <class>Vonnda_Taxify_Helper</class>
12
+ </taxify>
13
+ </helpers>
14
+ <models>
15
+ <taxify>
16
+ <class>Vonnda_Taxify_Model</class>
17
+ </taxify>
18
+ </models>
19
+ <events>
20
+ <sales_quote_collect_totals_before>
21
+ <observers>
22
+ <tax>
23
+ <class>Vonnda_Taxify_Model_Observer</class>
24
+ <method>quoteCollectTotalsBefore</method>
25
+ </tax>
26
+ </observers>
27
+ </sales_quote_collect_totals_before>
28
+ <sales_order_place_after>
29
+ <observers>
30
+ <tax_sales_order_observer>
31
+ <type>singleton</type>
32
+ <class>Vonnda_Taxify_Model_Observer</class>
33
+ <method>salesOrderPlaceAfter</method>
34
+ </tax_sales_order_observer>
35
+ </observers>
36
+ </sales_order_place_after>
37
+ <sales_order_payment_cancel>
38
+ <observers>
39
+ <tax_sales_order_payment_cancel_observer>
40
+ <type>singleton</type>
41
+ <class>Vonnda_Taxify_Model_Observer</class>
42
+ <method>salesOrderCancelAfter</method>
43
+ </tax_sales_order_payment_cancel_observer>
44
+ </observers>
45
+ </sales_order_payment_cancel>
46
+ </events>
47
+ </global>
48
+ <default>
49
+ <tax>
50
+ <taxify>
51
+ <enabled>0</enabled>
52
+ <test_mode>0</test_mode>
53
+ </taxify>
54
+ </tax>
55
+ </default>
56
+ </config>
app/code/local/Vonnda/Taxify/etc/system.xml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <tax translate="label" module="tax">
5
+ <class>separator-top</class>
6
+ <label>Tax</label>
7
+ <tab>sales</tab>
8
+ <sort_order>303</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <classes translate="label">
14
+ <label>Tax Classes</label>
15
+ <sort_order>10</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <shipping_tax_class translate="label">
21
+ <label>Tax Class for Shipping</label>
22
+ <frontend_type>select</frontend_type>
23
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
24
+ <sort_order>10</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>0</show_in_store>
28
+ </shipping_tax_class>
29
+ </fields>
30
+ </classes>
31
+ <taxify translate="label">
32
+ <label>Taxify Settings</label>
33
+ <sort_order>20</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <fields>
38
+ <enabled translate="label comment">
39
+ <label>Enabled</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_yesno</source_model>
42
+ <sort_order>10</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </enabled>
47
+ <password translate="label">
48
+ <label>API Key</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>30</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <comment>Taxify API Key</comment>
55
+ </password>
56
+ <test_mode translate="label comment">
57
+ <label>Test Mode</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_yesno</source_model>
60
+ <sort_order>50</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ </test_mode>
65
+ </fields>
66
+ </taxify>
67
+ </groups>
68
+ </tax>
69
+ </sections>
70
+ </config>
app/code/local/Vonnda/Taxify/tests/.DS_Store ADDED
Binary file
app/code/local/Vonnda/Taxify/tests/Request/CalculateTest.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once '../../app/Mage.php'; umask(0); Mage::app('default');
4
+
5
+ class CalculateTest extends PHPUnit_Framework_TestCase
6
+ {
7
+
8
+ public function setUp()
9
+ {
10
+ $this->calculateSuccess = unserialize(file_get_contents(__DIR__. '/../fixtures/calculateSuccess.txt'));
11
+ $this->calculateMultiSimpleProductSuccess = unserialize(file_get_contents(__DIR__. '/../fixtures/calculateMultiSimpleProductSuccess.txt'));
12
+ }
13
+
14
+
15
+ public function testCreateLineFromMageItem()
16
+ {
17
+ $calculate = $this->getMock('Vonnda_Taxify_Model_Request_Calculate', array('getItemTaxabilityCode'));
18
+ $calculate->expects($this->any())
19
+ ->method('getItemTaxabilityCode')
20
+ ->will($this->returnValue(''));
21
+
22
+ $item = $this->getMock('item', array('getItemId', 'getSku', 'getBaseRowTotal',
23
+ 'getQtyOrdered', 'getData', 'getName'));
24
+
25
+ $item->expects($this->any())
26
+ ->method('getItemId')
27
+ ->will($this->returnValue(123));
28
+
29
+ $item->expects($this->any())
30
+ ->method('getSku')
31
+ ->will($this->returnValue('abc123'));
32
+
33
+ $item->expects($this->any())
34
+ ->method('getData')
35
+ ->with($this->equalTo('qty'))
36
+ ->will($this->returnValue('1.0000'));
37
+
38
+ $item->expects($this->any())
39
+ ->method('getName')
40
+ ->will($this->returnValue('This is a foo'));
41
+
42
+ $resp = $calculate->createLineFromMageItem($item);
43
+ $this->assertEquals(123, $resp['LineNumber']);
44
+ $this->assertEquals('abc123', $resp['ItemKey']);
45
+ $this->assertEquals('1', $resp['Quantity']);
46
+ $this->assertEquals('This is a foo', $resp['ItemDescription']);
47
+ }
48
+
49
+ public function testGetTaxByLineNumber()
50
+ {
51
+ $calculate = Mage::getModel('taxify/request_calculate');
52
+ $calculate->response = $this->calculateSuccess;
53
+ $resp = $calculate->getTaxByLineNumber(2539);
54
+
55
+ $this->assertEquals(8.75, $resp['rate']);
56
+ $this->assertEquals(39.375, $resp['amount']);
57
+ }
58
+
59
+ public function testGetTaxByLineNumberWithMultipleProducts()
60
+ {
61
+ $calculate = Mage::getModel('taxify/request_calculate');
62
+ $calculate->response = $this->calculateMultiSimpleProductSuccess;
63
+ $resp = $calculate->getTaxByLineNumber(2543);
64
+
65
+ $this->assertEquals(8.75, $resp['rate']);
66
+ $this->assertEquals(25.8125, $resp['amount']);
67
+ }
68
+
69
+ public function testItemTaxabilityCode()
70
+ {
71
+ $calculate = Mage::getModel('taxify/request_calculate');
72
+
73
+ $product = $this->getMock('product', array('getTaxClassId'));
74
+ $product->method('getTaxClassId')
75
+ ->will($this->returnValue(6));
76
+
77
+ $item = $this->getMock('item', array('getProduct'));
78
+ $item->method('getProduct')
79
+ ->will($this->returnValue($product));
80
+
81
+ $resp = $calculate->getItemTaxabilityCode($item);
82
+
83
+ $this->assertEquals('NON', $resp);
84
+
85
+
86
+ $calculate = Mage::getModel('taxify/request_calculate');
87
+
88
+ $product = $this->getMock('product', array('getTaxClassId'));
89
+ $product->method('getTaxClassId')
90
+ ->will($this->returnValue(0));
91
+
92
+ $item = $this->getMock('item', array('getProduct'));
93
+ $item->method('getProduct')
94
+ ->will($this->returnValue($product));
95
+
96
+ $resp = $calculate->getItemTaxabilityCode($item);
97
+
98
+ $this->assertEquals('NON', $resp);
99
+ }
100
+
101
+ }
app/code/local/Vonnda/Taxify/tests/Request/CancelTest.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once '../../app/Mage.php'; umask(0); Mage::app('default');
4
+
5
+ class CancelTest extends PHPUnit_Framework_TestCase
6
+ {
7
+
8
+ public function testAssert()
9
+ {
10
+ $client = Mage::getModel('taxify/commit');
11
+ $this->assertTrue(true);
12
+ }
13
+
14
+ }
app/code/local/Vonnda/Taxify/tests/Request/CommitTest.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once '../../app/Mage.php'; umask(0); Mage::app('default');
4
+
5
+ class CommitTest extends PHPUnit_Framework_TestCase
6
+ {
7
+
8
+ public function testAssert()
9
+ {
10
+ $client = Mage::getModel('taxify/commit');
11
+ $this->assertTrue(true);
12
+ }
13
+
14
+ }
app/code/local/Vonnda/Taxify/tests/SampleTest.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once '../../app/Mage.php'; umask(0); Mage::app('default');
4
+
5
+ class ClientTest extends PHPUnit_Framework_TestCase
6
+ {
7
+ public function testAssert()
8
+ {
9
+ $client = Mage::getModel('taxify/client');
10
+ $this->assertTrue(true);
11
+ }
12
+ }
app/code/local/Vonnda/Taxify/tests/fixtures/calculateMultiSimpleProductSuccess.txt ADDED
@@ -0,0 +1 @@
 
1
+ O:8:"stdClass":1:{s:18:"CalculateTaxResult";O:8:"stdClass":9:{s:11:"DocumentKey";s:5:"q-720";s:14:"SalesTaxAmount";d:32.380000000000003;s:22:"TaxJurisdictionSummary";s:37:"CA, SAN FRANCISCO CNTY, SAN FRANCISCO";s:18:"DestinationAddress";O:8:"stdClass":14:{s:9:"FirstName";s:4:"Mark";s:8:"LastName";s:7:"Sanborn";s:7:"Company";s:0:"";s:7:"Street1";s:11:"660 York St";s:7:"Street2";s:7:"Ste 202";s:4:"City";s:13:"San Francisco";s:6:"County";s:13:"San Francisco";s:6:"Region";s:2:"CA";s:10:"PostalCode";s:10:"94110-2102";s:7:"Country";s:2:"US";s:5:"Email";s:23:"mark.sanborn@vonnda.com";s:5:"Phone";s:14:"(707) 726-2676";s:25:"ResidentialOrBusinessType";s:8:"Business";s:16:"ValidationStatus";s:12:"NotValidated";}s:13:"OriginAddress";O:8:"stdClass":14:{s:9:"FirstName";s:0:"";s:8:"LastName";s:0:"";s:7:"Company";s:0:"";s:7:"Street1";s:13:"1877 Broadway";s:7:"Street2";s:0:"";s:4:"City";s:7:"Boulder";s:6:"County";s:7:"Boulder";s:6:"Region";s:2:"CO";s:10:"PostalCode";s:10:"80302-5214";s:7:"Country";s:2:"US";s:5:"Email";s:0:"";s:5:"Phone";s:0:"";s:25:"ResidentialOrBusinessType";s:7:"Unknown";s:16:"ValidationStatus";s:9:"Validated";}s:22:"TaxJurisdictionDetails";O:8:"stdClass":1:{s:21:"TaxJurisdictionDetail";a:2:{i:0;O:8:"stdClass":6:{s:9:"AppliedTo";s:18:"GeneralMerchandise";s:16:"JurisdictionType";s:5:"State";s:16:"JurisdictionName";s:2:"CA";s:19:"JurisdictionTaxRate";d:0.074999999999999997;s:21:"JurisdictionTaxAmount";d:27.75;s:18:"ExtendedProperties";O:8:"stdClass":0:{}}i:1;O:8:"stdClass":6:{s:9:"AppliedTo";s:18:"GeneralMerchandise";s:16:"JurisdictionType";s:6:"County";s:16:"JurisdictionName";s:13:"San Francisco";s:19:"JurisdictionTaxRate";d:0.012500000000000001;s:21:"JurisdictionTaxAmount";d:4.6299999999999999;s:18:"ExtendedProperties";O:8:"stdClass":0:{}}}}s:14:"TaxLineDetails";O:8:"stdClass":1:{s:13:"TaxLineDetail";a:2:{i:0;O:8:"stdClass":7:{s:10:"LineNumber";s:4:"2543";s:7:"ItemKey";s:6:"ace002";s:6:"Amount";d:295;s:12:"ExemptAmount";d:0;s:7:"TaxRate";d:0.087499999999999994;s:14:"SalesTaxAmount";d:25.8125;s:18:"ExtendedProperties";O:8:"stdClass":0:{}}i:1;O:8:"stdClass":7:{s:10:"LineNumber";s:4:"2544";s:7:"ItemKey";s:6:"acj004";s:6:"Amount";d:75;s:12:"ExemptAmount";d:0;s:7:"TaxRate";d:0.087499999999999994;s:14:"SalesTaxAmount";d:6.5625;s:18:"ExtendedProperties";O:8:"stdClass":0:{}}}}s:18:"ExtendedProperties";O:8:"stdClass":0:{}s:14:"ResponseStatus";s:7:"Success";}}
app/code/local/Vonnda/Taxify/tests/fixtures/calculateSuccess.txt ADDED
@@ -0,0 +1 @@
 
1
+ O:8:"stdClass":1:{s:18:"CalculateTaxResult";O:8:"stdClass":9:{s:11:"DocumentKey";s:5:"q-716";s:14:"SalesTaxAmount";d:39.380000000000003;s:22:"TaxJurisdictionSummary";s:37:"CA, SAN FRANCISCO CNTY, SAN FRANCISCO";s:18:"DestinationAddress";O:8:"stdClass":14:{s:9:"FirstName";s:4:"Mark";s:8:"LastName";s:7:"Sanborn";s:7:"Company";s:0:"";s:7:"Street1";s:11:"660 York St";s:7:"Street2";s:7:"Ste 202";s:4:"City";s:13:"San Francisco";s:6:"County";s:13:"San Francisco";s:6:"Region";s:2:"CA";s:10:"PostalCode";s:10:"94110-2102";s:7:"Country";s:2:"US";s:5:"Email";s:23:"mark.sanborn@vonnda.com";s:5:"Phone";s:14:"(707) 726-2676";s:25:"ResidentialOrBusinessType";s:8:"Business";s:16:"ValidationStatus";s:12:"NotValidated";}s:13:"OriginAddress";O:8:"stdClass":14:{s:9:"FirstName";s:0:"";s:8:"LastName";s:0:"";s:7:"Company";s:0:"";s:7:"Street1";s:13:"1877 Broadway";s:7:"Street2";s:0:"";s:4:"City";s:7:"Boulder";s:6:"County";s:7:"Boulder";s:6:"Region";s:2:"CO";s:10:"PostalCode";s:10:"80302-5214";s:7:"Country";s:2:"US";s:5:"Email";s:0:"";s:5:"Phone";s:0:"";s:25:"ResidentialOrBusinessType";s:7:"Unknown";s:16:"ValidationStatus";s:9:"Validated";}s:22:"TaxJurisdictionDetails";O:8:"stdClass":1:{s:21:"TaxJurisdictionDetail";a:2:{i:0;O:8:"stdClass":6:{s:9:"AppliedTo";s:18:"GeneralMerchandise";s:16:"JurisdictionType";s:5:"State";s:16:"JurisdictionName";s:2:"CA";s:19:"JurisdictionTaxRate";d:0.074999999999999997;s:21:"JurisdictionTaxAmount";d:33.75;s:18:"ExtendedProperties";O:8:"stdClass":0:{}}i:1;O:8:"stdClass":6:{s:9:"AppliedTo";s:18:"GeneralMerchandise";s:16:"JurisdictionType";s:6:"County";s:16:"JurisdictionName";s:13:"San Francisco";s:19:"JurisdictionTaxRate";d:0.012500000000000001;s:21:"JurisdictionTaxAmount";d:5.6299999999999999;s:18:"ExtendedProperties";O:8:"stdClass":0:{}}}}s:14:"TaxLineDetails";O:8:"stdClass":1:{s:13:"TaxLineDetail";O:8:"stdClass":7:{s:10:"LineNumber";s:4:"2539";s:7:"ItemKey";s:6:"ace001";s:6:"Amount";d:450;s:12:"ExemptAmount";d:0;s:7:"TaxRate";d:0.087499999999999994;s:14:"SalesTaxAmount";d:39.375;s:18:"ExtendedProperties";O:8:"stdClass":0:{}}}s:18:"ExtendedProperties";O:8:"stdClass":0:{}s:14:"ResponseStatus";s:7:"Success";}}
app/etc/modules/Vonnda_Taxify.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Vonnda_Taxify>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Vonnda_Taxify>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Taxify_Sales_Tax_Rates_and_Filing</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License V2</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Connect Taxify to deliver accurate, automated U.S. sales tax rates, reports, filings and remittance.</summary>
10
+ <description>Taxify ensures that your Magento store collects, reports and remits accurate sales taxes for all Federal, state, and local jurisdictions throughout the United States</description>
11
+ <notes>Initial Public Release</notes>
12
+ <authors><author><name>Vonnda Development</name><user>Vonnda</user><email>info@vonnda.com</email></author></authors>
13
+ <date>2014-12-15</date>
14
+ <time>23:48:51</time>
15
+ <contents><target name="magelocal"><dir name="Vonnda"><dir name="Taxify"><dir name="Helper"><file name="Data.php" hash="e32968cf048260b74e517d3b89a2c958"/></dir><dir name="Model"><file name="Client.php" hash="cdf70e673f02fef1f6151767a2192a6d"/><file name="Config.php" hash="2db3425ee59a162dedf5ef8a4fa655e3"/><file name="Observer.php" hash="52d7d7e74b2a0676b58ad4262e26fc49"/><dir name="Request"><file name="Calculate.php" hash="04991b60a6d275dce10dff29b3587242"/><file name="Cancel.php" hash="2d1eadf52123f4db8151832502d8ba01"/><file name="Commit.php" hash="3ec21b8860ab14f3eadc7bb9e53c02c1"/><file name="Request.php" hash="c4e92c7d67e249750508017b74d0cc3c"/><file name="Verifyaddress.php" hash="fff9f9d0ac574ac185916afaf7bdde0c"/><file name="Version.php" hash="ff41825cbc827abed4e0a2597e67ee67"/></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Tax.php" hash="8f7ffa65d9d537e4558329d46f53b47a"/></dir><file name=".DS_Store" hash="597d6465d3bf56596aa5d8b6d9cea71a"/></dir><file name=".DS_Store" hash="5121c407478e52c47edd5676e190639f"/></dir><file name=".DS_Store" hash="53382ecfa4ef21cc00d74e43b14e2af3"/></dir><file name=".DS_Store" hash="7467329ac245e0cd056b0f6d16c2f265"/></dir><dir name="etc"><file name="config.xml" hash="ec35149e731c5954e683bcb2ab80900e"/><file name="system.xml" hash="f99743421bbf8bf7c4d19dca7a4b0d53"/></dir><dir name="tests"><dir name="Request"><file name="CalculateTest.php" hash="1e713f75e1d9c31f345785a01ed5514b"/><file name="CancelTest.php" hash="b8ba6f0004d493f72ce22c66375ffdac"/><file name="CommitTest.php" hash="59c4473ba919047dd821e05b335dbc38"/></dir><file name="SampleTest.php" hash="32606c8d8b84d95aec73bdeb1c03ca1e"/><dir name="fixtures"><file name="calculateMultiSimpleProductSuccess.txt" hash="6d7426310bebbcb0b758697035a4e8f7"/><file name="calculateSuccess.txt" hash="892ebdae0cd70bcf36cc34be2d21da76"/></dir><file name=".DS_Store" hash="602e058d9d6a6e59e71142f3530a0908"/></dir><file name=".DS_Store" hash="84b97966f4cf3cd32c9e809b24e70b4f"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vonnda_Taxify.xml" hash="2a0fff9753a9d1d84e4f10db680d30e3"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>5.6.2</max></php></required></dependencies>
18
+ </package>