Version Notes
Supported Magento 1.5.0.0 - 1.7.x, Magento Enterprise 1.8-1.12.x
Download this release
Release Info
Developer | Exactor, Inc. |
Extension | Mage_Exactor_Tax |
Version | 2012.12.27 |
Comparing to | |
See all releases |
Code changes from version 2012.11.12 to 2012.12.27
- app/code/local/Exactor/Sales/Model/Observer.php +36 -13
- app/code/local/Exactor/Tax/Helper/Mapping.php +34 -4
- app/code/local/Exactor/Tax/Model/Sales/Total/Quote/Tax.php +12 -4
- app/code/local/Exactor/Tax/etc/config.xml +1 -1
- lib/ExactorCommons/ExactorCommons.php +18 -1
- lib/ExactorCommons/ExactorDomainObjects.php +2 -2
- lib/ExactorCommons/config.php +9 -3
- package.xml +4 -4
app/code/local/Exactor/Sales/Model/Observer.php
CHANGED
@@ -97,6 +97,13 @@ class Exactor_Sales_Model_Observer {
|
|
97 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
98 |
$invoiceRequests = $this->exactorMappingHelper->buildInvoiceRequestForMagentoInvoice($invoice, $merchantSettings);
|
99 |
foreach ($invoiceRequests as $invoiceRequest) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
$exactorProcessingService->partialPayment($invoiceRequest, new DateTime(), $this->getInvoiceIncrementId($invoice));
|
101 |
}
|
102 |
} catch (Exception $e) {
|
@@ -114,6 +121,13 @@ class Exactor_Sales_Model_Observer {
|
|
114 |
}
|
115 |
$invoiceRequests = $this->exactorMappingHelper->buildInvoiceRequestForMagentoInvoice($invoice, $merchantSettings);
|
116 |
foreach ($invoiceRequests as $invoiceRequest) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
$exactorProcessingService->partialRefund($invoiceRequest, new DateTime(), $invoice->getIncrementId());
|
118 |
}
|
119 |
} catch (Exception $e) {
|
@@ -135,6 +149,13 @@ class Exactor_Sales_Model_Observer {
|
|
135 |
try{
|
136 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
|
137 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
$exactorProcessingService->refundTransactionForOrder($order->getIncrementId());
|
139 |
}catch (Exception $e){
|
140 |
$this->logger->error("Can't commit transaction. See details above.", 'refundTransactionForOrder');
|
@@ -176,19 +197,6 @@ class Exactor_Sales_Model_Observer {
|
|
176 |
}
|
177 |
//$this->exactorProcessingService->commitExistingInvoiceForOrder($orderId);
|
178 |
}
|
179 |
-
// TODO: REMOVE THIS COMMENTED CODE
|
180 |
-
/*else {
|
181 |
-
// Else we should check if there is invoice attached and we have commit option set in "On Invoice"
|
182 |
-
$incrementOrderId = $order->getIncrementId();
|
183 |
-
if ($merchantSettings->getCommitOption() == Exactor_Core_Model_MerchantSettings::COMMIT_ON_INVOICE
|
184 |
-
&& count($order->getInvoiceCollection()) && !in_array($incrementOrderId, $this->invoiceProcessingCompatibilityList)) {
|
185 |
-
foreach ($order->getInvoiceCollection() as $invoice) {
|
186 |
-
$this->logger->info("Commiting transaction for order $orderId, Commit On Invoice. Compatibility logic", 'processFinishedOrder');
|
187 |
-
$this->commitTransactionForInvoice($invoice, $merchantSettings);
|
188 |
-
$this->invoiceProcessingCompatibilityList[] = $incrementOrderId;
|
189 |
-
}
|
190 |
-
}
|
191 |
-
}*/
|
192 |
return true;
|
193 |
}
|
194 |
|
@@ -209,6 +217,14 @@ class Exactor_Sales_Model_Observer {
|
|
209 |
}
|
210 |
$exactorTransaction = $exactorProcessingService->loadTransactionInfoByOrderId($order->getIncrementId());
|
211 |
$invoiceRequests = $this->exactorMappingHelper->buildInvoiceRequestForMagentoOrder($order, $merchantSettings);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
if (count($invoiceRequests) == 1 && $exactorTransaction != null && !$exactorTransaction->getIsCommited()) {
|
213 |
$taxResponse = $exactorProcessingService->partialPayment($invoiceRequests[0], new DateTime(), "");
|
214 |
$exactorTransaction->setIsCommited(true);
|
@@ -246,9 +262,16 @@ class Exactor_Sales_Model_Observer {
|
|
246 |
return;
|
247 |
}
|
248 |
$invoiceRequests = $this->exactorMappingHelper->buildInvoiceRequestsForCreditMemo($creditMemo, $merchantSettings);
|
|
|
249 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()->buildExactorProcessingService($merchantSettings->getMerchantID(),
|
250 |
$merchantSettings->getUserID());
|
251 |
foreach ($invoiceRequests as $invoice) {
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
$exactorProcessingService->partialRefund($invoice, new DateTime(), "");
|
253 |
}
|
254 |
}
|
97 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
98 |
$invoiceRequests = $this->exactorMappingHelper->buildInvoiceRequestForMagentoInvoice($invoice, $merchantSettings);
|
99 |
foreach ($invoiceRequests as $invoiceRequest) {
|
100 |
+
$config = ExactorPluginConfig::getInstance();
|
101 |
+
if ($config->getFeatureConfig()->isFeatureEnabled(EXACTOR_CONFIG_FEATURE_TRN_FILTER)) {
|
102 |
+
if (!$this->exactorMappingHelper->isAllowedLocation($config->get(EXACTOR_CONFIG_TRN_FILTER), $invoiceRequest->getShipTo())) {
|
103 |
+
$this->logger->info('Order processing interrupted: Rejected by Exactor filter', 'commitTransactionForInvoice');
|
104 |
+
return null;
|
105 |
+
}
|
106 |
+
}
|
107 |
$exactorProcessingService->partialPayment($invoiceRequest, new DateTime(), $this->getInvoiceIncrementId($invoice));
|
108 |
}
|
109 |
} catch (Exception $e) {
|
121 |
}
|
122 |
$invoiceRequests = $this->exactorMappingHelper->buildInvoiceRequestForMagentoInvoice($invoice, $merchantSettings);
|
123 |
foreach ($invoiceRequests as $invoiceRequest) {
|
124 |
+
$config = ExactorPluginConfig::getInstance();
|
125 |
+
if ($config->getFeatureConfig()->isFeatureEnabled(EXACTOR_CONFIG_FEATURE_TRN_FILTER)) {
|
126 |
+
if (!$this->exactorMappingHelper->isAllowedLocation($config->get(EXACTOR_CONFIG_TRN_FILTER), $invoiceRequest->getShipTo())) {
|
127 |
+
$this->logger->info('Order processing interrupted: Rejected by Exactor filter', 'refundTransactionForInvoice');
|
128 |
+
return null;
|
129 |
+
}
|
130 |
+
}
|
131 |
$exactorProcessingService->partialRefund($invoiceRequest, new DateTime(), $invoice->getIncrementId());
|
132 |
}
|
133 |
} catch (Exception $e) {
|
149 |
try{
|
150 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
|
151 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
152 |
+
$config = ExactorPluginConfig::getInstance();
|
153 |
+
if ($config->getFeatureConfig()->isFeatureEnabled(EXACTOR_CONFIG_FEATURE_TRN_FILTER)) {
|
154 |
+
if (!$this->exactorMappingHelper->isAllowedLocation($config->get(EXACTOR_CONFIG_TRN_FILTER), $order->getShippingAddress())) {
|
155 |
+
$this->logger->info('Order processing interrupted: Rejected by Exactor filter', 'refundTransactionForOrder');
|
156 |
+
return null;
|
157 |
+
}
|
158 |
+
}
|
159 |
$exactorProcessingService->refundTransactionForOrder($order->getIncrementId());
|
160 |
}catch (Exception $e){
|
161 |
$this->logger->error("Can't commit transaction. See details above.", 'refundTransactionForOrder');
|
197 |
}
|
198 |
//$this->exactorProcessingService->commitExistingInvoiceForOrder($orderId);
|
199 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
return true;
|
201 |
}
|
202 |
|
217 |
}
|
218 |
$exactorTransaction = $exactorProcessingService->loadTransactionInfoByOrderId($order->getIncrementId());
|
219 |
$invoiceRequests = $this->exactorMappingHelper->buildInvoiceRequestForMagentoOrder($order, $merchantSettings);
|
220 |
+
// Check request filter if it is enabled
|
221 |
+
$config = ExactorPluginConfig::getInstance();
|
222 |
+
if ($config->getFeatureConfig()->isFeatureEnabled(EXACTOR_CONFIG_FEATURE_TRN_FILTER)) {
|
223 |
+
if (!$this->exactorMappingHelper->isAllowedLocation($config->get(EXACTOR_CONFIG_TRN_FILTER), $invoiceRequests[0]->getShipTo())) {
|
224 |
+
$this->logger->info('Rejected by Exactor filter. Order processing. Internal tax calculation will be used instead.', 'commitTransactionForOrder');
|
225 |
+
return null;
|
226 |
+
}
|
227 |
+
}
|
228 |
if (count($invoiceRequests) == 1 && $exactorTransaction != null && !$exactorTransaction->getIsCommited()) {
|
229 |
$taxResponse = $exactorProcessingService->partialPayment($invoiceRequests[0], new DateTime(), "");
|
230 |
$exactorTransaction->setIsCommited(true);
|
262 |
return;
|
263 |
}
|
264 |
$invoiceRequests = $this->exactorMappingHelper->buildInvoiceRequestsForCreditMemo($creditMemo, $merchantSettings);
|
265 |
+
$config = ExactorPluginConfig::getInstance();
|
266 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()->buildExactorProcessingService($merchantSettings->getMerchantID(),
|
267 |
$merchantSettings->getUserID());
|
268 |
foreach ($invoiceRequests as $invoice) {
|
269 |
+
if ($config->getFeatureConfig()->isFeatureEnabled(EXACTOR_CONFIG_FEATURE_TRN_FILTER)) {
|
270 |
+
if (!$this->exactorMappingHelper->isAllowedLocation($config->get(EXACTOR_CONFIG_TRN_FILTER), $invoice->getShipTo())) {
|
271 |
+
$this->logger->info('Order processing interrupted: Rejected by Exactor filter', 'partialRefund');
|
272 |
+
continue;
|
273 |
+
}
|
274 |
+
}
|
275 |
$exactorProcessingService->partialRefund($invoice, new DateTime(), "");
|
276 |
}
|
277 |
}
|
app/code/local/Exactor/Tax/Helper/Mapping.php
CHANGED
@@ -83,9 +83,10 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
83 |
if ($address->getStreetFull() != null)
|
84 |
$exactorAddress->setStreet1($address->getStreetFull());
|
85 |
$exactorAddress->setCity($address->getCity());
|
86 |
-
$exactorAddress->setStateOrProvince($address->
|
87 |
$exactorAddress->setCountry($address->getCountry());
|
88 |
$exactorAddress->setPostalCode($address->getPostcode());
|
|
|
89 |
return $exactorAddress;
|
90 |
}
|
91 |
|
@@ -282,9 +283,14 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
282 |
}
|
283 |
// Check if it is bundle or groped product
|
284 |
$product = $magentoItem->getProduct();
|
285 |
-
if ($product
|
286 |
$product = $magentoItem->getOrderItem()->getProduct();
|
287 |
}
|
|
|
|
|
|
|
|
|
|
|
288 |
if (in_array($product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
|
289 |
if ($product->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
|
290 |
$lineItem->setGrossAmount(0);
|
@@ -421,8 +427,8 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
421 |
$billingAddress = $shipToAddress;
|
422 |
}
|
423 |
// If shipping info unavailable - fallback to billing information
|
424 |
-
if (!$shipToAddress->hasData()) $shipToAddress=$billingAddress;
|
425 |
-
if (
|
426 |
// Composing invoice object
|
427 |
$invoiceRequest = new InvoiceRequestType();
|
428 |
$invoiceRequest->setSaleDate(new DateTime());
|
@@ -662,4 +668,28 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
662 |
$result[] = $invoiceRequest;
|
663 |
return $result;
|
664 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
665 |
}
|
83 |
if ($address->getStreetFull() != null)
|
84 |
$exactorAddress->setStreet1($address->getStreetFull());
|
85 |
$exactorAddress->setCity($address->getCity());
|
86 |
+
$exactorAddress->setStateOrProvince($address->getRegionCode());
|
87 |
$exactorAddress->setCountry($address->getCountry());
|
88 |
$exactorAddress->setPostalCode($address->getPostcode());
|
89 |
+
if (!$exactorAddress->hasData()) return null;
|
90 |
return $exactorAddress;
|
91 |
}
|
92 |
|
283 |
}
|
284 |
// Check if it is bundle or groped product
|
285 |
$product = $magentoItem->getProduct();
|
286 |
+
if (empty($product)) {
|
287 |
$product = $magentoItem->getOrderItem()->getProduct();
|
288 |
}
|
289 |
+
if (empty($product) && $magentoItem->getProductId() != null) {
|
290 |
+
$product = Mage::getModel('catalog/product')
|
291 |
+
->setStoreId($magentoItem->getStoreId())
|
292 |
+
->load($magentoItem->getProductId());
|
293 |
+
}
|
294 |
if (in_array($product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
|
295 |
if ($product->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
|
296 |
$lineItem->setGrossAmount(0);
|
427 |
$billingAddress = $shipToAddress;
|
428 |
}
|
429 |
// If shipping info unavailable - fallback to billing information
|
430 |
+
if ($shipToAddress == null || !$shipToAddress->hasData()) $shipToAddress=$billingAddress;
|
431 |
+
if ($shipToAddress == null || !$shipToAddress->hasData()) $shipToAddress=null;
|
432 |
// Composing invoice object
|
433 |
$invoiceRequest = new InvoiceRequestType();
|
434 |
$invoiceRequest->setSaleDate(new DateTime());
|
668 |
$result[] = $invoiceRequest;
|
669 |
return $result;
|
670 |
}
|
671 |
+
|
672 |
+
/**
|
673 |
+
* @param array $filter
|
674 |
+
* @param Mage_Customer_Model_Address_Abstract|AddressType $address
|
675 |
+
* @return bool
|
676 |
+
*/
|
677 |
+
public function isAllowedLocation($filter, $address) {
|
678 |
+
/* Filter has the following structure:
|
679 |
+
countryName1: array(state1, state2, state3)
|
680 |
+
countryName1: array(state1, state2, state3)
|
681 |
+
*/
|
682 |
+
if ($address instanceof Mage_Customer_Model_Address_Abstract) {
|
683 |
+
if (array_key_exists($address->getCountry(), $filter)) {
|
684 |
+
$states = $filter[$address->getCountry()];
|
685 |
+
return in_array($address->getRegionCode(), $states);
|
686 |
+
}
|
687 |
+
} else {
|
688 |
+
if (array_key_exists($address->getCountry(), $filter)) {
|
689 |
+
$states = $filter[$address->getCountry()];
|
690 |
+
return in_array($address->getStateOrProvince(), $states);
|
691 |
+
}
|
692 |
+
}
|
693 |
+
return false;
|
694 |
+
}
|
695 |
}
|
app/code/local/Exactor/Tax/Model/Sales/Total/Quote/Tax.php
CHANGED
@@ -117,19 +117,27 @@ class Exactor_Tax_Model_Sales_Total_Quote_Tax extends Mage_Sales_Model_Quote_Add
|
|
117 |
if (count($address->getAllItems())<=0) return; // Skip addresses without items
|
118 |
if ($address->getId() == null) return; // Skip if there is no address
|
119 |
//$this->_setAmount(0);
|
120 |
-
|
121 |
$merchantSettings = $this->loadMerchantSettings($address);
|
122 |
|
123 |
-
|
|
|
124 |
/*$this->applyTax(0);
|
125 |
$this->resetTaxForItems($address);*/
|
126 |
$this->logger->info(self::LOG_MESSAGE_TAX_CALC_FAILED . ' Missing or invalid Merchant Settings. Pass request to internal Mage tax calc. system', 'collect');
|
127 |
-
$internalTaxCalculator = Mage::getSingleton("Mage_Tax_Model_Sales_Total_Quote_Tax");
|
128 |
return $internalTaxCalculator->collect($address);
|
129 |
//return $this->processTaxCalculationFail('Missing or invalid Merchant Settings');
|
130 |
}
|
131 |
// Preparing Exactor Invoice Request
|
132 |
$invoiceRequest = $this->exactorMappingHelper->buildInvoiceRequestForQuoteAddress($address, $merchantSettings, $this->isMultishippingRequest(), $this->isEstimation());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
$this->logger->trace('Invoice ' . serialize($invoiceRequest),'collect');
|
134 |
if ($invoiceRequest != null && $this->checkIfCalculationNeeded($invoiceRequest, $merchantSettings)){
|
135 |
// Sending to Exactor Tax Calculation Request to Exactor
|
@@ -168,7 +176,7 @@ class Exactor_Tax_Model_Sales_Total_Quote_Tax extends Mage_Sales_Model_Quote_Add
|
|
168 |
* @var Mage_Sales_Model_Quote_Item $item
|
169 |
*/
|
170 |
$shippingTax = $address->getTaxAmount();
|
171 |
-
foreach ($address->getAllItems() as $item){
|
172 |
$shippingTax -= $item->getTaxAmount();
|
173 |
}
|
174 |
$shippingTax = Mage::app()->getStore()->roundPrice($shippingTax);
|
117 |
if (count($address->getAllItems())<=0) return; // Skip addresses without items
|
118 |
if ($address->getId() == null) return; // Skip if there is no address
|
119 |
//$this->_setAmount(0);
|
120 |
+
//$this->logger->trace('Called for address #' . $address->getId() . ' (' . $address->getAddressType() . ')','collect');
|
121 |
$merchantSettings = $this->loadMerchantSettings($address);
|
122 |
|
123 |
+
$internalTaxCalculator = Mage::getSingleton("Mage_Tax_Model_Sales_Total_Quote_Tax");
|
124 |
+
if ($merchantSettings == null) {
|
125 |
/*$this->applyTax(0);
|
126 |
$this->resetTaxForItems($address);*/
|
127 |
$this->logger->info(self::LOG_MESSAGE_TAX_CALC_FAILED . ' Missing or invalid Merchant Settings. Pass request to internal Mage tax calc. system', 'collect');
|
|
|
128 |
return $internalTaxCalculator->collect($address);
|
129 |
//return $this->processTaxCalculationFail('Missing or invalid Merchant Settings');
|
130 |
}
|
131 |
// Preparing Exactor Invoice Request
|
132 |
$invoiceRequest = $this->exactorMappingHelper->buildInvoiceRequestForQuoteAddress($address, $merchantSettings, $this->isMultishippingRequest(), $this->isEstimation());
|
133 |
+
// Check request filter if it is enabled
|
134 |
+
$config = ExactorPluginConfig::getInstance();
|
135 |
+
if ($config->getFeatureConfig()->isFeatureEnabled(EXACTOR_CONFIG_FEATURE_TRN_FILTER)) {
|
136 |
+
if (!$this->exactorMappingHelper->isAllowedLocation($config->get(EXACTOR_CONFIG_TRN_FILTER), $address)) {
|
137 |
+
$this->logger->info('Rejected by Exactor filter. Skipping tax calculation. Internal tax calculation will be used instead.', 'collect');
|
138 |
+
return $internalTaxCalculator->collect($address);
|
139 |
+
}
|
140 |
+
}
|
141 |
$this->logger->trace('Invoice ' . serialize($invoiceRequest),'collect');
|
142 |
if ($invoiceRequest != null && $this->checkIfCalculationNeeded($invoiceRequest, $merchantSettings)){
|
143 |
// Sending to Exactor Tax Calculation Request to Exactor
|
176 |
* @var Mage_Sales_Model_Quote_Item $item
|
177 |
*/
|
178 |
$shippingTax = $address->getTaxAmount();
|
179 |
+
foreach ($address->getAllItems() as $item) {
|
180 |
$shippingTax -= $item->getTaxAmount();
|
181 |
}
|
182 |
$shippingTax = Mage::app()->getStore()->roundPrice($shippingTax);
|
app/code/local/Exactor/Tax/etc/config.xml
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Exactor_Tax>
|
31 |
-
<version>2012.
|
32 |
</Exactor_Tax>
|
33 |
</modules>
|
34 |
<global>
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Exactor_Tax>
|
31 |
+
<version>2012.12.05</version>
|
32 |
</Exactor_Tax>
|
33 |
</modules>
|
34 |
<global>
|
lib/ExactorCommons/ExactorCommons.php
CHANGED
@@ -601,6 +601,21 @@ class ExactorProcessingService{
|
|
601 |
$this->logger = ExactorLoggingFactory::getInstance()->getLogger($this);
|
602 |
}
|
603 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
|
605 |
/**
|
606 |
* Fires following events:
|
@@ -613,6 +628,7 @@ class ExactorProcessingService{
|
|
613 |
public function calculateTax($invoiceRequest){
|
614 |
$this->logger->trace('Composing and sending request with one Invoice','calculateTax');
|
615 |
$request = ExactorConnectionFactory::getInstance()->buildRequest($this->merchantId, $this->userId, $this->partnerId);
|
|
|
616 |
$request->addInvoiceRequest($invoiceRequest);
|
617 |
// Create signature
|
618 |
$signatureBuilder = new ExactorDigitalSignatureBuilder();
|
@@ -773,12 +789,13 @@ class ExactorProcessingService{
|
|
773 |
$commitRequest = new CommitRequestType();
|
774 |
$commitRequest->setCommitDate($date);
|
775 |
$commitRequest->setInvoiceNumber($invoiceNumber);
|
|
|
776 |
$commitRequest->setInvoiceRequest($invoiceRequest);
|
777 |
$request = ExactorConnectionFactory::getInstance()->buildRequest($this->merchantId, $this->userId, $this->partnerId);
|
778 |
$request->addCommitRequest($commitRequest);
|
779 |
$response = ExactorConnectionFactory::getInstance()->buildExactorConnector()->sendRequest($request);
|
780 |
$signature='';
|
781 |
-
if ($response->hasErrors()){
|
782 |
if ($response->getFirstError()->getErrorCode() == ErrorResponseType::ERROR_INVALID_COMMIT_DATE){
|
783 |
$commitRequest->setCommitDate(new DateTime());
|
784 |
$response = ExactorConnectionFactory::getInstance()->buildExactorConnector()->sendRequest($request);
|
601 |
$this->logger = ExactorLoggingFactory::getInstance()->getLogger($this);
|
602 |
}
|
603 |
|
604 |
+
/**
|
605 |
+
* Applies address fallback logic(if needed).
|
606 |
+
* IMPORTANT: This method should be invoked AFTER all available address information was set in invoice obj.
|
607 |
+
*
|
608 |
+
* @param InvoiceRequestType $invoice
|
609 |
+
* @return void
|
610 |
+
*/
|
611 |
+
public function applyAddressFallbackLogic(&$invoice) {
|
612 |
+
if ($invoice->getBillTo() == null) {
|
613 |
+
$invoice->setBillTo($invoice->getShipFrom());
|
614 |
+
}
|
615 |
+
if ($invoice->getShipTo() == null) {
|
616 |
+
$invoice->setShipTo($invoice->getBillTo());
|
617 |
+
}
|
618 |
+
}
|
619 |
|
620 |
/**
|
621 |
* Fires following events:
|
628 |
public function calculateTax($invoiceRequest){
|
629 |
$this->logger->trace('Composing and sending request with one Invoice','calculateTax');
|
630 |
$request = ExactorConnectionFactory::getInstance()->buildRequest($this->merchantId, $this->userId, $this->partnerId);
|
631 |
+
$this->applyAddressFallbackLogic($invoiceRequest);
|
632 |
$request->addInvoiceRequest($invoiceRequest);
|
633 |
// Create signature
|
634 |
$signatureBuilder = new ExactorDigitalSignatureBuilder();
|
789 |
$commitRequest = new CommitRequestType();
|
790 |
$commitRequest->setCommitDate($date);
|
791 |
$commitRequest->setInvoiceNumber($invoiceNumber);
|
792 |
+
$this->applyAddressFallbackLogic($invoiceRequest);
|
793 |
$commitRequest->setInvoiceRequest($invoiceRequest);
|
794 |
$request = ExactorConnectionFactory::getInstance()->buildRequest($this->merchantId, $this->userId, $this->partnerId);
|
795 |
$request->addCommitRequest($commitRequest);
|
796 |
$response = ExactorConnectionFactory::getInstance()->buildExactorConnector()->sendRequest($request);
|
797 |
$signature='';
|
798 |
+
if ($response->hasErrors()) {
|
799 |
if ($response->getFirstError()->getErrorCode() == ErrorResponseType::ERROR_INVALID_COMMIT_DATE){
|
800 |
$commitRequest->setCommitDate(new DateTime());
|
801 |
$response = ExactorConnectionFactory::getInstance()->buildExactorConnector()->sendRequest($request);
|
lib/ExactorCommons/ExactorDomainObjects.php
CHANGED
@@ -206,8 +206,8 @@ class AddressType extends XmlSerializationSupport {
|
|
206 |
public function hasData(){
|
207 |
return //strlen(trim($this->getStreet1()))
|
208 |
// && strlen(trim($this->getCity()))
|
209 |
-
strlen(trim($this->getPostalCode()))
|
210 |
-
|
211 |
}
|
212 |
}
|
213 |
|
206 |
public function hasData(){
|
207 |
return //strlen(trim($this->getStreet1()))
|
208 |
// && strlen(trim($this->getCity()))
|
209 |
+
strlen(trim($this->getPostalCode()));
|
210 |
+
//&& strlen(trim($this->getStateOrProvince()));
|
211 |
}
|
212 |
}
|
213 |
|
lib/ExactorCommons/config.php
CHANGED
@@ -8,14 +8,20 @@
|
|
8 |
define('EXACTOR_CONFIG_EXEMPT_DISCOUNTS', 'exempt-descounts');
|
9 |
define('EXACTOR_CONFIG_FEATURE_EXEMPT_DISCOUNTS', 'discount-exemptions');
|
10 |
|
|
|
|
|
|
|
11 |
/* Initializing factories */
|
12 |
ExactorLoggingFactory::getInstance()->setup('MagentoLogger', IExactorLogger::TRACE);
|
13 |
-
ExactorConnectionFactory::getInstance()->setup('Magento','
|
14 |
ExactorProcessingServiceFactory::getInstance()->setup(new MagentoExactorCallback());
|
15 |
|
16 |
/* Initializing configuration object */
|
17 |
$config = ExactorPluginConfig::getInstance();
|
18 |
-
$config->pushFeatureConfigString(
|
19 |
|
20 |
/* Pushing parameters */
|
21 |
-
$config->set(
|
|
|
|
|
|
8 |
define('EXACTOR_CONFIG_EXEMPT_DISCOUNTS', 'exempt-descounts');
|
9 |
define('EXACTOR_CONFIG_FEATURE_EXEMPT_DISCOUNTS', 'discount-exemptions');
|
10 |
|
11 |
+
define('EXACTOR_CONFIG_TRN_FILTER', 'trn-filter');
|
12 |
+
define('EXACTOR_CONFIG_FEATURE_TRN_FILTER', 'trn-filter');
|
13 |
+
|
14 |
/* Initializing factories */
|
15 |
ExactorLoggingFactory::getInstance()->setup('MagentoLogger', IExactorLogger::TRACE);
|
16 |
+
ExactorConnectionFactory::getInstance()->setup('Magento','v20121227');
|
17 |
ExactorProcessingServiceFactory::getInstance()->setup(new MagentoExactorCallback());
|
18 |
|
19 |
/* Initializing configuration object */
|
20 |
$config = ExactorPluginConfig::getInstance();
|
21 |
+
$config->pushFeatureConfigString('TzoxOToiRmVhdHVyZUNvbmZpZ0hvbGRlciI6MTp7czoxMDoiACoAX2NvbmZpZyI7YToyOntzOjI2OiJlbmFibGUtZGlzY291bnQtZXhlbXB0aW9ucyI7czo0OiJ0cnVlIjtzOjE3OiJlbmFibGUtdHJuLWZpbHRlciI7czo0OiJ0cnVlIjt9fQ==');
|
22 |
|
23 |
/* Pushing parameters */
|
24 |
+
$config->set(EXACTOR_CONFIG_EXEMPT_DISCOUNTS, array());
|
25 |
+
$config->set(EXACTOR_CONFIG_TRN_FILTER, array(
|
26 |
+
'US' => array('NY', 'FL')
|
27 |
+
));
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Mage_Exactor_Tax</name>
|
4 |
-
<version>2012.
|
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, Magento Enterprise 1.8-1.12.x</notes>
|
14 |
<authors><author><name>Exactor, Inc.</name><user>exactor</user><email>support@exactor.com</email></author></authors>
|
15 |
-
<date>2012-
|
16 |
-
<time>
|
17 |
-
<contents><target name="magelocal"><dir name="Exactor"><dir name="Core"><dir name="Helper"><file name="SessionCache.php" hash="72692a33574f8ba2f1858e2e93aa4edf"/></dir><dir name="Model"><file name="ExactorTransaction.php" hash="852aa20f6e3b7aa0001439d4bffe9724"/><file name="MerchantSettings.php" hash="71a7c2308f6f0eda102ae84dd90df751"/><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="2441fb08bbeb579831cea4d3fbd31104"/></dir></dir><dir name="etc"><file name="config.xml" hash="98ecc82a5f7b74ac0bfc0f7ab512afdb"/></dir></dir><dir name="ExactorSettings"><dir name="Block"><file name="Form.php" hash="5ea1d72197306072fe5fad9b97d109e8"/></dir><dir name="Helper"><file name="Data.php" hash="a23bb9c251f0dbb77c107d01dde39e86"/><file name="VersionResolver.php" hash="14dce068dfe2a7d3364c4bd29e6f8431"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FormController.php" hash="c0985258b110e0314e6b6ea091ae8c19"/></dir><file name="AjaxController.php" hash="c07aeeca00e1408e52945fc027569793"/><file name="IndexController.php" hash="f47cbc274dd68c57c30b60bbee69259e"/></dir><dir name="etc"><file name="config.xml" hash="674c326bfc901d0becf7c94ddcdd1452"/></dir><dir name="sql"><dir name="ExactorSettings_setup"><file name="mysql4-install-14.04.2012.php" hash="f35af1e12921b57479cb4b5677937a0c"/><file name="upgrade-2012.06.14-2012.09.25.php" hash="174fda5224bc23cdf147fb059d079478"/></dir></dir></dir><dir name="Sales"><dir name="Model"><file name="Observer.php" 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.12.27</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, Magento Enterprise 1.8-1.12.x</notes>
|
14 |
<authors><author><name>Exactor, Inc.</name><user>exactor</user><email>support@exactor.com</email></author></authors>
|
15 |
+
<date>2012-12-27</date>
|
16 |
+
<time>15:15:29</time>
|
17 |
+
<contents><target name="magelocal"><dir name="Exactor"><dir name="Core"><dir name="Helper"><file name="SessionCache.php" hash="72692a33574f8ba2f1858e2e93aa4edf"/></dir><dir name="Model"><file name="ExactorTransaction.php" hash="852aa20f6e3b7aa0001439d4bffe9724"/><file name="MerchantSettings.php" hash="71a7c2308f6f0eda102ae84dd90df751"/><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="2441fb08bbeb579831cea4d3fbd31104"/></dir></dir><dir name="etc"><file name="config.xml" hash="98ecc82a5f7b74ac0bfc0f7ab512afdb"/></dir></dir><dir name="ExactorSettings"><dir name="Block"><file name="Form.php" hash="5ea1d72197306072fe5fad9b97d109e8"/></dir><dir name="Helper"><file name="Data.php" hash="a23bb9c251f0dbb77c107d01dde39e86"/><file name="VersionResolver.php" hash="14dce068dfe2a7d3364c4bd29e6f8431"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FormController.php" hash="c0985258b110e0314e6b6ea091ae8c19"/></dir><file name="AjaxController.php" hash="c07aeeca00e1408e52945fc027569793"/><file name="IndexController.php" hash="f47cbc274dd68c57c30b60bbee69259e"/></dir><dir name="etc"><file name="config.xml" hash="674c326bfc901d0becf7c94ddcdd1452"/></dir><dir name="sql"><dir name="ExactorSettings_setup"><file name="mysql4-install-14.04.2012.php" hash="f35af1e12921b57479cb4b5677937a0c"/><file name="upgrade-2012.06.14-2012.09.25.php" hash="174fda5224bc23cdf147fb059d079478"/></dir></dir></dir><dir name="Sales"><dir name="Model"><file name="Observer.php" hash="2c0ee19990b83aa2a5d774f69771de62"/></dir><dir name="etc"><file name="config.xml" hash="ba31618f5165dda20010c40e7ef8dad1"/></dir></dir><dir name="Tax"><dir name="Helper"><file name="Calculation.php" hash="29c5252bdd48b173c90588f449114024"/><file name="Mapping.php" hash="b009f893de345cc7981b5d3d440854b4"/></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="3c283d0960292d45fd95245c7ff11925"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="dac507a6a0437f511973c29646bd6a8d"/></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="3f6e14533076ab97dbb0c98ba770bf87"/></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="7721531d9aa9f3732997e7c0180477fb"/><file name="ExactorDomainObjects.php" hash="ddfc1d3b00874f545eed99d3d35efdc6"/><file name="Magento.php" hash="76da7333fe0692053a47f8564c7b513a"/><file name="RegionResolver.php" hash="2537638a7895a169cee4b1df786d22fb"/><file name="XmlProcessing.php" hash="383fd21839889d720e2094e83ccc7a2a"/><file name="config.php" hash="5c9d0445126ab8905a54f20b7ac3bb66"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|