Version Notes
Supported Magento 1.5.0.0 - 1.7.x
Download this release
Release Info
Developer | Exactor, Inc. |
Extension | Mage_Exactor_Tax |
Version | 2012.06.19 |
Comparing to | |
See all releases |
Code changes from version 2012.06.18 to 2012.06.19
app/code/local/Exactor/Core/etc/config.xml
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Exactor_Core>
|
31 |
-
<version>2012.06.
|
32 |
</Exactor_Core>
|
33 |
</modules>
|
34 |
<global>
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Exactor_Core>
|
31 |
+
<version>2012.06.19</version>
|
32 |
</Exactor_Core>
|
33 |
</modules>
|
34 |
<global>
|
app/code/local/Exactor/Tax/Helper/Mapping.php
CHANGED
@@ -20,6 +20,7 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
20 |
|
21 |
const LINE_ITEM_ID_SHIPPING = "SHIPPING";
|
22 |
const LINE_ITEM_ID_HANDLING = "HANDLING";
|
|
|
23 |
|
24 |
const ATTRIBUTE_NAME_EXEMPTION = 'taxvat';
|
25 |
|
@@ -32,6 +33,8 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
32 |
|
33 |
const UNKNOWN_STREET_TEXT = "";
|
34 |
|
|
|
|
|
35 |
private function getLogger(){
|
36 |
if ($this->logger==null)
|
37 |
$this->logger = ExactorLoggingFactory::getInstance()->getLogger($this);
|
@@ -154,7 +157,7 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
154 |
* @return void
|
155 |
*/
|
156 |
private function getHandlingFeeByMethodName($name){
|
157 |
-
if (strpos($name,
|
158 |
// Fetch carriers information from Magento config to determine handling amount
|
159 |
$carriers = Mage::getStoreConfig('carriers');
|
160 |
if (!array_key_exists($name, $carriers)) return 0;
|
@@ -258,9 +261,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
258 |
// Line items list
|
259 |
$magentoItems = $quoteAddress->getAllItems();
|
260 |
$itemNum = 0;
|
|
|
|
|
|
|
261 |
foreach ($magentoItems as $magentoItem){
|
262 |
$exactorLineItem = $this->buildLineItemForMagentoItem($magentoItem, $quoteAddress, $merchantSettings);
|
263 |
-
$exactorLineItem->setId(
|
264 |
// If this is non-multishipping request we should set
|
265 |
// ship to address to billing address for VIRTUAL ITEMS
|
266 |
if (!$isMultishipping){
|
20 |
|
21 |
const LINE_ITEM_ID_SHIPPING = "SHIPPING";
|
22 |
const LINE_ITEM_ID_HANDLING = "HANDLING";
|
23 |
+
const INDEXED_LINE_ITEM_ID_PREFIX = '_';
|
24 |
|
25 |
const ATTRIBUTE_NAME_EXEMPTION = 'taxvat';
|
26 |
|
33 |
|
34 |
const UNKNOWN_STREET_TEXT = "";
|
35 |
|
36 |
+
|
37 |
+
|
38 |
private function getLogger(){
|
39 |
if ($this->logger==null)
|
40 |
$this->logger = ExactorLoggingFactory::getInstance()->getLogger($this);
|
157 |
* @return void
|
158 |
*/
|
159 |
private function getHandlingFeeByMethodName($name){
|
160 |
+
if (strpos($name, "_")) $name = substr($name,0,strpos($name, "_"));
|
161 |
// Fetch carriers information from Magento config to determine handling amount
|
162 |
$carriers = Mage::getStoreConfig('carriers');
|
163 |
if (!array_key_exists($name, $carriers)) return 0;
|
261 |
// Line items list
|
262 |
$magentoItems = $quoteAddress->getAllItems();
|
263 |
$itemNum = 0;
|
264 |
+
/**
|
265 |
+
* @var $magentoItem Mage_Sales_Model_Quote_Item
|
266 |
+
*/
|
267 |
foreach ($magentoItems as $magentoItem){
|
268 |
$exactorLineItem = $this->buildLineItemForMagentoItem($magentoItem, $quoteAddress, $merchantSettings);
|
269 |
+
$exactorLineItem->setId(self::INDEXED_LINE_ITEM_ID_PREFIX . $magentoItem->getProductId());
|
270 |
// If this is non-multishipping request we should set
|
271 |
// ship to address to billing address for VIRTUAL ITEMS
|
272 |
if (!$isMultishipping){
|
app/code/local/Exactor/Tax/Model/Sales/Total/Quote/Tax.php
CHANGED
@@ -120,13 +120,13 @@ class Exactor_Tax_Model_Sales_Total_Quote_Tax extends Mage_Sales_Model_Quote_Add
|
|
120 |
$merchantSettings = $this->loadMerchantSettings($address);
|
121 |
|
122 |
if ($merchantSettings == null){
|
123 |
-
|
124 |
-
$this->
|
|
|
125 |
$internalTaxCalculator = Mage::getSingleton("Mage_Tax_Model_Sales_Total_Quote_Tax");
|
126 |
return $internalTaxCalculator->collect($address);
|
127 |
//return $this->processTaxCalculationFail('Missing or invalid Merchant Settings');
|
128 |
}
|
129 |
-
|
130 |
// Preparing Exactor Invoice Request
|
131 |
$invoiceRequest = $this->exactorMappingHelper->buildInvoiceRequestForQuoteAddress($address, $merchantSettings, $this->isMultishippingRequest());
|
132 |
$this->logger->trace('Invoice ' . serialize($invoiceRequest),'collect');
|
@@ -144,11 +144,14 @@ class Exactor_Tax_Model_Sales_Total_Quote_Tax extends Mage_Sales_Model_Quote_Add
|
|
144 |
return $this->processTaxCalculationFail($msg);
|
145 |
}else{
|
146 |
$invoiceResponse = $exactorResponse->getFirstInvoice();
|
147 |
-
if ($invoiceResponse!=null)
|
148 |
$calculatedTax = $invoiceResponse->getTotalTaxAmount();
|
|
|
|
|
149 |
}
|
150 |
}catch(Exception $e){ // Critical Exactor communication error - Network timeout for instance
|
151 |
$this->applyTax(0);
|
|
|
152 |
$this->logger->error(self::LOG_MESSAGE_TAX_CALC_FAILED . $e->getMessage(), 'collect');
|
153 |
$this->session->addError($e->getMessage());
|
154 |
}
|
@@ -157,11 +160,66 @@ class Exactor_Tax_Model_Sales_Total_Quote_Tax extends Mage_Sales_Model_Quote_Add
|
|
157 |
$address->setBaseTaxAmount($calculatedTax);
|
158 |
}else{
|
159 |
$this->applyTax($address->getTaxAmount());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
return $this;
|
162 |
}
|
163 |
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
private function applyTax($amount){
|
166 |
$this->_setBaseAmount($amount);
|
167 |
$this->_setAmount($amount);
|
120 |
$merchantSettings = $this->loadMerchantSettings($address);
|
121 |
|
122 |
if ($merchantSettings == null){
|
123 |
+
/*$this->applyTax(0);
|
124 |
+
$this->resetTaxForItems($address);*/
|
125 |
+
$this->logger->info(self::LOG_MESSAGE_TAX_CALC_FAILED . ' Missing or invalid Merchant Settings. Pass request to internal Mage tax calc. system', 'collect');
|
126 |
$internalTaxCalculator = Mage::getSingleton("Mage_Tax_Model_Sales_Total_Quote_Tax");
|
127 |
return $internalTaxCalculator->collect($address);
|
128 |
//return $this->processTaxCalculationFail('Missing or invalid Merchant Settings');
|
129 |
}
|
|
|
130 |
// Preparing Exactor Invoice Request
|
131 |
$invoiceRequest = $this->exactorMappingHelper->buildInvoiceRequestForQuoteAddress($address, $merchantSettings, $this->isMultishippingRequest());
|
132 |
$this->logger->trace('Invoice ' . serialize($invoiceRequest),'collect');
|
144 |
return $this->processTaxCalculationFail($msg);
|
145 |
}else{
|
146 |
$invoiceResponse = $exactorResponse->getFirstInvoice();
|
147 |
+
if ($invoiceResponse!=null){
|
148 |
$calculatedTax = $invoiceResponse->getTotalTaxAmount();
|
149 |
+
$this->applyTaxForItems($address, $invoiceResponse);
|
150 |
+
}
|
151 |
}
|
152 |
}catch(Exception $e){ // Critical Exactor communication error - Network timeout for instance
|
153 |
$this->applyTax(0);
|
154 |
+
$this->resetTaxForItems($address);
|
155 |
$this->logger->error(self::LOG_MESSAGE_TAX_CALC_FAILED . $e->getMessage(), 'collect');
|
156 |
$this->session->addError($e->getMessage());
|
157 |
}
|
160 |
$address->setBaseTaxAmount($calculatedTax);
|
161 |
}else{
|
162 |
$this->applyTax($address->getTaxAmount());
|
163 |
+
// For some reason shipping tax is 0 on this point
|
164 |
+
// We can't fetch it from the anywhere because we don't store any amounts,
|
165 |
+
// Thus the only solution for us - to calculate it. It's a little bit hacky way...
|
166 |
+
/**
|
167 |
+
* @var Mage_Sales_Model_Quote_Item $item
|
168 |
+
*/
|
169 |
+
$shippingTax = $address->getTaxAmount();
|
170 |
+
foreach ($address->getAllItems() as $item){
|
171 |
+
$shippingTax -= $item->getTaxAmount();
|
172 |
+
}
|
173 |
+
$address->setShippingTaxAmount($shippingTax);
|
174 |
+
$address->setBaseShippingTaxAmount($shippingTax);
|
175 |
}
|
176 |
return $this;
|
177 |
}
|
178 |
|
179 |
|
180 |
+
/**
|
181 |
+
* Set tax amount for each item
|
182 |
+
* @param \Mage_Sales_Model_Quote_Address $address
|
183 |
+
* @param InvoiceResponseType $invoice
|
184 |
+
* @return void
|
185 |
+
*/
|
186 |
+
private function applyTaxForItems(Mage_Sales_Model_Quote_Address $address, InvoiceResponseType $invoice){
|
187 |
+
$i = 0;
|
188 |
+
/**
|
189 |
+
* @var Mage_Sales_Model_Quote_Item $item
|
190 |
+
*/
|
191 |
+
foreach ($address->getAllItems() as $item){
|
192 |
+
$taxResultItem = $invoice->getItemById(Exactor_Tax_Helper_Mapping::INDEXED_LINE_ITEM_ID_PREFIX . $item->getProductId());
|
193 |
+
// If there is no item in response - set tax to 0
|
194 |
+
if ($taxResultItem==null){
|
195 |
+
$item->setTaxAmount(0);
|
196 |
+
$item->setBaseTaxAmount(0);
|
197 |
+
}else{ // Else - Apply tax to the item
|
198 |
+
$item->setTaxAmount($taxResultItem->getTotalTaxAmount());
|
199 |
+
$item->setBaseTaxAmount($taxResultItem->getTotalTaxAmount());
|
200 |
+
}
|
201 |
+
}
|
202 |
+
// Set Shipping + handling tax
|
203 |
+
$totalShippingTax = 0;
|
204 |
+
$shippingTaxItem = $invoice->getItemById(Exactor_Tax_Helper_Mapping::LINE_ITEM_ID_SHIPPING);
|
205 |
+
$handlingTaxItem = $invoice->getItemById(Exactor_Tax_Helper_Mapping::LINE_ITEM_ID_HANDLING);
|
206 |
+
if ($shippingTaxItem != null) $totalShippingTax+=$shippingTaxItem->getTotalTaxAmount();
|
207 |
+
if ($handlingTaxItem != null) $totalShippingTax+=$handlingTaxItem->getTotalTaxAmount();
|
208 |
+
$address->setShippingTaxAmount($totalShippingTax);
|
209 |
+
$address->setBaseShippingTaxAmount($totalShippingTax);
|
210 |
+
}
|
211 |
+
|
212 |
+
private function resetTaxForItems(Mage_Sales_Model_Quote_Address $address){
|
213 |
+
/**
|
214 |
+
* @var Mage_Sales_Model_Quote_Item $item
|
215 |
+
*/
|
216 |
+
foreach ($address->getAllItems() as $item){
|
217 |
+
$item->setTaxAmount(0);
|
218 |
+
$item->setBaseTaxAmount(0);
|
219 |
+
}
|
220 |
+
$address->setShippingTaxAmount(0);
|
221 |
+
}
|
222 |
+
|
223 |
private function applyTax($amount){
|
224 |
$this->_setBaseAmount($amount);
|
225 |
$this->_setAmount($amount);
|
lib/ExactorCommons/ExactorDomainObjects.php
CHANGED
@@ -808,6 +808,20 @@ class InvoiceResponseType extends XmlSerializationSupport{
|
|
808 |
{
|
809 |
return $this->TransactionId;
|
810 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
}
|
812 |
|
813 |
class CommitResponseType extends XmlSerializationSupport{
|
808 |
{
|
809 |
return $this->TransactionId;
|
810 |
}
|
811 |
+
|
812 |
+
/**
|
813 |
+
* @param $id
|
814 |
+
* @return null|ResponseLineItem
|
815 |
+
*/
|
816 |
+
public function getItemById($id){
|
817 |
+
/**
|
818 |
+
* @var $item ResponseLineItem
|
819 |
+
*/
|
820 |
+
foreach($this->getLineItems() as $item){
|
821 |
+
if ($item->getId() == $id) return $item;
|
822 |
+
}
|
823 |
+
return null;
|
824 |
+
}
|
825 |
}
|
826 |
|
827 |
class CommitResponseType extends XmlSerializationSupport{
|
lib/ExactorCommons/config.php
CHANGED
@@ -6,6 +6,6 @@
|
|
6 |
*/
|
7 |
|
8 |
ExactorLoggingFactory::getInstance()->setup('MagentoLogger', IExactorLogger::TRACE);
|
9 |
-
ExactorConnectionFactory::getInstance()->setup('Magento','
|
10 |
ExactorProcessingServiceFactory::getInstance()->setup(new MagentoExactorCallback());
|
11 |
|
6 |
*/
|
7 |
|
8 |
ExactorLoggingFactory::getInstance()->setup('MagentoLogger', IExactorLogger::TRACE);
|
9 |
+
ExactorConnectionFactory::getInstance()->setup('Magento','v20120619');
|
10 |
ExactorProcessingServiceFactory::getInstance()->setup(new MagentoExactorCallback());
|
11 |
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Mage_Exactor_Tax</name>
|
4 |
-
<version>2012.06.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -12,9 +12,9 @@ Once installed, neither the merchant, nor the customer, need to perform any addi
|
|
12 |
For additional information, please refer to the Exactor Magento User Guide that is attached to the plug-in, or which you can download directly from the Exactor control panel (navigate to Account Management Integration Points & PlugIns).</description>
|
13 |
<notes>Supported Magento 1.5.0.0 - 1.7.x</notes>
|
14 |
<authors><author><name>Exactor, Inc.</name><user>exactor</user><email>support@exactor.com</email></author></authors>
|
15 |
-
<date>2012-06-
|
16 |
-
<time>
|
17 |
-
<contents><target name="magelocal"><dir name="Exactor"><dir name="Core"><dir name="Helper"><file name="SessionCache.php" hash="4aab06767188e8ead64043654989473d"/></dir><dir name="Model"><file name="ExactorTransaction.php" hash="852aa20f6e3b7aa0001439d4bffe9724"/><file name="MerchantSettings.php" hash="b4c2acde5dfa929e89ea7ec9fe0f1b2f"/><dir name="Mysql4"><dir name="ExactorTransaction"><file name="Collection.php" hash="c7b890b4d3ab35e65a3856ae0e2fdf72"/></dir><file name="ExactorTransaction.php" hash="c91aebaae767613acf1c439a8b513c3b"/><dir name="MerchantSettings"><file name="Collection.php" hash="c1593f52e582e601409c4651c37495af"/><file name="Collection.php~" hash="d360e202eb30432ac41dc023ce13ffc0"/></dir><file name="MerchantSettings.php" hash="8f22b76bb64cdc7b1deb6f0e38889905"/></dir><dir name="Type"><file name="Onepage.php" hash="2d2aa64ed4562736e77b3cad12e8f48c"/></dir></dir><dir name="etc"><file name="config.xml" hash="
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Mage_Exactor_Tax</name>
|
4 |
+
<version>2012.06.19</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
12 |
For additional information, please refer to the Exactor Magento User Guide that is attached to the plug-in, or which you can download directly from the Exactor control panel (navigate to Account Management Integration Points & PlugIns).</description>
|
13 |
<notes>Supported Magento 1.5.0.0 - 1.7.x</notes>
|
14 |
<authors><author><name>Exactor, Inc.</name><user>exactor</user><email>support@exactor.com</email></author></authors>
|
15 |
+
<date>2012-06-21</date>
|
16 |
+
<time>09:40:11</time>
|
17 |
+
<contents><target name="magelocal"><dir name="Exactor"><dir name="Core"><dir name="Helper"><file name="SessionCache.php" hash="4aab06767188e8ead64043654989473d"/></dir><dir name="Model"><file name="ExactorTransaction.php" hash="852aa20f6e3b7aa0001439d4bffe9724"/><file name="MerchantSettings.php" hash="b4c2acde5dfa929e89ea7ec9fe0f1b2f"/><dir name="Mysql4"><dir name="ExactorTransaction"><file name="Collection.php" hash="c7b890b4d3ab35e65a3856ae0e2fdf72"/></dir><file name="ExactorTransaction.php" hash="c91aebaae767613acf1c439a8b513c3b"/><dir name="MerchantSettings"><file name="Collection.php" hash="c1593f52e582e601409c4651c37495af"/><file name="Collection.php~" hash="d360e202eb30432ac41dc023ce13ffc0"/></dir><file name="MerchantSettings.php" hash="8f22b76bb64cdc7b1deb6f0e38889905"/></dir><dir name="Type"><file name="Onepage.php" hash="2d2aa64ed4562736e77b3cad12e8f48c"/></dir></dir><dir name="etc"><file name="config.xml" hash="50c2cdf232f06125484ac8a715024262"/></dir></dir><dir name="ExactorSettings"><dir name="Block"><file name="Form.php" hash="7dcfb00922cfe305d8ae08cb20ca5e87"/></dir><dir name="Helper"><file name="Data.php" hash="9abafb58b091f8976fa289f394465415"/><file name="VersionResolver.php" hash="14dce068dfe2a7d3364c4bd29e6f8431"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FormController.php" hash="a154f13f8c4c04f838dfb79607078341"/></dir><file name="AjaxController.php" hash="c07aeeca00e1408e52945fc027569793"/><file name="IndexController.php" hash="f47cbc274dd68c57c30b60bbee69259e"/></dir><dir name="etc"><file name="config.xml" hash="6c2f28c302b359abd12565264fa23bc5"/></dir><dir name="sql"><dir name="ExactorSettings_setup"><file name="mysql4-install-14.04.2012.php" hash="f35af1e12921b57479cb4b5677937a0c"/></dir></dir></dir><dir name="Sales"><dir name="Model"><file name="Observer.php" hash="65e826c0493adece2476ed24788ecb06"/></dir><dir name="etc"><file name="config.xml" hash="2d6c2557632003318da9e3165944ecc6"/></dir></dir><dir name="Tax"><dir name="Helper"><file name="Calculation.php" hash="29c5252bdd48b173c90588f449114024"/><file name="Mapping.php" hash="64c6e0cc3ddb49a836dbbe92b2f97d35"/></dir><dir name="Model"><dir name="Sales"><dir name="Total"><dir name="Quote"><dir name="Nominal"><file name="Tax.php" hash="156eff380df5b16db55449759f193490"/></dir><file name="Tax.php" hash="908dad83333e61933684a9404b13769d"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="9a653c98a67e3743f45618d0890aab00"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="exactorsettings.xml" hash="3707eac08d2393c8796eebf1cf7a0bd9"/><file name="exactoronestepcheckout.xml" hash="9fdfa1db5e4e60b4eec8f348c10aab07"/></dir><dir name="template"><dir name="ExactorSettings"><file name="settingsform.phtml" hash="c77a9c5461dbb37f0a8835e55f48f1d6"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="exactoronestepcheckout.xml" hash="9fdfa1db5e4e60b4eec8f348c10aab07"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Exactor.xml" hash="e8997e8e36a265141b37790caaef39d6"/></dir></target><target name="mageweb"><dir name="js"><dir name="exactor"><file name="exactor.js" hash="5c23e40f4034e50a6e0df5b1c708b7e1"/></dir></dir></target><target name="magelib"><dir name="ExactorCommons"><file name="ExactorCommons.php" hash="b78ebfdd66c36c419a312fc5c2d1b4bd"/><file name="ExactorDomainObjects.php" hash="3633afb09bd82b35ed141c1200906097"/><file name="Magento.php" hash="76da7333fe0692053a47f8564c7b513a"/><file name="XmlProcessing.php" hash="383fd21839889d720e2094e83ccc7a2a"/><file name="config.php" hash="d921f8e8f9891e2c2cb44bdcd699bfd5"/><file name="config.php~" hash="f12c65295b05793efd89dd64748282d1"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|