Version Notes
Initial Public Release
Download this release
Release Info
Developer | Vonnda Development |
Extension | Taxify_Sales_Tax_Rates_and_Filing |
Version | 0.1.1 |
Comparing to | |
See all releases |
Code changes from version 0.1.0 to 0.1.1
- app/code/local/Vonnda/Taxify/.DS_Store +0 -0
- app/code/local/Vonnda/Taxify/Block/Adminhtml/Tax/Class/Edit/Form.php +24 -0
- app/code/local/Vonnda/Taxify/Helper/Data.php +34 -1
- app/code/local/Vonnda/Taxify/Model/.DS_Store +0 -0
- app/code/local/Vonnda/Taxify/Model/Client.php +1 -1
- app/code/local/Vonnda/Taxify/Model/Feed.php +163 -0
- app/code/local/Vonnda/Taxify/Model/Request/.Calculate.php.swp +0 -0
- app/code/local/Vonnda/Taxify/Model/Request/Calculate.php +68 -3
- app/code/local/Vonnda/Taxify/Model/Resource/Mysql4/Setup.php +6 -0
- app/code/local/Vonnda/Taxify/Model/Sales/.DS_Store +0 -0
- app/code/local/Vonnda/Taxify/Model/Sales/Quote/.DS_Store +0 -0
- app/code/local/Vonnda/Taxify/Model/Sales/Quote/Address/.DS_Store +0 -0
- app/code/local/Vonnda/Taxify/etc/config.xml +52 -1
- app/code/local/Vonnda/Taxify/sql/taxify_setup/mysql4-install-0.1.1.php +25 -0
- app/code/local/Vonnda/Taxify/tests/.DS_Store +0 -0
- app/code/local/Vonnda/Taxify/tests/Helper/DataTest.php +18 -0
- app/code/local/Vonnda/Taxify/tests/Request/CalculateTest.php +58 -0
- app/etc/modules/Vonnda_Taxify.xml +1 -1
- package.xml +4 -4
app/code/local/Vonnda/Taxify/.DS_Store
DELETED
Binary file
|
app/code/local/Vonnda/Taxify/Block/Adminhtml/Tax/Class/Edit/Form.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Vonnda_Taxify_Block_Adminhtml_Tax_Class_Edit_Form extends Mage_Adminhtml_Block_Tax_Class_Edit_Form
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _prepareForm()
|
7 |
+
{
|
8 |
+
parent::_prepareForm();
|
9 |
+
$fieldset = $this->getForm()->getElement('base_fieldset');
|
10 |
+
|
11 |
+
$model = Mage::registry('tax_class');
|
12 |
+
$fieldset->addField('taxify_code', 'select', array(
|
13 |
+
'name' => 'taxify_customer_taxability',
|
14 |
+
'label' => Mage::helper('taxify')->__('Taxify Customer Taxability'),
|
15 |
+
'required' => true,
|
16 |
+
'values' => Mage::helper('taxify')->getCustomerTaxabilityOptions(),
|
17 |
+
'value' => $model->getTaxifyCustomerTaxability(),
|
18 |
+
|
19 |
+
));
|
20 |
+
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
app/code/local/Vonnda/Taxify/Helper/Data.php
CHANGED
@@ -2,4 +2,37 @@
|
|
2 |
|
3 |
class Vonnda_Taxify_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
class Vonnda_Taxify_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
+
public function getCustomerTaxabilityOptions()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
'' => 'Default',
|
9 |
+
'R' => 'Reseller / Wholesale',
|
10 |
+
'NON' => 'Tax Exempt',
|
11 |
+
);
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getTaxifyCustomerTaxability($customerId)
|
15 |
+
{
|
16 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
17 |
+
if (!$customer->getId()) {
|
18 |
+
return '';
|
19 |
+
}
|
20 |
+
|
21 |
+
$taxId = $customer->getTaxClassId();
|
22 |
+
$tax = Mage::getModel('tax/class')->load($taxId);
|
23 |
+
|
24 |
+
return $tax->getTaxifyCustomerTaxability();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getTaxifyCustomerTaxabilityFromGroup($groupId)
|
28 |
+
{
|
29 |
+
$group = Mage::getModel('customer/group')->load($groupId);
|
30 |
+
if (!$group->getTaxClassId()) {
|
31 |
+
return '';
|
32 |
+
}
|
33 |
+
|
34 |
+
$tax = Mage::getModel('tax/class')->load($group->getTaxClassId());
|
35 |
+
|
36 |
+
return $tax->getTaxifyCustomerTaxability();
|
37 |
+
}
|
38 |
+
}
|
app/code/local/Vonnda/Taxify/Model/.DS_Store
DELETED
Binary file
|
app/code/local/Vonnda/Taxify/Model/Client.php
CHANGED
@@ -15,7 +15,6 @@ class Vonnda_Taxify_Model_Client extends Mage_Core_Model_Abstract
|
|
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,
|
@@ -45,6 +44,7 @@ class Vonnda_Taxify_Model_Client extends Mage_Core_Model_Abstract
|
|
45 |
|
46 |
public function logTransaction()
|
47 |
{
|
|
|
48 |
$this->log('REQUEST:');
|
49 |
$this->log($this->request);
|
50 |
$this->log('RESPONSE:');
|
15 |
{
|
16 |
$this->config = Mage::getModel('taxify/config');
|
17 |
$this->url = $this->config->getApiUrl(). '?wsdl';
|
|
|
18 |
|
19 |
$this->soapClient = new SoapClient($this->url, array(
|
20 |
'trace' => 1,
|
44 |
|
45 |
public function logTransaction()
|
46 |
{
|
47 |
+
$this->log('URL:'. $this->url);
|
48 |
$this->log('REQUEST:');
|
49 |
$this->log($this->request);
|
50 |
$this->log('RESPONSE:');
|
app/code/local/Vonnda/Taxify/Model/Feed.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Vonnda_Taxify_Model_Feed extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public $module = 'taxify';
|
7 |
+
|
8 |
+
const XML_USE_HTTPS_PATH = 'taxify/feed/use_https';
|
9 |
+
const XML_FEED_URL_PATH = 'taxify/feed/url';
|
10 |
+
const XML_FREQUENCY_PATH = 'taxify/feed/frequency';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Feed url
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_feedUrl;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Init model
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
protected function _construct()
|
24 |
+
{
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Retrieve feed url
|
29 |
+
*
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getFeedUrl()
|
33 |
+
{
|
34 |
+
if (is_null($this->_feedUrl)) {
|
35 |
+
$this->_feedUrl = (Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://')
|
36 |
+
. Mage::getStoreConfig(self::XML_FEED_URL_PATH);
|
37 |
+
}
|
38 |
+
return $this->_feedUrl;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Check feed for modification
|
43 |
+
*
|
44 |
+
* @return Mage_AdminNotification_Model_Feed
|
45 |
+
*/
|
46 |
+
public function checkUpdate()
|
47 |
+
{
|
48 |
+
if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
$feedData = array();
|
53 |
+
|
54 |
+
$feedXml = $this->getFeedData();
|
55 |
+
|
56 |
+
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
|
57 |
+
foreach ($feedXml->channel->item as $item) {
|
58 |
+
$feedData[] = array(
|
59 |
+
'severity' => (int)$item->severity,
|
60 |
+
'date_added' => $this->getDate((string)$item->pubDate),
|
61 |
+
'title' => (string)$item->title,
|
62 |
+
'description' => (string)$item->description,
|
63 |
+
'url' => (string)$item->link,
|
64 |
+
);
|
65 |
+
}
|
66 |
+
|
67 |
+
if ($feedData) {
|
68 |
+
Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
72 |
+
$this->setLastUpdate();
|
73 |
+
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Retrieve DB date from RSS date
|
79 |
+
*
|
80 |
+
* @param string $rssDate
|
81 |
+
* @return string YYYY-MM-DD YY:HH:SS
|
82 |
+
*/
|
83 |
+
public function getDate($rssDate)
|
84 |
+
{
|
85 |
+
return gmdate('Y-m-d H:i:s', strtotime($rssDate));
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Retrieve Update Frequency
|
90 |
+
*
|
91 |
+
* @return int
|
92 |
+
*/
|
93 |
+
public function getFrequency()
|
94 |
+
{
|
95 |
+
return Mage::getStoreConfig(self::XML_FREQUENCY_PATH) * 3600;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Retrieve Last update time
|
100 |
+
*
|
101 |
+
* @return int
|
102 |
+
*/
|
103 |
+
public function getLastUpdate()
|
104 |
+
{
|
105 |
+
return Mage::app()->loadCache($this->module. '_admin_notifications_lastcheck');
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Set last update time (now)
|
110 |
+
*
|
111 |
+
* @return Mage_AdminNotification_Model_Feed
|
112 |
+
*/
|
113 |
+
public function setLastUpdate()
|
114 |
+
{
|
115 |
+
Mage::app()->saveCache(time(), $this->module. '_admin_notifications_lastcheck');
|
116 |
+
|
117 |
+
return $this;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Retrieve feed data as XML element
|
122 |
+
*
|
123 |
+
* @return SimpleXMLElement
|
124 |
+
*/
|
125 |
+
public function getFeedData()
|
126 |
+
{
|
127 |
+
$curl = new Varien_Http_Adapter_Curl();
|
128 |
+
$curl->setConfig(array(
|
129 |
+
'timeout' => 2
|
130 |
+
));
|
131 |
+
$curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
|
132 |
+
$data = $curl->read();
|
133 |
+
if ($data === false) {
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
$data = preg_split('/^\r?$/m', $data, 2);
|
137 |
+
$data = trim($data[1]);
|
138 |
+
$curl->close();
|
139 |
+
|
140 |
+
try {
|
141 |
+
$xml = new SimpleXMLElement($data);
|
142 |
+
}
|
143 |
+
catch (Exception $e) {
|
144 |
+
return false;
|
145 |
+
}
|
146 |
+
|
147 |
+
return $xml;
|
148 |
+
}
|
149 |
+
|
150 |
+
public function getFeedXml()
|
151 |
+
{
|
152 |
+
try {
|
153 |
+
$data = $this->getFeedData();
|
154 |
+
$xml = new SimpleXMLElement($data);
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?>');
|
158 |
+
}
|
159 |
+
|
160 |
+
return $xml;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
app/code/local/Vonnda/Taxify/Model/Request/.Calculate.php.swp
ADDED
Binary file
|
app/code/local/Vonnda/Taxify/Model/Request/Calculate.php
CHANGED
@@ -143,7 +143,72 @@ class Vonnda_Taxify_Model_Request_Calculate extends Vonnda_Taxify_Model_Request_
|
|
143 |
}
|
144 |
$lines[] = $this->buildShipmentLineItem();
|
145 |
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
public function build()
|
@@ -160,7 +225,7 @@ class Vonnda_Taxify_Model_Request_Calculate extends Vonnda_Taxify_Model_Request_
|
|
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();
|
@@ -168,7 +233,7 @@ class Vonnda_Taxify_Model_Request_Calculate extends Vonnda_Taxify_Model_Request_
|
|
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['
|
172 |
|
173 |
return $this->request;
|
174 |
}
|
143 |
}
|
144 |
$lines[] = $this->buildShipmentLineItem();
|
145 |
|
146 |
+
return $lines;
|
147 |
+
}
|
148 |
+
|
149 |
+
private function isShippingItem($item)
|
150 |
+
{
|
151 |
+
if ($item['LineNumber'] == 0 || $item['ItemKey'] == 'SHIPPING') {
|
152 |
+
return true;
|
153 |
+
}
|
154 |
+
|
155 |
+
return false;
|
156 |
+
}
|
157 |
+
|
158 |
+
private function numNonShippingItems($items)
|
159 |
+
{
|
160 |
+
$count = 0;
|
161 |
+
foreach ($items as $item) {
|
162 |
+
if (!$this->isShippingItem($item)) {
|
163 |
+
$count = $count + 1;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
return $count;
|
168 |
+
}
|
169 |
+
|
170 |
+
public function spreadDiscountToItems($items, $discountAmount)
|
171 |
+
{
|
172 |
+
// No items, no discount spreading
|
173 |
+
if ($this->numNonShippingItems($items) < 1) {
|
174 |
+
return $items;
|
175 |
+
}
|
176 |
+
|
177 |
+
$pennies = (int) $discountAmount * 100;
|
178 |
+
while ($pennies > 0) {
|
179 |
+
foreach ($items as $index => $item) {
|
180 |
+
if ($this->isShippingItem($item)) {
|
181 |
+
continue; // Don't subtract discount from shipping line items
|
182 |
+
}
|
183 |
+
$items[$index]['ActualExtendedPrice'] = number_format($items[$index]['ActualExtendedPrice'] - 0.01, 2);
|
184 |
+
if ($items[$index]['ActualExtendedPrice'] == 0) {
|
185 |
+
$pennies = 0; // Stop, can't give a negative price on products
|
186 |
+
}
|
187 |
+
$pennies = $pennies - 1;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
return $items;
|
192 |
+
}
|
193 |
+
|
194 |
+
public function getTotalDiscount()
|
195 |
+
{
|
196 |
+
if (!$this->getMageModel()) {
|
197 |
+
return 0;
|
198 |
+
}
|
199 |
+
|
200 |
+
$totals = $this->getMageModel()->getTotals();
|
201 |
+
if (!$totals) {
|
202 |
+
return 0;
|
203 |
+
}
|
204 |
+
$discount = 0;
|
205 |
+
foreach ($totals as $total) {
|
206 |
+
if ($total->getValue() < 0) {
|
207 |
+
$discount = $discount + abs($total->getValue());
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
return $discount;
|
212 |
}
|
213 |
|
214 |
public function build()
|
225 |
$this->request['TaxDate'] = date('Y-m-d');
|
226 |
date_default_timezone_set($originalTimeZone);
|
227 |
|
228 |
+
$this->request['Lines']['TaxRequestLine'] = $this->spreadDiscountToItems($this->buildOrderLineItems(), $this->getTotalDiscount());
|
229 |
$this->buildDestinationAddress();
|
230 |
$this->request['IsCommited'] = false;
|
231 |
$this->request['CustomerKey'] = $this->getMageModel()->getCustomerId();
|
233 |
// (blank) : default, consumer
|
234 |
// "NON" : tax exempt customer – sales tax will not be charged
|
235 |
// "R" : reseller / wholesale transaction - sales tax will not be charged
|
236 |
+
$this->request['CustomerTaxabilityCode'] = Mage::helper('taxify')->getTaxifyCustomerTaxabilityFromGroup($this->getMageModel()->getCustomerGroupId());
|
237 |
|
238 |
return $this->request;
|
239 |
}
|
app/code/local/Vonnda/Taxify/Model/Resource/Mysql4/Setup.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Vonnda_Taxify_Model_Resource_Mysql4_Setup
|
4 |
+
extends Mage_Core_Model_Resource_Setup
|
5 |
+
{
|
6 |
+
}
|
app/code/local/Vonnda/Taxify/Model/Sales/.DS_Store
DELETED
Binary file
|
app/code/local/Vonnda/Taxify/Model/Sales/Quote/.DS_Store
DELETED
Binary file
|
app/code/local/Vonnda/Taxify/Model/Sales/Quote/Address/.DS_Store
DELETED
Binary file
|
app/code/local/Vonnda/Taxify/etc/config.xml
CHANGED
@@ -2,10 +2,41 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Vonnda_Taxify>
|
5 |
-
<version>0.1.
|
6 |
</Vonnda_Taxify>
|
7 |
</modules>
|
8 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
<helpers>
|
10 |
<taxify>
|
11 |
<class>Vonnda_Taxify_Helper</class>
|
@@ -45,6 +76,19 @@
|
|
45 |
</sales_order_payment_cancel>
|
46 |
</events>
|
47 |
</global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
<default>
|
49 |
<tax>
|
50 |
<taxify>
|
@@ -52,5 +96,12 @@
|
|
52 |
<test_mode>0</test_mode>
|
53 |
</taxify>
|
54 |
</tax>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
</default>
|
56 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Vonnda_Taxify>
|
5 |
+
<version>0.1.1</version>
|
6 |
</Vonnda_Taxify>
|
7 |
</modules>
|
8 |
<global>
|
9 |
+
<resources>
|
10 |
+
<taxify_setup>
|
11 |
+
<setup>
|
12 |
+
<module>Vonnda_Taxify</module>
|
13 |
+
<class>Vonnda_Taxify_Model_Resource_Mysql4_Setup</class>
|
14 |
+
</setup>
|
15 |
+
<connection>
|
16 |
+
<use>core_setup</use>
|
17 |
+
</connection>
|
18 |
+
</taxify_setup>
|
19 |
+
<taxify_write>
|
20 |
+
<connection>
|
21 |
+
<use>core_write</use>
|
22 |
+
</connection>
|
23 |
+
</taxify_write>
|
24 |
+
<taxify_read>
|
25 |
+
<connection>
|
26 |
+
<use>core_read</use>
|
27 |
+
</connection>
|
28 |
+
</taxify_read>
|
29 |
+
</resources>
|
30 |
+
<blocks>
|
31 |
+
<taxify>
|
32 |
+
<class>Vonnda_Taxify_Block</class>
|
33 |
+
</taxify>
|
34 |
+
<adminhtml>
|
35 |
+
<rewrite>
|
36 |
+
<tax_class_edit_form>Vonnda_Taxify_Block_Adminhtml_Tax_Class_Edit_Form</tax_class_edit_form>
|
37 |
+
</rewrite>
|
38 |
+
</adminhtml>
|
39 |
+
</blocks>
|
40 |
<helpers>
|
41 |
<taxify>
|
42 |
<class>Vonnda_Taxify_Helper</class>
|
76 |
</sales_order_payment_cancel>
|
77 |
</events>
|
78 |
</global>
|
79 |
+
<adminhtml>
|
80 |
+
<events>
|
81 |
+
<controller_action_predispatch>
|
82 |
+
<observers>
|
83 |
+
<taxify_notification>
|
84 |
+
<type>singleton</type>
|
85 |
+
<class>taxify/feed</class>
|
86 |
+
<method>checkUpdate</method>
|
87 |
+
</taxify_notification>
|
88 |
+
</observers>
|
89 |
+
</controller_action_predispatch>
|
90 |
+
</events>
|
91 |
+
</adminhtml>
|
92 |
<default>
|
93 |
<tax>
|
94 |
<taxify>
|
96 |
<test_mode>0</test_mode>
|
97 |
</taxify>
|
98 |
</tax>
|
99 |
+
<taxify>
|
100 |
+
<feed>
|
101 |
+
<url>http://magento.vonnda.net/rss/taxify.rss</url>
|
102 |
+
<use_https>0</use_https>
|
103 |
+
<frequency>24</frequency>
|
104 |
+
</feed>
|
105 |
+
</taxify>
|
106 |
</default>
|
107 |
</config>
|
app/code/local/Vonnda/Taxify/sql/taxify_setup/mysql4-install-0.1.1.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
try {
|
6 |
+
$installer->run("
|
7 |
+
|
8 |
+
ALTER TABLE `" . $this->getTable('tax/tax_class') . "`
|
9 |
+
ADD `taxify_customer_taxability` VARCHAR(255) DEFAULT '' NOT NULL COMMENT 'Used by Vonnda Taxify extension'
|
10 |
+
AFTER `class_name`;
|
11 |
+
|
12 |
+
");
|
13 |
+
} catch(Exception $e) { Mage::log($e->getMessage()); }
|
14 |
+
|
15 |
+
// Set Wholesale Customer tax class to 'R' if
|
16 |
+
// same ID and description as default Magento.
|
17 |
+
$tax = Mage::getModel('tax/class')->load(5);
|
18 |
+
if ($tax) {
|
19 |
+
if ($tax->getClassName() == 'Wholesale Customer') {
|
20 |
+
$tax->setTaxifyCustomerTaxability('R');
|
21 |
+
$tax->save();
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
$installer->endSetup();
|
app/code/local/Vonnda/Taxify/tests/.DS_Store
DELETED
Binary file
|
app/code/local/Vonnda/Taxify/tests/Helper/DataTest.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once '../../app/Mage.php'; umask(0); Mage::app('default');
|
4 |
+
|
5 |
+
class HelperDataTest extends PHPUnit_Framework_TestCase
|
6 |
+
{
|
7 |
+
public function testAssert()
|
8 |
+
{
|
9 |
+
$helper = Mage::helper('taxify');
|
10 |
+
$options = $helper->getCustomerTaxabilityOptions();
|
11 |
+
$expected = array(
|
12 |
+
'' => 'Default',
|
13 |
+
'R' => 'Reseller / Wholesale',
|
14 |
+
'NON' => 'Tax Exempt',
|
15 |
+
);
|
16 |
+
$this->assertEquals($expected, $options);
|
17 |
+
}
|
18 |
+
}
|
app/code/local/Vonnda/Taxify/tests/Request/CalculateTest.php
CHANGED
@@ -98,4 +98,62 @@ class CalculateTest extends PHPUnit_Framework_TestCase
|
|
98 |
$this->assertEquals('NON', $resp);
|
99 |
}
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
98 |
$this->assertEquals('NON', $resp);
|
99 |
}
|
100 |
|
101 |
+
public function testSpreadDiscountToItems()
|
102 |
+
{
|
103 |
+
$items = array (
|
104 |
+
array (
|
105 |
+
'LineNumber' => '2523',
|
106 |
+
'ItemKey' => 'ace000',
|
107 |
+
'ActualExtendedPrice' => '295.00',
|
108 |
+
'Quantity' => 1,
|
109 |
+
'ItemDescription' => 'Aviator Sunglasses',
|
110 |
+
'ItemTaxabilityCode' => '',
|
111 |
+
),
|
112 |
+
array (
|
113 |
+
'LineNumber' => 0,
|
114 |
+
'ItemKey' => 'SHIPPING',
|
115 |
+
'ActualExtendedPrice' => '5.00',
|
116 |
+
'Quantity' => 1,
|
117 |
+
'ItemDescription' => 'Shipping',
|
118 |
+
'ItemTaxabilityCode' => 'FR',
|
119 |
+
),
|
120 |
+
);
|
121 |
+
|
122 |
+
$tests = array(
|
123 |
+
10.000 => array(285.00, 5.00),
|
124 |
+
0.000 => array(295.00, 5.00),
|
125 |
+
295.000 => array(0.00, 5.00),
|
126 |
+
300.000 => array(0.00, 5.00),
|
127 |
+
);
|
128 |
+
|
129 |
+
$calculate = Mage::getModel('taxify/request_calculate');
|
130 |
+
|
131 |
+
foreach ($tests as $discountAmount => $values) {
|
132 |
+
$resp = $calculate->spreadDiscountToItems($items, $discountAmount);
|
133 |
+
$this->assertEquals($values[0], $resp[0]['ActualExtendedPrice']);
|
134 |
+
$this->assertEquals($values[1], $resp[1]['ActualExtendedPrice']);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
public function testSpreadDiscountToItemsDoesntInfiniteLoopWhenNoItems()
|
139 |
+
{
|
140 |
+
$items = array (
|
141 |
+
array (
|
142 |
+
'LineNumber' => 0,
|
143 |
+
'ItemKey' => 'SHIPPING',
|
144 |
+
'ActualExtendedPrice' => '5.00',
|
145 |
+
'Quantity' => 1,
|
146 |
+
'ItemDescription' => 'Shipping',
|
147 |
+
'ItemTaxabilityCode' => 'FR',
|
148 |
+
),
|
149 |
+
);
|
150 |
+
$calculate = Mage::getModel('taxify/request_calculate');
|
151 |
+
|
152 |
+
$resp = $calculate->spreadDiscountToItems($items, 20.00);
|
153 |
+
$this->assertEquals(5.00, $resp[0]['ActualExtendedPrice']);
|
154 |
+
|
155 |
+
// Make sure empty array doesn't loop forever
|
156 |
+
$calculate->spreadDiscountToItems(array(), 20.00);
|
157 |
+
}
|
158 |
+
|
159 |
}
|
app/etc/modules/Vonnda_Taxify.xml
CHANGED
@@ -6,4 +6,4 @@
|
|
6 |
<codePool>local</codePool>
|
7 |
</Vonnda_Taxify>
|
8 |
</modules>
|
9 |
-
</config>
|
6 |
<codePool>local</codePool>
|
7 |
</Vonnda_Taxify>
|
8 |
</modules>
|
9 |
+
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Taxify_Sales_Tax_Rates_and_Filing</name>
|
4 |
-
<version>0.1.
|
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>
|
@@ -10,9 +10,9 @@
|
|
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>
|
14 |
-
<time>23:
|
15 |
-
<contents><target name="magelocal"><dir name="Vonnda"><dir name="Taxify"><dir name="Helper"><file name="Data.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.2</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Taxify_Sales_Tax_Rates_and_Filing</name>
|
4 |
+
<version>0.1.1</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>
|
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>2015-02-18</date>
|
14 |
+
<time>23:42:21</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Vonnda"><dir name="Taxify"><dir name="Block"><dir name="Adminhtml"><dir name="Tax"><dir name="Class"><dir name="Edit"><file name="Form.php" hash="279d8ed35ba0111216682c1613e65e9f"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4849bb226490a464c65ccbb624b248a7"/></dir><dir name="Model"><file name="Client.php" hash="94166ffd2b1ad7da5aad6747656cb61a"/><file name="Config.php" hash="2db3425ee59a162dedf5ef8a4fa655e3"/><file name="Feed.php" hash="04f391cc7357d47184c243e81d068bf7"/><file name="Observer.php" hash="52d7d7e74b2a0676b58ad4262e26fc49"/><dir name="Request"><file name="Calculate.php" hash="f0b3e106601fbea1a3af114fbba7d573"/><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"/><file name=".Calculate.php.swp" hash="ad08fce503a30eacdf20d709cda773a3"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="326120cd05749e9b48e7dd966a3b2c19"/></dir></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Tax.php" hash="8f7ffa65d9d537e4558329d46f53b47a"/></dir></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="c45aad1a2501465e8a5e704e7ad8839f"/><file name="system.xml" hash="f99743421bbf8bf7c4d19dca7a4b0d53"/></dir><dir name="sql"><dir name="taxify_setup"><file name="mysql4-install-0.1.1.php" hash="523629216cc236efa1e3a08dc40b9291"/></dir></dir><dir name="tests"><dir name="Helper"><file name="DataTest.php" hash="da05ea802f6266b7a0fceed28c3d52c5"/></dir><dir name="Request"><file name="CalculateTest.php" hash="7bd6291be8d42329a211fd6f73161cd8"/><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></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vonnda_Taxify.xml" hash="b3120a86b364f80ee8daf825412a1318"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.2</max></php></required></dependencies>
|
18 |
</package>
|