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 | 2013.11.06 |
| Comparing to | |
| See all releases | |
Code changes from version 2013.07.24 to 2013.11.06
- app/code/local/Exactor/ExactorSettings/Helper/Data.php +9 -0
- app/code/local/Exactor/ExactorSettings/controllers/Adminhtml/FormController.php +9 -1
- app/code/local/Exactor/Sales/Model/Observer.php +43 -11
- app/code/local/Exactor/Tax/Helper/Mapping.php +130 -38
- app/code/local/Exactor/Tax/Model/Sales/Total/Quote/Tax.php +1 -1
- app/design/adminhtml/default/default/template/ExactorSettings/settingsform.phtml +13 -0
- lib/ExactorCommons/ExactorCommons.php +8 -3
- lib/ExactorCommons/XmlProcessing.php +6 -1
- lib/ExactorCommons/config.php +1 -1
- package.xml +4 -4
app/code/local/Exactor/ExactorSettings/Helper/Data.php
CHANGED
|
@@ -60,6 +60,15 @@ class Exactor_ExactorSettings_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
| 60 |
return $merchantSettingsModel;
|
| 61 |
}
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
/**
|
| 64 |
* Returns merchant settings from DB
|
| 65 |
* or null if there is <strong>no any record</strong> or settings <strong>are not populated</strong>
|
| 60 |
return $merchantSettingsModel;
|
| 61 |
}
|
| 62 |
|
| 63 |
+
function removeSettings($storeViewId) {
|
| 64 |
+
$merchantSettingsModel = $this->loadMerchantSettingsOrEmptyObject($storeViewId);
|
| 65 |
+
if ($merchantSettingsModel->getID() != null){
|
| 66 |
+
$merchantSettingsModel->delete();
|
| 67 |
+
return true;
|
| 68 |
+
}
|
| 69 |
+
return false;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
/**
|
| 73 |
* Returns merchant settings from DB
|
| 74 |
* or null if there is <strong>no any record</strong> or settings <strong>are not populated</strong>
|
app/code/local/Exactor/ExactorSettings/controllers/Adminhtml/FormController.php
CHANGED
|
@@ -66,6 +66,14 @@ class Exactor_ExactorSettings_Adminhtml_FormController extends Mage_Adminhtml_Co
|
|
| 66 |
$this->loadLayout();
|
| 67 |
$storeViewId = $this->getRequest()->getParam('storeview',Mage::app()->getDefaultStoreView()->getId());
|
| 68 |
$this->getLayout()->getBlock('ExactorSettingsForm')->setStoreViewId($storeViewId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
}catch(Exception $e){
|
| 70 |
Mage::log("$e");
|
| 71 |
}
|
|
@@ -78,7 +86,7 @@ class Exactor_ExactorSettings_Adminhtml_FormController extends Mage_Adminhtml_Co
|
|
| 78 |
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 79 |
* @return void
|
| 80 |
*/
|
| 81 |
-
protected function preprocessInput(
|
| 82 |
foreach($merchantSettings->getData() as $key => $value){
|
| 83 |
if (is_string($value))
|
| 84 |
$merchantSettings->setData($key, trim($value));
|
| 66 |
$this->loadLayout();
|
| 67 |
$storeViewId = $this->getRequest()->getParam('storeview',Mage::app()->getDefaultStoreView()->getId());
|
| 68 |
$this->getLayout()->getBlock('ExactorSettingsForm')->setStoreViewId($storeViewId);
|
| 69 |
+
// Additional Actions
|
| 70 |
+
if ($this->getRequest()->getParam('action_del_settings',null) != null) {
|
| 71 |
+
/** @var Exactor_ExactorSettings_Helper_Data $exactorSettingsHelper */
|
| 72 |
+
$exactorSettingsHelper = Mage::helper('ExactorSettings');
|
| 73 |
+
$exactorSettingsHelper->removeSettings($this->getRequest()->getParam('action_del_settings',null));
|
| 74 |
+
$this->sendSuccess("Successfully cleared settings");
|
| 75 |
+
return;
|
| 76 |
+
}
|
| 77 |
}catch(Exception $e){
|
| 78 |
Mage::log("$e");
|
| 79 |
}
|
| 86 |
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 87 |
* @return void
|
| 88 |
*/
|
| 89 |
+
protected function preprocessInput($merchantSettings){
|
| 90 |
foreach($merchantSettings->getData() as $key => $value){
|
| 91 |
if (is_string($value))
|
| 92 |
$merchantSettings->setData($key, trim($value));
|
app/code/local/Exactor/Sales/Model/Observer.php
CHANGED
|
@@ -74,7 +74,11 @@ class Exactor_Sales_Model_Observer {
|
|
| 74 |
return $merchantSettings;
|
| 75 |
}
|
| 76 |
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
if ($invoice->getIncrementId() == null) {
|
| 79 |
try{
|
| 80 |
$entityType = Mage::getModel('eav/entity_type')->loadByCode("invoice");
|
|
@@ -87,7 +91,12 @@ class Exactor_Sales_Model_Observer {
|
|
| 87 |
return $invoice->getIncrementId();
|
| 88 |
}
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
try {
|
| 92 |
if (!$this->underEffectiveDate($merchantSettings->getEffectiveDate(), $invoice->getOrder()->getCreatedAt())){
|
| 93 |
$this->logger->info("Order " . $invoice->getOrder()->getIncrementId() ." is not under effective date. Skipping.", "commitTransactionForInvoice");
|
|
@@ -111,7 +120,12 @@ class Exactor_Sales_Model_Observer {
|
|
| 111 |
}
|
| 112 |
}
|
| 113 |
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
try {
|
| 116 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
|
| 117 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
|
@@ -135,7 +149,11 @@ class Exactor_Sales_Model_Observer {
|
|
| 135 |
}
|
| 136 |
}
|
| 137 |
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
try{
|
| 140 |
foreach ($order->getInvoiceCollection() as $invoice){
|
| 141 |
$this->refundTransactionForInvoice($invoice, $merchantSettings);
|
|
@@ -166,12 +184,16 @@ class Exactor_Sales_Model_Observer {
|
|
| 166 |
* Stores order in our local DB, Commits transaction if needed.
|
| 167 |
* Returns false if for some reason operation wasn't successful.
|
| 168 |
*
|
| 169 |
-
* @param $order
|
| 170 |
* @return bool
|
| 171 |
*/
|
| 172 |
-
private function processFinishedOrder(
|
| 173 |
$merchantSettings = $this->loadMerchantSettings($order);
|
| 174 |
if ($merchantSettings==null) return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
|
| 176 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
| 177 |
$transactionInfo = $this->sessionCache->popTransactionInfo();
|
|
@@ -207,7 +229,7 @@ class Exactor_Sales_Model_Observer {
|
|
| 207 |
* @param \Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 208 |
* @return TaxResponseType
|
| 209 |
*/
|
| 210 |
-
public function commitTransactionForOrder(
|
| 211 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
|
| 212 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
| 213 |
try {
|
|
@@ -241,7 +263,10 @@ class Exactor_Sales_Model_Observer {
|
|
| 241 |
return null;
|
| 242 |
}
|
| 243 |
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
| 245 |
$this->logger->trace('called', 'handleAllOrdersCompleted');
|
| 246 |
if (is_array($observer->getOrders()))
|
| 247 |
$orders = array_reverse($observer->getOrders());
|
|
@@ -254,7 +279,10 @@ class Exactor_Sales_Model_Observer {
|
|
| 254 |
$this->sessionCache->clear();
|
| 255 |
}
|
| 256 |
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
| 258 |
$merchantSettings = $this->loadMerchantSettings($creditMemo->getOrder());
|
| 259 |
if ($merchantSettings==null) return;
|
| 260 |
if (!$this->underEffectiveDate($merchantSettings->getEffectiveDate(), $creditMemo->getOrder()->getCreatedAt())){
|
|
@@ -285,7 +313,7 @@ class Exactor_Sales_Model_Observer {
|
|
| 285 |
* @param Varien_Event_Observer $observer
|
| 286 |
* @return void
|
| 287 |
*/
|
| 288 |
-
public function handleCreatedOrder(
|
| 289 |
$this->logger->trace('called', 'handleCreatedOrder');
|
| 290 |
if ($this->shouldOrderProcessingRunInCompatibilityMode($observer->getOrder())) {
|
| 291 |
$this->logger->info('Order processing started in compatibility mode.', 'handleCreatedOrder');
|
|
@@ -301,13 +329,17 @@ class Exactor_Sales_Model_Observer {
|
|
| 301 |
return true;
|
| 302 |
}
|
| 303 |
$mageVersionInfo = Mage::getVersionInfo();
|
| 304 |
-
|
|
|
|
| 305 |
$this->logger->info('Magento Enterprise detected', 'shouldOrderProcessingRunInCompatibilityMode');
|
| 306 |
return true;
|
| 307 |
}
|
| 308 |
return false;
|
| 309 |
}
|
| 310 |
|
|
|
|
|
|
|
|
|
|
| 311 |
public function handleNewCreditMemo(Varien_Event_Observer $observer){
|
| 312 |
$this->logger->trace('called', 'handleNewCreditMemo');
|
| 313 |
$merchantSettings = $this->loadMerchantSettings($observer->getCreditmemo()->getOrder());
|
| 74 |
return $merchantSettings;
|
| 75 |
}
|
| 76 |
|
| 77 |
+
/**
|
| 78 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
| 79 |
+
* @return null|string
|
| 80 |
+
*/
|
| 81 |
+
private function getInvoiceIncrementId($invoice) {
|
| 82 |
if ($invoice->getIncrementId() == null) {
|
| 83 |
try{
|
| 84 |
$entityType = Mage::getModel('eav/entity_type')->loadByCode("invoice");
|
| 91 |
return $invoice->getIncrementId();
|
| 92 |
}
|
| 93 |
|
| 94 |
+
/**
|
| 95 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
| 96 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 97 |
+
* @return null
|
| 98 |
+
*/
|
| 99 |
+
private function commitTransactionForInvoice($invoice, $merchantSettings) {
|
| 100 |
try {
|
| 101 |
if (!$this->underEffectiveDate($merchantSettings->getEffectiveDate(), $invoice->getOrder()->getCreatedAt())){
|
| 102 |
$this->logger->info("Order " . $invoice->getOrder()->getIncrementId() ." is not under effective date. Skipping.", "commitTransactionForInvoice");
|
| 120 |
}
|
| 121 |
}
|
| 122 |
|
| 123 |
+
/**
|
| 124 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
| 125 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 126 |
+
* @return null
|
| 127 |
+
*/
|
| 128 |
+
private function refundTransactionForInvoice($invoice, $merchantSettings) {
|
| 129 |
try {
|
| 130 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
|
| 131 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
| 149 |
}
|
| 150 |
}
|
| 151 |
|
| 152 |
+
/**
|
| 153 |
+
* @param Mage_Sales_Model_Order $order
|
| 154 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 155 |
+
*/
|
| 156 |
+
private function refundAllInvoicesForOrder($order, $merchantSettings) {
|
| 157 |
try{
|
| 158 |
foreach ($order->getInvoiceCollection() as $invoice){
|
| 159 |
$this->refundTransactionForInvoice($invoice, $merchantSettings);
|
| 184 |
* Stores order in our local DB, Commits transaction if needed.
|
| 185 |
* Returns false if for some reason operation wasn't successful.
|
| 186 |
*
|
| 187 |
+
* @param Mage_Sales_Model_Order $order
|
| 188 |
* @return bool
|
| 189 |
*/
|
| 190 |
+
private function processFinishedOrder($order){
|
| 191 |
$merchantSettings = $this->loadMerchantSettings($order);
|
| 192 |
if ($merchantSettings==null) return false;
|
| 193 |
+
if (!$this->underEffectiveDate($merchantSettings->getEffectiveDate(), $order->getCreatedAt())){
|
| 194 |
+
$this->logger->info("Order " . $order->getIncrementId() ." is not under effective date. Skipping.",
|
| 195 |
+
"processFinishedOrder");
|
| 196 |
+
}
|
| 197 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
|
| 198 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
| 199 |
$transactionInfo = $this->sessionCache->popTransactionInfo();
|
| 229 |
* @param \Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 230 |
* @return TaxResponseType
|
| 231 |
*/
|
| 232 |
+
public function commitTransactionForOrder($order, $merchantSettings) {
|
| 233 |
$exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
|
| 234 |
->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
|
| 235 |
try {
|
| 263 |
return null;
|
| 264 |
}
|
| 265 |
|
| 266 |
+
/**
|
| 267 |
+
* @param Varien_Event_Observer $observer
|
| 268 |
+
*/
|
| 269 |
+
public function handleAllOrdersCompleted($observer){
|
| 270 |
$this->logger->trace('called', 'handleAllOrdersCompleted');
|
| 271 |
if (is_array($observer->getOrders()))
|
| 272 |
$orders = array_reverse($observer->getOrders());
|
| 279 |
$this->sessionCache->clear();
|
| 280 |
}
|
| 281 |
|
| 282 |
+
/**
|
| 283 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
| 284 |
+
*/
|
| 285 |
+
private function partialRefund($creditMemo){
|
| 286 |
$merchantSettings = $this->loadMerchantSettings($creditMemo->getOrder());
|
| 287 |
if ($merchantSettings==null) return;
|
| 288 |
if (!$this->underEffectiveDate($merchantSettings->getEffectiveDate(), $creditMemo->getOrder()->getCreatedAt())){
|
| 313 |
* @param Varien_Event_Observer $observer
|
| 314 |
* @return void
|
| 315 |
*/
|
| 316 |
+
public function handleCreatedOrder($observer){
|
| 317 |
$this->logger->trace('called', 'handleCreatedOrder');
|
| 318 |
if ($this->shouldOrderProcessingRunInCompatibilityMode($observer->getOrder())) {
|
| 319 |
$this->logger->info('Order processing started in compatibility mode.', 'handleCreatedOrder');
|
| 329 |
return true;
|
| 330 |
}
|
| 331 |
$mageVersionInfo = Mage::getVersionInfo();
|
| 332 |
+
$mageEdition = Mage::getEdition();
|
| 333 |
+
if ($mageEdition == Mage::EDITION_ENTERPRISE && $mageVersionInfo['major']==1 && $mageVersionInfo['minor'] == 8){
|
| 334 |
$this->logger->info('Magento Enterprise detected', 'shouldOrderProcessingRunInCompatibilityMode');
|
| 335 |
return true;
|
| 336 |
}
|
| 337 |
return false;
|
| 338 |
}
|
| 339 |
|
| 340 |
+
/**
|
| 341 |
+
* @param Varien_Event_Observer $observer
|
| 342 |
+
*/
|
| 343 |
public function handleNewCreditMemo(Varien_Event_Observer $observer){
|
| 344 |
$this->logger->trace('called', 'handleNewCreditMemo');
|
| 345 |
$merchantSettings = $this->loadMerchantSettings($observer->getCreditmemo()->getOrder());
|
app/code/local/Exactor/Tax/Helper/Mapping.php
CHANGED
|
@@ -85,7 +85,11 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 85 |
return join(' ', $parts);
|
| 86 |
}
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
$exactorAddress = new AddressType();
|
| 90 |
if ($address==null) return null;
|
| 91 |
// Set defaults
|
|
@@ -110,11 +114,19 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 110 |
return $exactorAddress;
|
| 111 |
}
|
| 112 |
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
return $this->buildExactorAddressForAbstractAddress($address);
|
| 115 |
}
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
return $this->buildExactorAddressForAbstractAddress($address);
|
| 119 |
}
|
| 120 |
|
|
@@ -123,8 +135,7 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 123 |
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 124 |
* @return string
|
| 125 |
*/
|
| 126 |
-
public function getSKUForItem($magentoItem,
|
| 127 |
-
Exactor_Core_Model_MerchantSettings $merchantSettings){
|
| 128 |
$sku='';
|
| 129 |
$product = $magentoItem->getProduct();
|
| 130 |
if ($product == null)
|
|
@@ -173,8 +184,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 173 |
return false;
|
| 174 |
}
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
if ($quoteAddress->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_BILLING) return null; // There is no shipping fees there
|
| 180 |
if ($quoteAddress->getShippingAmount()==0) return null;
|
|
@@ -185,7 +200,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 185 |
return $shippingLineItem;
|
| 186 |
}
|
| 187 |
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
if ($creditMemo->getShippingAmount()==0) return null;
|
| 190 |
$lineItem = $this->getShippingLineItem($merchantSettings, $creditMemo->getOrder()->getShippingMethod(),
|
| 191 |
$creditMemo->getOrder()->getShippingDescription(),
|
|
@@ -195,7 +215,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 195 |
return $lineItem;
|
| 196 |
}
|
| 197 |
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
if ($order->getBaseShippingAmount() == 0) return null;
|
| 200 |
$lineItem = $this->getShippingLineItem($merchantSettings, $order->getShippingMethod(),
|
| 201 |
$order->getShippingDescription(),
|
|
@@ -203,13 +228,25 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 203 |
return $lineItem;
|
| 204 |
}
|
| 205 |
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
if ($invoice->getBaseShippingAmount() == 0) return null;
|
| 208 |
return $this->getShippingLineItemForOrder($invoice->getOrder(), $merchantSettings);
|
| 209 |
}
|
| 210 |
|
| 211 |
-
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
$shippingLineItem = new LineItemType();
|
| 214 |
$shippingLineItem->setDescription(self::MSG_SHIPPING_DESCRIPTION_PREFIX . $carrierDescription);
|
| 215 |
if (trim($shippingLineItem->getDescription())==''){
|
|
@@ -257,7 +294,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 257 |
return self::PRICE_TYPE_DYNAMIC;
|
| 258 |
}
|
| 259 |
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
if ($merchantSettings->isShippingIncludeHandling()) return null; // Handling already included in the shipping
|
| 262 |
$handlingLineItem = new LineItemType();
|
| 263 |
$handlingLineItem->setId(self::LINE_ITEM_ID_HANDLING);
|
|
@@ -269,8 +311,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 269 |
return $handlingLineItem;
|
| 270 |
}
|
| 271 |
|
| 272 |
-
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
if ($quoteAddress->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_BILLING) return null; // There is no shipping fees there
|
| 275 |
return $this->getHandlingLineItem($merchantSettings, $quoteAddress->getShippingMethod());
|
| 276 |
}
|
|
@@ -282,8 +328,8 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 282 |
* @return LineItemType
|
| 283 |
*/
|
| 284 |
public function buildLineItemForMagentoItem($magentoItem,
|
| 285 |
-
|
| 286 |
-
|
| 287 |
$lineItem = new LineItemType();
|
| 288 |
$lineItem->setDescription($magentoItem->getName());
|
| 289 |
if ($magentoItem->getBaseRowTotal())
|
|
@@ -347,7 +393,11 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 347 |
return false;
|
| 348 |
}
|
| 349 |
|
| 350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
if ($discountAmount > 0){
|
| 352 |
$discountedLine = self::MSG_DISCOUNTED_BY . $discountAmount;
|
| 353 |
$item->setDescription($item->getDescription() . " ($discountedLine)");
|
|
@@ -355,8 +405,13 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 355 |
}
|
| 356 |
}
|
| 357 |
|
| 358 |
-
|
| 359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
$exemptionId = '';
|
| 361 |
if ($merchantSettings->getExemptionsSupported()){
|
| 362 |
$customerExemptionId = $quoteAddress->getQuote()->getCustomer()->getData(self::ATTRIBUTE_NAME_EXEMPTION);
|
|
@@ -365,8 +420,13 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 365 |
return $exemptionId;
|
| 366 |
}
|
| 367 |
|
| 368 |
-
|
| 369 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
$exemptionId = '';
|
| 371 |
if ($merchantSettings->getExemptionsSupported()){
|
| 372 |
$customerExemptionId = $creditMemo->getOrder()->getCustomerTaxvat();
|
|
@@ -375,8 +435,13 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 375 |
return $exemptionId;
|
| 376 |
}
|
| 377 |
|
| 378 |
-
|
| 379 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
$exemptionId = '';
|
| 381 |
if ($merchantSettings->getExemptionsSupported()){
|
| 382 |
$customerExemptionId = $order->getCustomerTaxvat();
|
|
@@ -385,7 +450,11 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 385 |
return $exemptionId;
|
| 386 |
}
|
| 387 |
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
$store = Mage::app()->getStore();
|
| 390 |
if ($quoteAddress->getQuote() != null && $quoteAddress->getQuote()->getStoreId() != null){
|
| 391 |
$store = $quoteAddress->getQuote()->getStore();
|
|
@@ -393,7 +462,11 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 393 |
return $this->getCurrencyCodeForStore($store);
|
| 394 |
}
|
| 395 |
|
| 396 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
$currency = 'USD';
|
| 398 |
if ($store != null){
|
| 399 |
$currency = $store->getBaseCurrencyCode()!=null ? $store->getBaseCurrencyCode() : $currency;
|
|
@@ -428,8 +501,8 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 428 |
* @param $isEstimation
|
| 429 |
* @return InvoiceRequestType
|
| 430 |
*/
|
| 431 |
-
public function buildInvoiceRequestForQuoteAddress(
|
| 432 |
-
|
| 433 |
$isMultishipping, $isEstimation){
|
| 434 |
// Building Invoice Parts
|
| 435 |
$shipToAddress = $this->buildExactorAddressForQuoteAddress($quoteAddress);
|
|
@@ -505,7 +578,7 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 505 |
*/
|
| 506 |
private function calculateProratedShippingAndHandling($orderedShippingAmount, $alreadyProcessedAmount,
|
| 507 |
$targetShippingAmount, $handlingTotalAmount,
|
| 508 |
-
|
| 509 |
// $orderedShippingAmount = $invoice->getOrder()->getBaseShippingAmount();
|
| 510 |
// $alreadyProcessedAmount = $invoice->getOrder()->getBaseShippingRefunded();
|
| 511 |
// $targetShippingAmount = $invoice->getBaseShippingAmount();
|
|
@@ -523,7 +596,7 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 523 |
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 524 |
* @return array InvoiceRequestType
|
| 525 |
*/
|
| 526 |
-
public function buildInvoiceRequestsForCreditMemo(
|
| 527 |
$result = array();
|
| 528 |
$invoiceRequest = new InvoiceRequestType();
|
| 529 |
$invoiceRequest->setBillTo($this->buildExactorAddressForOrderAddress($creditMemo->getBillingAddress()));
|
|
@@ -594,7 +667,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 594 |
return $result;
|
| 595 |
}
|
| 596 |
|
| 597 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 598 |
$res = $default;
|
| 599 |
try{
|
| 600 |
$res= '@'.$order->getCreatedAtDate()->getTimestamp();
|
|
@@ -605,7 +683,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 605 |
return new DateTime($res);
|
| 606 |
}
|
| 607 |
|
| 608 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 609 |
$result = array();
|
| 610 |
$invoiceRequest = new InvoiceRequestType();
|
| 611 |
$invoiceRequest->setBillTo($this->buildExactorAddressForOrderAddress($invoice->getBillingAddress()));
|
|
@@ -646,7 +729,12 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 646 |
return $result;
|
| 647 |
}
|
| 648 |
|
| 649 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 650 |
$result = array();
|
| 651 |
$invoiceRequest = new InvoiceRequestType();
|
| 652 |
$invoiceRequest->setBillTo($this->buildExactorAddressForOrderAddress($order->getBillingAddress()));
|
|
@@ -712,11 +800,15 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 712 |
return false;
|
| 713 |
}
|
| 714 |
|
| 715 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 716 |
if ($address==null || !$address->hasData()) return false;
|
| 717 |
return strlen(trim($address->getStreet1())) > 0
|
| 718 |
&& strlen(trim($address->getFullName())) > 0
|
| 719 |
-
&& strlen(trim($address->getCity()));
|
| 720 |
}
|
| 721 |
|
| 722 |
/**
|
|
@@ -727,9 +819,9 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
|
|
| 727 |
* @param InvoiceRequestType $invoice
|
| 728 |
* @return bool
|
| 729 |
*/
|
| 730 |
-
public function isInvoiceAddressesFullyPopulated(
|
| 731 |
if ($invoice == null) return false;
|
| 732 |
-
return $this->isAddessFullyPopulated($invoice->getShipTo())
|
| 733 |
-
|
| 734 |
}
|
| 735 |
}
|
| 85 |
return join(' ', $parts);
|
| 86 |
}
|
| 87 |
|
| 88 |
+
/**
|
| 89 |
+
* @param Mage_Customer_Model_Address_Abstract $address
|
| 90 |
+
* @return AddressType|null
|
| 91 |
+
*/
|
| 92 |
+
private function buildExactorAddressForAbstractAddress($address){
|
| 93 |
$exactorAddress = new AddressType();
|
| 94 |
if ($address==null) return null;
|
| 95 |
// Set defaults
|
| 114 |
return $exactorAddress;
|
| 115 |
}
|
| 116 |
|
| 117 |
+
/**
|
| 118 |
+
* @param Mage_Sales_Model_Order_Address $address
|
| 119 |
+
* @return AddressType|null
|
| 120 |
+
*/
|
| 121 |
+
public function buildExactorAddressForOrderAddress($address){
|
| 122 |
return $this->buildExactorAddressForAbstractAddress($address);
|
| 123 |
}
|
| 124 |
|
| 125 |
+
/**
|
| 126 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 127 |
+
* @return AddressType|null
|
| 128 |
+
*/
|
| 129 |
+
public function buildExactorAddressForQuoteAddress($address){
|
| 130 |
return $this->buildExactorAddressForAbstractAddress($address);
|
| 131 |
}
|
| 132 |
|
| 135 |
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 136 |
* @return string
|
| 137 |
*/
|
| 138 |
+
public function getSKUForItem($magentoItem, $merchantSettings){
|
|
|
|
| 139 |
$sku='';
|
| 140 |
$product = $magentoItem->getProduct();
|
| 141 |
if ($product == null)
|
| 184 |
return false;
|
| 185 |
}
|
| 186 |
|
| 187 |
+
/**
|
| 188 |
+
* @param Mage_Sales_Model_Quote_Address $quoteAddress
|
| 189 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 190 |
+
* @return LineItemType|null
|
| 191 |
+
*/
|
| 192 |
+
public function getShippingLineItemForQuoteAddress($quoteAddress, $merchantSettings) {
|
| 193 |
|
| 194 |
if ($quoteAddress->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_BILLING) return null; // There is no shipping fees there
|
| 195 |
if ($quoteAddress->getShippingAmount()==0) return null;
|
| 200 |
return $shippingLineItem;
|
| 201 |
}
|
| 202 |
|
| 203 |
+
/**
|
| 204 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
| 205 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 206 |
+
* @return LineItemType|null
|
| 207 |
+
*/
|
| 208 |
+
public function getShippingLineItemForCreditMemo($creditMemo, $merchantSettings){
|
| 209 |
if ($creditMemo->getShippingAmount()==0) return null;
|
| 210 |
$lineItem = $this->getShippingLineItem($merchantSettings, $creditMemo->getOrder()->getShippingMethod(),
|
| 211 |
$creditMemo->getOrder()->getShippingDescription(),
|
| 215 |
return $lineItem;
|
| 216 |
}
|
| 217 |
|
| 218 |
+
/**
|
| 219 |
+
* @param Mage_Sales_Model_Order $order
|
| 220 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 221 |
+
* @return LineItemType|null
|
| 222 |
+
*/
|
| 223 |
+
public function getShippingLineItemForOrder($order, $merchantSettings) {
|
| 224 |
if ($order->getBaseShippingAmount() == 0) return null;
|
| 225 |
$lineItem = $this->getShippingLineItem($merchantSettings, $order->getShippingMethod(),
|
| 226 |
$order->getShippingDescription(),
|
| 228 |
return $lineItem;
|
| 229 |
}
|
| 230 |
|
| 231 |
+
/**
|
| 232 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
| 233 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 234 |
+
* @return LineItemType|null
|
| 235 |
+
*/
|
| 236 |
+
public function getShippingLineItemForInvoice($invoice, $merchantSettings) {
|
| 237 |
if ($invoice->getBaseShippingAmount() == 0) return null;
|
| 238 |
return $this->getShippingLineItemForOrder($invoice->getOrder(), $merchantSettings);
|
| 239 |
}
|
| 240 |
|
| 241 |
+
/**
|
| 242 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 243 |
+
* @param $carrierName
|
| 244 |
+
* @param $carrierDescription
|
| 245 |
+
* @param $amount
|
| 246 |
+
* @param int $discount
|
| 247 |
+
* @return LineItemType
|
| 248 |
+
*/
|
| 249 |
+
private function getShippingLineItem($merchantSettings, $carrierName, $carrierDescription, $amount, $discount=0){
|
| 250 |
$shippingLineItem = new LineItemType();
|
| 251 |
$shippingLineItem->setDescription(self::MSG_SHIPPING_DESCRIPTION_PREFIX . $carrierDescription);
|
| 252 |
if (trim($shippingLineItem->getDescription())==''){
|
| 294 |
return self::PRICE_TYPE_DYNAMIC;
|
| 295 |
}
|
| 296 |
|
| 297 |
+
/**
|
| 298 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 299 |
+
* @param $carrierName
|
| 300 |
+
* @return LineItemType|null
|
| 301 |
+
*/
|
| 302 |
+
public function getHandlingLineItem($merchantSettings, $carrierName){
|
| 303 |
if ($merchantSettings->isShippingIncludeHandling()) return null; // Handling already included in the shipping
|
| 304 |
$handlingLineItem = new LineItemType();
|
| 305 |
$handlingLineItem->setId(self::LINE_ITEM_ID_HANDLING);
|
| 311 |
return $handlingLineItem;
|
| 312 |
}
|
| 313 |
|
| 314 |
+
/**
|
| 315 |
+
* @param Mage_Sales_Model_Quote_Address $quoteAddress
|
| 316 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 317 |
+
* @return LineItemType|null
|
| 318 |
+
*/
|
| 319 |
+
private function getHandlingLineItemForQuoteAddress($quoteAddress, $merchantSettings){
|
| 320 |
if ($quoteAddress->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_BILLING) return null; // There is no shipping fees there
|
| 321 |
return $this->getHandlingLineItem($merchantSettings, $quoteAddress->getShippingMethod());
|
| 322 |
}
|
| 328 |
* @return LineItemType
|
| 329 |
*/
|
| 330 |
public function buildLineItemForMagentoItem($magentoItem,
|
| 331 |
+
$quoteAddress,
|
| 332 |
+
$merchantSettings){
|
| 333 |
$lineItem = new LineItemType();
|
| 334 |
$lineItem->setDescription($magentoItem->getName());
|
| 335 |
if ($magentoItem->getBaseRowTotal())
|
| 393 |
return false;
|
| 394 |
}
|
| 395 |
|
| 396 |
+
/**
|
| 397 |
+
* @param LineItemType $item
|
| 398 |
+
* @param int $discountAmount
|
| 399 |
+
*/
|
| 400 |
+
private function applyDiscountToLineItem($item, $discountAmount=0){
|
| 401 |
if ($discountAmount > 0){
|
| 402 |
$discountedLine = self::MSG_DISCOUNTED_BY . $discountAmount;
|
| 403 |
$item->setDescription($item->getDescription() . " ($discountedLine)");
|
| 405 |
}
|
| 406 |
}
|
| 407 |
|
| 408 |
+
/**
|
| 409 |
+
* @param Mage_Sales_Model_Quote_Address $quoteAddress
|
| 410 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 411 |
+
* @return mixed|string
|
| 412 |
+
*/
|
| 413 |
+
private function getExemptionIdForQuoteAddress($quoteAddress,
|
| 414 |
+
$merchantSettings){
|
| 415 |
$exemptionId = '';
|
| 416 |
if ($merchantSettings->getExemptionsSupported()){
|
| 417 |
$customerExemptionId = $quoteAddress->getQuote()->getCustomer()->getData(self::ATTRIBUTE_NAME_EXEMPTION);
|
| 420 |
return $exemptionId;
|
| 421 |
}
|
| 422 |
|
| 423 |
+
/**
|
| 424 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
| 425 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 426 |
+
* @return string
|
| 427 |
+
*/
|
| 428 |
+
private function getExemptionIdForCreditMemo($creditMemo,
|
| 429 |
+
$merchantSettings){
|
| 430 |
$exemptionId = '';
|
| 431 |
if ($merchantSettings->getExemptionsSupported()){
|
| 432 |
$customerExemptionId = $creditMemo->getOrder()->getCustomerTaxvat();
|
| 435 |
return $exemptionId;
|
| 436 |
}
|
| 437 |
|
| 438 |
+
/**
|
| 439 |
+
* @param Mage_Sales_Model_Order $order
|
| 440 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 441 |
+
* @return string
|
| 442 |
+
*/
|
| 443 |
+
private function getExemptionIdForOrder($order,
|
| 444 |
+
$merchantSettings){
|
| 445 |
$exemptionId = '';
|
| 446 |
if ($merchantSettings->getExemptionsSupported()){
|
| 447 |
$customerExemptionId = $order->getCustomerTaxvat();
|
| 450 |
return $exemptionId;
|
| 451 |
}
|
| 452 |
|
| 453 |
+
/**
|
| 454 |
+
* @param Mage_Sales_Model_Quote_Address $quoteAddress
|
| 455 |
+
* @return string
|
| 456 |
+
*/
|
| 457 |
+
private function getCurrentCurrencyCode($quoteAddress){
|
| 458 |
$store = Mage::app()->getStore();
|
| 459 |
if ($quoteAddress->getQuote() != null && $quoteAddress->getQuote()->getStoreId() != null){
|
| 460 |
$store = $quoteAddress->getQuote()->getStore();
|
| 462 |
return $this->getCurrencyCodeForStore($store);
|
| 463 |
}
|
| 464 |
|
| 465 |
+
/**
|
| 466 |
+
* @param Mage_Core_Model_Store $store
|
| 467 |
+
* @return string
|
| 468 |
+
*/
|
| 469 |
+
private function getCurrencyCodeForStore($store){
|
| 470 |
$currency = 'USD';
|
| 471 |
if ($store != null){
|
| 472 |
$currency = $store->getBaseCurrencyCode()!=null ? $store->getBaseCurrencyCode() : $currency;
|
| 501 |
* @param $isEstimation
|
| 502 |
* @return InvoiceRequestType
|
| 503 |
*/
|
| 504 |
+
public function buildInvoiceRequestForQuoteAddress($quoteAddress,
|
| 505 |
+
$merchantSettings,
|
| 506 |
$isMultishipping, $isEstimation){
|
| 507 |
// Building Invoice Parts
|
| 508 |
$shipToAddress = $this->buildExactorAddressForQuoteAddress($quoteAddress);
|
| 578 |
*/
|
| 579 |
private function calculateProratedShippingAndHandling($orderedShippingAmount, $alreadyProcessedAmount,
|
| 580 |
$targetShippingAmount, $handlingTotalAmount,
|
| 581 |
+
$store) {
|
| 582 |
// $orderedShippingAmount = $invoice->getOrder()->getBaseShippingAmount();
|
| 583 |
// $alreadyProcessedAmount = $invoice->getOrder()->getBaseShippingRefunded();
|
| 584 |
// $targetShippingAmount = $invoice->getBaseShippingAmount();
|
| 596 |
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 597 |
* @return array InvoiceRequestType
|
| 598 |
*/
|
| 599 |
+
public function buildInvoiceRequestsForCreditMemo($creditMemo, $merchantSettings){
|
| 600 |
$result = array();
|
| 601 |
$invoiceRequest = new InvoiceRequestType();
|
| 602 |
$invoiceRequest->setBillTo($this->buildExactorAddressForOrderAddress($creditMemo->getBillingAddress()));
|
| 667 |
return $result;
|
| 668 |
}
|
| 669 |
|
| 670 |
+
/**
|
| 671 |
+
* @param Mage_Sales_Model_Order $order
|
| 672 |
+
* @param string $default
|
| 673 |
+
* @return DateTime
|
| 674 |
+
*/
|
| 675 |
+
private function getCreatedAtDateForMageOrder($order, $default='now') {
|
| 676 |
$res = $default;
|
| 677 |
try{
|
| 678 |
$res= '@'.$order->getCreatedAtDate()->getTimestamp();
|
| 683 |
return new DateTime($res);
|
| 684 |
}
|
| 685 |
|
| 686 |
+
/**
|
| 687 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
| 688 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 689 |
+
* @return array
|
| 690 |
+
*/
|
| 691 |
+
public function buildInvoiceRequestForMagentoInvoice($invoice, $merchantSettings){
|
| 692 |
$result = array();
|
| 693 |
$invoiceRequest = new InvoiceRequestType();
|
| 694 |
$invoiceRequest->setBillTo($this->buildExactorAddressForOrderAddress($invoice->getBillingAddress()));
|
| 729 |
return $result;
|
| 730 |
}
|
| 731 |
|
| 732 |
+
/**
|
| 733 |
+
* @param Mage_Sales_Model_Order $order
|
| 734 |
+
* @param Exactor_Core_Model_MerchantSettings $merchantSettings
|
| 735 |
+
* @return array
|
| 736 |
+
*/
|
| 737 |
+
public function buildInvoiceRequestForMagentoOrder($order, $merchantSettings){
|
| 738 |
$result = array();
|
| 739 |
$invoiceRequest = new InvoiceRequestType();
|
| 740 |
$invoiceRequest->setBillTo($this->buildExactorAddressForOrderAddress($order->getBillingAddress()));
|
| 800 |
return false;
|
| 801 |
}
|
| 802 |
|
| 803 |
+
/**
|
| 804 |
+
* @param AddressType $address
|
| 805 |
+
* @return bool
|
| 806 |
+
*/
|
| 807 |
+
private function isAddessFullyPopulated($address) {
|
| 808 |
if ($address==null || !$address->hasData()) return false;
|
| 809 |
return strlen(trim($address->getStreet1())) > 0
|
| 810 |
&& strlen(trim($address->getFullName())) > 0
|
| 811 |
+
&& strlen(trim($address->getCity())) > 0;
|
| 812 |
}
|
| 813 |
|
| 814 |
/**
|
| 819 |
* @param InvoiceRequestType $invoice
|
| 820 |
* @return bool
|
| 821 |
*/
|
| 822 |
+
public function isInvoiceAddressesFullyPopulated($invoice) {
|
| 823 |
if ($invoice == null) return false;
|
| 824 |
+
return $this->isAddessFullyPopulated($invoice->getShipTo());
|
| 825 |
+
//&& $this->isAddessFullyPopulated($invoice->getBillTo());
|
| 826 |
}
|
| 827 |
}
|
app/code/local/Exactor/Tax/Model/Sales/Total/Quote/Tax.php
CHANGED
|
@@ -90,7 +90,7 @@ class Exactor_Tax_Model_Sales_Total_Quote_Tax extends Mage_Sales_Model_Quote_Add
|
|
| 90 |
* @param Mage_Sales_Model_Quote_Address $address
|
| 91 |
* @return Exactor_Core_Model_MerchantSettings
|
| 92 |
*/
|
| 93 |
-
public function loadMerchantSettings(
|
| 94 |
$storeViewId = $address->getQuote()->getStoreId();//Mage::app()->getStore()->getId();
|
| 95 |
return $this->exactorSettingsHelper->loadValidMerchantSettings($storeViewId);
|
| 96 |
}
|
| 90 |
* @param Mage_Sales_Model_Quote_Address $address
|
| 91 |
* @return Exactor_Core_Model_MerchantSettings
|
| 92 |
*/
|
| 93 |
+
public function loadMerchantSettings($address=null){
|
| 94 |
$storeViewId = $address->getQuote()->getStoreId();//Mage::app()->getStore()->getId();
|
| 95 |
return $this->exactorSettingsHelper->loadValidMerchantSettings($storeViewId);
|
| 96 |
}
|
app/design/adminhtml/default/default/template/ExactorSettings/settingsform.phtml
CHANGED
|
@@ -236,6 +236,9 @@
|
|
| 236 |
<tr>
|
| 237 |
<td class="a-left">
|
| 238 |
<button id="saveBtn" onclick="editForm.submit();" class="scalable save" type="button"><span>Save Data</span></button>
|
|
|
|
|
|
|
|
|
|
| 239 |
</td>
|
| 240 |
</tr>
|
| 241 |
</table>
|
|
@@ -310,6 +313,16 @@
|
|
| 310 |
return this.replace(/(^\s*)|(\s*$)/g, "");
|
| 311 |
}
|
| 312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
function switchStore(obj){
|
| 314 |
var storeParam = obj.value ? 'storeview/'+obj.value + '/' : '';
|
| 315 |
if(obj.switchParams){
|
| 236 |
<tr>
|
| 237 |
<td class="a-left">
|
| 238 |
<button id="saveBtn" onclick="editForm.submit();" class="scalable save" type="button"><span>Save Data</span></button>
|
| 239 |
+
<?php if ($accountSettings->getID() != null): ?>
|
| 240 |
+
<button id="clearSettingsBtn" onclick="clearExactorSettings();" class="scalable delete" type="button"><span>Clear Settings</span></button>
|
| 241 |
+
<?php endif ?>
|
| 242 |
</td>
|
| 243 |
</tr>
|
| 244 |
</table>
|
| 313 |
return this.replace(/(^\s*)|(\s*$)/g, "");
|
| 314 |
}
|
| 315 |
|
| 316 |
+
function clearExactorSettings() {
|
| 317 |
+
if (confirm("<?php echo $this->__('This action will remove currently saved settings and deactivate the plug-in for the selected store.\nPlease confirm clearing settings') ?>")) {
|
| 318 |
+
showLoading();
|
| 319 |
+
var params = "/action_del_settings/" + '<?php echo $accountSettings->getStoreViewID(); ?>/';
|
| 320 |
+
setLocation('<?php echo $this->getUrl('*/*/index', array('_secure' => true)); ?>key/<?php echo $this->getRequest()->getParam('key') ?>'+params);
|
| 321 |
+
return true;
|
| 322 |
+
}
|
| 323 |
+
return false;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
function switchStore(obj){
|
| 327 |
var storeParam = obj.value ? 'storeview/'+obj.value + '/' : '';
|
| 328 |
if(obj.switchParams){
|
lib/ExactorCommons/ExactorCommons.php
CHANGED
|
@@ -608,7 +608,7 @@ class ExactorProcessingService{
|
|
| 608 |
* @param InvoiceRequestType $invoice
|
| 609 |
* @return void
|
| 610 |
*/
|
| 611 |
-
public function applyAddressFallbackLogic(
|
| 612 |
if ($invoice->getBillTo() == null && $invoice->getShipTo() == null) {
|
| 613 |
return;
|
| 614 |
}
|
|
@@ -655,7 +655,7 @@ class ExactorProcessingService{
|
|
| 655 |
* @internal param $validationMessage
|
| 656 |
* @return bool
|
| 657 |
*/
|
| 658 |
-
public function validateSettings(
|
| 659 |
$exactorConnector = ExactorConnectionFactory::getInstance();
|
| 660 |
$request = ExactorConnectionFactory::getInstance()->buildRequest($this->merchantId, $this->userId, $this->partnerId);
|
| 661 |
$invoiceRequest = new InvoiceRequestType();
|
|
@@ -680,7 +680,12 @@ class ExactorProcessingService{
|
|
| 680 |
}
|
| 681 |
}
|
| 682 |
|
| 683 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 684 |
$invoiceResponse = $taxResponse->getFirstInvoice();
|
| 685 |
$exactorResponse = new ExactorTransactionInfo();
|
| 686 |
$exactorResponse->setCreatedDate($invoiceResponse->getTransactionDate());
|
| 608 |
* @param InvoiceRequestType $invoice
|
| 609 |
* @return void
|
| 610 |
*/
|
| 611 |
+
public function applyAddressFallbackLogic($invoice) {
|
| 612 |
if ($invoice->getBillTo() == null && $invoice->getShipTo() == null) {
|
| 613 |
return;
|
| 614 |
}
|
| 655 |
* @internal param $validationMessage
|
| 656 |
* @return bool
|
| 657 |
*/
|
| 658 |
+
public function validateSettings($address, $errorObject){
|
| 659 |
$exactorConnector = ExactorConnectionFactory::getInstance();
|
| 660 |
$request = ExactorConnectionFactory::getInstance()->buildRequest($this->merchantId, $this->userId, $this->partnerId);
|
| 661 |
$invoiceRequest = new InvoiceRequestType();
|
| 680 |
}
|
| 681 |
}
|
| 682 |
|
| 683 |
+
/**
|
| 684 |
+
* @param TaxResponseType $taxResponse
|
| 685 |
+
* @param $signature
|
| 686 |
+
* @return ExactorTransactionInfo
|
| 687 |
+
*/
|
| 688 |
+
private function createExactorTransactionInfoForInvoiceResponse($taxResponse, $signature){
|
| 689 |
$invoiceResponse = $taxResponse->getFirstInvoice();
|
| 690 |
$exactorResponse = new ExactorTransactionInfo();
|
| 691 |
$exactorResponse->setCreatedDate($invoiceResponse->getTransactionDate());
|
lib/ExactorCommons/XmlProcessing.php
CHANGED
|
@@ -111,6 +111,7 @@ class XmlSerializationSupport {
|
|
| 111 |
|
| 112 |
private $mappingRules = array();
|
| 113 |
private $isBindingInitialized = false;
|
|
|
|
| 114 |
|
| 115 |
protected function getNamespace(){
|
| 116 |
return null;
|
|
@@ -283,7 +284,11 @@ class XmlSerializationSupport {
|
|
| 283 |
if (trim($targetClass)==='') throw new Exception();
|
| 284 |
$obj = new $targetClass;
|
| 285 |
}catch (Exception $e){
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
}
|
| 288 |
if (!$this->isComplexSerializableObject($obj))
|
| 289 |
throw new Exception("Class ($targetClass) is not a child of XmlSerializationSupport. Element $xmlElement");
|
| 111 |
|
| 112 |
private $mappingRules = array();
|
| 113 |
private $isBindingInitialized = false;
|
| 114 |
+
private $ignoreUnknownElements = true;
|
| 115 |
|
| 116 |
protected function getNamespace(){
|
| 117 |
return null;
|
| 284 |
if (trim($targetClass)==='') throw new Exception();
|
| 285 |
$obj = new $targetClass;
|
| 286 |
}catch (Exception $e){
|
| 287 |
+
if ($this->ignoreUnknownElements) {
|
| 288 |
+
return null;
|
| 289 |
+
} else {
|
| 290 |
+
throw new Exception("Can't instantiate class '$targetClass'. Please provide type annotation for element $xmlElement");
|
| 291 |
+
}
|
| 292 |
}
|
| 293 |
if (!$this->isComplexSerializableObject($obj))
|
| 294 |
throw new Exception("Class ($targetClass) is not a child of XmlSerializationSupport. Element $xmlElement");
|
lib/ExactorCommons/config.php
CHANGED
|
@@ -16,7 +16,7 @@ define('EXACTOR_CONFIG_FEATURE_DISABLE_ESTIMATES', 'disable-estimates');
|
|
| 16 |
|
| 17 |
/* Initializing factories */
|
| 18 |
ExactorLoggingFactory::getInstance()->setup('MagentoLogger', IExactorLogger::DEBUG);
|
| 19 |
-
ExactorConnectionFactory::getInstance()->setup('Magento','
|
| 20 |
ExactorProcessingServiceFactory::getInstance()->setup(new MagentoExactorCallback());
|
| 21 |
|
| 22 |
/* Initializing configuration object */
|
| 16 |
|
| 17 |
/* Initializing factories */
|
| 18 |
ExactorLoggingFactory::getInstance()->setup('MagentoLogger', IExactorLogger::DEBUG);
|
| 19 |
+
ExactorConnectionFactory::getInstance()->setup('Magento','20131105');
|
| 20 |
ExactorProcessingServiceFactory::getInstance()->setup(new MagentoExactorCallback());
|
| 21 |
|
| 22 |
/* Initializing configuration object */
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_Exactor_Tax</name>
|
| 4 |
-
<version>2013.
|
| 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>2013-
|
| 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="
|
| 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>2013.11.06</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>2013-11-06</date>
|
| 16 |
+
<time>12:01:48</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="659cee9ec4cb12af6bb9be13c3a4eb55"/><file name="VersionResolver.php" hash="14dce068dfe2a7d3364c4bd29e6f8431"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FormController.php" hash="2a7c77cd96316601928713f42127f5ee"/></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="453e96aaccaecee92490286f956339e5"/></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="f245e1374132283e0a3e968d06a49123"/></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="8e8302178f1f50410c11cbfa4b8f31b0"/></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="c423218861b708c3d572ac77623c6280"/></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="62b8c768d268a70812f3db62f7aaf25a"/><file name="ExactorDomainObjects.php" hash="a7ab4b08aab05061bc554f7c4405fde4"/><file name="Magento.php" hash="76da7333fe0692053a47f8564c7b513a"/><file name="RegionResolver.php" hash="2537638a7895a169cee4b1df786d22fb"/><file name="XmlProcessing.php" hash="1fe961d5c14d507b2bb82fd3dd94237c"/><file name="config.php" hash="cdcf77cbcace60f3e2bec45264b22928"/></dir></target></contents>
|
| 18 |
<compatible/>
|
| 19 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
</package>
|
