Version Notes
- Fixed issues with shipping outside of US
- Added indexes for log table
- Code refactor to be compliant with Zend, PSR-2, ECG standards
Download this release
Release Info
Developer | Vertex SMB |
Extension | VertexSMB_TaxCE |
Version | 1.1.8 |
Comparing to | |
See all releases |
Code changes from version 1.1.6 to 1.1.8
- app/code/community/VertexSMB/TaxCE/Block/Adminhtml/Order/View.php +47 -0
- app/code/community/VertexSMB/TaxCE/Block/Adminhtml/System/Config/Form/Field/ShippingCodes.php +85 -0
- app/code/community/VertexSMB/TaxCE/Block/Adminhtml/System/Config/Form/Field/VertexSMBStatus.php +35 -0
- app/code/community/VertexSMB/TaxCE/Helper/Config.php +95 -0
- app/code/community/VertexSMB/TaxCE/Helper/Data.php +723 -0
- app/code/community/VertexSMB/TaxCE/Model/Observer.php +175 -0
- app/code/community/VertexSMB/TaxCE/Model/RequestItem.php +131 -0
- app/code/{local → community}/VertexSMB/TaxCE/Model/Resource/Setup.php +29 -26
- app/code/{local → community}/VertexSMB/TaxCE/Model/Resource/TaxRequest.php +20 -18
- app/code/{local → community}/VertexSMB/TaxCE/Model/Resource/TaxRequest/Collection.php +28 -27
- app/code/community/VertexSMB/TaxCE/Model/Source/Taxinvoice.php +33 -0
- app/code/community/VertexSMB/TaxCE/Model/Tax/Sales/Total/Quote/Tax.php +263 -0
- app/code/community/VertexSMB/TaxCE/Model/TaxAreaRequest.php +71 -0
- app/code/community/VertexSMB/TaxCE/Model/TaxAreaResponse.php +79 -0
- app/code/community/VertexSMB/TaxCE/Model/TaxInvoice.php +174 -0
- app/code/community/VertexSMB/TaxCE/Model/TaxQuote.php +155 -0
- app/code/community/VertexSMB/TaxCE/Model/TaxQuoteResponse.php +72 -0
- app/code/community/VertexSMB/TaxCE/Model/TaxRequest.php +110 -0
- app/code/community/VertexSMB/TaxCE/Model/VertexSMB.php +184 -0
- app/code/community/VertexSMB/TaxCE/controllers/OnepageController.php +301 -0
- app/code/community/VertexSMB/TaxCE/controllers/VertexSMBController.php +189 -0
- app/code/community/VertexSMB/TaxCE/data/taxce_setup/data-install-0.1.1.php +24 -0
- app/code/community/VertexSMB/TaxCE/data/taxce_setup/data-upgrade-0.1.4-0.1.5.php +22 -0
- app/code/{local → community}/VertexSMB/TaxCE/etc/adminhtml.xml +3 -1
- app/code/{local → community}/VertexSMB/TaxCE/etc/config.xml +205 -212
- app/code/{local → community}/VertexSMB/TaxCE/etc/system.xml +3 -1
- app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-install-0.1.1.php +125 -0
- app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.3-0.1.4.php +26 -0
- app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.6-0.1.7.php +26 -0
- app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.7-0.1.8.php +36 -0
- app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-1.1.0-1.1.1.php +50 -0
- app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-1.1.6-1.1.7.php +54 -0
- app/code/local/VertexSMB/TaxCE/Block/Adminhtml/Order/View.php +0 -30
- app/code/local/VertexSMB/TaxCE/Block/Adminhtml/System/Config/Form/Field/ShippingCodes.php +0 -67
- app/code/local/VertexSMB/TaxCE/Block/Adminhtml/System/Config/Form/Field/VertexSMBStatus.php +0 -27
- app/code/local/VertexSMB/TaxCE/Helper/Config.php +0 -48
- app/code/local/VertexSMB/TaxCE/Helper/Data.php +0 -481
- app/code/local/VertexSMB/TaxCE/Model/Observer.php +0 -168
- app/code/local/VertexSMB/TaxCE/Model/RequestItem.php +0 -95
- app/code/local/VertexSMB/TaxCE/Model/Source/Taxinvoice.php +0 -20
- app/code/local/VertexSMB/TaxCE/Model/Tax/Sales/Total/Quote/Tax.php +0 -287
- app/code/local/VertexSMB/TaxCE/Model/TaxAreaRequest.php +0 -53
- app/code/local/VertexSMB/TaxCE/Model/TaxAreaResponse.php +0 -30
- app/code/local/VertexSMB/TaxCE/Model/TaxInvoice.php +0 -167
- app/code/local/VertexSMB/TaxCE/Model/TaxQuote.php +0 -126
- app/code/local/VertexSMB/TaxCE/Model/TaxQuoteResponse.php +0 -55
- app/code/local/VertexSMB/TaxCE/Model/TaxRequest.php +0 -51
- app/code/local/VertexSMB/TaxCE/Model/VertexSMB.php +0 -144
- app/code/local/VertexSMB/TaxCE/controllers/OnepageController.php +0 -237
- app/code/local/VertexSMB/TaxCE/controllers/VertexSMBController.php +0 -150
- app/code/local/VertexSMB/TaxCE/data/taxce_setup/data-install-0.1.1.php +0 -26
- app/code/local/VertexSMB/TaxCE/data/taxce_setup/data-upgrade-0.1.4-0.1.5.php +0 -24
- app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-install-0.1.1.php +0 -68
- app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.3-0.1.4.php +0 -26
- app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.6-0.1.7.php +0 -26
- app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.7-0.1.8.php +0 -33
- app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-1.1.0-1.1.1.php +0 -49
- app/design/adminhtml/default/default/template/vertexsmb/addresschange-popup-content.phtml +0 -64
- app/design/adminhtml/default/default/template/vertexsmb/popup-content.phtml +39 -30
- app/design/adminhtml/default/default/template/vertexsmb/popup.phtml +16 -31
- app/design/frontend/base/default/template/vertexsmb/addresschange-popup-content.phtml +0 -78
- app/design/frontend/base/default/template/vertexsmb/popup-content.phtml +42 -36
- app/design/frontend/base/default/template/vertexsmb/popup.phtml +3 -1
- app/etc/modules/VertexSMB_TaxCE.xml +1 -1
- package.xml +7 -11
app/code/community/VertexSMB/TaxCE/Block/Adminhtml/Order/View.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Block_Adminhtml_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return VertexSMB_TaxCE_Block_Adminhtml_Order_View
|
15 |
+
*/
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
if (Mage::Helper('taxce')->isVertexSMBActive()) {
|
21 |
+
$totalInvoicedTax = Mage::getModel('taxce/taxRequest')->getTotalInvoicedTax(
|
22 |
+
$this->getOrder()
|
23 |
+
->getId()
|
24 |
+
);
|
25 |
+
if ($totalInvoicedTax || ! Mage::helper('taxce')->showManualInvoiceButton()) {
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
$this->_addButton(
|
29 |
+
'vertex_invoice',
|
30 |
+
array(
|
31 |
+
'label' => Mage::helper('taxce')->__("Vertex SMB Invoice"),
|
32 |
+
'onclick' => 'setLocation(\'' . $this->getVertexInvoiceUrl() . '\')',
|
33 |
+
'class' => 'go'
|
34 |
+
)
|
35 |
+
);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Vertex Invoice Url
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getVertexInvoiceUrl()
|
44 |
+
{
|
45 |
+
return $this->getUrl('*/vertexSMB/invoicetax');
|
46 |
+
}
|
47 |
+
}
|
app/code/community/VertexSMB/TaxCE/Block/Adminhtml/System/Config/Form/Field/ShippingCodes.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Block_Adminhtml_System_Config_Form_Field_ShippingCodes extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
18 |
+
{
|
19 |
+
$helper = Mage::helper('taxce');
|
20 |
+
$html = '<table cellspacing="0" class="form-list"><colgroup class="label"></colgroup><colgroup class="value"></colgroup><tbody>';
|
21 |
+
$html .= '<tr><td class="label">Shipping Method</td><td class="value">Product Code</td></tr>';
|
22 |
+
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
|
23 |
+
foreach ($methods as $cCode => $_carrier) {
|
24 |
+
$_methodOptions = array();
|
25 |
+
if ($_methods = $_carrier->getAllowedMethods()) {
|
26 |
+
if (! $_title = Mage::getStoreConfig("carriers/$cCode/title")) {
|
27 |
+
$_title = $cCode;
|
28 |
+
}
|
29 |
+
$html .= '<tr><td class="label" colspan="2"><b>' . $_title . '</b></td></tr>';
|
30 |
+
foreach ($_methods as $_mcode => $_method) {
|
31 |
+
$_code = $cCode . '_' . $_mcode;
|
32 |
+
$_methodOptions[] = array(
|
33 |
+
'value' => $_code,
|
34 |
+
'label' => $_method
|
35 |
+
);
|
36 |
+
}
|
37 |
+
$html .= '<tr><td class="label">' . $_method . ': </td><td class="value"> ' . $_code . '</td></tr>';
|
38 |
+
}
|
39 |
+
if ($cCode == 'ups' && $ups = Mage::getSingleton('usa/shipping_carrier_ups')) {
|
40 |
+
foreach ($ups->getCode('method') as $k => $v) {
|
41 |
+
$html .= '<tr><td class="label">' . Mage::helper('usa')->__($v) . ': </td><td class="value"> ' . $cCode . '_' . $k . '</td></tr>';
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
if ($cCode == 'usps' && $usps = Mage::getSingleton('usa/shipping_carrier_usps')) {
|
46 |
+
foreach ($usps->getCode('method') as $k => $v) {
|
47 |
+
$html .= '<tr><td class="label">' . $usps->getMethodLabel($v) . ': </td><td class="value"> ' . $cCode . '_' . $k . '</td></tr>';
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
if ($cCode == 'fedex' && $fedex = Mage::getSingleton('usa/shipping_carrier_fedex')) {
|
52 |
+
foreach ($fedex->getCode('method') as $k => $v) {
|
53 |
+
$html .= '<tr><td class="label">' . $v . ': </td><td class="value"> ' . $cCode . '_' . $k . '</td></tr>';
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
if ($cCode == 'dhl' && $dhl = Mage::getSingleton('usa/shipping_carrier_dhl')) {
|
58 |
+
foreach ($dhl->getCode('service') as $k => $v) {
|
59 |
+
$html .= '<tr><td class="label">' . $v . ': </td><td class="value"> ' . $cCode . '_' . $k . '</td></tr>';
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
if ($cCode == 'dhlint' && $dhlint = Mage::getSingleton('usa/shipping_carrier_dhl_international')) {
|
64 |
+
foreach ($dhlint->getDhlProducts($this->_contentType) as $k => $v) {
|
65 |
+
$html .= '<tr><td class="label">' . $v . ': </td><td class="value"> ' . $cCode . '_' . $k . '</td></tr>';
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
$html .= '</tbody></table>';
|
70 |
+
return $html;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
78 |
+
{
|
79 |
+
$id = $element->getHtmlId();
|
80 |
+
$html = '<td>';
|
81 |
+
$html .= $this->_getElementHtml($element);
|
82 |
+
$html .= '</td>';
|
83 |
+
return $this->_decorateRowHtml($element, $html);
|
84 |
+
}
|
85 |
+
}
|
app/code/community/VertexSMB/TaxCE/Block/Adminhtml/System/Config/Form/Field/VertexSMBStatus.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Block_Adminhtml_System_Config_Form_Field_VertexSMBStatus extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
19 |
+
{
|
20 |
+
$helper = Mage::helper('taxce');
|
21 |
+
if (! $helper->isVertexSMBActive()) {
|
22 |
+
$status = "Disabled";
|
23 |
+
$state = "critical";
|
24 |
+
} else {
|
25 |
+
$status = $helper->checkCredentials();
|
26 |
+
if ($status == 'Valid') {
|
27 |
+
$state = "notice";
|
28 |
+
} else {
|
29 |
+
$state = "minor";
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return '<span class="grid-severity-' . $state . '"><span style=" background-color: #FAFAFA;">' . $status . '</span></span>';
|
34 |
+
}
|
35 |
+
}
|
app/code/community/VertexSMB/TaxCE/Helper/Config.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Helper_Config extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @var CONFIG_XML_PATH_VERTEX_TRANSACTION_TYPE @values SALE,RENTAl,LEASE
|
16 |
+
*/
|
17 |
+
const CONFIG_XML_PATH_ENABLE_VERTEX = 'tax/vertexsmb_settings/enable_vertexsmb';
|
18 |
+
|
19 |
+
const CONFIG_XML_PATH_DEFAULT_TAX_CALCULATION_ADDRESS_TYPE = 'tax/calculation/based_on';
|
20 |
+
|
21 |
+
const CONFIG_XML_PATH_DEFAULT_CUSTOMER_CODE = 'tax/classes/default_customer_code';
|
22 |
+
|
23 |
+
const VERTEX_API_HOST = 'tax/vertexsmb_settings/api_url';
|
24 |
+
|
25 |
+
const CONFIG_XML_PATH_VERTEX_API_USER = 'tax/vertexsmb_settings/login';
|
26 |
+
|
27 |
+
const CONFIG_XML_PATH_VERTEX_API_KEY = 'tax/vertexsmb_settings/password';
|
28 |
+
|
29 |
+
const CONFIG_XML_PATH_VERTEX_API_TRUSTED_ID = 'tax/vertexsmb_settings/trustedId';
|
30 |
+
|
31 |
+
const CONFIG_XML_PATH_VERTEX_COMPANY_CODE = 'tax/vertexsmb_seller_info/company';
|
32 |
+
|
33 |
+
const CONFIG_XML_PATH_VERTEX_LOCATION_CODE = 'tax/vertexsmb_seller_info/location_code';
|
34 |
+
|
35 |
+
const CONFIG_XML_PATH_VERTEX_STREET1 = 'tax/vertexsmb_seller_info/streetAddress1';
|
36 |
+
|
37 |
+
const CONFIG_XML_PATH_VERTEX_STREET2 = 'tax/vertexsmb_seller_info/streetAddress2';
|
38 |
+
|
39 |
+
const CONFIG_XML_PATH_VERTEX_CITY = 'tax/vertexsmb_seller_info/city';
|
40 |
+
|
41 |
+
const CONFIG_XML_PATH_VERTEX_COUNTRY = 'tax/vertexsmb_seller_info/country_id';
|
42 |
+
|
43 |
+
const CONFIG_XML_PATH_VERTEX_REGION = 'tax/vertexsmb_seller_info/region_id';
|
44 |
+
|
45 |
+
const CONFIG_XML_PATH_VERTEX_POSTAL_CODE = 'tax/vertexsmb_seller_info/postalCode';
|
46 |
+
|
47 |
+
const CONFIG_XML_PATH_VERTEX_INVOICE_DATE = 'tax/vertexsmb_settings/invoice_tax_date';
|
48 |
+
|
49 |
+
const CONFIG_XML_PATH_VERTEX_TRANSACTION_TYPE = 'SALE';
|
50 |
+
|
51 |
+
const CONFIG_XML_PATH_VERTEX_INVOICE_ORDER = 'tax/vertexsmb_settings/invoice_order';
|
52 |
+
|
53 |
+
const CONFIG_XML_PATH_VERTEX_INVOICE_ORDER_STATUS = 'tax/vertexsmb_settings/invoice_order_status';
|
54 |
+
|
55 |
+
const CONFIG_XML_PATH_SHIPPING_TAX_CLASS = 'tax/classes/shipping_tax_class';
|
56 |
+
|
57 |
+
const VERTEX_ADDRESS_API_HOST = 'tax/vertexsmb_settings/address_api_url';
|
58 |
+
|
59 |
+
const VERTEX_CREDITMEMO_ADJUSTMENT_CLASS = 'tax/classes/creditmemo_adjustment_class';
|
60 |
+
|
61 |
+
const VERTEX_CREDITMEMO_ADJUSTMENT_NEGATIVE_CODE = 'tax/classes/creditmemo_adjustment_negative_code';
|
62 |
+
|
63 |
+
const VERTEX_CREDITMEMO_ADJUSTMENT_POSITIVE_CODE = 'tax/classes/creditmemo_adjustment_positive_code';
|
64 |
+
|
65 |
+
const VERTEX_GIFTWRAP_ORDER_CLASS = 'tax/classes/giftwrap_order_class';
|
66 |
+
|
67 |
+
const VERTEX_GIFTWRAP_ORDER_CODE = 'tax/classes/giftwrap_order_code';
|
68 |
+
|
69 |
+
const VERTEX_GIFTWRAP_ITEM_CLASS = 'tax/classes/giftwrap_item_class';
|
70 |
+
|
71 |
+
const VERTEX_GIFTWRAP_ITEM_CODE_PREFIX = 'tax/classes/giftwrap_item_code';
|
72 |
+
|
73 |
+
const VERTEX_PRINTED_GIFTCARD_CLASS = 'tax/classes/printed_giftcard_class';
|
74 |
+
|
75 |
+
const VERTEX_PRINTED_GIFTCARD_CODE = 'tax/classes/printed_giftcard_code';
|
76 |
+
|
77 |
+
const CONFIG_XML_PATH_VERTEX_ALLOW_CART_QUOTE = 'tax/vertexsmb_settings/allow_cart_request';
|
78 |
+
|
79 |
+
const CONFIG_XML_PATH_VERTEX_SHOW_MANUAL_BUTTON = 'tax/vertexsmb_settings/show_manual_button';
|
80 |
+
|
81 |
+
const CONFIG_XML_PATH_VERTEX_SHOW_POPUP = 'tax/vertexsmb_settings/show_tarequest_popup';
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @return multitype:string
|
85 |
+
*/
|
86 |
+
public function getQuoteAllowedControllers()
|
87 |
+
{
|
88 |
+
$quoteAllowedControllers = array(
|
89 |
+
'onepage',
|
90 |
+
'multishipping',
|
91 |
+
'sales_order_create'
|
92 |
+
);
|
93 |
+
return $quoteAllowedControllers;
|
94 |
+
}
|
95 |
+
}
|
app/code/community/VertexSMB/TaxCE/Helper/Data.php
ADDED
@@ -0,0 +1,723 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return boolean
|
15 |
+
*/
|
16 |
+
public function isVertexSMBActive()
|
17 |
+
{
|
18 |
+
if (Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_ENABLE_VERTEX)) {
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
return false;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @return string
|
26 |
+
*/
|
27 |
+
public function getLocationCode()
|
28 |
+
{
|
29 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_LOCATION_CODE);
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function getCompanyCode()
|
36 |
+
{
|
37 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_COMPANY_CODE);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getCompanyStreet1()
|
44 |
+
{
|
45 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_STREET1);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
public function getCompanyStreet2()
|
52 |
+
{
|
53 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_STREET2);
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function getCompanyCity()
|
60 |
+
{
|
61 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_CITY);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getCompanyCountry()
|
68 |
+
{
|
69 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_COUNTRY);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function getCompanyRegionId()
|
76 |
+
{
|
77 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_REGION);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
+
public function getCompanyPostalCode()
|
84 |
+
{
|
85 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_POSTAL_CODE);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @return string
|
90 |
+
*/
|
91 |
+
public function getShippingTaxClassId()
|
92 |
+
{
|
93 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS);
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @return string
|
98 |
+
*/
|
99 |
+
public function getTrustedId()
|
100 |
+
{
|
101 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_API_TRUSTED_ID);
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @return string
|
106 |
+
*/
|
107 |
+
public function getTransactionType()
|
108 |
+
{
|
109 |
+
return VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_TRANSACTION_TYPE;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
public function getVertexHost()
|
116 |
+
{
|
117 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_API_HOST);
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @return string
|
122 |
+
*/
|
123 |
+
public function getVertexAddressHost()
|
124 |
+
{
|
125 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_ADDRESS_API_HOST);
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
public function getDefaultCustomerCode()
|
132 |
+
{
|
133 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_DEFAULT_CUSTOMER_CODE);
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @return string
|
138 |
+
*/
|
139 |
+
public function getCreditmemoAdjustmentFeeCode()
|
140 |
+
{
|
141 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_CREDITMEMO_ADJUSTMENT_NEGATIVE_CODE);
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* @return string
|
146 |
+
*/
|
147 |
+
public function getCreditmemoAdjustmentFeeClass()
|
148 |
+
{
|
149 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_CREDITMEMO_ADJUSTMENT_CLASS);
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @return string
|
154 |
+
*/
|
155 |
+
public function getCreditmemoAdjustmentPositiveCode()
|
156 |
+
{
|
157 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_CREDITMEMO_ADJUSTMENT_POSITIVE_CODE);
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
public function getCreditmemoAdjustmentPositiveClass()
|
164 |
+
{
|
165 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_CREDITMEMO_ADJUSTMENT_CLASS);
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* @return string
|
170 |
+
*/
|
171 |
+
public function allowCartQuote()
|
172 |
+
{
|
173 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_ALLOW_CART_QUOTE);
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* @return string
|
178 |
+
*/
|
179 |
+
public function getGiftWrappingOrderClass()
|
180 |
+
{
|
181 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_GIFTWRAP_ORDER_CLASS);
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* @return string
|
186 |
+
*/
|
187 |
+
public function getGiftWrappingOrderCode()
|
188 |
+
{
|
189 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_GIFTWRAP_ORDER_CODE);
|
190 |
+
}
|
191 |
+
|
192 |
+
public function getGiftWrappingItemClass()
|
193 |
+
{
|
194 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_GIFTWRAP_ITEM_CLASS);
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* @return string
|
199 |
+
*/
|
200 |
+
public function getGiftWrappingItemCodePrefix()
|
201 |
+
{
|
202 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_GIFTWRAP_ITEM_CODE_PREFIX);
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* @return string
|
207 |
+
*/
|
208 |
+
public function getPrintedGiftcardClass()
|
209 |
+
{
|
210 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_PRINTED_GIFTCARD_CLASS);
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* @return string
|
215 |
+
*/
|
216 |
+
public function getPrintedGiftcardCode()
|
217 |
+
{
|
218 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_PRINTED_GIFTCARD_CODE);
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* @return boolean
|
223 |
+
*/
|
224 |
+
public function isAllowedQuote()
|
225 |
+
{
|
226 |
+
$quoteAllowedControllers = Mage::helper('taxce/config')->getQuoteAllowedControllers();
|
227 |
+
if ($this->allowCartQuote()) {
|
228 |
+
$quoteAllowedControllers[] = 'cart';
|
229 |
+
}
|
230 |
+
|
231 |
+
if (in_array(Mage::app()->getRequest()->getControllerName(), $quoteAllowedControllers)) {
|
232 |
+
return true;
|
233 |
+
}
|
234 |
+
|
235 |
+
return false;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @return string
|
240 |
+
*/
|
241 |
+
public function showManualInvoiceButton()
|
242 |
+
{
|
243 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_SHOW_MANUAL_BUTTON);
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Is Popup Window Allowed
|
248 |
+
* @return string
|
249 |
+
*/
|
250 |
+
public function showPopup()
|
251 |
+
{
|
252 |
+
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_SHOW_POPUP);
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* @return boolean
|
257 |
+
*/
|
258 |
+
public function requestByInvoiceCreation()
|
259 |
+
{
|
260 |
+
$vertexInvoiceEvent = Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER);
|
261 |
+
if ($vertexInvoiceEvent == 'invoice_created') {
|
262 |
+
return true;
|
263 |
+
}
|
264 |
+
return false;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* @param unknown $status
|
269 |
+
* @return boolean
|
270 |
+
*/
|
271 |
+
public function requestByOrderStatus($status)
|
272 |
+
{
|
273 |
+
$vertexInvoiceEvent = Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER);
|
274 |
+
$vertexInvoiceOrderStatus = Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER_STATUS);
|
275 |
+
if ($vertexInvoiceEvent == 'order_status' && $vertexInvoiceOrderStatus == $status) {
|
276 |
+
return true;
|
277 |
+
}
|
278 |
+
return false;
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* @param unknown $classId
|
283 |
+
* @return string
|
284 |
+
*/
|
285 |
+
public function taxClassNameByClassId($classId)
|
286 |
+
{
|
287 |
+
if (! $classId) {
|
288 |
+
$taxclassName = "None";
|
289 |
+
} else {
|
290 |
+
$taxclassName = Mage::getModel('tax/class')->load($classId)->getClassName();
|
291 |
+
}
|
292 |
+
return $taxclassName;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* @return Ambigous <string, unknown>
|
297 |
+
*/
|
298 |
+
public function getSourcePath()
|
299 |
+
{
|
300 |
+
$controller = Mage::app()->getRequest()->getControllerName();
|
301 |
+
$module = Mage::app()->getRequest()->getModuleName();
|
302 |
+
$action = Mage::app()->getRequest()->getActionName();
|
303 |
+
$sourcePath = "";
|
304 |
+
if ($controller) {
|
305 |
+
$sourcePath .= $controller;
|
306 |
+
}
|
307 |
+
if ($module) {
|
308 |
+
$sourcePath .= "_" . $module;
|
309 |
+
}
|
310 |
+
if ($action) {
|
311 |
+
$sourcePath .= "_" . $action;
|
312 |
+
}
|
313 |
+
|
314 |
+
return $sourcePath;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* @param int $groupId
|
319 |
+
* @return string
|
320 |
+
*/
|
321 |
+
public function taxClassNameByCustomerGroupId($groupId)
|
322 |
+
{
|
323 |
+
$classId = Mage::getModel('customer/group')->getTaxClassId($groupId);
|
324 |
+
return $this->taxClassNameByClassId($classId);
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* @param unknown $customerId
|
329 |
+
* @return unknown
|
330 |
+
*/
|
331 |
+
public function getCustomerCodeById($customerId)
|
332 |
+
{
|
333 |
+
$customerCode = $this->getDefaultCustomerCode();
|
334 |
+
if ($customerId) {
|
335 |
+
$customerCode = Mage::getModel('customer/customer')->load($customerId)->getCustomerCode();
|
336 |
+
}
|
337 |
+
|
338 |
+
if (empty($customerCode)) {
|
339 |
+
$customerCode = $this->getDefaultCustomerCode();
|
340 |
+
}
|
341 |
+
|
342 |
+
return $customerCode;
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* @return string
|
347 |
+
*/
|
348 |
+
public function checkCredentials()
|
349 |
+
{
|
350 |
+
if (! $this->getVertexHost()) {
|
351 |
+
return "Not Valid: Missing Api Url";
|
352 |
+
}
|
353 |
+
if (! $this->getVertexAddressHost()) {
|
354 |
+
return "Not Valid: Missing Address Validation Api Url";
|
355 |
+
}
|
356 |
+
if (! $this->getTrustedId()) {
|
357 |
+
return "Not Valid: Missing Trusted Id";
|
358 |
+
}
|
359 |
+
if (! $this->getCompanyRegionId()) {
|
360 |
+
return "Not Valid: Missing Company State";
|
361 |
+
}
|
362 |
+
if (! $this->getCompanyCountry()) {
|
363 |
+
return "Not Valid: Missing Company Country";
|
364 |
+
}
|
365 |
+
if (! $this->getCompanyStreet1()) {
|
366 |
+
return "Not Valid: Missing Company Street Address";
|
367 |
+
}
|
368 |
+
if (! $this->getCompanyCity()) {
|
369 |
+
return "Not Valid: Missing Company City";
|
370 |
+
}
|
371 |
+
if (! $this->getCompanyPostalCode()) {
|
372 |
+
return "Not Valid: Missing Company Postal Code";
|
373 |
+
}
|
374 |
+
|
375 |
+
$regionId = $this->getCompanyRegionId();
|
376 |
+
if (is_int($regionId)) {
|
377 |
+
$regionModel = Mage::getModel('directory/region')->load($regionId);
|
378 |
+
$companyState = $regionModel->getCode();
|
379 |
+
} else {
|
380 |
+
$companyState = $regionId;
|
381 |
+
}
|
382 |
+
|
383 |
+
$countryModel = Mage::getModel('directory/country')->load($this->getCompanyCountry());
|
384 |
+
$countryName = $countryModel->getIso3Code();
|
385 |
+
|
386 |
+
$address = new Varien_Object();
|
387 |
+
$address->setStreet1($this->getCompanyStreet1());
|
388 |
+
$address->setStreet2($this->getCompanyStreet2());
|
389 |
+
$address->setCity($this->getCompanyCity());
|
390 |
+
$address->setRegionCode($companyState);
|
391 |
+
$address->setPostcode($this->getCompanyPostalCode());
|
392 |
+
|
393 |
+
if ($countryName != 'USA') {
|
394 |
+
return "Valid";
|
395 |
+
}
|
396 |
+
|
397 |
+
$requestResult = Mage::getModel('taxce/TaxAreaRequest')->prepareRequest($address)->taxAreaLookup();
|
398 |
+
if ($requestResult instanceof Exception) {
|
399 |
+
return "Address Validation Error: Please check settings";
|
400 |
+
}
|
401 |
+
return "Valid";
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Company Information
|
406 |
+
*
|
407 |
+
* @param array $data
|
408 |
+
* @return unknown
|
409 |
+
*/
|
410 |
+
public function addSellerInformation($data)
|
411 |
+
{
|
412 |
+
$regionId = $this->getCompanyRegionId();
|
413 |
+
if (is_int($regionId)) {
|
414 |
+
$regionModel = Mage::getModel('directory/region')->load($regionId);
|
415 |
+
$companyState = $regionModel->getCode();
|
416 |
+
} else {
|
417 |
+
$companyState = $regionId;
|
418 |
+
}
|
419 |
+
|
420 |
+
$countryModel = Mage::getModel('directory/country')->load($this->getCompanyCountry());
|
421 |
+
$countryName = $countryModel->getIso3Code();
|
422 |
+
$data['location_code'] = $this->getLocationCode();
|
423 |
+
$data['transaction_type'] = $this->getTransactionType();
|
424 |
+
$data['company_id'] = $this->getCompanyCode();
|
425 |
+
$data['company_street_1'] = $this->getCompanyStreet1();
|
426 |
+
$data['company_street_2'] = $this->getCompanyStreet2();
|
427 |
+
$data['company_city'] = $this->getCompanyCity();
|
428 |
+
$data['company_state'] = $companyState;
|
429 |
+
$data['company_postcode'] = $this->getCompanyPostalCode();
|
430 |
+
$data['company_country'] = $countryName;
|
431 |
+
$data['trusted_id'] = $this->getTrustedId();
|
432 |
+
return $data;
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
*
|
437 |
+
* @param array $data
|
438 |
+
* @param unknown $address
|
439 |
+
* @return unknown
|
440 |
+
*/
|
441 |
+
public function addAddressInformation($data, $address)
|
442 |
+
{
|
443 |
+
$data['customer_street1'] = $address->getStreet1();
|
444 |
+
$data['customer_street2'] = $address->getStreet2();
|
445 |
+
$data['customer_city'] = $address->getCity();
|
446 |
+
$data['customer_region'] = $address->getRegionCode();
|
447 |
+
$data['customer_postcode'] = $address->getPostcode();
|
448 |
+
$countryModel = Mage::getModel('directory/country')->load($address->getCountryId());
|
449 |
+
$countryName = $countryModel->getIso3Code();
|
450 |
+
$data['customer_country'] = $countryName;
|
451 |
+
$data['tax_area_id'] = $address->getTaxAreaId();
|
452 |
+
return $data;
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* @param unknown $originalEntity
|
457 |
+
* @return boolean
|
458 |
+
*/
|
459 |
+
public function isFirstOfPartial($originalEntity)
|
460 |
+
{
|
461 |
+
if ($originalEntity instanceof Mage_Sales_Model_Order_Invoice) {
|
462 |
+
if (! $originalEntity->getShippingTaxAmount()) {
|
463 |
+
return false;
|
464 |
+
}
|
465 |
+
}
|
466 |
+
if ($this->requestByInvoiceCreation() && $originalEntity instanceof Mage_Sales_Model_Order && $originalEntity->getShippingInvoiced()) {
|
467 |
+
return false;
|
468 |
+
}
|
469 |
+
if ($originalEntity instanceof Mage_Sales_Model_Order_Creditmemo) {
|
470 |
+
if (! $originalEntity->getShippingAMount()) {
|
471 |
+
return false;
|
472 |
+
}
|
473 |
+
}
|
474 |
+
return true;
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* @param unknown $info
|
479 |
+
* @param unknown $creditmemoModel
|
480 |
+
* @return Ambigous <multitype:number NULL , multitype:number NULL string >
|
481 |
+
*/
|
482 |
+
public function addRefundAdjustments($info, $creditmemoModel)
|
483 |
+
{
|
484 |
+
if ($creditmemoModel->getAdjustmentPositive()) {
|
485 |
+
$itemData = array();
|
486 |
+
$itemData['product_class'] = $this->taxClassNameByClassId($this->getCreditmemoAdjustmentPositiveClass());
|
487 |
+
$itemData['product_code'] = $this->getCreditmemoAdjustmentPositiveCode();
|
488 |
+
$itemData['qty'] = 1;
|
489 |
+
$itemData['price'] = - 1 * $creditmemoModel->getAdjustmentPositive();
|
490 |
+
$itemData['extended_price'] = - 1 * $creditmemoModel->getAdjustmentPositive();
|
491 |
+
$info[] = $itemData;
|
492 |
+
}
|
493 |
+
if ($creditmemoModel->getAdjustmentNegative()) {
|
494 |
+
$itemData = array();
|
495 |
+
$itemData['product_class'] = $this->taxClassNameByClassId($this->getCreditmemoAdjustmentFeeClass());
|
496 |
+
$itemData['product_code'] = $this->getCreditmemoAdjustmentFeeCode();
|
497 |
+
$itemData['qty'] = 1;
|
498 |
+
$itemData['price'] = $creditmemoModel->getAdjustmentNegative();
|
499 |
+
$itemData['extended_price'] = $creditmemoModel->getAdjustmentNegative();
|
500 |
+
$info[] = $itemData;
|
501 |
+
}
|
502 |
+
return $info;
|
503 |
+
}
|
504 |
+
|
505 |
+
/**
|
506 |
+
* @param unknown $orderAddress
|
507 |
+
* @param string $originalEntity
|
508 |
+
* @param string $event
|
509 |
+
* @return multitype:|multitype:number NULL string
|
510 |
+
*/
|
511 |
+
public function addOrderGiftWrap($orderAddress, $originalEntity = null, $event = null)
|
512 |
+
{
|
513 |
+
$itemData = array();
|
514 |
+
if (! $this->isFirstOfPartial($originalEntity)) {
|
515 |
+
return $itemData;
|
516 |
+
}
|
517 |
+
|
518 |
+
$itemData['product_class'] = $this->taxClassNameByClassId($this->getGiftWrappingOrderClass());
|
519 |
+
$itemData['product_code'] = $this->getGiftWrappingOrderCode();
|
520 |
+
$itemData['qty'] = 1;
|
521 |
+
$itemData['price'] = $orderAddress->getGwPrice();
|
522 |
+
$itemData['extended_price'] = $itemData['qty'] * $itemData['price'];
|
523 |
+
|
524 |
+
if ($event == 'cancel' || $event == 'refund') {
|
525 |
+
$itemData['price'] = - 1 * $itemData['price'];
|
526 |
+
$itemData['extended_price'] = - 1 * $itemData['extended_price'];
|
527 |
+
}
|
528 |
+
|
529 |
+
return $itemData;
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* @param unknown $orderAddress
|
534 |
+
* @param string $originalEntity
|
535 |
+
* @param string $event
|
536 |
+
* @return multitype:|multitype:number NULL string
|
537 |
+
*/
|
538 |
+
public function addOrderPrintCard($orderAddress, $originalEntity = null, $event = null)
|
539 |
+
{
|
540 |
+
$itemData = array();
|
541 |
+
if (! $this->isFirstOfPartial($originalEntity)) {
|
542 |
+
return $itemData;
|
543 |
+
}
|
544 |
+
$itemData['product_class'] = $this->taxClassNameByClassId($this->getPrintedGiftcardClass());
|
545 |
+
$itemData['product_code'] = $this->getPrintedGiftcardCode();
|
546 |
+
$itemData['qty'] = 1;
|
547 |
+
$itemData['price'] = $orderAddress->getGwCardPrice();
|
548 |
+
$itemData['extended_price'] = $orderAddress->getGwCardPrice();
|
549 |
+
|
550 |
+
if ($event == 'cancel' || $event == 'refund') {
|
551 |
+
$itemData['price'] = - 1 * $itemData['price'];
|
552 |
+
$itemData['extended_price'] = - 1 * $itemData['extended_price'];
|
553 |
+
}
|
554 |
+
|
555 |
+
return $itemData;
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* @param unknown $orderAddress
|
560 |
+
* @param string $originalEntity
|
561 |
+
* @param string $event
|
562 |
+
* @return multitype:number Ambigous <number> Ambigous <number, Ambigous <number>> NULL string
|
563 |
+
*/
|
564 |
+
public function addShippingInfo($orderAddress, $originalEntity = null, $event = null)
|
565 |
+
{
|
566 |
+
$itemData = array();
|
567 |
+
if ($orderAddress->getShippingMethod() && $this->isFirstOfPartial($originalEntity)) {
|
568 |
+
$itemData['product_class'] = $this->taxClassNameByClassId($this->getShippingTaxClassId());
|
569 |
+
$itemData['product_code'] = $orderAddress->getShippingMethod();
|
570 |
+
$itemData['price'] = $orderAddress->getShippingAmount() - $orderAddress->getShippingDiscountAmount();
|
571 |
+
$itemData['qty'] = 1;
|
572 |
+
$itemData['extended_price'] = $itemData['price'];
|
573 |
+
|
574 |
+
if ($originalEntity instanceof Mage_Sales_Model_Order_Creditmemo) {
|
575 |
+
$itemData['price'] = $originalEntity->getShippingAmount();
|
576 |
+
$itemData['extended_price'] = $itemData['price'];
|
577 |
+
}
|
578 |
+
if ($event == 'cancel' || $event == 'refund') {
|
579 |
+
$itemData['price'] = - 1 * $itemData['price'];
|
580 |
+
$itemData['extended_price'] = - 1 * $itemData['extended_price'];
|
581 |
+
}
|
582 |
+
}
|
583 |
+
return $itemData;
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* @param unknown $address
|
588 |
+
* @return unknown
|
589 |
+
*/
|
590 |
+
public function taxQuoteItems($address)
|
591 |
+
{
|
592 |
+
$informationArray = Mage::getModel('taxce/taxQuote')->collectQuotedata($address);
|
593 |
+
$information = new Varien_Object($informationArray);
|
594 |
+
$information->setTaxAreaId();
|
595 |
+
$taxedItemsInfo = Mage::getModel('taxce/taxQuote')->getTaxQuote($informationArray);
|
596 |
+
return $taxedItemsInfo;
|
597 |
+
}
|
598 |
+
|
599 |
+
/**
|
600 |
+
* @return boolean
|
601 |
+
*/
|
602 |
+
public function canQuoteTax()
|
603 |
+
{
|
604 |
+
if (! $this->isAllowedQuote()) {
|
605 |
+
return false;
|
606 |
+
}
|
607 |
+
if ($this->getSourcePath() == 'onepage_checkout_index') {
|
608 |
+
return false;
|
609 |
+
}
|
610 |
+
return true;
|
611 |
+
}
|
612 |
+
|
613 |
+
/**
|
614 |
+
* Common function for item preparation
|
615 |
+
*
|
616 |
+
* @uses Always send discounted. Discount on TotalRowAmount
|
617 |
+
* @param unknown $item
|
618 |
+
* @param string $type
|
619 |
+
* @param string $originalEntityItem
|
620 |
+
* @param string $event
|
621 |
+
* @return multitype:number NULL unknown string
|
622 |
+
*/
|
623 |
+
public function prepareItem($item, $type = 'ordered', $originalEntityItem = null, $event = null)
|
624 |
+
{
|
625 |
+
$itemData = array();
|
626 |
+
|
627 |
+
$itemData['product_class'] = $this->taxClassNameByClassId(
|
628 |
+
$item->getProduct()
|
629 |
+
->getTaxClassId()
|
630 |
+
);
|
631 |
+
$itemData['product_code'] = $item->getSku();
|
632 |
+
$itemData['item_id'] = $item->getId();
|
633 |
+
|
634 |
+
if ($type == 'invoiced') {
|
635 |
+
$price = $originalEntityItem->getPrice();
|
636 |
+
} else {
|
637 |
+
$price = $item->getPrice();
|
638 |
+
}
|
639 |
+
|
640 |
+
$itemData['price'] = $price;
|
641 |
+
if ($type == 'ordered' && $this->requestByInvoiceCreation()) {
|
642 |
+
$itemData['qty'] = $item->getQtyOrdered() - $item->getQtyInvoiced();
|
643 |
+
} elseif ($type == 'ordered')
|
644 |
+
$itemData['qty'] = $item->getQtyOrdered();
|
645 |
+
elseif ($type == 'invoiced')
|
646 |
+
$itemData['qty'] = $originalEntityItem->getQty();
|
647 |
+
elseif ($type == 'quote')
|
648 |
+
$itemData['qty'] = $item->getQty();
|
649 |
+
|
650 |
+
if ($type == 'invoiced') {
|
651 |
+
$itemData['extended_price'] = $originalEntityItem->getRowTotal() - $originalEntityItem->getDiscountAmount();
|
652 |
+
} elseif ($type == 'ordered' && $this->requestByInvoiceCreation()) {
|
653 |
+
$itemData['extended_price'] = $item->getRowTotal() - $item->getRowInvoiced() - $item->getDiscountAmount() + $item->getDiscountInvoiced();
|
654 |
+
} else {
|
655 |
+
$itemData['extended_price'] = $item->getRowTotal() - $item->getDiscountAmount();
|
656 |
+
}
|
657 |
+
|
658 |
+
if ($event == 'cancel' || $event == 'refund') {
|
659 |
+
$itemData['price'] = - 1 * $itemData['price'];
|
660 |
+
$itemData['extended_price'] = - 1 * $itemData['extended_price'];
|
661 |
+
}
|
662 |
+
return $itemData;
|
663 |
+
}
|
664 |
+
|
665 |
+
/**
|
666 |
+
*
|
667 |
+
* @param unknown $item
|
668 |
+
* @param string $type
|
669 |
+
* @param string $originalEntityItem
|
670 |
+
* @param string $event
|
671 |
+
* @return multitype:string number NULL unknown
|
672 |
+
*/
|
673 |
+
public function prepareGiftWrapItem($item, $type = 'ordered', $originalEntityItem = null, $event = null)
|
674 |
+
{
|
675 |
+
$itemData = array();
|
676 |
+
|
677 |
+
$itemData['product_class'] = $this->taxClassNameByClassId($this->getGiftWrappingItemClass());
|
678 |
+
$itemData['product_code'] = $this->getGiftWrappingItemCodePrefix() . '-' . $item->getSku();
|
679 |
+
|
680 |
+
if ($type == 'invoiced') {
|
681 |
+
$price = $item->getGwPriceInvoiced();
|
682 |
+
} else {
|
683 |
+
$price = $item->getGwPrice();
|
684 |
+
}
|
685 |
+
|
686 |
+
$itemData['price'] = $price;
|
687 |
+
if ($type == 'ordered' && $this->requestByInvoiceCreation()) {
|
688 |
+
$itemData['qty'] = $item->getQtyOrdered() - $item->getQtyInvoiced();
|
689 |
+
} elseif ($type == 'ordered')
|
690 |
+
$itemData['qty'] = $item->getQtyOrdered();
|
691 |
+
elseif ($type == 'invoiced')
|
692 |
+
$itemData['qty'] = $originalEntityItem->getQty();
|
693 |
+
elseif ($type == 'quote')
|
694 |
+
$itemData['qty'] = $item->getQty();
|
695 |
+
|
696 |
+
if ($type == 'invoiced') {
|
697 |
+
$itemData['extended_price'] = $itemData['qty'] * $itemData['price'];
|
698 |
+
} elseif ($type == 'ordered' && $this->requestByInvoiceCreation()) {
|
699 |
+
$itemData['extended_price'] = $itemData['qty'] * $itemData['price'];
|
700 |
+
} else {
|
701 |
+
$itemData['extended_price'] = $itemData['qty'] * ($item->getGwPrice());
|
702 |
+
}
|
703 |
+
|
704 |
+
if ($event == 'cancel' || $event == 'refund') {
|
705 |
+
$itemData['price'] = - 1 * $itemData['price'];
|
706 |
+
$itemData['extended_price'] = - 1 * $itemData['extended_price'];
|
707 |
+
}
|
708 |
+
|
709 |
+
return $itemData;
|
710 |
+
}
|
711 |
+
|
712 |
+
/**
|
713 |
+
* @return Mage_Checkout_Model_Session | Mage_Adminhtml_Model_Session_Quote
|
714 |
+
*/
|
715 |
+
public function getSession()
|
716 |
+
{
|
717 |
+
if (Mage::app()->getRequest()->getControllerName() != 'sales_order_create') {
|
718 |
+
return Mage::getSingleton('checkout/session');
|
719 |
+
} else {
|
720 |
+
return Mage::getSingleton('adminhtml/session_quote');
|
721 |
+
}
|
722 |
+
}
|
723 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/Observer.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_Observer
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @param Varien_Event_Observer $observer
|
16 |
+
* @return VertexSMB_TaxCE_Model_Observer
|
17 |
+
*/
|
18 |
+
public function invoiceCreated(Varien_Event_Observer $observer)
|
19 |
+
{
|
20 |
+
if (! $this->_getHelper()->isVertexSMBActive() || ! $this->_getHelper()->requestByInvoiceCreation()) {
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
|
24 |
+
$invoice = $observer->getEvent()->getInvoice();
|
25 |
+
$invoiceRequestData = Mage::getModel('taxce/taxInvoice')->prepareInvoiceData($invoice, 'invoice');
|
26 |
+
|
27 |
+
if ($invoiceRequestData && Mage::getModel('taxce/taxInvoice')->sendInvoiceRequest($invoiceRequestData, $invoice->getOrder())) {
|
28 |
+
$this->_getSession()->addSuccess(
|
29 |
+
$this->_getHelper()
|
30 |
+
->__('The Vertex SMB invoice has been sent.')
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
*
|
39 |
+
* @param Varien_Event_Observer $observer
|
40 |
+
* @return VertexSMB_TaxCE_Model_Observer
|
41 |
+
*/
|
42 |
+
public function orderSaved(Varien_Event_Observer $observer)
|
43 |
+
{
|
44 |
+
$order = $observer->getEvent()->getOrder();
|
45 |
+
if (! $this->_getHelper()->isVertexSMBActive() || ! $this->_getHelper()->requestByOrderStatus($order->getStatus())) {
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
$invoiceRequestData = Mage::getModel('taxce/taxInvoice')->prepareInvoiceData($order);
|
50 |
+
if ($invoiceRequestData && Mage::getModel('taxce/taxInvoice')->sendInvoiceRequest($invoiceRequestData, $order)) {
|
51 |
+
$this->_getSession()->addSuccess(
|
52 |
+
$this->_getHelper()
|
53 |
+
->__('The Vertex SMB invoice has been sent.')
|
54 |
+
);
|
55 |
+
}
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
*
|
61 |
+
* @param Varien_Event_Observer $observer
|
62 |
+
* @return VertexSMB_TaxCE_Model_Observer
|
63 |
+
*/
|
64 |
+
public function orderCreditmemoRefund(Varien_Event_Observer $observer)
|
65 |
+
{
|
66 |
+
$creditMemo = $observer->getCreditmemo();
|
67 |
+
$order = $creditMemo->getOrder();
|
68 |
+
$invoicedTax = Mage::getModel('taxce/taxRequest')->getTotalInvoicedTax($order->getId());
|
69 |
+
if (! $this->_getHelper()->isVertexSMBActive() || ! $invoicedTax) {
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
$creditmemoRequestData = Mage::getModel('taxce/taxInvoice')->prepareInvoiceData($creditMemo, 'refund');
|
73 |
+
if ($creditmemoRequestData && Mage::getModel('taxce/taxInvoice')->sendRefundRequest($creditmemoRequestData, $order)) {
|
74 |
+
$this->_getSession()->addSuccess(
|
75 |
+
$this->_getHelper()
|
76 |
+
->__('The Vertex SMB invoice has been refunded.')
|
77 |
+
);
|
78 |
+
}
|
79 |
+
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
*
|
85 |
+
* @param Varien_Event_Observer $observer
|
86 |
+
* @return VertexSMB_TaxCE_Model_Observer
|
87 |
+
*/
|
88 |
+
public function changeSystemConfig(Varien_Event_Observer $observer)
|
89 |
+
{
|
90 |
+
$config = $observer->getConfig();
|
91 |
+
$config->getNode('sections/tax/groups/calculation/fields/algorithm')->show_in_website = 0;
|
92 |
+
$config->getNode('sections/tax/groups/calculation/fields/algorithm')->show_in_default = 0;
|
93 |
+
$config->getNode('sections/tax/groups/calculation/fields/algorithm')->show_in_store = 0;
|
94 |
+
|
95 |
+
$config->getNode('sections/tax/groups/calculation/fields/based_on')->show_in_website = 0;
|
96 |
+
$config->getNode('sections/tax/groups/calculation/fields/based_on')->show_in_default = 0;
|
97 |
+
$config->getNode('sections/tax/groups/calculation/fields/based_on')->show_in_store = 0;
|
98 |
+
|
99 |
+
$config->getNode('sections/tax/groups/calculation/fields/discount_tax')->show_in_website = 0;
|
100 |
+
$config->getNode('sections/tax/groups/calculation/fields/discount_tax')->show_in_default = 0;
|
101 |
+
$config->getNode('sections/tax/groups/calculation/fields/discount_tax')->show_in_store = 0;
|
102 |
+
|
103 |
+
$config->getNode('sections/tax/groups/calculation/fields/apply_tax_on')->show_in_website = 0;
|
104 |
+
$config->getNode('sections/tax/groups/calculation/fields/apply_tax_on')->show_in_default = 0;
|
105 |
+
$config->getNode('sections/tax/groups/calculation/fields/apply_tax_on')->show_in_store = 0;
|
106 |
+
|
107 |
+
$config->getNode('sections/tax/groups/weee')->show_in_website = 0;
|
108 |
+
$config->getNode('sections/tax/groups/weee')->show_in_default = 0;
|
109 |
+
$config->getNode('sections/tax/groups/weee')->show_in_store = 0;
|
110 |
+
|
111 |
+
$config->getNode('sections/tax/groups/defaults')->show_in_website = 0;
|
112 |
+
$config->getNode('sections/tax/groups/defaults')->show_in_default = 0;
|
113 |
+
$config->getNode('sections/tax/groups/defaults')->show_in_store = 0;
|
114 |
+
|
115 |
+
if (! Mage::getConfig()->getModuleConfig('Enterprise_Enterprise') || ! Mage::getConfig()->getModuleConfig('Enterprise_Enterprise')->is('active', 'true')) {
|
116 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_class')->show_in_website = 0;
|
117 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_class')->show_in_default = 0;
|
118 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_class')->show_in_store = 0;
|
119 |
+
|
120 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_code')->show_in_website = 0;
|
121 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_code')->show_in_default = 0;
|
122 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_code')->show_in_store = 0;
|
123 |
+
|
124 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_class')->show_in_website = 0;
|
125 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_class')->show_in_default = 0;
|
126 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_class')->show_in_store = 0;
|
127 |
+
|
128 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_code')->show_in_website = 0;
|
129 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_code')->show_in_default = 0;
|
130 |
+
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_code')->show_in_store = 0;
|
131 |
+
|
132 |
+
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_class')->show_in_website = 0;
|
133 |
+
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_class')->show_in_default = 0;
|
134 |
+
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_class')->show_in_store = 0;
|
135 |
+
|
136 |
+
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_code')->show_in_website = 0;
|
137 |
+
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_code')->show_in_default = 0;
|
138 |
+
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_code')->show_in_store = 0;
|
139 |
+
}
|
140 |
+
|
141 |
+
return $this;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
*
|
146 |
+
* @param unknown $schedule
|
147 |
+
* @return VertexSMB_TaxCE_Model_Observer
|
148 |
+
*/
|
149 |
+
public function cleanLogs($schedule)
|
150 |
+
{
|
151 |
+
$requestModel = Mage::getModel('taxce/taxRequest');
|
152 |
+
$requestModel->removeQuotesLookupRequests();
|
153 |
+
$requestModel->removeInvoicesforCompletedOrders();
|
154 |
+
return $this;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
*
|
159 |
+
* @return VertexSMB_TaxCE_Helper_Data
|
160 |
+
*/
|
161 |
+
public function _getHelper()
|
162 |
+
{
|
163 |
+
return Mage::helper('taxce');
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Retrieve adminhtml session model object
|
168 |
+
*
|
169 |
+
* @return Mage_Adminhtml_Model_Session
|
170 |
+
*/
|
171 |
+
protected function _getSession()
|
172 |
+
{
|
173 |
+
return Mage::getSingleton('adminhtml/session');
|
174 |
+
}
|
175 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/RequestItem.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_RequestItem extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('taxce/requestItem');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return VertexSMB_TaxCE_Helper_Data
|
23 |
+
*/
|
24 |
+
public function getHelper()
|
25 |
+
{
|
26 |
+
return Mage::helper('taxce');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* requestType: TaxAreaRequest, InvoiceRequest, QuotationRequest
|
31 |
+
* @return multitype:unknown
|
32 |
+
*/
|
33 |
+
public function exportAsArray()
|
34 |
+
{
|
35 |
+
$request = array(
|
36 |
+
'Login' => array(
|
37 |
+
'TrustedId' => $this->getTrustedId()
|
38 |
+
),
|
39 |
+
$this->getRequestType() => array(
|
40 |
+
'documentDate' => $this->getDocumentDate(),
|
41 |
+
'postingDate' => $this->getPostingDate(),
|
42 |
+
'transactionType' => $this->getTransactionType(),
|
43 |
+
'documentNumber' => $this->getDocumentNumber(),
|
44 |
+
'LineItem' => array()
|
45 |
+
)
|
46 |
+
)
|
47 |
+
;
|
48 |
+
|
49 |
+
if ($this->getDocumentNumber()) {
|
50 |
+
$request[$this->getRequestType()]['documentNumber'] = $this->getDocumentNumber();
|
51 |
+
}
|
52 |
+
|
53 |
+
$orderItems = $this->getOrderItems();
|
54 |
+
$request[$this->getRequestType()]['LineItem'] = $this->addItems($orderItems);
|
55 |
+
|
56 |
+
return $request;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @param unknown $items
|
61 |
+
* @return multitype:unknown
|
62 |
+
*/
|
63 |
+
public function addItems($items)
|
64 |
+
{
|
65 |
+
$queryItems = array();
|
66 |
+
$i = 1;
|
67 |
+
/**
|
68 |
+
* lineItemNumber
|
69 |
+
*/
|
70 |
+
foreach ($items as $key => $item) {
|
71 |
+
/**
|
72 |
+
* $key - quote_item_id
|
73 |
+
*/
|
74 |
+
$tmpItem = array(
|
75 |
+
'lineItemNumber' => $i,
|
76 |
+
'lineItemId' => $key,
|
77 |
+
'locationCode' => $this->getLocationCode(),
|
78 |
+
'Seller' => array(
|
79 |
+
'Company' => $this->getCompanyId(),
|
80 |
+
'PhysicalOrigin' => array(
|
81 |
+
'StreetAddress1' => $this->getData('company_street_1'),
|
82 |
+
'StreetAddress2' => $this->getData('company_street_2'),
|
83 |
+
'City' => $this->getCompanyCity(),
|
84 |
+
'Country' => $this->getCompanyCountry(),
|
85 |
+
'MainDivision' => $this->getCompanyState(),
|
86 |
+
'PostalCode' => $this->getCompanyPostcode()
|
87 |
+
)
|
88 |
+
),
|
89 |
+
'Customer' => array(
|
90 |
+
'CustomerCode' => array(
|
91 |
+
'classCode' => $this->getCustomerClass(),
|
92 |
+
'_' => $this->getCustomerCode()
|
93 |
+
),
|
94 |
+
'Destination' => array(
|
95 |
+
'StreetAddress1' => $this->getCustomerStreet1(),
|
96 |
+
'StreetAddress2' => $this->getCustomerStreet2(),
|
97 |
+
'City' => $this->getCustomerCity(),
|
98 |
+
'MainDivision' => $this->getCustomerRegion(),
|
99 |
+
'PostalCode' => $this->getCustomerPostcode(),
|
100 |
+
'Country' => $this->getCustomerCountry()
|
101 |
+
)
|
102 |
+
),
|
103 |
+
'Product' => array(
|
104 |
+
'productClass' => $item['product_class'],
|
105 |
+
'_' => $item['product_code']
|
106 |
+
),
|
107 |
+
'UnitPrice' => array(
|
108 |
+
'_' => $item['price']
|
109 |
+
),
|
110 |
+
'Quantity' => array(
|
111 |
+
'_' => $item['qty']
|
112 |
+
),
|
113 |
+
'ExtendedPrice' => array(
|
114 |
+
'_' => $item['extended_price']
|
115 |
+
)
|
116 |
+
);
|
117 |
+
|
118 |
+
if ($this->getCustomerCountry() == 'CAN') {
|
119 |
+
$tmpItem['deliveryTerm'] = 'SUP';
|
120 |
+
}
|
121 |
+
|
122 |
+
if ($this->getTaxAreaId()) {
|
123 |
+
$tmpItem['Customer']['Destination']['taxAreaId'] = $this->getTaxAreaId();
|
124 |
+
}
|
125 |
+
|
126 |
+
$queryItems[] = $tmpItem;
|
127 |
+
$i ++;
|
128 |
+
}
|
129 |
+
return $queryItems;
|
130 |
+
}
|
131 |
+
}
|
app/code/{local → community}/VertexSMB/TaxCE/Model/Resource/Setup.php
RENAMED
@@ -1,26 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
* @
|
5 |
-
* @
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
*
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
}
|
26 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @param unknown $entityTypeId
|
16 |
+
* @param unknown $attributeId
|
17 |
+
* @return boolean
|
18 |
+
*/
|
19 |
+
public function attributeExists($entityTypeId, $attributeId)
|
20 |
+
{
|
21 |
+
try {
|
22 |
+
$entityTypeId = $this->getEntityTypeId($entityTypeId);
|
23 |
+
$attributeId = $this->getAttributeId($entityTypeId, $attributeId);
|
24 |
+
return ! empty($attributeId);
|
25 |
+
} catch (Exception $e) {
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
app/code/{local → community}/VertexSMB/TaxCE/Model/Resource/TaxRequest.php
RENAMED
@@ -1,18 +1,20 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
* @
|
5 |
-
* @
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_Resource_TaxRequest extends Mage_Core_Model_Resource_Db_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Resource initialization
|
15 |
+
*/
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('taxce/taxrequest', 'request_id');
|
19 |
+
}
|
20 |
+
}
|
app/code/{local → community}/VertexSMB/TaxCE/Model/Resource/TaxRequest/Collection.php
RENAMED
@@ -1,27 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
* @
|
5 |
-
* @
|
6 |
-
* @author Alex Lukyanau
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
}
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_Resource_Taxrequest_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Resource initialization
|
15 |
+
*/
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('taxce/taxrequest');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param unknown $requestType
|
23 |
+
*/
|
24 |
+
public function setRequestTypeFilter($requestType)
|
25 |
+
{
|
26 |
+
return $this->addFieldToFilter('main_table.request_type', $requestType);
|
27 |
+
}
|
28 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/Source/Taxinvoice.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_Source_Taxinvoice
|
11 |
+
{
|
12 |
+
|
13 |
+
protected $_options;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @return multitype:string NULL
|
17 |
+
*/
|
18 |
+
public function toOptionArray()
|
19 |
+
{
|
20 |
+
if (! $this->_options) {
|
21 |
+
$this->_options[] = array(
|
22 |
+
'label' => Mage::helper('taxce')->__("When Invoice Created"),
|
23 |
+
'value' => 'invoice_created'
|
24 |
+
);
|
25 |
+
$this->_options[] = array(
|
26 |
+
'label' => Mage::helper('taxce')->__("When Order Status Is"),
|
27 |
+
'value' => 'order_status'
|
28 |
+
);
|
29 |
+
}
|
30 |
+
$options = $this->_options;
|
31 |
+
return $options;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/Tax/Sales/Total/Quote/Tax.php
ADDED
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_Tax_Sales_Total_Quote_Tax extends Mage_Tax_Model_Sales_Total_Quote_Tax
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Collect tax totals for quote address
|
15 |
+
*
|
16 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
17 |
+
* @return Mage_Tax_Model_Sales_Total_Quote
|
18 |
+
*/
|
19 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
20 |
+
{
|
21 |
+
if (! Mage::helper('taxce')->isVertexSMBActive()) {
|
22 |
+
parent::collect($address);
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
$addressType = $address->getAddressType();
|
26 |
+
|
27 |
+
if ($address->getQuote()->isVirtual() && $addressType == 'shipping') {
|
28 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
29 |
+
Mage::log("Quote request was not sent. Address Type: " . $addressType . ", Order is virtual.", null, 'vertexsmb.log');
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
if (! $address->getQuote()->isVirtual() && ! $address->getShippingMethod()) {
|
33 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
34 |
+
Mage::log("Quote request was not sent. Order is not virtual and doesnt have shipping method.", null, 'vertexsmb.log');
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
if (! $address->getStreet1() && ! Mage::helper('taxce')->allowCartQuote()) {
|
39 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
40 |
+
Mage::log("Quote request was not sent. Street not specified.", null, 'vertexsmb.log');
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
if (! $address->getCountryId() || ! $address->getRegion() || ! $address->getPostcode() || ! count($address->getAllNonNominalItems())) {
|
45 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
46 |
+
Mage::log("Quote request was not sent. Address not specified. ", null, 'vertexsmb.log');
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
if (Mage::app()->getRequest()->getControllerName() == 'cart' && ! Mage::helper('taxce')->allowCartQuote()) {
|
51 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
52 |
+
Mage::log("Quote request was not sent.It is not allowed in the quote ", null, 'vertexsmb.log');
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
if (! Mage::helper('taxce')->canQuoteTax()) {
|
57 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
58 |
+
Mage::log("Quote request not have enought information", null, 'vertexsmb.log');
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
63 |
+
$this->_roundingDeltas = array();
|
64 |
+
$this->_baseRoundingDeltas = array();
|
65 |
+
$this->_hiddenTaxes = array();
|
66 |
+
$address->setShippingTaxAmount(0);
|
67 |
+
$address->setBaseShippingTaxAmount(0);
|
68 |
+
|
69 |
+
$this->_store = $address->getQuote()->getStore();
|
70 |
+
$customer = $address->getQuote()->getCustomer();
|
71 |
+
if ($customer) {
|
72 |
+
$this->_calculator->setCustomer($customer);
|
73 |
+
}
|
74 |
+
|
75 |
+
if (! $address->getAppliedTaxesReset()) {
|
76 |
+
$address->setAppliedTaxes(array());
|
77 |
+
}
|
78 |
+
|
79 |
+
$items = $this->_getAddressItems($address);
|
80 |
+
if (! count($items)) {
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
$request = new Varien_Object();
|
85 |
+
|
86 |
+
if ($this->_config->priceIncludesTax($this->_store)) {
|
87 |
+
$this->_areTaxRequestsSimilar = $this->_calculator->compareRequests($this->_calculator->getRateOriginRequest($this->_store), $request);
|
88 |
+
}
|
89 |
+
|
90 |
+
$itemsVertexTaxes = Mage::helper('taxce')->taxQuoteItems($address);
|
91 |
+
$request->setItemsVertexTax($itemsVertexTaxes);
|
92 |
+
|
93 |
+
$this->_rowBaseCalculation($address, $request);
|
94 |
+
$this->_addAmount($address->getExtraTaxAmount());
|
95 |
+
$this->_addBaseAmount($address->getBaseExtraTaxAmount());
|
96 |
+
$this->_calculateShippingTax($address, $request);
|
97 |
+
|
98 |
+
$this->_processHiddenTaxes();
|
99 |
+
$this->_roundTotals($address);
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
105 |
+
* @param unknown $taxRateRequest
|
106 |
+
* @return VertexSMB_TaxCE_Model_Tax_Sales_Total_Quote_Tax
|
107 |
+
*/
|
108 |
+
protected function _rowBaseCalculation(Mage_Sales_Model_Quote_Address $address, $taxRateRequest)
|
109 |
+
{
|
110 |
+
if (! Mage::helper('taxce')->isVertexSMBActive()) {
|
111 |
+
parent::_rowBaseCalculation($address, $taxRateRequest);
|
112 |
+
return $this;
|
113 |
+
}
|
114 |
+
|
115 |
+
$items = $this->_getAddressItems($address);
|
116 |
+
$itemTaxGroups = array();
|
117 |
+
|
118 |
+
$itemsVertexTaxes = $taxRateRequest->getItemsVertexTax();
|
119 |
+
|
120 |
+
foreach ($items as $item) {
|
121 |
+
if ($item->getParentItem()) {
|
122 |
+
continue;
|
123 |
+
}
|
124 |
+
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
|
125 |
+
foreach ($item->getChildren() as $child) {
|
126 |
+
$taxRateRequest->setProductClassId(
|
127 |
+
$child->getProduct()
|
128 |
+
->getTaxClassId()
|
129 |
+
);
|
130 |
+
$rate = $this->_calculator->getRate($taxRateRequest);
|
131 |
+
$this->_calcRowTaxAmount($child, $itemsVertexTaxes);
|
132 |
+
$this->_addAmount($child->getTaxAmount());
|
133 |
+
$this->_addBaseAmount($child->getBaseTaxAmount());
|
134 |
+
$applied = $this->_calculator->getAppliedRates($taxRateRequest);
|
135 |
+
if ($rate > 0) {
|
136 |
+
$itemTaxGroups[$child->getId()] = $applied;
|
137 |
+
}
|
138 |
+
$this->_saveAppliedTaxes($address, $applied, $child->getTaxAmount(), $child->getBaseTaxAmount(), $rate);
|
139 |
+
$child->setTaxRates($applied);
|
140 |
+
}
|
141 |
+
$this->_recalculateParent($item);
|
142 |
+
} else {
|
143 |
+
$taxRateRequest->setProductClassId(
|
144 |
+
$item->getProduct()
|
145 |
+
->getTaxClassId()
|
146 |
+
);
|
147 |
+
$rate = $this->_calculator->getRate($taxRateRequest);
|
148 |
+
$this->_calcRowTaxAmount($item, $itemsVertexTaxes);
|
149 |
+
$this->_addAmount($item->getTaxAmount());
|
150 |
+
$this->_addBaseAmount($item->getBaseTaxAmount());
|
151 |
+
$applied = $this->_calculator->getAppliedRates($taxRateRequest);
|
152 |
+
if ($rate > 0) {
|
153 |
+
$itemTaxGroups[$item->getId()] = $applied;
|
154 |
+
}
|
155 |
+
$this->_saveAppliedTaxes($address, $applied, $item->getTaxAmount(), $item->getBaseTaxAmount(), $rate);
|
156 |
+
$item->setTaxRates($applied);
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
if ($address->getQuote()->getTaxesForItems()) {
|
161 |
+
$itemTaxGroups += $address->getQuote()->getTaxesForItems();
|
162 |
+
}
|
163 |
+
$address->getQuote()->setTaxesForItems($itemTaxGroups);
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
/**
|
169 |
+
* @param unknown $item
|
170 |
+
* @param unknown $rate
|
171 |
+
* @param string $taxGroups
|
172 |
+
* @param string $taxId
|
173 |
+
* @param string $recalculateRowTotalInclTax
|
174 |
+
* @return VertexSMB_TaxCE_Model_Tax_Sales_Total_Quote_Tax
|
175 |
+
*/
|
176 |
+
protected function _calcRowTaxAmount($item, $rate, &$taxGroups = null, $taxId = null, $recalculateRowTotalInclTax = false)
|
177 |
+
{
|
178 |
+
if (! Mage::helper('taxce')->isVertexSMBActive()) {
|
179 |
+
parent::_calcRowTaxAmount($item, $rate);
|
180 |
+
return $this;
|
181 |
+
}
|
182 |
+
|
183 |
+
$subtotal = $taxSubtotal = $item->getTaxableAmount();
|
184 |
+
$baseSubtotal = $baseTaxSubtotal = $item->getBaseTaxableAmount();
|
185 |
+
$rowTax = 0;
|
186 |
+
$baseRowTax = 0;
|
187 |
+
$taxRate = 0;
|
188 |
+
$itemTax = $rate[$item->getId()];
|
189 |
+
if ($itemTax instanceof Varien_Object) {
|
190 |
+
$rowTax = $itemTax->getTaxAmount();
|
191 |
+
$baseRowTax = $itemTax->getBaseTaxAmount();
|
192 |
+
$taxRate = $itemTax->getTaxPercent();
|
193 |
+
} else {
|
194 |
+
Mage::log("ItemTax is not instance of Varien_Object. ", null, 'vertexsmb.log');
|
195 |
+
}
|
196 |
+
|
197 |
+
$item->setTaxPercent($taxRate);
|
198 |
+
$item->setTaxAmount(max(0, $rowTax));
|
199 |
+
$item->setBaseTaxAmount(max(0, $baseRowTax));
|
200 |
+
$rowTotalInclTax = $item->getRowTotalInclTax();
|
201 |
+
|
202 |
+
if (! isset($rowTotalInclTax)) {
|
203 |
+
$weeeTaxBeforeDiscount = 0;
|
204 |
+
$baseWeeeTaxBeforeDiscount = 0;
|
205 |
+
|
206 |
+
if ($this->_config->priceIncludesTax($this->_store)) {
|
207 |
+
$item->setRowTotalInclTax($subtotal + $weeeTaxBeforeDiscount);
|
208 |
+
$item->setBaseRowTotalInclTax($baseSubtotal + $baseWeeeTaxBeforeDiscount);
|
209 |
+
} else {
|
210 |
+
$taxCompensation = $item->getDiscountTaxCompensation() ? $item->getDiscountTaxCompensation() : 0;
|
211 |
+
$item->setRowTotalInclTax($subtotal + $rowTax + $taxCompensation);
|
212 |
+
$item->setBaseRowTotalInclTax($baseSubtotal + $baseRowTax + $item->getBaseDiscountTaxCompensation());
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
return $this;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
221 |
+
* @param unknown $taxRateRequest
|
222 |
+
* @return VertexSMB_TaxCE_Model_Tax_Sales_Total_Quote_Tax
|
223 |
+
*/
|
224 |
+
protected function _calculateShippingTax(Mage_Sales_Model_Quote_Address $address, $taxRateRequest)
|
225 |
+
{
|
226 |
+
if (! Mage::helper('taxce')->isVertexSMBActive()) {
|
227 |
+
parent::_calculateShippingTax($address, $taxRateRequest);
|
228 |
+
return $this;
|
229 |
+
}
|
230 |
+
|
231 |
+
$itemsVertexTaxes = $taxRateRequest->getItemsVertexTax();
|
232 |
+
|
233 |
+
$taxRateRequest->setProductClassId($this->_config->getShippingTaxClass($this->_store));
|
234 |
+
$tax = 0;
|
235 |
+
$baseTax = 0;
|
236 |
+
$rate = 0;
|
237 |
+
$shippingTax = 0;
|
238 |
+
|
239 |
+
if (is_array($itemsVertexTaxes) && array_key_exists('shipping', $itemsVertexTaxes)) {
|
240 |
+
$shippingTax = $itemsVertexTaxes['shipping'];
|
241 |
+
}
|
242 |
+
|
243 |
+
Mage::log($itemsVertexTaxes, null, 'vertexsmb.log');
|
244 |
+
|
245 |
+
if ($shippingTax instanceof Varien_Object) {
|
246 |
+
$tax = $shippingTax->getTaxAmount();
|
247 |
+
$baseTax = $shippingTax->getBaseTaxAmount();
|
248 |
+
$rate = $shippingTax->getTaxPercent();
|
249 |
+
} else {
|
250 |
+
Mage::log("calculateShippingTax::shippingTax is not instance of Varien_Object. ", null, 'vertexsmb.log');
|
251 |
+
}
|
252 |
+
|
253 |
+
$this->_addAmount(max(0, $tax));
|
254 |
+
$this->_addBaseAmount(max(0, $baseTax));
|
255 |
+
$address->setShippingTaxAmount(max(0, $tax));
|
256 |
+
$address->setBaseShippingTaxAmount(max(0, $baseTax));
|
257 |
+
|
258 |
+
$applied = $this->_calculator->getAppliedRates($taxRateRequest);
|
259 |
+
$this->_saveAppliedTaxes($address, $applied, $tax, $baseTax, $rate);
|
260 |
+
|
261 |
+
return $this;
|
262 |
+
}
|
263 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/TaxAreaRequest.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_TaxAreaRequest extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param unknown $address
|
15 |
+
* @return VertexSMB_TaxCE_Model_TaxAreaRequest
|
16 |
+
*/
|
17 |
+
public function prepareRequest($address)
|
18 |
+
{
|
19 |
+
$request = array(
|
20 |
+
'Login' => array(
|
21 |
+
'TrustedId' => $this->getHelper()->getTrustedId()
|
22 |
+
),
|
23 |
+
'TaxAreaRequest' => array(
|
24 |
+
'TaxAreaLookup' => array(
|
25 |
+
'PostalAddress' => array(
|
26 |
+
'StreetAddress1' => $address->getStreet1(),
|
27 |
+
'StreetAddress2' => $address->getStreet2(),
|
28 |
+
'City' => $address->getCity(),
|
29 |
+
'MainDivision' => $address->getRegionCode(),
|
30 |
+
'PostalCode' => $address->getPostcode()
|
31 |
+
)
|
32 |
+
)
|
33 |
+
)
|
34 |
+
);
|
35 |
+
|
36 |
+
$this->setRequest($request);
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return boolean|Exception
|
42 |
+
*/
|
43 |
+
public function taxAreaLookup()
|
44 |
+
{
|
45 |
+
if (! $this->getRequest()) {
|
46 |
+
Mage::log("Tax area lookup error: request information not exist", null, 'vertexsmb.log');
|
47 |
+
return false;
|
48 |
+
}
|
49 |
+
$requestData = $this->getRequest();
|
50 |
+
|
51 |
+
$requestResult = Mage::getModel('taxce/vertexSMB')->sendApiRequest($requestData, 'tax_area_lookup');
|
52 |
+
if ($requestResult instanceof Exception) {
|
53 |
+
Mage::log("Tax Area Lookup Error: " . $requestResult->getMessage(), null, 'vertexsmb.log');
|
54 |
+
return $requestResult;
|
55 |
+
}
|
56 |
+
|
57 |
+
$response = Mage::getModel('taxce/TaxAreaResponse')->parseResponse($requestResult);
|
58 |
+
$response->setRequestCity($requestData['TaxAreaRequest']['TaxAreaLookup']['PostalAddress']['City']);
|
59 |
+
$this->setResponse($response);
|
60 |
+
|
61 |
+
return $requestResult;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return VertexSMB_TaxCE_Helper_Data
|
66 |
+
*/
|
67 |
+
public function getHelper()
|
68 |
+
{
|
69 |
+
return Mage::helper('taxce');
|
70 |
+
}
|
71 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/TaxAreaResponse.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_TaxAreaResponse extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param unknown $responseObject
|
15 |
+
* @return VertexSMB_TaxCE_Model_TaxAreaResponse
|
16 |
+
*/
|
17 |
+
public function parseResponse($responseObject)
|
18 |
+
{
|
19 |
+
if (is_array($responseObject->TaxAreaResponse->TaxAreaResult)) {
|
20 |
+
$taxAreaResults = $responseObject->TaxAreaResponse->TaxAreaResult;
|
21 |
+
} else {
|
22 |
+
$taxAreaResults[] = $responseObject->TaxAreaResponse->TaxAreaResult;
|
23 |
+
}
|
24 |
+
|
25 |
+
$this->setTaxAreaResults($taxAreaResults);
|
26 |
+
$this->setResultsCount(count($taxAreaResults));
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @return Varien_Data_Collection_Element
|
32 |
+
*/
|
33 |
+
public function getFirstTaxAreaInfo()
|
34 |
+
{
|
35 |
+
$collection = $this->getTaxAreaLocationsCollection();
|
36 |
+
return $collection->getFirstItem();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Used for popup window frontend/adminhtml
|
41 |
+
*
|
42 |
+
* @return Varien_Data_Collection|unknown
|
43 |
+
*/
|
44 |
+
public function getTaxAreaLocationsCollection()
|
45 |
+
{
|
46 |
+
$taxAreaInfoCollection = new Varien_Data_Collection();
|
47 |
+
|
48 |
+
if (! $this->getTaxAreaResults()) {
|
49 |
+
return $taxAreaInfoCollection;
|
50 |
+
}
|
51 |
+
|
52 |
+
$taxAreaResults = $this->getTaxAreaResults();
|
53 |
+
|
54 |
+
foreach ($taxAreaResults as $taxResponse) {
|
55 |
+
$taxJurisdictions = $taxResponse->Jurisdiction;
|
56 |
+
krsort($taxJurisdictions);
|
57 |
+
$areaNames = array();
|
58 |
+
$areaName = "";
|
59 |
+
foreach ($taxJurisdictions as $areaJursdiction) {
|
60 |
+
$areaNames[] = $areaJursdiction->_;
|
61 |
+
}
|
62 |
+
$areaName = ucwords(strtolower(implode(', ', $areaNames)));
|
63 |
+
|
64 |
+
$taxAreaInfo = new Varien_Object();
|
65 |
+
$taxAreaInfo->setAreaName($areaName);
|
66 |
+
$taxAreaInfo->setTaxAreaId($taxResponse->taxAreaId);
|
67 |
+
if (property_exists($taxResponse, "PostalAddress")) {
|
68 |
+
$taxAreaInfo->setTaxAreaCity($taxResponse->PostalAddress->City);
|
69 |
+
} else {
|
70 |
+
$taxAreaInfo->setTaxAreaCity($this->getRequestCity());
|
71 |
+
}
|
72 |
+
|
73 |
+
$taxAreaInfo->setRequestCity($this->getRequestCity());
|
74 |
+
$taxAreaInfoCollection->addItem($taxAreaInfo);
|
75 |
+
}
|
76 |
+
|
77 |
+
return $taxAreaInfoCollection;
|
78 |
+
}
|
79 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/TaxInvoice.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_TaxInvoice extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('taxce/taxinvoice');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return VertexSMB_TaxCE_Helper_Data
|
23 |
+
*/
|
24 |
+
public function getHelper()
|
25 |
+
{
|
26 |
+
return Mage::helper('taxce');
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param unknown $entityItem
|
32 |
+
* @param string $event
|
33 |
+
* @return unknown
|
34 |
+
*/
|
35 |
+
public function prepareInvoiceData($entityItem, $event = null)
|
36 |
+
{
|
37 |
+
$info = array();
|
38 |
+
$info = $this->getHelper()->addSellerInformation($info);
|
39 |
+
|
40 |
+
if ($entityItem instanceof Mage_Sales_Model_Order) {
|
41 |
+
$order = $entityItem;
|
42 |
+
} elseif ($entityItem instanceof Mage_Sales_Model_Order_Invoice) {
|
43 |
+
$order = $entityItem->getOrder();
|
44 |
+
} elseif ($entityItem instanceof Mage_Sales_Model_Order_Creditmemo) {
|
45 |
+
$order = $entityItem->getOrder();
|
46 |
+
}
|
47 |
+
$info['order_id'] = $order->getIncrementId();
|
48 |
+
$info['document_number'] = $order->getIncrementId();
|
49 |
+
$info['document_date'] = date("Y-m-d", strtotime($order->getCreatedAt()));
|
50 |
+
$info['posting_date'] = date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
|
51 |
+
|
52 |
+
$customerClass = $this->getHelper()->taxClassNameByCustomerGroupId($order->getCustomerGroupId());
|
53 |
+
$customerCode = $this->getHelper()->getCustomerCodeById($order->getCustomerId());
|
54 |
+
|
55 |
+
$info['customer_class'] = $customerClass;
|
56 |
+
$info['customer_code'] = $customerCode;
|
57 |
+
|
58 |
+
if ($order->getIsVirtual()) {
|
59 |
+
$address = $order->getBillingAddress();
|
60 |
+
} else {
|
61 |
+
$address = $order->getShippingAddress();
|
62 |
+
}
|
63 |
+
|
64 |
+
$info = $this->getHelper()->addAddressInformation($info, $address);
|
65 |
+
|
66 |
+
$orderItems = array();
|
67 |
+
$orderedItems = $entityItem->getAllItems();
|
68 |
+
|
69 |
+
foreach ($orderedItems as $item) {
|
70 |
+
$originalItem = $item;
|
71 |
+
if ($entityItem instanceof Mage_Sales_Model_Order_Invoice) {
|
72 |
+
$item = $item->getOrderItem();
|
73 |
+
} elseif ($entityItem instanceof Mage_Sales_Model_Order_Creditmemo)
|
74 |
+
$item = $item->getOrderItem();
|
75 |
+
|
76 |
+
if ($item->getParentItem()) {
|
77 |
+
continue;
|
78 |
+
}
|
79 |
+
|
80 |
+
if ($item->getHasChildren() && $item->getProduct()->getPriceType() !== null && (int) $item->getProduct()->getPriceType() === Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
|
81 |
+
foreach ($item->getChildrenItems() as $child) {
|
82 |
+
if ($entityItem instanceof Mage_Sales_Model_Order_Invoice || $entityItem instanceof Mage_Sales_Model_Order_Creditmemo) {
|
83 |
+
$orderItems[] = $this->getHelper()->prepareItem($child, 'invoiced', $originalItem, $event);
|
84 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping') && Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping')->is('active', 'true') && $child->getGwId()) {
|
85 |
+
$orderItems[] = $this->getHelper()->prepareGiftWrapItem($child, 'invoiced', $originalItem, $event);
|
86 |
+
}
|
87 |
+
} elseif ($entityItem instanceof Mage_Sales_Model_Order) {
|
88 |
+
$orderItems[] = $this->getHelper()->prepareItem($child, 'ordered', $originalItem, $event);
|
89 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping') && Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping')->is('active', 'true') && $child->getGwId()) {
|
90 |
+
$orderItems[] = $this->getHelper()->prepareGiftWrapItem($child, 'ordered', $originalItem, $event);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
} else {
|
95 |
+
if ($entityItem instanceof Mage_Sales_Model_Order_Invoice || $entityItem instanceof Mage_Sales_Model_Order_Creditmemo) {
|
96 |
+
$orderItems[] = $this->getHelper()->prepareItem($item, 'invoiced', $originalItem, $event);
|
97 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping') && Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping')->is('active', 'true') && $item->getGwId()) {
|
98 |
+
$orderItems[] = $this->getHelper()->prepareGiftWrapItem($item, 'invoiced', $originalItem, $event);
|
99 |
+
}
|
100 |
+
} elseif ($entityItem instanceof Mage_Sales_Model_Order) {
|
101 |
+
$orderItems[] = $this->getHelper()->prepareItem($item, 'ordered', $originalItem, $event);
|
102 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping') && Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping')->is('active', 'true') && $item->getGwId()) {
|
103 |
+
$orderItems[] = $this->getHelper()->prepareGiftWrapItem($item, 'ordered', $originalItem, $event);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
if (! $order->getIsVirtual() && count($this->getHelper()->addShippingInfo($order, $entityItem, $event))) {
|
110 |
+
$orderItems[] = $this->getHelper()->addShippingInfo($order, $entityItem, $event);
|
111 |
+
}
|
112 |
+
|
113 |
+
if ($entityItem instanceof Mage_Sales_Model_Order_Creditmemo) {
|
114 |
+
$orderItems = $this->getHelper()->addRefundAdjustments($orderItems, $entityItem);
|
115 |
+
}
|
116 |
+
|
117 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping') && Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping')->is('active', 'true')) {
|
118 |
+
if (count($this->getHelper()->addOrderGiftWrap($order, $entityItem, $event))) {
|
119 |
+
$orderItems[] = $this->getHelper()->addOrderGiftWrap($order, $entityItem, $event);
|
120 |
+
}
|
121 |
+
if (count($this->getHelper()->addOrderPrintCard($order, $entityItem, $event))) {
|
122 |
+
$orderItems[] = $this->getHelper()->addOrderPrintCard($order, $entityItem, $event);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
$info['request_type'] = 'InvoiceRequest';
|
127 |
+
$info['order_items'] = $orderItems;
|
128 |
+
$request = Mage::getModel('taxce/requestItem')->setData($info)->exportAsArray();
|
129 |
+
|
130 |
+
return $request;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @param unknown $data
|
135 |
+
* @param string $order
|
136 |
+
* @return boolean
|
137 |
+
*/
|
138 |
+
public function sendInvoiceRequest($data, $order = null)
|
139 |
+
{
|
140 |
+
if ($order == null) {
|
141 |
+
$order = Mage::registry('current_order');
|
142 |
+
}
|
143 |
+
|
144 |
+
$requestResult = Mage::getModel('taxce/vertexSMB')->sendApiRequest($data, 'invoice', $order);
|
145 |
+
if ($requestResult instanceof Exception) {
|
146 |
+
Mage::log("Invoice Request Error: " . $requestResult->getMessage(), null, 'vertexsmb.log');
|
147 |
+
Mage::getSingleton('adminhtml/session')->addError($requestResult->getMessage());
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
|
151 |
+
$order->addStatusHistoryComment('Vertex SMB Invoice sent successfully. Amount: $' . $requestResult->InvoiceResponse->TotalTax->_, false)->save();
|
152 |
+
return true;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @param unknown $data
|
157 |
+
* @param string $order
|
158 |
+
* @return boolean
|
159 |
+
*/
|
160 |
+
public function sendRefundRequest($data, $order = null)
|
161 |
+
{
|
162 |
+
if ($order == null) {
|
163 |
+
$order = Mage::registry('current_order');
|
164 |
+
}
|
165 |
+
$requestResult = Mage::getModel('taxce/vertexSMB')->sendApiRequest($data, 'invoice_refund', $order);
|
166 |
+
if ($requestResult instanceof Exception) {
|
167 |
+
Mage::log("Refund Request Error: " . $requestResult->getMessage(), null, 'vertexsmb.log');
|
168 |
+
Mage::getSingleton('adminhtml/session')->addError($requestResult->getMessage());
|
169 |
+
return false;
|
170 |
+
}
|
171 |
+
$order->addStatusHistoryComment('Vertex SMB Invoice refunded successfully. Amount: $' . $requestResult->InvoiceResponse->TotalTax->_, false)->save();
|
172 |
+
return true;
|
173 |
+
}
|
174 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/TaxQuote.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_TaxQuote extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('taxce/taxquote');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return VertexSMB_TaxCE_Helper_Data
|
23 |
+
*/
|
24 |
+
public function getHelper()
|
25 |
+
{
|
26 |
+
return Mage::helper('taxce');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
*
|
31 |
+
* @param unknown $information
|
32 |
+
* @return boolean|unknown
|
33 |
+
*/
|
34 |
+
public function getTaxQuote($information)
|
35 |
+
{
|
36 |
+
Mage::log("VertexSMB_TaxCE_Model_TaxQuote::getTaxQuote", null, 'vertexsmb.log');
|
37 |
+
|
38 |
+
if ($this->getHelper()->getSourcePath() == 'cart_checkout_index' || $this->getHelper()->getSourcePath() == 'cart_checkout_couponPost') {
|
39 |
+
$information['tax_area_id'] = '';
|
40 |
+
$information['customer_street1'] = '';
|
41 |
+
$information['customer_street2'] = '';
|
42 |
+
}
|
43 |
+
|
44 |
+
$information['request_type'] = 'QuotationRequest';
|
45 |
+
$request = Mage::getModel('taxce/requestItem')->setData($information)->exportAsArray();
|
46 |
+
|
47 |
+
$taxQuoteResult = Mage::getModel('taxce/vertexSMB')->sendApiRequest($request, 'quote');
|
48 |
+
if ($taxQuoteResult instanceof Exception) {
|
49 |
+
if (Mage::app()->getRequest()->getControllerName() == 'onepage' || Mage::app()->getRequest()->getControllerName() == 'sales_order_create') {
|
50 |
+
Mage::log("Quote Request Error: " . $taxQuoteResult->getMessage() . "Controller: " . $this->getHelper()->getSourcePath(), null, 'vertexsmb.log');
|
51 |
+
$result = array(
|
52 |
+
'error' => 1,
|
53 |
+
'message' => "Tax calculation request error. Please check your address"
|
54 |
+
);
|
55 |
+
Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
56 |
+
$action = Mage::app()->getRequest()->getActionName();
|
57 |
+
Mage::log("Controller action to dispatch " . $action, null, 'vertexsmb.log');
|
58 |
+
Mage::app()->getFrontController()
|
59 |
+
->getAction()
|
60 |
+
->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
if ($this->getHelper()->getSourcePath() == 'cart_checkout_index' || $this->getHelper()->getSourcePath() == 'cart_checkout_couponPost') {
|
64 |
+
$this->getHelper()
|
65 |
+
->getSession()
|
66 |
+
->addError(Mage::helper('core')->escapeHtml("Tax Calculation Request Error. Please check your address"));
|
67 |
+
}
|
68 |
+
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
$responseModel = Mage::getModel('taxce/TaxQuoteResponse')->parseResponse($taxQuoteResult);
|
73 |
+
$this->setResponse($responseModel);
|
74 |
+
|
75 |
+
$itemsTax = $responseModel->getTaxLineItems();
|
76 |
+
$quoteTaxedItems = $responseModel->getQuoteTaxedItems();
|
77 |
+
|
78 |
+
return $quoteTaxedItems;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
*
|
83 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
84 |
+
* @return unknown
|
85 |
+
*/
|
86 |
+
public function collectQuotedata(Mage_Sales_Model_Quote_Address $address)
|
87 |
+
{
|
88 |
+
$information = array();
|
89 |
+
$information = $this->getHelper()->addSellerInformation($information);
|
90 |
+
|
91 |
+
$customerClassName = $this->getHelper()->taxClassNameByClassId(
|
92 |
+
$address->getQuote()
|
93 |
+
->getCustomerTaxClassId()
|
94 |
+
);
|
95 |
+
$customerCode = $this->getHelper()->getCustomerCodeById(
|
96 |
+
$address->getQuote()
|
97 |
+
->getCustomer()
|
98 |
+
->getId()
|
99 |
+
);
|
100 |
+
|
101 |
+
$information['customer_code'] = $customerCode;
|
102 |
+
$information['customer_class'] = $customerClassName;
|
103 |
+
|
104 |
+
$information = $this->getHelper()->addAddressInformation($information, $address);
|
105 |
+
|
106 |
+
$information['store_id'] = $address->getQuote()
|
107 |
+
->getStore()
|
108 |
+
->getId();
|
109 |
+
$date = date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
|
110 |
+
$information['posting_date'] = $date;
|
111 |
+
$information['document_date'] = $date;
|
112 |
+
|
113 |
+
$information['order_items'] = array();
|
114 |
+
$items = $address->getAllNonNominalItems();
|
115 |
+
foreach ($items as $item) {
|
116 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_CatalogPermissions') && Mage::getConfig()->getModuleConfig('Enterprise_CatalogPermissions')->is('active', 'true')) {
|
117 |
+
if ($item->getDisableAddToCart() && ! $item->isDeleted()) {
|
118 |
+
continue;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
if ($item->getParentItem()) {
|
123 |
+
continue;
|
124 |
+
}
|
125 |
+
|
126 |
+
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
|
127 |
+
foreach ($item->getChildren() as $child) {
|
128 |
+
$information['order_items'][$child->getId()] = $this->getHelper()->prepareItem($child, 'quote');
|
129 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping') && Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping')->is('active', 'true') && $child->getGwId()) {
|
130 |
+
$information['order_items']['gift_wrap_' . $child->getId()] = $this->getHelper()->prepareGiftWrapItem($child, 'quote');
|
131 |
+
}
|
132 |
+
}
|
133 |
+
} else {
|
134 |
+
$information['order_items'][$item->getId()] = $this->getHelper()->prepareItem($item, 'quote');
|
135 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping') && Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping')->is('active', 'true') && $item->getGwId()) {
|
136 |
+
$information['order_items']['gift_wrap_' . $item->getId()] = $this->getHelper()->prepareGiftWrapItem($item, 'quote');
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
if (count($this->getHelper()->addShippingInfo($address))) {
|
141 |
+
$information['order_items']['shipping'] = $this->getHelper()->addShippingInfo($address);
|
142 |
+
}
|
143 |
+
|
144 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping') && Mage::getConfig()->getModuleConfig('Enterprise_GiftWrapping')->is('active', 'true')) {
|
145 |
+
if ($address->getGwPrice()) {
|
146 |
+
$information['order_items']['gift_wrapping'] = $this->getHelper()->addOrderGiftWrap($address);
|
147 |
+
}
|
148 |
+
if ($address->getGwCardPrice()) {
|
149 |
+
$information['order_items']['gift_print_card'] = $this->getHelper()->addOrderPrintCard($address);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
return $information;
|
154 |
+
}
|
155 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/TaxQuoteResponse.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_TaxQuoteResponse extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param unknown $responseObject
|
15 |
+
* @return VertexSMB_TaxCE_Model_TaxQuoteResponse
|
16 |
+
*/
|
17 |
+
public function parseResponse($responseObject)
|
18 |
+
{
|
19 |
+
if (is_array($responseObject->QuotationResponse->LineItem)) {
|
20 |
+
$taxLineItems = $responseObject->QuotationResponse->LineItem;
|
21 |
+
} else {
|
22 |
+
$taxLineItems[] = $responseObject->QuotationResponse->LineItem;
|
23 |
+
}
|
24 |
+
|
25 |
+
$this->setTaxLineItems($taxLineItems);
|
26 |
+
$this->setLineItemsCount(count($taxLineItems));
|
27 |
+
$this->prepareQuoteTaxedItems($taxLineItems);
|
28 |
+
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param array $itemsTax
|
34 |
+
*/
|
35 |
+
public function prepareQuoteTaxedItems(array $itemsTax)
|
36 |
+
{
|
37 |
+
$quoteTaxedItems = array();
|
38 |
+
|
39 |
+
foreach ($itemsTax as $item) {
|
40 |
+
$lineItemNumber = $item->lineItemNumber;
|
41 |
+
$itemTotalTax = $item->TotalTax->_;
|
42 |
+
$taxPercent = 0;
|
43 |
+
foreach ($item->Taxes as $key => $taxValue) {
|
44 |
+
if (is_object($taxValue) && property_exists($taxValue, "EffectiveRate")) {
|
45 |
+
$taxPercent += (float) $taxValue->EffectiveRate;
|
46 |
+
} elseif ($key == "EffectiveRate") {
|
47 |
+
$taxPercent += (float) $taxValue;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
$taxPercent = $taxPercent * 100;
|
52 |
+
|
53 |
+
$quoiteItemId = $item->lineItemId;
|
54 |
+
$taxItemInfo = new Varien_Object();
|
55 |
+
$taxItemInfo->setProductClass($item->Product->productClass);
|
56 |
+
$taxItemInfo->setProductSku($item->Product->_);
|
57 |
+
if (property_exists($item, "Quantity")) {
|
58 |
+
$taxItemInfo->setProductQty($item->Quantity->_);
|
59 |
+
}
|
60 |
+
if (property_exists($item, "UnitPrice")) {
|
61 |
+
$taxItemInfo->setUnitPrice($item->UnitPrice->_);
|
62 |
+
}
|
63 |
+
$taxItemInfo->setTaxPercent($taxPercent);
|
64 |
+
$taxItemInfo->setBaseTaxAmount($itemTotalTax);
|
65 |
+
$taxItemInfo->setTaxAmount($itemTotalTax);
|
66 |
+
$quoteTaxedItems[$quoiteItemId] = $taxItemInfo;
|
67 |
+
}
|
68 |
+
|
69 |
+
$this->setQuoteTaxedItems($quoteTaxedItems);
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/TaxRequest.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_TaxRequest extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return VertexSMB_TaxCE_Helper_Data
|
15 |
+
*/
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('taxce/taxRequest');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param int $orderId
|
23 |
+
* @return number
|
24 |
+
*/
|
25 |
+
public function getTotalInvoicedTax($orderId)
|
26 |
+
{
|
27 |
+
$totalTax = 0;
|
28 |
+
$invoices = $this->getCollection()
|
29 |
+
->addFieldToSelect('total_tax')
|
30 |
+
->addFieldToFilter('order_id', $orderId)
|
31 |
+
->addFieldToFilter('request_type', 'invoice');
|
32 |
+
foreach ($invoices as $invoice) {
|
33 |
+
$totalTax += $invoice->getTotalTax();
|
34 |
+
}
|
35 |
+
return $totalTax;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @return VertexSMB_TaxCE_Model_TaxRequest
|
40 |
+
*/
|
41 |
+
public function removeQuotesLookupRequests()
|
42 |
+
{
|
43 |
+
$quotes = $this->getCollection()
|
44 |
+
->addFieldToSelect('request_id')
|
45 |
+
->addFieldToFilter(
|
46 |
+
'request_type',
|
47 |
+
array(
|
48 |
+
'in' => array(
|
49 |
+
'quote',
|
50 |
+
'tax_area_lookup'
|
51 |
+
)
|
52 |
+
)
|
53 |
+
);
|
54 |
+
|
55 |
+
foreach ($quotes as $quote) {
|
56 |
+
$quote->delete();
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @return VertexSMB_TaxCE_Model_TaxRequest
|
64 |
+
*/
|
65 |
+
public function removeInvoicesforCompletedOrders()
|
66 |
+
{
|
67 |
+
$invoices = $this->getCollection()
|
68 |
+
->addFieldToSelect('order_id')
|
69 |
+
->addFieldToFilter('request_type', 'invoice');
|
70 |
+
|
71 |
+
$invoices->getSelect()->join(
|
72 |
+
array(
|
73 |
+
'order' => 'sales_flat_order'
|
74 |
+
),
|
75 |
+
'order.entity_id = main_table.order_id',
|
76 |
+
array(
|
77 |
+
'order.state'
|
78 |
+
)
|
79 |
+
);
|
80 |
+
$invoices->addFieldToFilter(
|
81 |
+
'order.state',
|
82 |
+
array(
|
83 |
+
'in' => array(
|
84 |
+
'complete',
|
85 |
+
'canceled',
|
86 |
+
'closed'
|
87 |
+
)
|
88 |
+
)
|
89 |
+
);
|
90 |
+
|
91 |
+
$completedOrderIds = array();
|
92 |
+
foreach ($invoices as $invoice) {
|
93 |
+
$completedOrderIds[] = $invoice->getOrderId();
|
94 |
+
}
|
95 |
+
|
96 |
+
$completedInvoices = $this->getCollection()
|
97 |
+
->addFieldToSelect('request_id')
|
98 |
+
->addFieldToFilter(
|
99 |
+
'order_id',
|
100 |
+
array(
|
101 |
+
'in' => $completedOrderIds
|
102 |
+
)
|
103 |
+
);
|
104 |
+
foreach ($completedInvoices as $completedInvoice) {
|
105 |
+
$completedInvoice->delete();
|
106 |
+
}
|
107 |
+
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
}
|
app/code/community/VertexSMB/TaxCE/Model/VertexSMB.php
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_Model_VertexSMB extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return VertexSMB_TaxCE_Helper_Data
|
15 |
+
*/
|
16 |
+
public function getHelper()
|
17 |
+
{
|
18 |
+
return Mage::helper('taxce');
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param unknown $request
|
24 |
+
* @param unknown $type
|
25 |
+
* @param string $order
|
26 |
+
* @return Exception|unknown
|
27 |
+
*/
|
28 |
+
public function sendApiRequest($request, $type, $order = null)
|
29 |
+
{
|
30 |
+
$objectId = null;
|
31 |
+
if (strpos($type, 'invoice') === 0) {
|
32 |
+
$objectId = $order->getId();
|
33 |
+
} elseif ($type == 'quote')
|
34 |
+
$objectId = $this->getHelper()
|
35 |
+
->getSession()
|
36 |
+
->getQuote()
|
37 |
+
->getId();
|
38 |
+
elseif ($type == 'tax_area_lookup') {
|
39 |
+
$objectId = 0;
|
40 |
+
if (is_object(
|
41 |
+
$this->getHelper()
|
42 |
+
->getSession()
|
43 |
+
->getQuote()
|
44 |
+
)) {
|
45 |
+
$objectId = $this->getHelper()
|
46 |
+
->getSession()
|
47 |
+
->getQuote()
|
48 |
+
->getId();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
try {
|
52 |
+
$apiUrl = $this->getHelper()->getVertexHost();
|
53 |
+
if ($type == 'tax_area_lookup') {
|
54 |
+
$apiUrl = $this->getHelper()->getVertexAddressHost();
|
55 |
+
}
|
56 |
+
|
57 |
+
$client = new SoapClient(
|
58 |
+
$apiUrl,
|
59 |
+
array(
|
60 |
+
'connection_timeout' => 300,
|
61 |
+
'trace' => true,
|
62 |
+
'soap_version' => SOAP_1_1
|
63 |
+
)
|
64 |
+
);
|
65 |
+
|
66 |
+
if ($type == 'tax_area_lookup') {
|
67 |
+
$taxRequestResult = $client->LookupTaxAreas60($request);
|
68 |
+
} else {
|
69 |
+
$taxRequestResult = $client->calculateTax60($request);
|
70 |
+
}
|
71 |
+
} catch (Exception $e) {
|
72 |
+
if ($client instanceof SoapClient) {
|
73 |
+
$this->logRequest($type, $objectId, $client->__getLastRequest(), $client->__getLastResponse());
|
74 |
+
} else {
|
75 |
+
$this->logRequest($type, $objectId, $e->getMessage(), $e->getMessage());
|
76 |
+
}
|
77 |
+
return $e;
|
78 |
+
}
|
79 |
+
$totalTax = 0;
|
80 |
+
$taxAreaId = 0;
|
81 |
+
if (strpos($type, 'invoice') === 0) {
|
82 |
+
$totalTax = $taxRequestResult->InvoiceResponse->TotalTax->_;
|
83 |
+
$lineItem = $taxRequestResult->InvoiceResponse->LineItem;
|
84 |
+
if (is_array($lineItem)) {
|
85 |
+
$taxAreaId = $lineItem[0]->Customer->Destination->taxAreaId;
|
86 |
+
} else {
|
87 |
+
$taxAreaId = $lineItem->Customer->Destination->taxAreaId;
|
88 |
+
}
|
89 |
+
} elseif ($type == 'quote') {
|
90 |
+
$totalTax = $taxRequestResult->QuotationResponse->TotalTax->_;
|
91 |
+
$lineItem = $taxRequestResult->QuotationResponse->LineItem;
|
92 |
+
if (is_array($lineItem)) {
|
93 |
+
$taxAreaId = $lineItem[0]->Customer->Destination->taxAreaId;
|
94 |
+
} else {
|
95 |
+
$taxAreaId = $lineItem->Customer->Destination->taxAreaId;
|
96 |
+
}
|
97 |
+
} elseif ($type == 'tax_area_lookup') {
|
98 |
+
$taxAreaResults = $taxRequestResult->TaxAreaResponse->TaxAreaResult;
|
99 |
+
if (is_array($taxAreaResults)) {
|
100 |
+
$taxAreaResIds = array();
|
101 |
+
foreach ($taxAreaResults as $taxAreaResult) {
|
102 |
+
$taxAreaResIds[] = $taxAreaResult->taxAreaId;
|
103 |
+
}
|
104 |
+
$taxAreaId = implode(',', $taxAreaResIds);
|
105 |
+
} else {
|
106 |
+
$taxAreaId = $taxAreaResults->taxAreaId;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
$this->logRequest($type, $objectId, $client->__getLastRequest(), $client->__getLastResponse(), $totalTax, $taxAreaId);
|
111 |
+
|
112 |
+
return $taxRequestResult;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @param unknown $type
|
117 |
+
* @param unknown $objectId
|
118 |
+
* @param unknown $requestXml
|
119 |
+
* @param unknown $responseXml
|
120 |
+
* @param number $totalTax
|
121 |
+
* @param number $taxAreaId
|
122 |
+
* @return void
|
123 |
+
*/
|
124 |
+
public function logRequest($type, $objectId, $requestXml, $responseXml, $totalTax = 0, $taxAreaId = 0)
|
125 |
+
{
|
126 |
+
$taxRequest = Mage::getModel('taxce/taxRequest');
|
127 |
+
$taxRequest->setRequestType($type)->setRequestDate(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
|
128 |
+
if (strpos($type, 'invoice') === 0) {
|
129 |
+
$taxRequest->setOrderId($objectId);
|
130 |
+
} elseif ($type == 'quote' || $type = 'tax_area_lookup')
|
131 |
+
$taxRequest->setQuoteId($objectId);
|
132 |
+
|
133 |
+
$dom = new DOMDocument();
|
134 |
+
$dom->preserveWhiteSpace = false;
|
135 |
+
$dom->loadXML($requestXml);
|
136 |
+
$dom->formatOutput = true;
|
137 |
+
if ($dom->saveXml()) {
|
138 |
+
$requestXml = $dom->saveXml();
|
139 |
+
}
|
140 |
+
|
141 |
+
$dom->loadXML($responseXml);
|
142 |
+
|
143 |
+
$dom->formatOutput = true;
|
144 |
+
if ($dom->saveXml()) {
|
145 |
+
$responseXml = $dom->saveXml();
|
146 |
+
}
|
147 |
+
|
148 |
+
$totalNode = $dom->getElementsByTagName('Total');
|
149 |
+
$subtotalNode = $dom->getElementsByTagName('SubTotal');
|
150 |
+
$lookupResultNode = $dom->getElementsByTagName('Status');
|
151 |
+
$addressLookupFaultNode = $dom->getElementsByTagName('exceptionType');
|
152 |
+
$total = 0;
|
153 |
+
$subtotal = 0;
|
154 |
+
$lookupResult = "";
|
155 |
+
|
156 |
+
if ($totalNode->length > 0) {
|
157 |
+
$total = $totalNode->item(0)->nodeValue;
|
158 |
+
}
|
159 |
+
|
160 |
+
if ($subtotalNode->length > 0) {
|
161 |
+
$subtotal = $subtotalNode->item(0)->nodeValue;
|
162 |
+
}
|
163 |
+
|
164 |
+
if ($lookupResultNode->length > 0) {
|
165 |
+
$lookupResult = $lookupResultNode->item(0)->getAttribute('lookupResult');
|
166 |
+
}
|
167 |
+
|
168 |
+
if (! $lookupResult && $addressLookupFaultNode->length > 0) {
|
169 |
+
$lookupResult = $addressLookupFaultNode->item(0)->nodeValue;
|
170 |
+
}
|
171 |
+
|
172 |
+
$sourcePath = $this->getHelper()->getSourcePath();
|
173 |
+
$taxRequest->setSourcePath($sourcePath);
|
174 |
+
$taxRequest->setTotalTax($totalTax);
|
175 |
+
$taxRequest->setRequestXml($requestXml);
|
176 |
+
$taxRequest->setResponseXml($responseXml);
|
177 |
+
$taxRequest->setTaxAreaId($taxAreaId);
|
178 |
+
$taxRequest->setTotal($total);
|
179 |
+
$taxRequest->setSubTotal($subtotal);
|
180 |
+
$taxRequest->setLookupResult($lookupResult);
|
181 |
+
$taxRequest->save();
|
182 |
+
/** Mage::log($taxRequest->getData(), null, 'vertexsmb.log'); */
|
183 |
+
}
|
184 |
+
}
|
app/code/community/VertexSMB/TaxCE/controllers/OnepageController.php
ADDED
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require Mage::getModuleDir('controllers', 'Mage_Checkout') . DS . 'OnepageController.php';
|
3 |
+
|
4 |
+
/**
|
5 |
+
* @category VertexSMB
|
6 |
+
* @package VertexSMB_TaxCE
|
7 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
8 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
9 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
10 |
+
*/
|
11 |
+
|
12 |
+
class VertexSMB_TaxCE_OnepageController extends Mage_Checkout_OnepageController
|
13 |
+
{
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @return void|VertexSMB_TaxCE_OnepageController
|
18 |
+
*/
|
19 |
+
public function saveShippingAction()
|
20 |
+
{
|
21 |
+
if (! Mage::helper('taxce')->isVertexSMBActive()) {
|
22 |
+
parent::saveShippingAction();
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
if ($this->_expireAjax()) {
|
26 |
+
return;
|
27 |
+
}
|
28 |
+
if ($this->getRequest()->isPost()) {
|
29 |
+
$data = $this->getRequest()->getPost('shipping', array());
|
30 |
+
$customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
|
31 |
+
|
32 |
+
$result = $this->getOnepage()->saveShipping($data, $customerAddressId);
|
33 |
+
|
34 |
+
$address = $this->getOnepage()
|
35 |
+
->getQuote()
|
36 |
+
->getShippingAddress();
|
37 |
+
/**
|
38 |
+
* Save Tax Area & Correct City | Show popup window
|
39 |
+
*/
|
40 |
+
if (! $this->saveTaxAreaId($address)) {
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
/**
|
44 |
+
* Save Tax Area & Correct City | Show popup window
|
45 |
+
*/
|
46 |
+
|
47 |
+
$result['goto_section'] = 'shipping_method';
|
48 |
+
$result['update_section'] = array(
|
49 |
+
'name' => 'shipping-method',
|
50 |
+
'html' => $this->_getShippingMethodsHtml()
|
51 |
+
);
|
52 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @return void|VertexSMB_TaxCE_OnepageController
|
58 |
+
*/
|
59 |
+
public function saveBillingAction()
|
60 |
+
{
|
61 |
+
if (! Mage::helper('taxce')->isVertexSMBActive()) {
|
62 |
+
parent::saveBillingAction();
|
63 |
+
return $this;
|
64 |
+
}
|
65 |
+
if ($this->_expireAjax()) {
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
if ($this->getRequest()->isPost()) {
|
69 |
+
$data = $this->getRequest()->getPost('billing', array());
|
70 |
+
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
|
71 |
+
|
72 |
+
if (isset($data['email'])) {
|
73 |
+
$data['email'] = trim($data['email']);
|
74 |
+
}
|
75 |
+
|
76 |
+
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
|
77 |
+
|
78 |
+
if (! isset($result['error'])) {
|
79 |
+
if ($this->getOnepage()
|
80 |
+
->getQuote()
|
81 |
+
->isVirtual()) {
|
82 |
+
$result['goto_section'] = 'payment';
|
83 |
+
$result['update_section'] = array(
|
84 |
+
'name' => 'payment-method',
|
85 |
+
'html' => $this->_getPaymentMethodsHtml()
|
86 |
+
);
|
87 |
+
$address = $this->getOnepage()
|
88 |
+
->getQuote()
|
89 |
+
->getBillingAddress();
|
90 |
+
/**
|
91 |
+
* Save Tax Area & Correct City | Show popup window
|
92 |
+
*/
|
93 |
+
if (! $this->saveTaxAreaId($address)) {
|
94 |
+
return $this;
|
95 |
+
}
|
96 |
+
/**
|
97 |
+
* Save Tax Area & Correct City | Show popup window
|
98 |
+
*/
|
99 |
+
} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
|
100 |
+
$result['goto_section'] = 'shipping_method';
|
101 |
+
$result['update_section'] = array(
|
102 |
+
'name' => 'shipping-method',
|
103 |
+
'html' => $this->_getShippingMethodsHtml()
|
104 |
+
);
|
105 |
+
|
106 |
+
$result['allow_sections'] = array(
|
107 |
+
'shipping'
|
108 |
+
);
|
109 |
+
$result['duplicateBillingInfo'] = 'true';
|
110 |
+
$address = $this->getOnepage()
|
111 |
+
->getQuote()
|
112 |
+
->getShippingAddress();
|
113 |
+
/**
|
114 |
+
* Save Tax Area & Correct City | Show popup window
|
115 |
+
*/
|
116 |
+
if (! $this->saveTaxAreaId($address)) {
|
117 |
+
return $this;
|
118 |
+
}
|
119 |
+
/**
|
120 |
+
* Save Tax Area & Correct City | Show popup window
|
121 |
+
*/
|
122 |
+
} else {
|
123 |
+
$result['goto_section'] = 'shipping';
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Save Tax Area Action
|
133 |
+
* @return void
|
134 |
+
*/
|
135 |
+
public function saveTaxAreaAction()
|
136 |
+
{
|
137 |
+
if ($this->_expireAjax()) {
|
138 |
+
return;
|
139 |
+
}
|
140 |
+
if ($this->getRequest()->isPost()) {
|
141 |
+
$taxAreaId = $this->getRequest()->getPost('tax_area_id', 0);
|
142 |
+
$newCity = $this->getRequest()->getPost('tax_new_city', 0);
|
143 |
+
|
144 |
+
if ($this->getOnepage()
|
145 |
+
->getQuote()
|
146 |
+
->isVirtual()) {
|
147 |
+
$address = $this->getOnepage()
|
148 |
+
->getQuote()
|
149 |
+
->getBillingAddress();
|
150 |
+
$result['goto_section'] = 'payment';
|
151 |
+
$result['update_section'] = array(
|
152 |
+
'name' => 'payment-method',
|
153 |
+
'html' => $this->_getPaymentMethodsHtml()
|
154 |
+
);
|
155 |
+
$shippingAddress = $this->getOnepage()
|
156 |
+
->getQuote()
|
157 |
+
->getShippingAddress();
|
158 |
+
$oldCity = $shippingAddress->getCity();
|
159 |
+
if (strtolower($oldCity) != strtolower($newCity)) {
|
160 |
+
$shippingAddress->setCity($newCity);
|
161 |
+
}
|
162 |
+
|
163 |
+
$shippingAddress->setTaxAreaId($taxAreaId)->save();
|
164 |
+
} else {
|
165 |
+
$address = $this->getOnepage()
|
166 |
+
->getQuote()
|
167 |
+
->getShippingAddress();
|
168 |
+
$result['goto_section'] = 'shipping_method';
|
169 |
+
$result['update_section'] = array(
|
170 |
+
'name' => 'shipping-method',
|
171 |
+
'html' => $this->_getShippingMethodsHtml()
|
172 |
+
);
|
173 |
+
|
174 |
+
$oldCity = $address->getCity();
|
175 |
+
if (strtolower($oldCity) != strtolower($newCity)) {
|
176 |
+
$address->setCity($newCity);
|
177 |
+
}
|
178 |
+
}
|
179 |
+
$address->setTaxAreaId($taxAreaId)->save();
|
180 |
+
$this->getOnepage()
|
181 |
+
->getQuote()
|
182 |
+
->collectTotals()
|
183 |
+
->save();
|
184 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Previous step should never be null. We always start with billing and go forward
|
190 |
+
* @return NULL|unknown
|
191 |
+
*/
|
192 |
+
public function progressAction()
|
193 |
+
{
|
194 |
+
|
195 |
+
$prevStep = $this->getRequest()->getParam('prevStep', false);
|
196 |
+
|
197 |
+
if ($this->_expireAjax() || ! $prevStep) {
|
198 |
+
return null;
|
199 |
+
}
|
200 |
+
if ($prevStep == 'selectaddress') {
|
201 |
+
$prevStep = 'shipping';
|
202 |
+
}
|
203 |
+
|
204 |
+
if ($prevStep == 'selectaddress' && $this->getOnepage()
|
205 |
+
->getQuote()
|
206 |
+
->isVirtual()) {
|
207 |
+
$prevStep = 'billing';
|
208 |
+
}
|
209 |
+
|
210 |
+
$layout = $this->getLayout();
|
211 |
+
$update = $layout->getUpdate();
|
212 |
+
$update->load('checkout_onepage_progress_' . $prevStep);
|
213 |
+
$layout->generateXml();
|
214 |
+
$layout->generateBlocks();
|
215 |
+
$output = $layout->getOutput();
|
216 |
+
$this->getResponse()->setBody($output);
|
217 |
+
return $output;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* @param unknown $address
|
222 |
+
* @return boolean
|
223 |
+
*/
|
224 |
+
public function saveTaxAreaId($address)
|
225 |
+
{
|
226 |
+
if ($address->getCountryId() !== 'US') {
|
227 |
+
return true;
|
228 |
+
}
|
229 |
+
|
230 |
+
$taxAreaModel = Mage::getModel('taxce/TaxAreaRequest');
|
231 |
+
$requestResult = $taxAreaModel->prepareRequest($address)->taxAreaLookup();
|
232 |
+
$addressChanged = false;
|
233 |
+
if ($requestResult instanceof Exception) {
|
234 |
+
if (Mage::app()->getRequest()->getControllerName() == 'onepage') {
|
235 |
+
Mage::log("Quote Request Error: " . $requestResult->getMessage() . "Controller: " . Mage::helper('taxce')->getSourcePath(), null, 'vertexsmb.log');
|
236 |
+
$result = array(
|
237 |
+
'error' => 1,
|
238 |
+
'message' => "Tax Calculation Request Error. Please check your address"
|
239 |
+
);
|
240 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
241 |
+
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
|
242 |
+
}
|
243 |
+
|
244 |
+
return false;
|
245 |
+
}
|
246 |
+
$taxAreaResposeModel = $taxAreaModel->getResponse();
|
247 |
+
|
248 |
+
if ($taxAreaResposeModel->getResultsCount() > 1 && Mage::helper('taxce')->showPopup()) {
|
249 |
+
$taxAreaInfoCollection = $taxAreaResposeModel->getTaxAreaLocationsCollection();
|
250 |
+
|
251 |
+
$block = Mage::app()->getLayout()
|
252 |
+
->createBlock('core/template')
|
253 |
+
->setTemplate('vertexsmb/popup-content.phtml')
|
254 |
+
->setData('items_collection', $taxAreaInfoCollection)
|
255 |
+
->setData('is_multiple', 1)
|
256 |
+
->toHtml();
|
257 |
+
$result['goto_section'] = 'selectaddress';
|
258 |
+
$result['update_section'] = array(
|
259 |
+
'name' => 'selectaddress',
|
260 |
+
'html' => $block
|
261 |
+
);
|
262 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
263 |
+
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
|
264 |
+
return false;
|
265 |
+
} else {
|
266 |
+
$firstTaxArea = $taxAreaResposeModel->getFirstTaxAreaInfo();
|
267 |
+
|
268 |
+
if (strcmp(strtolower($address->getCity()), strtolower($firstTaxArea->getTaxAreaCity())) !== 0) {
|
269 |
+
Mage::log("Original City: " . $address->getCity() . " - New City: " . $firstTaxArea->getTaxAreaCity(), null, 'vertexsmb.log');
|
270 |
+
$addressChanged = true;
|
271 |
+
$blockAddressUpdate = Mage::app()->getLayout()
|
272 |
+
->createBlock('core/template')
|
273 |
+
->setTemplate('vertexsmb/popup-content.phtml')
|
274 |
+
->setData('is_multiple', 0)
|
275 |
+
->setFirstItem($firstTaxArea)
|
276 |
+
->toHtml();
|
277 |
+
}
|
278 |
+
$address->setCity($firstTaxArea->getTaxAreaCity());
|
279 |
+
|
280 |
+
$address->setTaxAreaId($firstTaxArea->getTaxAreaId())
|
281 |
+
->save();
|
282 |
+
$this->getOnepage()
|
283 |
+
->getQuote()
|
284 |
+
->collectTotals()
|
285 |
+
->save();
|
286 |
+
}
|
287 |
+
|
288 |
+
if ($addressChanged) {
|
289 |
+
$result['goto_section'] = 'selectaddress';
|
290 |
+
$result['update_section'] = array(
|
291 |
+
'name' => 'selectaddress',
|
292 |
+
'html' => $blockAddressUpdate
|
293 |
+
);
|
294 |
+
|
295 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
296 |
+
return false;
|
297 |
+
}
|
298 |
+
|
299 |
+
return true;
|
300 |
+
}
|
301 |
+
}
|
app/code/community/VertexSMB/TaxCE/controllers/VertexSMBController.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
class VertexSMB_TaxCE_VertexSMBController extends Mage_Adminhtml_Controller_Action
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
protected function _construct()
|
17 |
+
{
|
18 |
+
$this->setUsedModuleName('VertexSMB_TaxCE');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return boolean
|
23 |
+
*/
|
24 |
+
protected function _isAllowed()
|
25 |
+
{
|
26 |
+
return Mage::getSingleton('admin/session')->isAllowed('sales/order/view');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Initialize order model instance
|
31 |
+
*
|
32 |
+
* @return Mage_Sales_Model_Order || false
|
33 |
+
*/
|
34 |
+
protected function _initOrder()
|
35 |
+
{
|
36 |
+
$id = $this->getRequest()->getParam('order_id');
|
37 |
+
$order = Mage::getModel('sales/order')->load($id);
|
38 |
+
|
39 |
+
if (! $order->getId()) {
|
40 |
+
$this->_getSession()->addError($this->__('This order no longer exists.'));
|
41 |
+
$this->_redirect('*/*/');
|
42 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
Mage::register('sales_order', $order);
|
46 |
+
Mage::register('current_order', $order);
|
47 |
+
return $order;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
*
|
52 |
+
*/
|
53 |
+
public function invoiceTaxAction()
|
54 |
+
{
|
55 |
+
if ($order = $this->_initOrder()) {
|
56 |
+
$invoiceRequestData = Mage::getModel('taxce/taxInvoice')->PrepareInvoiceData($order);
|
57 |
+
if ($invoiceRequestData && Mage::getModel('taxce/taxInvoice')->SendInvoiceRequest($invoiceRequestData)) {
|
58 |
+
$this->_getSession()->addSuccess($this->__('The Vertex SMB invoice has been sent.'));
|
59 |
+
}
|
60 |
+
}
|
61 |
+
$this->_redirect(
|
62 |
+
'*/sales_order/view',
|
63 |
+
array(
|
64 |
+
'order_id' => $order->getId()
|
65 |
+
)
|
66 |
+
);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return boolean
|
71 |
+
*/
|
72 |
+
public function taxAreaAction()
|
73 |
+
{
|
74 |
+
$orderCreateModel = Mage::getSingleton('adminhtml/sales_order_create');
|
75 |
+
$addressChanged = false;
|
76 |
+
|
77 |
+
if ($orderCreateModel->getQuote()->isVirtual() || $orderCreateModel->getQuote()
|
78 |
+
->getShippingAddress()
|
79 |
+
->getSameAsBilling()) {
|
80 |
+
$address = $orderCreateModel->getQuote()->getBillingAddress();
|
81 |
+
} else {
|
82 |
+
$address = $orderCreateModel->getQuote()->getShippingAddress();
|
83 |
+
}
|
84 |
+
|
85 |
+
if (! $address->getStreet1() || ! $address->getCity() || ! $address->getRegion() || ! $address->getPostcode()) {
|
86 |
+
$result['message'] = 'address_not_complete';
|
87 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
88 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
|
92 |
+
if ($address->getCountryId() !== 'US') {
|
93 |
+
$result['message'] = 'not_usa_address';
|
94 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
95 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
$taxAreaModel = Mage::getModel('taxce/TaxAreaRequest');
|
100 |
+
$requestResult = $taxAreaModel->prepareRequest($address)->taxAreaLookup();
|
101 |
+
if ($requestResult instanceof Exception) {
|
102 |
+
Mage::log("Admin Tax Area Lookup Error: " . $requestResult->getMessage(), null, 'vertexsmb.log');
|
103 |
+
$result['message'] = $requestResult->getMessage();
|
104 |
+
$result['error'] = 1;
|
105 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
106 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
|
110 |
+
$taxAreaResposeModel = $taxAreaModel->getResponse();
|
111 |
+
|
112 |
+
if ($taxAreaResposeModel->getResultsCount() > 1 && Mage::helper('taxce')->showPopup()) {
|
113 |
+
$taxAreaInfoCollection = $taxAreaResposeModel->getTaxAreaLocationsCollection();
|
114 |
+
|
115 |
+
$block = Mage::app()->getLayout()
|
116 |
+
->createBlock('page/html')
|
117 |
+
->setData('is_multiple', 1)
|
118 |
+
->setTemplate('vertexsmb/popup-content.phtml')
|
119 |
+
->setData('items_collection', $taxAreaInfoCollection)
|
120 |
+
->toHtml();
|
121 |
+
$result['message'] = "show_popup";
|
122 |
+
$result['html'] = $block;
|
123 |
+
} else {
|
124 |
+
$firstTaxArea = $taxAreaResposeModel->getFirstTaxAreaInfo();
|
125 |
+
$result['message'] = 'tax_area_id_found';
|
126 |
+
if (strtolower($address->getCity()) != strtolower($firstTaxArea->getTaxAreaCity())) {
|
127 |
+
$addressChanged = true;
|
128 |
+
$blockAddressUpdate = Mage::app()->getLayout()
|
129 |
+
->createBlock('page/html')
|
130 |
+
->setData('is_multiple', 0)
|
131 |
+
->setFirstItem($firstTaxArea)
|
132 |
+
->setTemplate('vertexsmb/popup-content.phtml')
|
133 |
+
->toHtml();
|
134 |
+
}
|
135 |
+
$address->setCity($firstTaxArea->getTaxAreaCity());
|
136 |
+
$address->setTaxAreaId($firstTaxArea->getTaxAreaId())
|
137 |
+
->save();
|
138 |
+
$orderCreateModel->saveQuote();
|
139 |
+
}
|
140 |
+
|
141 |
+
if ($addressChanged && ! $address->getQuote()->isVirtual()) {
|
142 |
+
$result['message'] = "show_popup";
|
143 |
+
$result['html'] = $blockAddressUpdate;
|
144 |
+
}
|
145 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
146 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
*
|
151 |
+
*/
|
152 |
+
public function saveTaxAreaAction()
|
153 |
+
{
|
154 |
+
$orderCreateModel = Mage::getSingleton('adminhtml/sales_order_create');
|
155 |
+
|
156 |
+
if ($orderCreateModel->getQuote()->isVirtual() || $orderCreateModel->getQuote()
|
157 |
+
->getShippingAddress()
|
158 |
+
->getSameAsBilling()) {
|
159 |
+
$address = $orderCreateModel->getQuote()->getBillingAddress();
|
160 |
+
} else {
|
161 |
+
$address = $orderCreateModel->getQuote()->getShippingAddress();
|
162 |
+
}
|
163 |
+
|
164 |
+
$taxAreaId = $this->getRequest()->getParam('tax_area_id');
|
165 |
+
$city = $this->getRequest()->getPost('new_city', 0);
|
166 |
+
|
167 |
+
$address->setTaxAreaId($taxAreaId);
|
168 |
+
$oldCity = $address->getCity();
|
169 |
+
if (strtolower($oldCity) != strtolower($city)) {
|
170 |
+
$address->setCity($city);
|
171 |
+
}
|
172 |
+
|
173 |
+
$orderCreateModel->saveQuote();
|
174 |
+
$result['message'] = 'ok';
|
175 |
+
|
176 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
177 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Retrieve adminhtml session model object
|
182 |
+
*
|
183 |
+
* @return Mage_Adminhtml_Model_Session
|
184 |
+
*/
|
185 |
+
protected function _getSession()
|
186 |
+
{
|
187 |
+
return Mage::getSingleton('adminhtml/session');
|
188 |
+
}
|
189 |
+
}
|
app/code/community/VertexSMB/TaxCE/data/taxce_setup/data-install-0.1.1.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category VertexSMB
|
4 |
+
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
+
*/
|
9 |
+
$installer = $this;
|
10 |
+
|
11 |
+
$data = array(
|
12 |
+
array(
|
13 |
+
'class_name' => 'Refund Adjustments',
|
14 |
+
'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT
|
15 |
+
),
|
16 |
+
array(
|
17 |
+
'class_name' => 'Gift Options',
|
18 |
+
'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT
|
19 |
+
)
|
20 |
+
);
|
21 |
+
|
22 |
+
foreach ($data as $row) {
|
23 |
+
$installer->getConnection()->insertForce($installer->getTable('tax/tax_class'), $row);
|
24 |
+
}
|
app/code/community/VertexSMB/TaxCE/data/taxce_setup/data-upgrade-0.1.4-0.1.5.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category VertexSMB
|
4 |
+
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
+
*/
|
9 |
+
$installer = $this;
|
10 |
+
|
11 |
+
$data = array(
|
12 |
+
array(
|
13 |
+
'class_name' => 'Reward Points',
|
14 |
+
'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT
|
15 |
+
)
|
16 |
+
);
|
17 |
+
|
18 |
+
if (Mage::getConfig()->getModuleConfig('Enterprise_Reward') && Mage::getConfig()->getModuleConfig('Enterprise_Reward')->is('active', 'true')) {
|
19 |
+
foreach ($data as $row) {
|
20 |
+
$installer->getConnection()->insertForce($installer->getTable('tax/tax_class'), $row);
|
21 |
+
}
|
22 |
+
}
|
app/code/{local → community}/VertexSMB/TaxCE/etc/adminhtml.xml
RENAMED
@@ -1,9 +1,11 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
|
|
4 |
* @package VertexSMB_TaxCE
|
|
|
5 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
6 |
-
* @
|
7 |
*/
|
8 |
-->
|
9 |
<config>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* @category VertexSMB
|
5 |
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
*/
|
10 |
-->
|
11 |
<config>
|
app/code/{local → community}/VertexSMB/TaxCE/etc/config.xml
RENAMED
@@ -1,212 +1,205 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @
|
5 |
-
* @
|
6 |
-
* @author Alex Lukyanau
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
<
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
<
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
<
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
<
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
</
|
115 |
-
</
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
</
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
<
|
128 |
-
<
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
</args>
|
133 |
-
</
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
<
|
154 |
-
<
|
155 |
-
<
|
156 |
-
<
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
<
|
162 |
-
<
|
163 |
-
|
164 |
-
|
165 |
-
</
|
166 |
-
</args>
|
167 |
-
</
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
<
|
183 |
-
<
|
184 |
-
<
|
185 |
-
<
|
186 |
-
<
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
<
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
</run>
|
207 |
-
</vertexsmb_log_cleanup>
|
208 |
-
</jobs>
|
209 |
-
</crontab>
|
210 |
-
</config>
|
211 |
-
|
212 |
-
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category VertexSMB
|
5 |
+
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<VertexSMB_TaxCE>
|
14 |
+
<version>1.1.8</version>
|
15 |
+
</VertexSMB_TaxCE>
|
16 |
+
</modules>
|
17 |
+
<global>
|
18 |
+
<blocks>
|
19 |
+
<taxce>
|
20 |
+
<class>VertexSMB_TaxCE_Block</class>
|
21 |
+
</taxce>
|
22 |
+
<adminhtml>
|
23 |
+
<rewrite>
|
24 |
+
<sales_order_view>VertexSMB_TaxCE_Block_Adminhtml_Order_View</sales_order_view>
|
25 |
+
</rewrite>
|
26 |
+
</adminhtml>
|
27 |
+
</blocks>
|
28 |
+
<models>
|
29 |
+
<taxce>
|
30 |
+
<class>VertexSMB_TaxCE_Model</class>
|
31 |
+
<resourceModel>taxce_resource</resourceModel>
|
32 |
+
</taxce>
|
33 |
+
<tax>
|
34 |
+
<rewrite>
|
35 |
+
<sales_total_quote_tax>VertexSMB_TaxCE_Model_Tax_Sales_Total_Quote_Tax</sales_total_quote_tax>
|
36 |
+
</rewrite>
|
37 |
+
</tax>
|
38 |
+
<taxce_resource>
|
39 |
+
<class>VertexSMB_TaxCE_Model_Resource</class>
|
40 |
+
<entities>
|
41 |
+
<taxrequest>
|
42 |
+
<table>vertexsmb_taxrequest</table>
|
43 |
+
</taxrequest>
|
44 |
+
</entities>
|
45 |
+
</taxce_resource>
|
46 |
+
</models>
|
47 |
+
<helpers>
|
48 |
+
<taxce>
|
49 |
+
<class>VertexSMB_TaxCE_Helper</class>
|
50 |
+
</taxce>
|
51 |
+
</helpers>
|
52 |
+
<resources>
|
53 |
+
<taxce_setup>
|
54 |
+
<setup>
|
55 |
+
<module>VertexSMB_TaxCE</module>
|
56 |
+
<class>VertexSMB_TaxCE_Model_Resource_Setup</class>
|
57 |
+
</setup>
|
58 |
+
<connection>
|
59 |
+
<use>core_setup</use>
|
60 |
+
</connection>
|
61 |
+
</taxce_setup>
|
62 |
+
<taxce_write>
|
63 |
+
<connection>
|
64 |
+
<use>core_write</use>
|
65 |
+
</connection>
|
66 |
+
</taxce_write>
|
67 |
+
<taxce_read>
|
68 |
+
<connection>
|
69 |
+
<use>core_read</use>
|
70 |
+
</connection>
|
71 |
+
</taxce_read>
|
72 |
+
</resources>
|
73 |
+
<events>
|
74 |
+
<sales_order_invoice_save_after>
|
75 |
+
<observers>
|
76 |
+
<vertexsmb_invoice_created_observer>
|
77 |
+
<type>singleton</type>
|
78 |
+
<class>taxce/observer</class>
|
79 |
+
<method>invoiceCreated</method>
|
80 |
+
</vertexsmb_invoice_created_observer>
|
81 |
+
</observers>
|
82 |
+
</sales_order_invoice_save_after>
|
83 |
+
<sales_order_save_after>
|
84 |
+
<observers>
|
85 |
+
<vertexsmb_order_saved_observer>
|
86 |
+
<type>singleton</type>
|
87 |
+
<class>taxce/observer</class>
|
88 |
+
<method>orderSaved</method>
|
89 |
+
</vertexsmb_order_saved_observer>
|
90 |
+
</observers>
|
91 |
+
</sales_order_save_after>
|
92 |
+
<sales_order_creditmemo_refund>
|
93 |
+
<observers>
|
94 |
+
<vertexsmb_order_creditmemo_observer>
|
95 |
+
<type>singleton</type>
|
96 |
+
<class>taxce/observer</class>
|
97 |
+
<method>orderCreditmemoRefund</method>
|
98 |
+
</vertexsmb_order_creditmemo_observer>
|
99 |
+
</observers>
|
100 |
+
</sales_order_creditmemo_refund>
|
101 |
+
<adminhtml_init_system_config>
|
102 |
+
<observers>
|
103 |
+
<vertexsmb_init_system_config>
|
104 |
+
<class>taxce/observer</class>
|
105 |
+
<method>changeSystemConfig</method>
|
106 |
+
</vertexsmb_init_system_config>
|
107 |
+
</observers>
|
108 |
+
</adminhtml_init_system_config>
|
109 |
+
</events>
|
110 |
+
<fieldsets>
|
111 |
+
<sales_convert_quote_address>
|
112 |
+
<tax_area_id>
|
113 |
+
<to_order_address>*</to_order_address>
|
114 |
+
</tax_area_id>
|
115 |
+
</sales_convert_quote_address>
|
116 |
+
</fieldsets>
|
117 |
+
</global>
|
118 |
+
<admin>
|
119 |
+
<routers>
|
120 |
+
<taxce>
|
121 |
+
<use>admin</use>
|
122 |
+
<args>
|
123 |
+
<module>VertexSMB_TaxCE</module>
|
124 |
+
<frontName>vertexsmb</frontName>
|
125 |
+
</args>
|
126 |
+
</taxce>
|
127 |
+
<adminhtml>
|
128 |
+
<args>
|
129 |
+
<modules>
|
130 |
+
<VertexSMB_TaxCE before="Mage_Adminhtml">VertexSMB_TaxCE</VertexSMB_TaxCE>
|
131 |
+
</modules>
|
132 |
+
</args>
|
133 |
+
</adminhtml>
|
134 |
+
</routers>
|
135 |
+
</admin>
|
136 |
+
<adminhtml>
|
137 |
+
<layout>
|
138 |
+
<updates>
|
139 |
+
<taxce>
|
140 |
+
<file>vertexsmb.xml</file>
|
141 |
+
</taxce>
|
142 |
+
</updates>
|
143 |
+
</layout>
|
144 |
+
</adminhtml>
|
145 |
+
<frontend>
|
146 |
+
<layout>
|
147 |
+
<updates>
|
148 |
+
<taxce>
|
149 |
+
<file>vertexsmb.xml</file>
|
150 |
+
</taxce>
|
151 |
+
</updates>
|
152 |
+
</layout>
|
153 |
+
<routers>
|
154 |
+
<checkout>
|
155 |
+
<args>
|
156 |
+
<modules>
|
157 |
+
<VertexSMB_TaxCE before="Mage_Checkout">VertexSMB_TaxCE</VertexSMB_TaxCE>
|
158 |
+
</modules>
|
159 |
+
</args>
|
160 |
+
</checkout>
|
161 |
+
<taxce>
|
162 |
+
<use>standard</use>
|
163 |
+
<args>
|
164 |
+
<module>VertexSMB_TaxCE</module>
|
165 |
+
<frontName>vertexsmb</frontName>
|
166 |
+
</args>
|
167 |
+
</taxce>
|
168 |
+
</routers>
|
169 |
+
</frontend>
|
170 |
+
<default>
|
171 |
+
<tax>
|
172 |
+
<vertexsmb_settings>
|
173 |
+
<enable_vertexsmb><![CDATA[0]]></enable_vertexsmb>
|
174 |
+
<trustedId><![CDATA[]]></trustedId>
|
175 |
+
<invoice_order><![CDATA[invoice_created]]></invoice_order>
|
176 |
+
<api_url><![CDATA[]]></api_url>
|
177 |
+
<address_api_url><![CDATA[]]></address_api_url>
|
178 |
+
<show_manual_button><![CDATA[0]]></show_manual_button>
|
179 |
+
<show_tarequest_popup><![CDATA[1]]></show_tarequest_popup>
|
180 |
+
</vertexsmb_settings>
|
181 |
+
<classes>
|
182 |
+
<default_customer_code><![CDATA[General]]></default_customer_code>
|
183 |
+
<creditmemo_adjustment_negative_code><![CDATA[adjustment-negative]]></creditmemo_adjustment_negative_code>
|
184 |
+
<creditmemo_adjustment_positive_code><![CDATA[adjustment-positive]]></creditmemo_adjustment_positive_code>
|
185 |
+
<giftwrap_order_code><![CDATA[order-gift-wrapping]]></giftwrap_order_code>
|
186 |
+
<giftwrap_item_code><![CDATA[giftwrap-]]></giftwrap_item_code>
|
187 |
+
<printed_giftcard_code><![CDATA[printed-giftcard]]></printed_giftcard_code>
|
188 |
+
</classes>
|
189 |
+
</tax>
|
190 |
+
</default>
|
191 |
+
<crontab>
|
192 |
+
<jobs>
|
193 |
+
<vertexsmb_log_cleanup>
|
194 |
+
<schedule>
|
195 |
+
<cron_expr>00 2 * * *</cron_expr>
|
196 |
+
</schedule>
|
197 |
+
<run>
|
198 |
+
<model>taxce/observer::cleanLogs</model>
|
199 |
+
</run>
|
200 |
+
</vertexsmb_log_cleanup>
|
201 |
+
</jobs>
|
202 |
+
</crontab>
|
203 |
+
</config>
|
204 |
+
|
205 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/{local → community}/VertexSMB/TaxCE/etc/system.xml
RENAMED
@@ -1,9 +1,11 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
|
|
4 |
* @package VertexSMB_TaxCE
|
|
|
5 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
6 |
-
* @
|
7 |
*/
|
8 |
-->
|
9 |
<config>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* @category VertexSMB
|
5 |
* @package VertexSMB_TaxCE
|
6 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
7 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
8 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
9 |
*/
|
10 |
-->
|
11 |
<config>
|
app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-install-0.1.1.php
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category VertexSMB
|
4 |
+
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
+
*/
|
9 |
+
$installer = $this;
|
10 |
+
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) != true) {
|
11 |
+
/**
|
12 |
+
* Create table 'taxce/taxrequest'
|
13 |
+
*/
|
14 |
+
$table = $installer->getConnection()
|
15 |
+
->newTable($installer->getTable('taxce/taxrequest'))
|
16 |
+
->addColumn(
|
17 |
+
'request_id',
|
18 |
+
Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
19 |
+
null,
|
20 |
+
array(
|
21 |
+
'identity' => true,
|
22 |
+
'nullable' => false,
|
23 |
+
'primary' => true
|
24 |
+
),
|
25 |
+
'Request Id'
|
26 |
+
)
|
27 |
+
->addColumn(
|
28 |
+
'request_type',
|
29 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
30 |
+
255,
|
31 |
+
array(
|
32 |
+
'nullable' => false,
|
33 |
+
'default' => null
|
34 |
+
),
|
35 |
+
'Request Type'
|
36 |
+
)
|
37 |
+
->addColumn(
|
38 |
+
'quote_id',
|
39 |
+
Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
40 |
+
null,
|
41 |
+
array(
|
42 |
+
'nullable' => false
|
43 |
+
),
|
44 |
+
'Quote Id'
|
45 |
+
)
|
46 |
+
->addColumn(
|
47 |
+
'order_id',
|
48 |
+
Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
49 |
+
null,
|
50 |
+
array(
|
51 |
+
'nullable' => false,
|
52 |
+
'default' => 0
|
53 |
+
),
|
54 |
+
'Order Id'
|
55 |
+
)
|
56 |
+
->addColumn(
|
57 |
+
'total_tax',
|
58 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
59 |
+
255,
|
60 |
+
array(
|
61 |
+
'nullable' => false,
|
62 |
+
'default' => null
|
63 |
+
),
|
64 |
+
'Total Tax'
|
65 |
+
)
|
66 |
+
->addColumn(
|
67 |
+
'request_date',
|
68 |
+
Varien_Db_Ddl_Table::TYPE_DATETIME,
|
69 |
+
0,
|
70 |
+
array(
|
71 |
+
'nullable' => false
|
72 |
+
),
|
73 |
+
'Request Date'
|
74 |
+
)
|
75 |
+
->addColumn(
|
76 |
+
'request_xml',
|
77 |
+
Varien_Db_Ddl_Table::TYPE_TEXT,
|
78 |
+
0,
|
79 |
+
array(
|
80 |
+
'nullable' => false,
|
81 |
+
'default' => null
|
82 |
+
),
|
83 |
+
'Request XML'
|
84 |
+
)
|
85 |
+
->addColumn(
|
86 |
+
'response_xml',
|
87 |
+
Varien_Db_Ddl_Table::TYPE_TEXT,
|
88 |
+
0,
|
89 |
+
array(
|
90 |
+
'nullable' => false,
|
91 |
+
'default' => null
|
92 |
+
),
|
93 |
+
'Response XML'
|
94 |
+
)
|
95 |
+
->setComment('Log of requests to Vertex SMB');
|
96 |
+
$installer->getConnection()->createTable($table);
|
97 |
+
}
|
98 |
+
/**
|
99 |
+
* Customer Attribute
|
100 |
+
*/
|
101 |
+
$entity = $this->getEntityTypeId('customer');
|
102 |
+
if (! $this->attributeExists($entity, 'customer_code')) {
|
103 |
+
$this->addAttribute(
|
104 |
+
$entity,
|
105 |
+
'customer_code',
|
106 |
+
array(
|
107 |
+
'type' => 'text',
|
108 |
+
'label' => 'Vertex SMB Customer Code',
|
109 |
+
'input' => 'text',
|
110 |
+
'visible' => true,
|
111 |
+
'required' => false,
|
112 |
+
'default_value' => '',
|
113 |
+
'user_defined' => true
|
114 |
+
)
|
115 |
+
);
|
116 |
+
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'customer_code');
|
117 |
+
$attribute->setData(
|
118 |
+
'used_in_forms',
|
119 |
+
array(
|
120 |
+
'adminhtml_customer'
|
121 |
+
)
|
122 |
+
)->save();
|
123 |
+
}
|
124 |
+
|
125 |
+
$this->endSetup();
|
app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.3-0.1.4.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category VertexSMB
|
4 |
+
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
+
*/
|
9 |
+
$installer = $this;
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) == true) {
|
13 |
+
$installer->getConnection()->addColumn(
|
14 |
+
$installer->getTable('taxce/taxrequest'),
|
15 |
+
'source_path',
|
16 |
+
array(
|
17 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
18 |
+
'nullable' => false,
|
19 |
+
'default' => null,
|
20 |
+
'length' => 255,
|
21 |
+
'comment' => 'Source path controller_module_action'
|
22 |
+
)
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
$this->endSetup();
|
app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.6-0.1.7.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category VertexSMB
|
4 |
+
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
+
*/
|
9 |
+
$installer = $this;
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) == true) {
|
13 |
+
$installer->getConnection()->addColumn(
|
14 |
+
$installer->getTable('taxce/taxrequest'),
|
15 |
+
'tax_area_id',
|
16 |
+
array(
|
17 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
18 |
+
'nullable' => false,
|
19 |
+
'default' => null,
|
20 |
+
'length' => 255,
|
21 |
+
'comment' => 'Tax Jurisdictions Id'
|
22 |
+
)
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
$this->endSetup();
|
app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.7-0.1.8.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category VertexSMB
|
4 |
+
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
+
*/
|
9 |
+
$installer = $this;
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
$installer->getConnection()->addColumn(
|
13 |
+
$installer->getTable('sales/quote_address'),
|
14 |
+
'tax_area_id',
|
15 |
+
array(
|
16 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
17 |
+
'nullable' => false,
|
18 |
+
'default' => null,
|
19 |
+
'length' => 255,
|
20 |
+
'comment' => 'Tax Jurisdiction Id'
|
21 |
+
)
|
22 |
+
);
|
23 |
+
|
24 |
+
$installer->getConnection()->addColumn(
|
25 |
+
$installer->getTable('sales/order_address'),
|
26 |
+
'tax_area_id',
|
27 |
+
array(
|
28 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
29 |
+
'nullable' => false,
|
30 |
+
'default' => null,
|
31 |
+
'length' => 255,
|
32 |
+
'comment' => 'Tax Jurisdiction Id'
|
33 |
+
)
|
34 |
+
);
|
35 |
+
|
36 |
+
$this->endSetup();
|
app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-1.1.0-1.1.1.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category VertexSMB
|
4 |
+
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
+
*/
|
9 |
+
$installer = $this;
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) == true) {
|
13 |
+
$installer->getConnection()->addColumn(
|
14 |
+
$installer->getTable('taxce/taxrequest'),
|
15 |
+
'sub_total',
|
16 |
+
array(
|
17 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
18 |
+
'nullable' => false,
|
19 |
+
'default' => null,
|
20 |
+
'length' => 255,
|
21 |
+
'comment' => 'Response Subtotal Amount'
|
22 |
+
)
|
23 |
+
);
|
24 |
+
|
25 |
+
$installer->getConnection()->addColumn(
|
26 |
+
$installer->getTable('taxce/taxrequest'),
|
27 |
+
'total',
|
28 |
+
array(
|
29 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
30 |
+
'nullable' => false,
|
31 |
+
'default' => null,
|
32 |
+
'length' => 255,
|
33 |
+
'comment' => 'Response Total Amount'
|
34 |
+
)
|
35 |
+
);
|
36 |
+
|
37 |
+
$installer->getConnection()->addColumn(
|
38 |
+
$installer->getTable('taxce/taxrequest'),
|
39 |
+
'lookup_result',
|
40 |
+
array(
|
41 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
42 |
+
'nullable' => false,
|
43 |
+
'default' => null,
|
44 |
+
'length' => 255,
|
45 |
+
'comment' => 'Tax Area Response Lookup Result'
|
46 |
+
)
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->endSetup();
|
app/code/community/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-1.1.6-1.1.7.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category VertexSMB
|
4 |
+
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
+
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
+
*/
|
9 |
+
$installer = $this;
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) == true) {
|
13 |
+
$installer->getConnection()->addIndex(
|
14 |
+
$installer->getTable('taxce/taxrequest'),
|
15 |
+
$installer->getIdxName(
|
16 |
+
'taxce/taxrequest',
|
17 |
+
array(
|
18 |
+
'request_id'
|
19 |
+
)
|
20 |
+
),
|
21 |
+
array(
|
22 |
+
'request_id'
|
23 |
+
),
|
24 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
25 |
+
);
|
26 |
+
|
27 |
+
$installer->getConnection()->addIndex(
|
28 |
+
$installer->getTable('taxce/taxrequest'),
|
29 |
+
$installer->getIdxName(
|
30 |
+
'taxce/taxrequest',
|
31 |
+
array(
|
32 |
+
'request_type'
|
33 |
+
)
|
34 |
+
),
|
35 |
+
array(
|
36 |
+
'request_type'
|
37 |
+
)
|
38 |
+
);
|
39 |
+
|
40 |
+
$installer->getConnection()->addIndex(
|
41 |
+
$installer->getTable('taxce/taxrequest'),
|
42 |
+
$installer->getIdxName(
|
43 |
+
'taxce/taxrequest',
|
44 |
+
array(
|
45 |
+
'order_id'
|
46 |
+
)
|
47 |
+
),
|
48 |
+
array(
|
49 |
+
'order_id'
|
50 |
+
)
|
51 |
+
);
|
52 |
+
}
|
53 |
+
|
54 |
+
$this->endSetup();
|
app/code/local/VertexSMB/TaxCE/Block/Adminhtml/Order/View.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Block_Adminhtml_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {
|
9 |
-
|
10 |
-
public function __construct()
|
11 |
-
{
|
12 |
-
parent::__construct();
|
13 |
-
|
14 |
-
if (Mage::Helper('taxce')->IsVertexSMBActive()) {
|
15 |
-
$TotalInvoicedTax=Mage::getModel('taxce/taxRequest')->getTotalInvoicedTax( $this->getOrder()->getId());
|
16 |
-
if ($TotalInvoicedTax || !Mage::helper('taxce')->ShowManualInvoiceButton())
|
17 |
-
return $this;
|
18 |
-
$this->_addButton('vertex_invoice', array(
|
19 |
-
'label' => Mage::helper('taxce')->__("Vertex SMB Invoice"),
|
20 |
-
'onclick' => 'setLocation(\'' . $this->getVertexInvoiceUrl() . '\')',
|
21 |
-
'class' => 'go'
|
22 |
-
));
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getVertexInvoiceUrl(){
|
27 |
-
return $this->getUrl('*/vertexSMB/invoicetax');
|
28 |
-
}
|
29 |
-
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Block/Adminhtml/System/Config/Form/Field/ShippingCodes.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
class VertexSMB_TaxCE_Block_Adminhtml_System_Config_Form_Field_ShippingCodes extends Mage_Adminhtml_Block_System_Config_Form_Field
|
8 |
-
{
|
9 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$helper=Mage::helper('taxce');
|
12 |
-
$html='<table cellspacing="0" class="form-list"><colgroup class="label"></colgroup><colgroup class="value"></colgroup><tbody>';
|
13 |
-
$html.='<tr><td class="label">Shipping Method</td><td class="value">Product Code</td></tr>';
|
14 |
-
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
|
15 |
-
foreach($methods as $_ccode => $_carrier)
|
16 |
-
{
|
17 |
-
|
18 |
-
$_methodOptions = array();
|
19 |
-
if($_methods = $_carrier->getAllowedMethods())
|
20 |
-
{
|
21 |
-
|
22 |
-
if(!$_title = Mage::getStoreConfig("carriers/$_ccode/title"))
|
23 |
-
$_title = $_ccode;
|
24 |
-
$html.='<tr><td class="label" colspan="2"><b>'.$_title.'</b></td></tr>';
|
25 |
-
foreach($_methods as $_mcode => $_method)
|
26 |
-
{
|
27 |
-
$_code = $_ccode . '_' . $_mcode;
|
28 |
-
$_methodOptions[] = array('value' => $_code, 'label' => $_method);
|
29 |
-
}
|
30 |
-
$html.='<tr><td class="label">'.$_method.': </td><td class="value"> '.$_code.'</td></tr>';
|
31 |
-
}
|
32 |
-
if ($_ccode=='ups' && $ups = Mage::getSingleton('usa/shipping_carrier_ups') )
|
33 |
-
foreach ($ups->getCode('method') as $k=>$v)
|
34 |
-
$html.='<tr><td class="label">'.Mage::helper('usa')->__($v).': </td><td class="value"> '.$_ccode . '_' .$k.'</td></tr>';
|
35 |
-
|
36 |
-
if ($_ccode=='usps' && $usps = Mage::getSingleton('usa/shipping_carrier_usps') )
|
37 |
-
foreach ($usps->getCode('method') as $k=>$v)
|
38 |
-
$html.='<tr><td class="label">'.$usps->getMethodLabel($v).': </td><td class="value"> '.$_ccode . '_' .$k.'</td></tr>';
|
39 |
-
|
40 |
-
if ($_ccode=='fedex' && $fedex = Mage::getSingleton('usa/shipping_carrier_fedex') )
|
41 |
-
foreach ($fedex->getCode('method') as $k=>$v)
|
42 |
-
$html.='<tr><td class="label">'.$v.': </td><td class="value"> '.$_ccode . '_' .$k.'</td></tr>';
|
43 |
-
|
44 |
-
if ($_ccode=='dhl' && $dhl = Mage::getSingleton('usa/shipping_carrier_dhl') )
|
45 |
-
foreach ($dhl->getCode('service') as $k=>$v)
|
46 |
-
$html.='<tr><td class="label">'.$v.': </td><td class="value"> '.$_ccode . '_' .$k.'</td></tr>';
|
47 |
-
|
48 |
-
if ($_ccode=='dhlint' && $dhlint = Mage::getSingleton('usa/shipping_carrier_dhl_international') )
|
49 |
-
foreach ($dhlint->getDhlProducts($this->_contentType) as $k=>$v)
|
50 |
-
$html.='<tr><td class="label">'.$v.': </td><td class="value"> '.$_ccode . '_' .$k.'</td></tr>';
|
51 |
-
|
52 |
-
}
|
53 |
-
$html.='</tbody></table>';
|
54 |
-
return $html;
|
55 |
-
}
|
56 |
-
|
57 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
58 |
-
{
|
59 |
-
$id = $element->getHtmlId();
|
60 |
-
$html='<td>';
|
61 |
-
$html .= $this->_getElementHtml($element);
|
62 |
-
$html.= '</td>';
|
63 |
-
return $this->_decorateRowHtml($element, $html);
|
64 |
-
}
|
65 |
-
|
66 |
-
}
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Block/Adminhtml/System/Config/Form/Field/VertexSMBStatus.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Block_Adminhtml_System_Config_Form_Field_VertexSMBStatus extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
-
{
|
10 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
11 |
-
{
|
12 |
-
$helper=Mage::helper('taxce');
|
13 |
-
if (!$helper->IsVertexSMBActive()) {
|
14 |
-
$status="Disabled";
|
15 |
-
$state="critical";
|
16 |
-
}else{
|
17 |
-
$status=$helper->CheckCredentials();
|
18 |
-
if ($status=='Valid')
|
19 |
-
$state="notice";
|
20 |
-
else
|
21 |
-
$state="minor";
|
22 |
-
}
|
23 |
-
|
24 |
-
return '<span class="grid-severity-'.$state.'"><span style=" background-color: #FAFAFA;">'.$status.'</span></span>';
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Helper/Config.php
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Helper_Config extends Mage_Core_Helper_Abstract {
|
9 |
-
|
10 |
-
const CONFIG_XML_PATH_ENABLE_VERTEX='tax/vertexsmb_settings/enable_vertexsmb';
|
11 |
-
const CONFIG_XML_PATH_DEFAULT_TAX_CALCULATION_ADDRESS_TYPE='tax/calculation/based_on';
|
12 |
-
const CONFIG_XML_PATH_DEFAULT_CUSTOMER_CODE = 'tax/classes/default_customer_code';
|
13 |
-
const VERTEX_API_HOST='tax/vertexsmb_settings/api_url';
|
14 |
-
const CONFIG_XML_PATH_VERTEX_API_USER = 'tax/vertexsmb_settings/login';
|
15 |
-
const CONFIG_XML_PATH_VERTEX_API_KEY = 'tax/vertexsmb_settings/password';
|
16 |
-
const CONFIG_XML_PATH_VERTEX_API_TRUSTED_ID = 'tax/vertexsmb_settings/trustedId';
|
17 |
-
const CONFIG_XML_PATH_VERTEX_COMPANY_CODE = 'tax/vertexsmb_seller_info/company';
|
18 |
-
const CONFIG_XML_PATH_VERTEX_LOCATION_CODE = 'tax/vertexsmb_seller_info/location_code';
|
19 |
-
const CONFIG_XML_PATH_VERTEX_STREET1 = 'tax/vertexsmb_seller_info/streetAddress1';
|
20 |
-
const CONFIG_XML_PATH_VERTEX_STREET2 = 'tax/vertexsmb_seller_info/streetAddress2';
|
21 |
-
const CONFIG_XML_PATH_VERTEX_CITY = 'tax/vertexsmb_seller_info/city';
|
22 |
-
const CONFIG_XML_PATH_VERTEX_COUNTRY = 'tax/vertexsmb_seller_info/country_id';
|
23 |
-
const CONFIG_XML_PATH_VERTEX_REGION = 'tax/vertexsmb_seller_info/region_id';
|
24 |
-
const CONFIG_XML_PATH_VERTEX_POSTAL_CODE = 'tax/vertexsmb_seller_info/postalCode';
|
25 |
-
const CONFIG_XML_PATH_VERTEX_INVOICE_DATE = 'tax/vertexsmb_settings/invoice_tax_date';
|
26 |
-
const CONFIG_XML_PATH_VERTEX_TRANSACTION_TYPE = 'SALE'; /* SALE,RENTAl,LEASE*/
|
27 |
-
const CONFIG_XML_PATH_VERTEX_INVOICE_ORDER = 'tax/vertexsmb_settings/invoice_order';
|
28 |
-
const CONFIG_XML_PATH_VERTEX_INVOICE_ORDER_STATUS = 'tax/vertexsmb_settings/invoice_order_status';
|
29 |
-
const CONFIG_XML_PATH_SHIPPING_TAX_CLASS = 'tax/classes/shipping_tax_class';
|
30 |
-
const VERTEX_ADDRESS_API_HOST='tax/vertexsmb_settings/address_api_url';
|
31 |
-
const VERTEX_CREDITMEMO_ADJUSTMENT_CLASS='tax/classes/creditmemo_adjustment_class';
|
32 |
-
const VERTEX_CREDITMEMO_ADJUSTMENT_NEGATIVE_CODE='tax/classes/creditmemo_adjustment_negative_code';
|
33 |
-
const VERTEX_CREDITMEMO_ADJUSTMENT_POSITIVE_CODE='tax/classes/creditmemo_adjustment_positive_code';
|
34 |
-
const VERTEX_GIFTWRAP_ORDER_CLASS='tax/classes/giftwrap_order_class';
|
35 |
-
const VERTEX_GIFTWRAP_ORDER_CODE='tax/classes/giftwrap_order_code';
|
36 |
-
const VERTEX_GIFTWRAP_ITEM_CLASS='tax/classes/giftwrap_item_class';
|
37 |
-
const VERTEX_GIFTWRAP_ITEM_CODE_PREFIX='tax/classes/giftwrap_item_code';
|
38 |
-
const VERTEX_PRINTED_GIFTCARD_CLASS='tax/classes/printed_giftcard_class';
|
39 |
-
const VERTEX_PRINTED_GIFTCARD_CODE='tax/classes/printed_giftcard_code';
|
40 |
-
const CONFIG_XML_PATH_VERTEX_ALLOW_CART_QUOTE = 'tax/vertexsmb_settings/allow_cart_request';
|
41 |
-
const CONFIG_XML_PATH_VERTEX_SHOW_MANUAL_BUTTON = 'tax/vertexsmb_settings/show_manual_button';
|
42 |
-
const CONFIG_XML_PATH_VERTEX_SHOW_POPUP= 'tax/vertexsmb_settings/show_tarequest_popup';
|
43 |
-
|
44 |
-
public function getQuoteAllowedControllers(){
|
45 |
-
$_quote_allowed_controllers=array('onepage','multishipping','sales_order_create');
|
46 |
-
return $_quote_allowed_controllers;
|
47 |
-
}
|
48 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Helper/Data.php
DELETED
@@ -1,481 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Helper_Data extends Mage_Core_Helper_Abstract {
|
9 |
-
|
10 |
-
public function IsVertexSMBActive(){
|
11 |
-
if (Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_ENABLE_VERTEX, Mage::app()->getStore()->getId()))
|
12 |
-
return true;
|
13 |
-
return false;
|
14 |
-
}
|
15 |
-
public function getLocationCode(){
|
16 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_LOCATION_CODE, Mage::app()->getStore()->getId());
|
17 |
-
}
|
18 |
-
public function getCompanyCode(){
|
19 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_COMPANY_CODE, Mage::app()->getStore()->getId());
|
20 |
-
}
|
21 |
-
public function getCompanyStreet1(){
|
22 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_STREET1, Mage::app()->getStore()->getId());
|
23 |
-
}
|
24 |
-
public function getCompanyStreet2(){
|
25 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_STREET2, Mage::app()->getStore()->getId());
|
26 |
-
}
|
27 |
-
public function getCompanyCity(){
|
28 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_CITY, Mage::app()->getStore()->getId());
|
29 |
-
}
|
30 |
-
public function getCompanyCountry(){
|
31 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_COUNTRY, Mage::app()->getStore()->getId());
|
32 |
-
}
|
33 |
-
public function getCompanyRegionId(){
|
34 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_REGION, Mage::app()->getStore()->getId());
|
35 |
-
}
|
36 |
-
public function getCompanyPostalCode(){
|
37 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_POSTAL_CODE, Mage::app()->getStore()->getId());
|
38 |
-
}
|
39 |
-
public function getShippingTaxClassId(){
|
40 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, Mage::app()->getStore()->getId());
|
41 |
-
}
|
42 |
-
public function getTrustedId(){
|
43 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_API_TRUSTED_ID, Mage::app()->getStore()->getId());
|
44 |
-
}
|
45 |
-
public function getTransactionType(){
|
46 |
-
return VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_TRANSACTION_TYPE;
|
47 |
-
}
|
48 |
-
public function getVertexHost(){
|
49 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_API_HOST, Mage::app()->getStore()->getId());
|
50 |
-
}
|
51 |
-
public function getVertexAddressHost(){
|
52 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_ADDRESS_API_HOST, Mage::app()->getStore()->getId());
|
53 |
-
}
|
54 |
-
public function getDefaultCustomerCode(){
|
55 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_DEFAULT_CUSTOMER_CODE, Mage::app()->getStore()->getId());
|
56 |
-
}
|
57 |
-
public function getCreditmemoAdjustmentFeeCode(){
|
58 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_CREDITMEMO_ADJUSTMENT_NEGATIVE_CODE, Mage::app()->getStore()->getId());
|
59 |
-
}
|
60 |
-
public function getCreditmemoAdjustmentFeeClass(){
|
61 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_CREDITMEMO_ADJUSTMENT_CLASS, Mage::app()->getStore()->getId());
|
62 |
-
}
|
63 |
-
public function getCreditmemoAdjustmentPositiveCode(){
|
64 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_CREDITMEMO_ADJUSTMENT_POSITIVE_CODE, Mage::app()->getStore()->getId());
|
65 |
-
}
|
66 |
-
public function getCreditmemoAdjustmentPositiveClass(){
|
67 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_CREDITMEMO_ADJUSTMENT_CLASS, Mage::app()->getStore()->getId());
|
68 |
-
}
|
69 |
-
public function AllowCartQuote(){
|
70 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_ALLOW_CART_QUOTE, Mage::app()->getStore()->getId());
|
71 |
-
}
|
72 |
-
public function getGiftWrappingOrderClass(){
|
73 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_GIFTWRAP_ORDER_CLASS, Mage::app()->getStore()->getId());
|
74 |
-
}
|
75 |
-
public function getGiftWrappingOrderCode(){
|
76 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_GIFTWRAP_ORDER_CODE, Mage::app()->getStore()->getId());
|
77 |
-
}
|
78 |
-
public function getGiftWrappingItemClass(){
|
79 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_GIFTWRAP_ITEM_CLASS, Mage::app()->getStore()->getId());
|
80 |
-
}
|
81 |
-
public function getGiftWrappingItemCodePrefix(){
|
82 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_GIFTWRAP_ITEM_CODE_PREFIX, Mage::app()->getStore()->getId());
|
83 |
-
}
|
84 |
-
public function getPrintedGiftcardClass(){
|
85 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_PRINTED_GIFTCARD_CLASS, Mage::app()->getStore()->getId());
|
86 |
-
}
|
87 |
-
public function getPrintedGiftcardCode(){
|
88 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::VERTEX_PRINTED_GIFTCARD_CODE, Mage::app()->getStore()->getId());
|
89 |
-
}
|
90 |
-
public function IsAllowedQuote() {
|
91 |
-
$quote_allowed_controllers=Mage::helper('taxce/config')->getQuoteAllowedControllers();
|
92 |
-
if ($this->AllowCartQuote())
|
93 |
-
$quote_allowed_controllers[]='cart';
|
94 |
-
|
95 |
-
if (in_array( Mage::app()->getRequest()->getControllerName(), $quote_allowed_controllers))
|
96 |
-
return true;
|
97 |
-
|
98 |
-
return false;
|
99 |
-
}
|
100 |
-
|
101 |
-
public function ShowManualInvoiceButton(){
|
102 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_SHOW_MANUAL_BUTTON, Mage::app()->getStore()->getId());
|
103 |
-
}
|
104 |
-
|
105 |
-
public function ShowPopup(){
|
106 |
-
return Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_SHOW_POPUP, Mage::app()->getStore()->getId());
|
107 |
-
}
|
108 |
-
|
109 |
-
public function RequestbyInvoiceCreation(){
|
110 |
-
$vertex_invoice_event=Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER, Mage::app()->getStore()->getId());
|
111 |
-
if ($vertex_invoice_event=='invoice_created')
|
112 |
-
return true;
|
113 |
-
return false;
|
114 |
-
}
|
115 |
-
|
116 |
-
public function RequestbyOrderStatus($status){
|
117 |
-
$vertex_invoice_event=Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER, Mage::app()->getStore()->getId());
|
118 |
-
$vertex_invoice_order_status=Mage::getStoreConfig(VertexSMB_TaxCE_Helper_Config::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER_STATUS, Mage::app()->getStore()->getId());
|
119 |
-
if ($vertex_invoice_event=='order_status' && $vertex_invoice_order_status==$status)
|
120 |
-
return true;
|
121 |
-
return false;
|
122 |
-
}
|
123 |
-
|
124 |
-
public function TaxClassNameByClassId($class_id) {
|
125 |
-
|
126 |
-
$tax_class_name = Mage::getModel('tax/class')->load($class_id)->getClassName();
|
127 |
-
if ($class_id == 0 && !$tax_class_name)
|
128 |
-
$tax_class_name = "None";
|
129 |
-
return $tax_class_name;
|
130 |
-
}
|
131 |
-
|
132 |
-
public function getSourcePath(){
|
133 |
-
$controller=Mage::app()->getRequest()->getControllerName();
|
134 |
-
$module=Mage::app()->getRequest()->getModuleName();
|
135 |
-
$action=Mage::app()->getRequest()->getActionName();
|
136 |
-
$source_path="";
|
137 |
-
if ($controller)
|
138 |
-
$source_path.=$controller;
|
139 |
-
if ($module)
|
140 |
-
$source_path.="_".$module;
|
141 |
-
if ($action)
|
142 |
-
$source_path.="_".$action;
|
143 |
-
|
144 |
-
return $source_path;
|
145 |
-
}
|
146 |
-
|
147 |
-
public function TaxClassNameByCustomerGroupId($group_id) {
|
148 |
-
$classId = Mage::getModel('customer/group')->getTaxClassId($group_id);
|
149 |
-
return $this->TaxClassNameByClassId($classId);
|
150 |
-
}
|
151 |
-
|
152 |
-
public function getCustomerCodeById($customer_id=0) {
|
153 |
-
$customer_code = $this->getDefaultCustomerCode();
|
154 |
-
if ($customer_id)
|
155 |
-
$customer_code = Mage::getModel('customer/customer')->load($customer_id)->getCustomerCode();
|
156 |
-
|
157 |
-
if (empty($customer_code))
|
158 |
-
$customer_code=$this->getDefaultCustomerCode();
|
159 |
-
|
160 |
-
return $customer_code;
|
161 |
-
}
|
162 |
-
|
163 |
-
public function CheckCredentials() {
|
164 |
-
|
165 |
-
if (!$this->getVertexHost())
|
166 |
-
return "Not Valid: Missing Api Url";
|
167 |
-
if (!$this->getVertexAddressHost())
|
168 |
-
return "Not Valid: Missing Address Validation Api Url";
|
169 |
-
if (!$this->getTrustedId())
|
170 |
-
return "Not Valid: Missing Trusted Id";
|
171 |
-
if (!$this->getCompanyRegionId())
|
172 |
-
return "Not Valid: Missing Company State";
|
173 |
-
if (!$this->getCompanyCountry())
|
174 |
-
return "Not Valid: Missing Company Country";
|
175 |
-
if (!$this->getCompanyStreet1())
|
176 |
-
return "Not Valid: Missing Company Street Address";
|
177 |
-
if (!$this->getCompanyCity())
|
178 |
-
return "Not Valid: Missing Company City";
|
179 |
-
if (!$this->getCompanyPostalCode())
|
180 |
-
return "Not Valid: Missing Company Postal Code";
|
181 |
-
|
182 |
-
$region_id=$this->getCompanyRegionId();
|
183 |
-
if (is_int($region_id)) {
|
184 |
-
$regionModel = Mage::getModel('directory/region')->load($region_id);
|
185 |
-
$company_state=$regionModel->getCode();
|
186 |
-
} else {
|
187 |
-
$company_state=$region_id;
|
188 |
-
}
|
189 |
-
|
190 |
-
$countryModel=Mage::getModel('directory/country')->load($this->getCompanyCountry());
|
191 |
-
$countryName = $countryModel->getIso3Code();
|
192 |
-
|
193 |
-
/*Admin API verification*/
|
194 |
-
$address=new Varien_Object();
|
195 |
-
$address->setStreet1($this->getCompanyStreet1());
|
196 |
-
$address->setStreet2($this->getCompanyStreet2());
|
197 |
-
$address->setCity($this->getCompanyCity());
|
198 |
-
$address->setRegionCode($company_state);
|
199 |
-
$address->setPostcode($this->getCompanyPostalCode());
|
200 |
-
|
201 |
-
if ($countryName!='USA')
|
202 |
-
return "Valid";
|
203 |
-
|
204 |
-
$request_result=Mage::getModel('taxce/TaxAreaRequest')->prepareRequest($address)->taxAreaLookup();
|
205 |
-
if ($request_result instanceof Exception) {
|
206 |
-
return "Address Validation Error: Please check settings";
|
207 |
-
}
|
208 |
-
return "Valid";
|
209 |
-
}
|
210 |
-
|
211 |
-
|
212 |
-
/* Company Information */
|
213 |
-
public function AddSellerInformation($data){
|
214 |
-
|
215 |
-
$region_id=$this->getCompanyRegionId();
|
216 |
-
if (is_int($region_id)) {
|
217 |
-
$regionModel = Mage::getModel('directory/region')->load($region_id);
|
218 |
-
$company_state=$regionModel->getCode();
|
219 |
-
} else {
|
220 |
-
$company_state=$region_id;
|
221 |
-
}
|
222 |
-
|
223 |
-
$countryModel=Mage::getModel('directory/country')->load($this->getCompanyCountry());
|
224 |
-
$countryName = $countryModel->getIso3Code();
|
225 |
-
|
226 |
-
$data['location_code']=$this->getLocationCode();
|
227 |
-
$data['transaction_type']=$this->getTransactionType();
|
228 |
-
$data['company_id']=$this->getCompanyCode();
|
229 |
-
$data['company_street_1']=$this->getCompanyStreet1();
|
230 |
-
$data['company_street_2']=$this->getCompanyStreet2();
|
231 |
-
$data['company_city']=$this->getCompanyCity();
|
232 |
-
$data['company_state']=$company_state;
|
233 |
-
$data['company_postcode']=$this->getCompanyPostalCode();
|
234 |
-
|
235 |
-
$data['company_country'] =$countryName;
|
236 |
-
|
237 |
-
$data['trusted_id']= $this->getTrustedId();
|
238 |
-
|
239 |
-
return $data;
|
240 |
-
}
|
241 |
-
|
242 |
-
public function AddAddressInformation($data,$address) {
|
243 |
-
$data['customer_street1'] = $address->getStreet1();
|
244 |
-
$data['customer_street2'] = $address->getStreet2();
|
245 |
-
$data['customer_city'] = $address->getCity();
|
246 |
-
$data['customer_region'] = $address->getRegionCode();
|
247 |
-
$data['customer_postcode'] = $address->getPostcode();
|
248 |
-
|
249 |
-
$countryModel=Mage::getModel('directory/country')->load($address->getCountryId());
|
250 |
-
$countryName = $countryModel->getIso3Code();
|
251 |
-
$data['customer_country'] =$countryName;
|
252 |
-
|
253 |
-
$data['tax_area_id'] = $address->getTaxAreaId();
|
254 |
-
return $data;
|
255 |
-
}
|
256 |
-
|
257 |
-
public function IsFirstOfPartial($order_address,$original_entity){
|
258 |
-
|
259 |
-
/* Invoice Shipping with first partial invoice */
|
260 |
-
if ($original_entity instanceof Mage_Sales_Model_Order_Invoice) {
|
261 |
-
if (!$original_entity->getShippingTaxAmount())
|
262 |
-
return false;
|
263 |
-
}
|
264 |
-
/* Not invoice shipping if there is partial invoice */
|
265 |
-
if ($this->RequestbyInvoiceCreation() && $original_entity instanceof Mage_Sales_Model_Order && $original_entity->getShippingInvoiced())
|
266 |
-
return false;
|
267 |
-
|
268 |
-
if ($original_entity instanceof Mage_Sales_Model_Order_Creditmemo) {
|
269 |
-
if (!$original_entity->getShippingAMount())
|
270 |
-
return false;
|
271 |
-
}
|
272 |
-
|
273 |
-
return true;
|
274 |
-
}
|
275 |
-
|
276 |
-
public function AddRefundAdjustments($info, $creditmemo_model){
|
277 |
-
|
278 |
-
if ($creditmemo_model->getAdjustmentPositive()) {
|
279 |
-
$item_data=array();
|
280 |
-
$item_data['product_class']=$this->TaxClassNameByClassId($this->getCreditmemoAdjustmentPositiveClass());
|
281 |
-
$item_data['product_code']=$this->getCreditmemoAdjustmentPositiveCode();
|
282 |
-
$item_data['qty']=1;
|
283 |
-
$item_data['price']=-1*$creditmemo_model->getAdjustmentPositive();
|
284 |
-
$item_data['extended_price']=-1*$creditmemo_model->getAdjustmentPositive();
|
285 |
-
$info[]=$item_data;
|
286 |
-
}
|
287 |
-
if ($creditmemo_model->getAdjustmentNegative()) {
|
288 |
-
$item_data=array();
|
289 |
-
$item_data['product_class']=$this->TaxClassNameByClassId($this->getCreditmemoAdjustmentFeeClass());
|
290 |
-
$item_data['product_code']=$this->getCreditmemoAdjustmentFeeCode();
|
291 |
-
$item_data['qty']=1;
|
292 |
-
$item_data['price']=$creditmemo_model->getAdjustmentNegative();
|
293 |
-
$item_data['extended_price']=$creditmemo_model->getAdjustmentNegative();
|
294 |
-
$info[]=$item_data;
|
295 |
-
}
|
296 |
-
return $info;
|
297 |
-
}
|
298 |
-
|
299 |
-
public function AddOrderGiftWrap($order_address, $original_entity=null,$event=null) {
|
300 |
-
$item_data=array();
|
301 |
-
if (!$this->IsFirstOfPartial($order_address,$original_entity)) {
|
302 |
-
return $item_data;
|
303 |
-
}
|
304 |
-
|
305 |
-
$item_data['product_class']=$this->TaxClassNameByClassId($this->getGiftWrappingOrderClass());
|
306 |
-
$item_data['product_code']=$this->getGiftWrappingOrderCode();
|
307 |
-
$item_data['qty']=1;
|
308 |
-
$item_data['price']=$order_address->getGwPrice();
|
309 |
-
$item_data['extended_price']=$item_data['qty']*$item_data['price'];
|
310 |
-
|
311 |
-
/* Negative amounts */
|
312 |
-
if ($event=='cancel' || $event=='refund' ){
|
313 |
-
$item_data['price']=-1*$item_data['price'];
|
314 |
-
$item_data['extended_price']=-1*$item_data['extended_price'];
|
315 |
-
}
|
316 |
-
/* Negative amounts */
|
317 |
-
|
318 |
-
return $item_data;
|
319 |
-
}
|
320 |
-
|
321 |
-
public function AddOrderPrintCard($order_address, $original_entity=null,$event=null) {
|
322 |
-
$item_data=array();
|
323 |
-
if (!$this->IsFirstOfPartial($order_address,$original_entity)) {
|
324 |
-
return $item_data;
|
325 |
-
}
|
326 |
-
$item_data['product_class']=$this->TaxClassNameByClassId($this->getPrintedGiftcardClass());
|
327 |
-
$item_data['product_code']=$this->getPrintedGiftcardCode();
|
328 |
-
$item_data['qty']=1;
|
329 |
-
$item_data['price']=$order_address->getGwCardPrice();
|
330 |
-
$item_data['extended_price']=$order_address->getGwCardPrice();
|
331 |
-
|
332 |
-
/* Negative amounts */
|
333 |
-
if ($event=='cancel' || $event=='refund' ){
|
334 |
-
$item_data['price']=-1*$item_data['price'];
|
335 |
-
$item_data['extended_price']=-1*$item_data['extended_price'];
|
336 |
-
}
|
337 |
-
/* Negative amounts */
|
338 |
-
|
339 |
-
return $item_data;
|
340 |
-
}
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
public function AddShippingInfo($order_address, $original_entity=null,$event=null) {
|
345 |
-
$item_data=array();
|
346 |
-
if ($order_address->getShippingMethod() && $this->IsFirstOfPartial($order_address,$original_entity)) {
|
347 |
-
|
348 |
-
$item_data['product_class']=$this->TaxClassNameByClassId($this->getShippingTaxClassId());
|
349 |
-
$item_data['product_code']=$order_address->getShippingMethod();
|
350 |
-
$item_data['price']=$order_address->getShippingAmount()-$order_address->getShippingDiscountAmount();
|
351 |
-
$item_data['qty']=1;
|
352 |
-
$item_data['extended_price']=$item_data['price'];
|
353 |
-
|
354 |
-
if ($original_entity instanceof Mage_Sales_Model_Order_Creditmemo) {
|
355 |
-
$item_data['price']=$original_entity->getShippingAmount();
|
356 |
-
$item_data['extended_price']=$item_data['price'];
|
357 |
-
}
|
358 |
-
/* Negative amounts */
|
359 |
-
if ($event=='cancel' || $event=='refund' ){
|
360 |
-
$item_data['price']=-1*$item_data['price'];
|
361 |
-
$item_data['extended_price']=-1*$item_data['extended_price'];
|
362 |
-
}
|
363 |
-
/* Negative amounts */
|
364 |
-
}
|
365 |
-
return $item_data;
|
366 |
-
}
|
367 |
-
|
368 |
-
/*beta*/
|
369 |
-
/* Tax Quote calculation*/
|
370 |
-
public function TaxQuoteItems($address){
|
371 |
-
$information_array = Mage::getModel('taxce/taxQuote')->collectQuotedata($address);
|
372 |
-
$information= new Varien_Object($information_array);
|
373 |
-
$information->setTaxAreaId();
|
374 |
-
$taxed_items_info=Mage::getModel('taxce/taxQuote')->getTaxQuote($information_array);
|
375 |
-
|
376 |
-
return $taxed_items_info;
|
377 |
-
}
|
378 |
-
|
379 |
-
public function CanQuoteTax(){
|
380 |
-
if (!$this->IsAllowedQuote() )
|
381 |
-
return false;
|
382 |
-
/* disable for index page. */
|
383 |
-
if ($this->getSourcePath()=='onepage_checkout_index')
|
384 |
-
return false;
|
385 |
-
|
386 |
-
return true;
|
387 |
-
}
|
388 |
-
/*beta*/
|
389 |
-
|
390 |
-
|
391 |
-
/* Common function for item preparation */
|
392 |
-
public function PrepareItem($item, $type='ordered', $original_entity_item=null,$event=null){
|
393 |
-
$item_data=array();
|
394 |
-
|
395 |
-
$item_data['product_class']=$this->TaxClassNameByClassId($item->getProduct()->getTaxClassId());
|
396 |
-
$item_data['product_code']=$item->getSku();
|
397 |
-
$item_data['item_id']=$item->getId();
|
398 |
-
|
399 |
-
/* Price */
|
400 |
-
if ($type=='invoiced')
|
401 |
-
$price=$original_entity_item->getPrice();
|
402 |
-
else
|
403 |
-
$price=$item->getPrice();//-$item->getDiscountAmount();
|
404 |
-
/* Price */
|
405 |
-
|
406 |
-
$item_data['price']=$price;
|
407 |
-
if ($type=='ordered' && $this->RequestbyInvoiceCreation() ) /*In case order partically being invoiced*/
|
408 |
-
$item_data['qty']=$item->getQtyOrdered()-$item->getQtyInvoiced();
|
409 |
-
elseif ($type=='ordered')
|
410 |
-
$item_data['qty']=$item->getQtyOrdered();
|
411 |
-
elseif ($type=='invoiced')
|
412 |
-
$item_data['qty']=$original_entity_item->getQty();
|
413 |
-
elseif ($type=='quote')
|
414 |
-
$item_data['qty']=$item->getQty();
|
415 |
-
|
416 |
-
/* Always send discounted. Discount on TotalRowAmount*/
|
417 |
-
if ($type=='invoiced')
|
418 |
-
$item_data['extended_price']=$original_entity_item->getRowTotal()-$original_entity_item->getDiscountAmount();
|
419 |
-
else if ($type=='ordered' && $this->RequestbyInvoiceCreation() ) /*In case order partically being invoiced*/
|
420 |
-
$item_data['extended_price']=$item->getRowTotal()-$item->getRowInvoiced()-$item->getDiscountAmount()+$item->getDiscountInvoiced();
|
421 |
-
else
|
422 |
-
$item_data['extended_price']=$item->getRowTotal()-$item->getDiscountAmount();
|
423 |
-
|
424 |
-
/* Negative amounts */
|
425 |
-
if ($event=='cancel' || $event=='refund'){
|
426 |
-
$item_data['price']=-1*$item_data['price'];
|
427 |
-
$item_data['extended_price']=-1*$item_data['extended_price'];
|
428 |
-
}
|
429 |
-
return $item_data;
|
430 |
-
}
|
431 |
-
|
432 |
-
public function PrepareGiftWrapItem($item, $type='ordered', $original_entity_item=null,$event=null){
|
433 |
-
$item_data=array();
|
434 |
-
|
435 |
-
/* @todo move to config */
|
436 |
-
$item_data['product_class']=$this->TaxClassNameByClassId($this->getGiftWrappingItemClass());
|
437 |
-
$item_data['product_code']=$this->getGiftWrappingItemCodePrefix().'-'.$item->getSku();
|
438 |
-
|
439 |
-
/* Price */
|
440 |
-
if ($type=='invoiced')
|
441 |
-
$price=$item->getGwPriceInvoiced();
|
442 |
-
else
|
443 |
-
$price=$item->getGwPrice();
|
444 |
-
/* Price */
|
445 |
-
|
446 |
-
$item_data['price']=$price;
|
447 |
-
if ($type=='ordered' && $this->RequestbyInvoiceCreation() ) /*In case order partically being invoiced*/
|
448 |
-
$item_data['qty']=$item->getQtyOrdered()-$item->getQtyInvoiced();
|
449 |
-
elseif ($type=='ordered')
|
450 |
-
$item_data['qty']=$item->getQtyOrdered();
|
451 |
-
elseif ($type=='invoiced')
|
452 |
-
$item_data['qty']=$original_entity_item->getQty();
|
453 |
-
elseif ($type=='quote')
|
454 |
-
$item_data['qty']=$item->getQty();
|
455 |
-
|
456 |
-
if ($type=='invoiced')
|
457 |
-
$item_data['extended_price']= $item_data['qty']*$item_data['price'];
|
458 |
-
else if ($type=='ordered' && $this->RequestbyInvoiceCreation() ) /*In case order partically being invoiced*/
|
459 |
-
$item_data['extended_price']= $item_data['qty']*$item_data['price'];
|
460 |
-
else
|
461 |
-
$item_data['extended_price']= $item_data['qty']*($item->getGwPrice());
|
462 |
-
|
463 |
-
/* Negative amounts */
|
464 |
-
if ($event=='cancel' || $event=='refund'){
|
465 |
-
$item_data['price']=-1*$item_data['price'];
|
466 |
-
$item_data['extended_price']=-1*$item_data['extended_price'];
|
467 |
-
}
|
468 |
-
|
469 |
-
return $item_data;
|
470 |
-
}
|
471 |
-
|
472 |
-
/* Used in other files for corrent session & access to quote*/
|
473 |
-
public function getSession(){
|
474 |
-
if (Mage::app()->getRequest()->getControllerName()!='sales_order_create')
|
475 |
-
return Mage::getSingleton('checkout/session');
|
476 |
-
else
|
477 |
-
return Mage::getSingleton('adminhtml/session_quote');
|
478 |
-
}
|
479 |
-
|
480 |
-
|
481 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/Observer.php
DELETED
@@ -1,168 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
**/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_Observer {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* @param Varien_Event_Observer $observer
|
12 |
-
* @return VertexSMB_TaxCE_Model_Observer
|
13 |
-
*/
|
14 |
-
public function InvoiceCreated(Varien_Event_Observer $observer) {
|
15 |
-
if (!$this->_getHelper()->IsVertexSMBActive() || !$this->_getHelper()->RequestbyInvoiceCreation())
|
16 |
-
return $this;
|
17 |
-
|
18 |
-
/* @var $order Magento_Sales_Model_Order_Invoice */
|
19 |
-
$invoice = $observer->getEvent()->getInvoice();
|
20 |
-
$invoice_request_data=Mage::getModel('taxce/taxInvoice')->PrepareInvoiceData($invoice,'invoice');
|
21 |
-
|
22 |
-
if ($invoice_request_data && Mage::getModel('taxce/taxInvoice')->SendInvoiceRequest($invoice_request_data,$invoice->getOrder()))
|
23 |
-
$this->_getSession()->addSuccess( $this->_getHelper()->__('The Vertex SMB invoice has been sent.'));
|
24 |
-
|
25 |
-
return $this;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @param Varien_Event_Observer $observer
|
30 |
-
* @return VertexSMB_TaxCE_Model_Observer
|
31 |
-
*/
|
32 |
-
public function OrderSaved(Varien_Event_Observer $observer) {
|
33 |
-
$order = $observer->getEvent()->getOrder();
|
34 |
-
if (!$this->_getHelper()->IsVertexSMBActive() || !$this->_getHelper()->RequestbyOrderStatus($order->getStatus()))
|
35 |
-
return $this;
|
36 |
-
|
37 |
-
$invoice_request_data=Mage::getModel('taxce/taxInvoice')->PrepareInvoiceData($order);
|
38 |
-
if ($invoice_request_data && Mage::getModel('taxce/taxInvoice')->SendInvoiceRequest($invoice_request_data,$order))
|
39 |
-
$this->_getSession()->addSuccess( $this->_getHelper()->__('The Vertex SMB invoice has been sent.'));
|
40 |
-
return $this;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @deprecated
|
45 |
-
* @param Varien_Event_Observer $observer
|
46 |
-
* @return VertexSMB_TaxCE_Model_Observer
|
47 |
-
*/
|
48 |
-
|
49 |
-
public function OrderCancelled(Varien_Event_Observer $observer) {
|
50 |
-
/* Commented upon new logic
|
51 |
-
* $order = $observer->getEvent()->getOrder();
|
52 |
-
$invoiced_tax= Mage::getModel('vertex/taxrequest')->getTotalInvoicedTax($order->getId());
|
53 |
-
if (!$this->_getHelper()->IsVertexSMBActive() || !$invoiced_tax)
|
54 |
-
return $this;
|
55 |
-
$cancel_request_data=Mage::getModel('vertex/taxInvoice')->PrepareInvoiceData($order,'cancel');
|
56 |
-
if ($cancel_request_data && Mage::getModel('vertex/taxInvoice')->SendCancelRequest($cancel_request_data,$order))
|
57 |
-
$this->_getSession()->addSuccess( $this->_getHelper()->__('The Vertex invoice has been canceled.'));
|
58 |
-
*/
|
59 |
-
return $this;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* @param Varien_Event_Observer $observer
|
64 |
-
* @return VertexSMB_TaxCE_Model_Observer
|
65 |
-
*/
|
66 |
-
public function OrderCreditmemoRefund(Varien_Event_Observer $observer){
|
67 |
-
$credit_memo= $observer->getCreditmemo();
|
68 |
-
$order=$credit_memo->getOrder();
|
69 |
-
$invoiced_tax= Mage::getModel('taxce/taxRequest')->getTotalInvoicedTax($order->getId());
|
70 |
-
if (!$this->_getHelper()->IsVertexSMBActive() || !$invoiced_tax)
|
71 |
-
return $this;
|
72 |
-
$creditmemo_request_data=Mage::getModel('taxce/taxInvoice')->PrepareInvoiceData($credit_memo,'refund');
|
73 |
-
if ($creditmemo_request_data && Mage::getModel('taxce/taxInvoice')->SendRefundRequest($creditmemo_request_data,$order))
|
74 |
-
$this->_getSession()->addSuccess( $this->_getHelper()->__('The Vertex SMB invoice has been refunded.'));
|
75 |
-
|
76 |
-
return $this;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* @param Varien_Event_Observer $observer
|
81 |
-
* @return VertexSMB_TaxCE_Model_Observer
|
82 |
-
*/
|
83 |
-
public function changeSystemConfig(Varien_Event_Observer $observer) {
|
84 |
-
$config = $observer->getConfig();
|
85 |
-
$config->getNode('sections/tax/groups/calculation/fields/algorithm')->show_in_website=0;
|
86 |
-
$config->getNode('sections/tax/groups/calculation/fields/algorithm')->show_in_default=0;
|
87 |
-
$config->getNode('sections/tax/groups/calculation/fields/algorithm')->show_in_store=0;
|
88 |
-
|
89 |
-
$config->getNode('sections/tax/groups/calculation/fields/based_on')->show_in_website=0;
|
90 |
-
$config->getNode('sections/tax/groups/calculation/fields/based_on')->show_in_default=0;
|
91 |
-
$config->getNode('sections/tax/groups/calculation/fields/based_on')->show_in_store=0;
|
92 |
-
|
93 |
-
$config->getNode('sections/tax/groups/calculation/fields/discount_tax')->show_in_website=0;
|
94 |
-
$config->getNode('sections/tax/groups/calculation/fields/discount_tax')->show_in_default=0;
|
95 |
-
$config->getNode('sections/tax/groups/calculation/fields/discount_tax')->show_in_store=0;
|
96 |
-
|
97 |
-
$config->getNode('sections/tax/groups/calculation/fields/apply_tax_on')->show_in_website=0;
|
98 |
-
$config->getNode('sections/tax/groups/calculation/fields/apply_tax_on')->show_in_default=0;
|
99 |
-
$config->getNode('sections/tax/groups/calculation/fields/apply_tax_on')->show_in_store=0;
|
100 |
-
|
101 |
-
$config->getNode('sections/tax/groups/weee')->show_in_website=0;
|
102 |
-
$config->getNode('sections/tax/groups/weee')->show_in_default=0;
|
103 |
-
$config->getNode('sections/tax/groups/weee')->show_in_store=0;
|
104 |
-
|
105 |
-
$config->getNode('sections/tax/groups/defaults')->show_in_website=0;
|
106 |
-
$config->getNode('sections/tax/groups/defaults')->show_in_default=0;
|
107 |
-
$config->getNode('sections/tax/groups/defaults')->show_in_store=0;
|
108 |
-
|
109 |
-
if (!Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' )
|
110 |
-
|| !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' )->is('active', 'true')) {
|
111 |
-
|
112 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_class')->show_in_website=0;
|
113 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_class')->show_in_default=0;
|
114 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_class')->show_in_store=0;
|
115 |
-
|
116 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_code')->show_in_website=0;
|
117 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_code')->show_in_default=0;
|
118 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_order_code')->show_in_store=0;
|
119 |
-
|
120 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_class')->show_in_website=0;
|
121 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_class')->show_in_default=0;
|
122 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_class')->show_in_store=0;
|
123 |
-
|
124 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_code')->show_in_website=0;
|
125 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_code')->show_in_default=0;
|
126 |
-
$config->getNode('sections/tax/groups/classes/fields/giftwrap_item_code')->show_in_store=0;
|
127 |
-
|
128 |
-
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_class')->show_in_website=0;
|
129 |
-
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_class')->show_in_default=0;
|
130 |
-
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_class')->show_in_store=0;
|
131 |
-
|
132 |
-
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_code')->show_in_website=0;
|
133 |
-
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_code')->show_in_default=0;
|
134 |
-
$config->getNode('sections/tax/groups/classes/fields/printed_giftcard_code')->show_in_store=0;
|
135 |
-
|
136 |
-
}
|
137 |
-
|
138 |
-
return $this;
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* @param unknown $schedule
|
143 |
-
* @return VertexSMB_TaxCE_Model_Observer
|
144 |
-
*/
|
145 |
-
public function CleanLogs($schedule){
|
146 |
-
$request_model = Mage::getModel('taxce/taxRequest');
|
147 |
-
$request_model->RemoveQuotesLookupRequests();
|
148 |
-
$request_model->RemoveInvoicesforCompletedOrders();
|
149 |
-
return $this;
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* @return VertexSMB_TaxCE_Helper_Data
|
154 |
-
*/
|
155 |
-
public function _getHelper() {
|
156 |
-
return Mage::helper('taxce');
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Retrieve adminhtml session model object
|
161 |
-
*
|
162 |
-
* @return Mage_Adminhtml_Model_Session
|
163 |
-
*/
|
164 |
-
protected function _getSession()
|
165 |
-
{
|
166 |
-
return Mage::getSingleton('adminhtml/session');
|
167 |
-
}
|
168 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/RequestItem.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
**/
|
7 |
-
|
8 |
-
|
9 |
-
class VertexSMB_TaxCE_Model_RequestItem extends Mage_Core_Model_Abstract {
|
10 |
-
|
11 |
-
public function _construct()
|
12 |
-
{
|
13 |
-
$this->_init('taxce/requestItem');
|
14 |
-
}
|
15 |
-
|
16 |
-
public function getHelper() {
|
17 |
-
return Mage::helper('taxce');
|
18 |
-
}
|
19 |
-
|
20 |
-
/* RequestType:
|
21 |
-
* TaxAreaRequest
|
22 |
-
* InvoiceRequest
|
23 |
-
* QuotationRequest
|
24 |
-
*/
|
25 |
-
public function exportAsArray(){
|
26 |
-
$request=array(
|
27 |
-
'Login'=>array('TrustedId'=>$this->getTrustedId()),
|
28 |
-
$this->getRequestType()=>array(
|
29 |
-
'documentDate'=>$this->getDocumentDate(),
|
30 |
-
'postingDate'=>$this->getPostingDate(),
|
31 |
-
'transactionType'=>$this->getTransactionType(),
|
32 |
-
'documentNumber' => $this->getDocumentNumber(),
|
33 |
-
'LineItem'=> array(),
|
34 |
-
|
35 |
-
)
|
36 |
-
);
|
37 |
-
|
38 |
-
if ($this->getDocumentNumber())
|
39 |
-
$request[$this->getRequestType()]['documentNumber']=$this->getDocumentNumber();
|
40 |
-
|
41 |
-
$order_items=$this->getOrderItems();
|
42 |
-
$request[$this->getRequestType()]['LineItem']=$this->AddItems($order_items);
|
43 |
-
|
44 |
-
return $request;
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
public function AddItems($items){
|
49 |
-
|
50 |
-
$query_items=array();
|
51 |
-
$i=1; /* lineItemNumber */
|
52 |
-
foreach($items as $key=>$item){
|
53 |
-
/* $key - quote_item_id */
|
54 |
-
$tmp_item=array('lineItemNumber'=>$i,'lineItemId'=>$key, 'locationCode'=>$this->getLocationCode(),
|
55 |
-
'Seller'=> array (
|
56 |
-
'Company'=> $this->getCompanyId(),
|
57 |
-
'PhysicalOrigin'=>array(
|
58 |
-
'StreetAddress1'=>$this->getData('company_street_1'),
|
59 |
-
'StreetAddress2'=>$this->getData('company_street_2'),
|
60 |
-
'City'=>$this->getCompanyCity(),
|
61 |
-
'Country'=>$this->getCompanyCountry(),
|
62 |
-
'MainDivision'=>$this->getCompanyState(),
|
63 |
-
'PostalCode'=>$this->getCompanyPostcode())
|
64 |
-
),
|
65 |
-
'Customer'=> array('CustomerCode'=>array('classCode'=>$this->getCustomerClass(),'_'=>$this->getCustomerCode()),
|
66 |
-
'Destination'=>
|
67 |
-
array(
|
68 |
-
'StreetAddress1'=>$this->getCustomerStreet1(),
|
69 |
-
'StreetAddress2'=>$this->getCustomerStreet2(),
|
70 |
-
'City'=>$this->getCustomerCity(),
|
71 |
-
'MainDivision'=>$this->getCustomerRegion(),
|
72 |
-
'PostalCode'=>$this->getCustomerPostcode(),
|
73 |
-
'Country'=> $this->getCustomerCountry(),
|
74 |
-
),
|
75 |
-
),
|
76 |
-
'Product' => array ('productClass'=>$item['product_class'],'_'=>$item['product_code']),
|
77 |
-
'UnitPrice' => array('_'=>$item['price']),
|
78 |
-
'Quantity' => array('_'=>$item['qty']),
|
79 |
-
'ExtendedPrice'=> array('_'=>$item['extended_price']),
|
80 |
-
);
|
81 |
-
|
82 |
-
|
83 |
-
if ($this->getCustomerCountry()=='CAN')
|
84 |
-
$tmp_item['deliveryTerm']='SUP';
|
85 |
-
|
86 |
-
if ($this->getTaxAreaId())
|
87 |
-
$tmp_item['Customer']['Destination']['taxAreaId']=$this->getTaxAreaId();
|
88 |
-
|
89 |
-
|
90 |
-
$query_items[]=$tmp_item;
|
91 |
-
$i++;
|
92 |
-
}
|
93 |
-
return $query_items;
|
94 |
-
}
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/Source/Taxinvoice.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
**/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_Source_Taxinvoice {
|
9 |
-
protected $_options;
|
10 |
-
|
11 |
-
public function toOptionArray($isMultiselect=false)
|
12 |
-
{
|
13 |
-
if (!$this->_options) {
|
14 |
-
$this->_options[]=array('label'=>"When Invoice Created", 'value'=>'invoice_created');
|
15 |
-
$this->_options[]=array('label'=>"When Order Status Is", 'value'=>'order_status');
|
16 |
-
}
|
17 |
-
$options = $this->_options;
|
18 |
-
return $options;
|
19 |
-
}
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/Tax/Sales/Total/Quote/Tax.php
DELETED
@@ -1,287 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
**/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_Tax_Sales_Total_Quote_Tax extends Mage_Tax_Model_Sales_Total_Quote_Tax {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Collect tax totals for quote address
|
12 |
-
*
|
13 |
-
* @param Mage_Sales_Model_Quote_Address $address
|
14 |
-
* @return Mage_Tax_Model_Sales_Total_Quote
|
15 |
-
*/
|
16 |
-
public function collect(Mage_Sales_Model_Quote_Address $address)
|
17 |
-
{
|
18 |
-
if (!Mage::helper('taxce')->IsVertexSMBActive()) {
|
19 |
-
parent::collect($address);
|
20 |
-
return $this;
|
21 |
-
}
|
22 |
-
/*Limit tax quote amounts*/
|
23 |
-
$address_type=$address->getAddressType();
|
24 |
-
|
25 |
-
|
26 |
-
if ($address->getQuote()->isVirtual() && $address_type=='shipping'){
|
27 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
28 |
-
Mage::log("Quote request was not sent. Address Type: ".$address_type.", Order is virtual. ", null, 'vertexsmb.log');
|
29 |
-
return $this;
|
30 |
-
}
|
31 |
-
if (!$address->getQuote()->isVirtual() && !$address->getShippingMethod()) {
|
32 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
33 |
-
Mage::log("Quote request was not sent. Order is not virtual and doesnt have shipping address. ", null, 'vertexsmb.log');
|
34 |
-
return $this;
|
35 |
-
}
|
36 |
-
/* Commented before */
|
37 |
-
/*if($address_type!=$based_on && ($address_type=='billing' && !$address->getQuote()->isVirtual()) ){
|
38 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
39 |
-
return $this;
|
40 |
-
} */
|
41 |
-
if ( !$address->getStreet1() && !Mage::helper('taxce')->AllowCartQuote() ) {
|
42 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
43 |
-
Mage::log("Quote request was not sent. Address Street not specified. ", null, 'vertexsmb.log');
|
44 |
-
return $this;
|
45 |
-
}
|
46 |
-
|
47 |
-
if (!$address->getCountryId() || !$address->getRegion() || !$address->getPostcode() || !count($address->getAllNonNominalItems())) {
|
48 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
49 |
-
Mage::log("Quote request was not sent. Address not specified. ", null, 'vertexsmb.log');
|
50 |
-
return $this;
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
if (!$address->getTaxAreaId() && !Mage::helper('taxce')->AllowCartQuote() ) {
|
56 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
57 |
-
Mage::log("Quote request was not sent. Address area id not specified yet. ", null, 'vertexsmb.log');
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
|
61 |
-
/*Vertex SMB */
|
62 |
-
if (!Mage::helper('taxce')->CanQuoteTax()) {
|
63 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
64 |
-
Mage::log("Quote request not have enought information", null, 'vertexsmb.log');
|
65 |
-
return $this;
|
66 |
-
}
|
67 |
-
/*Vertex SMB*/
|
68 |
-
|
69 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
70 |
-
$this->_roundingDeltas = array();
|
71 |
-
$this->_baseRoundingDeltas = array();
|
72 |
-
$this->_hiddenTaxes = array();
|
73 |
-
$address->setShippingTaxAmount(0);
|
74 |
-
$address->setBaseShippingTaxAmount(0);
|
75 |
-
|
76 |
-
$this->_store = $address->getQuote()->getStore();
|
77 |
-
$customer = $address->getQuote()->getCustomer();
|
78 |
-
if ($customer) {
|
79 |
-
$this->_calculator->setCustomer($customer);
|
80 |
-
}
|
81 |
-
|
82 |
-
if (!$address->getAppliedTaxesReset()) {
|
83 |
-
$address->setAppliedTaxes(array());
|
84 |
-
}
|
85 |
-
|
86 |
-
$items = $this->_getAddressItems($address);
|
87 |
-
if (!count($items)) {
|
88 |
-
return $this;
|
89 |
-
}
|
90 |
-
|
91 |
-
$request = new Varien_Object();
|
92 |
-
/* Removed to not match any of rules */
|
93 |
-
/* $request->setCountryId($address->getCountryId())
|
94 |
-
->setRegionId($address->getRegionId())
|
95 |
-
->setPostcode($address->getPostcode())
|
96 |
-
->setStore($address->getQuote()->getStore())
|
97 |
-
->setCustomerClassId($address->getQuote()->getCustomerTaxClassId());
|
98 |
-
*/
|
99 |
-
if ($this->_config->priceIncludesTax($this->_store)) {
|
100 |
-
$this->_areTaxRequestsSimilar = $this->_calculator->compareRequests(
|
101 |
-
$this->_calculator->getRateOriginRequest($this->_store),
|
102 |
-
$request
|
103 |
-
);
|
104 |
-
}
|
105 |
-
|
106 |
-
/*beta*/
|
107 |
-
$itemsVertexTaxes=Mage::helper('taxce')->TaxQuoteItems($address);
|
108 |
-
$request->setItemsVertexTax($itemsVertexTaxes);
|
109 |
-
/*beta*/
|
110 |
-
|
111 |
-
$this->_rowBaseCalculation($address, $request);
|
112 |
-
$this->_addAmount($address->getExtraTaxAmount());
|
113 |
-
$this->_addBaseAmount($address->getBaseExtraTaxAmount());
|
114 |
-
/* Shipping Tax */
|
115 |
-
$this->_calculateShippingTax($address,$request);
|
116 |
-
/* Shipping Tax */
|
117 |
-
|
118 |
-
$this->_processHiddenTaxes();
|
119 |
-
//round total amounts in address
|
120 |
-
$this->_roundTotals($address);
|
121 |
-
return $this;
|
122 |
-
}
|
123 |
-
|
124 |
-
|
125 |
-
/* (non-PHPdoc)
|
126 |
-
* @see Mage_Tax_Model_Sales_Total_Quote_Tax::_rowBaseCalculation()
|
127 |
-
*/
|
128 |
-
protected function _rowBaseCalculation(Mage_Sales_Model_Quote_Address $address, $taxRateRequest)
|
129 |
-
{
|
130 |
-
if (!Mage::helper('taxce')->IsVertexSMBActive()) {
|
131 |
-
parent::_rowBaseCalculation( $address, $taxRateRequest);
|
132 |
-
return $this;
|
133 |
-
}
|
134 |
-
|
135 |
-
$items = $this->_getAddressItems($address);
|
136 |
-
$itemTaxGroups = array();
|
137 |
-
/*beta*/
|
138 |
-
$itemsVertexTaxes=$taxRateRequest->getItemsVertexTax();
|
139 |
-
/*beta*/
|
140 |
-
foreach ($items as $item) {
|
141 |
-
if ($item->getParentItem()) {
|
142 |
-
continue;
|
143 |
-
}
|
144 |
-
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
|
145 |
-
foreach ($item->getChildren() as $child) {
|
146 |
-
$taxRateRequest->setProductClassId($child->getProduct()->getTaxClassId());
|
147 |
-
$rate = $this->_calculator->getRate($taxRateRequest);
|
148 |
-
$this->_calcRowTaxAmount($child, $itemsVertexTaxes);
|
149 |
-
$this->_addAmount($child->getTaxAmount());
|
150 |
-
$this->_addBaseAmount($child->getBaseTaxAmount());
|
151 |
-
$applied = $this->_calculator->getAppliedRates($taxRateRequest);
|
152 |
-
if ($rate > 0) {
|
153 |
-
$itemTaxGroups[$child->getId()] = $applied;
|
154 |
-
}
|
155 |
-
$this->_saveAppliedTaxes(
|
156 |
-
$address,
|
157 |
-
$applied,
|
158 |
-
$child->getTaxAmount(),
|
159 |
-
$child->getBaseTaxAmount(),
|
160 |
-
$rate
|
161 |
-
);
|
162 |
-
$child->setTaxRates($applied);
|
163 |
-
}
|
164 |
-
$this->_recalculateParent($item);
|
165 |
-
}
|
166 |
-
else {
|
167 |
-
$taxRateRequest->setProductClassId($item->getProduct()->getTaxClassId());
|
168 |
-
$rate = $this->_calculator->getRate($taxRateRequest);
|
169 |
-
$this->_calcRowTaxAmount($item, $itemsVertexTaxes);
|
170 |
-
$this->_addAmount($item->getTaxAmount());
|
171 |
-
$this->_addBaseAmount($item->getBaseTaxAmount());
|
172 |
-
$applied = $this->_calculator->getAppliedRates($taxRateRequest);
|
173 |
-
if ($rate > 0) {
|
174 |
-
$itemTaxGroups[$item->getId()] = $applied;
|
175 |
-
}
|
176 |
-
$this->_saveAppliedTaxes(
|
177 |
-
$address,
|
178 |
-
$applied,
|
179 |
-
$item->getTaxAmount(),
|
180 |
-
$item->getBaseTaxAmount(),
|
181 |
-
$rate
|
182 |
-
);
|
183 |
-
$item->setTaxRates($applied);
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
if ($address->getQuote()->getTaxesForItems()) {
|
188 |
-
$itemTaxGroups += $address->getQuote()->getTaxesForItems();
|
189 |
-
}
|
190 |
-
$address->getQuote()->setTaxesForItems($itemTaxGroups);
|
191 |
-
return $this;
|
192 |
-
}
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
/* (non-PHPdoc)
|
197 |
-
* @see Mage_Tax_Model_Sales_Total_Quote_Tax::_calcRowTaxAmount()
|
198 |
-
*/
|
199 |
-
protected function _calcRowTaxAmount( $item, $rate, &$taxGroups = null, $taxId = null, $recalculateRowTotalInclTax = false )
|
200 |
-
{
|
201 |
-
/* Vertex SMB*/
|
202 |
-
if (!Mage::helper('taxce')->IsVertexSMBActive()) {
|
203 |
-
parent::_calcRowTaxAmount($item, $rate);
|
204 |
-
return $this;
|
205 |
-
}
|
206 |
-
|
207 |
-
$subtotal = $taxSubtotal = $item->getTaxableAmount();
|
208 |
-
$baseSubtotal = $baseTaxSubtotal = $item->getBaseTaxableAmount();
|
209 |
-
$rowTax=0;
|
210 |
-
$baseRowTax=0;
|
211 |
-
$taxRate=0;
|
212 |
-
$ItemTax= $rate[$item->getId()];
|
213 |
-
if ($ItemTax instanceof Varien_Object ){
|
214 |
-
$rowTax=$ItemTax->getTaxAmount();
|
215 |
-
$baseRowTax=$ItemTax->getBaseTaxAmount();
|
216 |
-
$taxRate=$ItemTax->getTaxPercent();
|
217 |
-
} else
|
218 |
-
Mage::log("ItemTax is not instance of Varien_Object. ", null, 'vertexsmb.log');
|
219 |
-
/* Vertex */
|
220 |
-
|
221 |
-
$item->setTaxPercent($taxRate);
|
222 |
-
$item->setTaxAmount(max(0, $rowTax));
|
223 |
-
$item->setBaseTaxAmount(max(0, $baseRowTax));
|
224 |
-
$rowTotalInclTax = $item->getRowTotalInclTax();
|
225 |
-
|
226 |
-
if (!isset($rowTotalInclTax)) {
|
227 |
-
$weeeTaxBeforeDiscount = 0;
|
228 |
-
$baseWeeeTaxBeforeDiscount = 0;
|
229 |
-
|
230 |
-
if ($this->_config->priceIncludesTax($this->_store)) {
|
231 |
-
$item->setRowTotalInclTax($subtotal + $weeeTaxBeforeDiscount);
|
232 |
-
$item->setBaseRowTotalInclTax($baseSubtotal + $baseWeeeTaxBeforeDiscount);
|
233 |
-
} else {
|
234 |
-
$taxCompensation = $item->getDiscountTaxCompensation() ? $item->getDiscountTaxCompensation() : 0;
|
235 |
-
$item->setRowTotalInclTax($subtotal + $rowTax + $taxCompensation);
|
236 |
-
$item->setBaseRowTotalInclTax($baseSubtotal + $baseRowTax + $item->getBaseDiscountTaxCompensation());
|
237 |
-
}
|
238 |
-
}
|
239 |
-
|
240 |
-
return $this;
|
241 |
-
}
|
242 |
-
|
243 |
-
/* (non-PHPdoc)
|
244 |
-
* @see Mage_Tax_Model_Sales_Total_Quote_Tax::_calculateShippingTax()
|
245 |
-
*/
|
246 |
-
protected function _calculateShippingTax(Mage_Sales_Model_Quote_Address $address, $taxRateRequest)
|
247 |
-
{
|
248 |
-
if (!Mage::helper('taxce')->IsVertexSMBActive()) {
|
249 |
-
parent::_calculateShippingTax($address, $taxRateRequest);
|
250 |
-
return $this;
|
251 |
-
}
|
252 |
-
/*beta*/
|
253 |
-
$itemsVertexTaxes=$taxRateRequest->getItemsVertexTax();
|
254 |
-
/*beta*/
|
255 |
-
|
256 |
-
$taxRateRequest->setProductClassId($this->_config->getShippingTaxClass($this->_store));
|
257 |
-
$tax=0;
|
258 |
-
$baseTax=0;
|
259 |
-
$rate=0;
|
260 |
-
$shipping_tax=0;
|
261 |
-
|
262 |
-
if (is_array($itemsVertexTaxes) && array_key_exists('shipping',$itemsVertexTaxes))
|
263 |
-
$shipping_tax= $itemsVertexTaxes['shipping'] ;
|
264 |
-
|
265 |
-
Mage::log($itemsVertexTaxes, null, 'vertexsmb.log');
|
266 |
-
|
267 |
-
if ($shipping_tax instanceof Varien_Object ){
|
268 |
-
$tax=$shipping_tax->getTaxAmount();
|
269 |
-
$baseTax=$shipping_tax->getBaseTaxAmount();
|
270 |
-
$rate=$shipping_tax->getTaxPercent();
|
271 |
-
}else
|
272 |
-
Mage::log("shipping_tax is not instance of Varien_Object. ", null, 'vertexsmb.log');
|
273 |
-
|
274 |
-
$this->_addAmount(max(0, $tax));
|
275 |
-
$this->_addBaseAmount(max(0, $baseTax));
|
276 |
-
$address->setShippingTaxAmount(max(0, $tax));
|
277 |
-
$address->setBaseShippingTaxAmount(max(0, $baseTax));
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
$applied = $this->_calculator->getAppliedRates($taxRateRequest);
|
282 |
-
$this->_saveAppliedTaxes($address, $applied, $tax, $baseTax, $rate);
|
283 |
-
|
284 |
-
return $this;
|
285 |
-
}
|
286 |
-
|
287 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/TaxAreaRequest.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_TaxAreaRequest extends Mage_Core_Model_Abstract {
|
9 |
-
|
10 |
-
public function prepareRequest($address) {
|
11 |
-
$request=array(
|
12 |
-
'Login'=>array('TrustedId'=>$this->getHelper()->getTrustedId()),
|
13 |
-
'TaxAreaRequest'=>array(
|
14 |
-
'TaxAreaLookup'=> array(
|
15 |
-
'PostalAddress'=>array(
|
16 |
-
'StreetAddress1'=>$address->getStreet1(),
|
17 |
-
'StreetAddress2'=>$address->getStreet2(),
|
18 |
-
'City'=>$address->getCity(),
|
19 |
-
'MainDivision'=>$address->getRegionCode(),
|
20 |
-
'PostalCode'=>$address->getPostcode(),
|
21 |
-
)
|
22 |
-
)
|
23 |
-
)
|
24 |
-
);
|
25 |
-
|
26 |
-
$this->setRequest($request);
|
27 |
-
return $this;
|
28 |
-
}
|
29 |
-
|
30 |
-
public function taxAreaLookup(){
|
31 |
-
|
32 |
-
if (!$this->getRequest()) {
|
33 |
-
Mage::log("Tax area lookup error: request information not exist", null, 'vertexsmb.log');
|
34 |
-
return false;
|
35 |
-
}
|
36 |
-
|
37 |
-
$request_result=Mage::getModel('taxce/vertexSMB')->SendApiRequest($this->getRequest(),null, 'tax_area_lookup');
|
38 |
-
if ($request_result instanceof Exception) {
|
39 |
-
Mage::log("Tax Area Lookup Error: ".$request_result->getMessage(), null, 'vertexsmb.log');
|
40 |
-
return $request_result;
|
41 |
-
}
|
42 |
-
|
43 |
-
$response=Mage::getModel('taxce/TaxAreaResponse')->parseResponse($request_result);
|
44 |
-
$this->setResponse($response);
|
45 |
-
|
46 |
-
return $request_result;
|
47 |
-
}
|
48 |
-
|
49 |
-
public function getHelper() {
|
50 |
-
return Mage::helper('taxce');
|
51 |
-
}
|
52 |
-
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/TaxAreaResponse.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_TaxAreaResponse extends Mage_Core_Model_Abstract {
|
9 |
-
|
10 |
-
|
11 |
-
public function parseResponse($response_object){
|
12 |
-
if (is_array($response_object->TaxAreaResponse->TaxAreaResult))
|
13 |
-
$taxAreaResults=$response_object->TaxAreaResponse->TaxAreaResult;
|
14 |
-
else
|
15 |
-
$taxAreaResults[]=$response_object->TaxAreaResponse->TaxAreaResult;
|
16 |
-
|
17 |
-
$this->setTaxAreaResults($taxAreaResults);
|
18 |
-
$this->setResultsCount(count($taxAreaResults));
|
19 |
-
return $this;
|
20 |
-
}
|
21 |
-
|
22 |
-
public function GetFirstTaxAreaInfo(){
|
23 |
-
$TaxAreaFirstResults=$this->getTaxAreaResults();
|
24 |
-
$TaxAreaFirstResult=$TaxAreaFirstResults[0];
|
25 |
-
$TaxAreInfoFirst=new Varien_Object;
|
26 |
-
$TaxAreInfoFirst->setTaxAreaId($TaxAreaFirstResult->taxAreaId);
|
27 |
-
$TaxAreInfoFirst->setCity($TaxAreaFirstResult->PostalAddress->City);
|
28 |
-
return $TaxAreInfoFirst;
|
29 |
-
}
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/TaxInvoice.php
DELETED
@@ -1,167 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
|
9 |
-
class VertexSMB_TaxCE_Model_TaxInvoice extends Mage_Core_Model_Abstract {
|
10 |
-
|
11 |
-
public function _construct()
|
12 |
-
{
|
13 |
-
$this->_init('taxce/taxinvoice');
|
14 |
-
}
|
15 |
-
|
16 |
-
public function getHelper() {
|
17 |
-
return Mage::helper('taxce');
|
18 |
-
}
|
19 |
-
|
20 |
-
/* Prepare Invoice Request Data (Order|Invoice)
|
21 |
-
* @todo Add event names
|
22 |
-
*
|
23 |
-
*/
|
24 |
-
public function PrepareInvoiceData($entity_item, $event=null){
|
25 |
-
|
26 |
-
$info=array();
|
27 |
-
$info=$this->getHelper()->AddSellerInformation($info);
|
28 |
-
|
29 |
-
if ($entity_item instanceof Mage_Sales_Model_Order) {
|
30 |
-
$order=$entity_item;
|
31 |
-
}elseif($entity_item instanceof Mage_Sales_Model_Order_Invoice) {
|
32 |
-
$order=$entity_item->getOrder();
|
33 |
-
}elseif($entity_item instanceof Mage_Sales_Model_Order_Creditmemo) {
|
34 |
-
$order=$entity_item->getOrder();
|
35 |
-
}
|
36 |
-
$info['order_id']=$order->getIncrementId();
|
37 |
-
$info['document_number']=$order->getIncrementId();
|
38 |
-
$info['document_date']=date("Y-m-d", strtotime($order->getCreatedAt()));
|
39 |
-
$info['posting_date']=date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
|
40 |
-
|
41 |
-
$customer_class = $this->getHelper()->TaxClassNameByCustomerGroupId($order->getCustomerGroupId());
|
42 |
-
$customer_code = $this->getHelper()->getCustomerCodeById($order->getCustomerId());
|
43 |
-
|
44 |
-
$info['customer_class']=$customer_class;
|
45 |
-
$info['customer_code']=$customer_code;
|
46 |
-
|
47 |
-
if ($order->getIsVirtual())
|
48 |
-
$address=$order->getBillingAddress();
|
49 |
-
else
|
50 |
-
$address=$order->getShippingAddress();
|
51 |
-
|
52 |
-
$info=$this->getHelper()->AddAddressInformation($info,$address);
|
53 |
-
|
54 |
-
/* Get Items Information*/
|
55 |
-
$order_items=array();
|
56 |
-
$ordered_items = $entity_item->getAllItems();
|
57 |
-
|
58 |
-
foreach($ordered_items as $item){
|
59 |
-
$original_item=$item;
|
60 |
-
if ($entity_item instanceof Mage_Sales_Model_Order_Invoice)
|
61 |
-
$item=$item->getOrderItem();
|
62 |
-
elseif ($entity_item instanceof Mage_Sales_Model_Order_Creditmemo)
|
63 |
-
$item=$item->getOrderItem();
|
64 |
-
|
65 |
-
if ($item->getParentItem())
|
66 |
-
continue;
|
67 |
-
|
68 |
-
if ($item->getHasChildren() && $item->getProduct()->getPriceType()!==null
|
69 |
-
&& (int)$item->getProduct()->getPriceType()===Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD)
|
70 |
-
foreach ($item->getChildrenItems() as $child) {
|
71 |
-
if ( $entity_item instanceof Mage_Sales_Model_Order_Invoice || $entity_item instanceof Mage_Sales_Model_Order_Creditmemo ) {
|
72 |
-
$order_items[]=$this->getHelper()->PrepareItem($child,'invoiced',$original_item,$event);
|
73 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )
|
74 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )->is('active', 'true') && $child->getGwId())
|
75 |
-
$order_items[] = $this->getHelper()->PrepareGiftWrapItem($child,'invoiced',$original_item,$event);
|
76 |
-
}elseif ($entity_item instanceof Mage_Sales_Model_Order) {
|
77 |
-
$order_items[]=$this->getHelper()->PrepareItem($child,'ordered',$original_item,$event);
|
78 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )
|
79 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )->is('active', 'true') && $child->getGwId())
|
80 |
-
$order_items[] = $this->getHelper()->PrepareGiftWrapItem($child,'ordered',$original_item,$event);
|
81 |
-
}
|
82 |
-
}
|
83 |
-
else {
|
84 |
-
if ( $entity_item instanceof Mage_Sales_Model_Order_Invoice || $entity_item instanceof Mage_Sales_Model_Order_Creditmemo ) {
|
85 |
-
$order_items[]=$this->getHelper()->PrepareItem($item,'invoiced',$original_item,$event);
|
86 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )
|
87 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )->is('active', 'true') && $item->getGwId())
|
88 |
-
$order_items[] = $this->getHelper()->PrepareGiftWrapItem($item,'invoiced',$original_item,$event);
|
89 |
-
}elseif ($entity_item instanceof Mage_Sales_Model_Order) {
|
90 |
-
$order_items[]=$this->getHelper()->PrepareItem($item,'ordered',$original_item,$event);
|
91 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )
|
92 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )->is('active', 'true') && $item->getGwId())
|
93 |
-
$order_items[] = $this->getHelper()->PrepareGiftWrapItem($item,'ordered',$original_item,$event);
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
if (!$order->getIsVirtual() && count($this->getHelper()->AddShippingInfo($order,$entity_item,$event)))
|
99 |
-
$order_items[]=$this->getHelper()->AddShippingInfo($order,$entity_item,$event);
|
100 |
-
|
101 |
-
if ($entity_item instanceof Mage_Sales_Model_Order_Creditmemo )
|
102 |
-
$order_items=$this->getHelper()->AddRefundAdjustments($order_items,$entity_item);
|
103 |
-
|
104 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )
|
105 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )->is('active', 'true') ) {
|
106 |
-
if (count($this->getHelper()->AddOrderGiftWrap($order,$entity_item,$event)))
|
107 |
-
$order_items[]=$this->getHelper()->AddOrderGiftWrap($order,$entity_item,$event);
|
108 |
-
if (count($this->getHelper()->AddOrderPrintCard($order,$entity_item,$event)))
|
109 |
-
$order_items[]=$this->getHelper()->AddOrderPrintCard($order,$entity_item,$event);
|
110 |
-
}
|
111 |
-
/* Get Items Information*/
|
112 |
-
/* Making Request Array*/
|
113 |
-
$info['request_type']='InvoiceRequest';
|
114 |
-
$info['order_items']=$order_items;
|
115 |
-
$request=Mage::getModel('taxce/requestItem')->setData($info)->exportAsArray();
|
116 |
-
|
117 |
-
/* Making Request Array*/
|
118 |
-
return $request;
|
119 |
-
}
|
120 |
-
|
121 |
-
/* Invoice Request Preparation*/
|
122 |
-
public function SendInvoiceRequest($data,$order=null){
|
123 |
-
if ($order==null)
|
124 |
-
$order=Mage::registry('current_order');
|
125 |
-
|
126 |
-
$request_result=Mage::getModel('taxce/vertexSMB')->SendApiRequest($data,$order,'invoice');
|
127 |
-
if ($request_result instanceof Exception) {
|
128 |
-
Mage::log("Invoice Request Error: ".$request_result->getMessage(), null, 'vertexsmb.log');
|
129 |
-
Mage::getSingleton('adminhtml/session')->addError($request_result->getMessage());
|
130 |
-
return false;
|
131 |
-
}
|
132 |
-
|
133 |
-
$order->addStatusHistoryComment('Vertex SMB Invoice sent successfully. Amount: $'.$request_result->InvoiceResponse->TotalTax->_, false)->save();
|
134 |
-
return true;
|
135 |
-
}
|
136 |
-
|
137 |
-
/* Cancel Request Preparation*/
|
138 |
-
public function SendCancelRequest($data,$order=null){
|
139 |
-
if ($order==null)
|
140 |
-
$order=Mage::registry('current_order');
|
141 |
-
|
142 |
-
$request_result=Mage::getModel('taxce/vertexSMB')->SendApiRequest($data,$order,'invoice_cancel');
|
143 |
-
if ($request_result instanceof Exception) {
|
144 |
-
Mage::log("Cancel Request Error: ".$request_result->getMessage(), null, 'vertexsmb.log');
|
145 |
-
Mage::getSingleton('adminhtml/session')->addError($request_result->getMessage());
|
146 |
-
return false;
|
147 |
-
}
|
148 |
-
|
149 |
-
$order->addStatusHistoryComment('Vertex SMB Invoice canceled successfully. Amount: $'.$request_result->InvoiceResponse->TotalTax->_, false)->save();
|
150 |
-
return true;
|
151 |
-
}
|
152 |
-
/* Cancel Request Preparation*/
|
153 |
-
public function SendRefundRequest($data,$order=null){
|
154 |
-
if ($order==null)
|
155 |
-
$order=Mage::registry('current_order');
|
156 |
-
$request_result=Mage::getModel('taxce/vertexSMB')->SendApiRequest($data,$order,'invoice_refund');
|
157 |
-
if ($request_result instanceof Exception) {
|
158 |
-
Mage::log("Refund Request Error: ".$request_result->getMessage(), null, 'vertexsmb.log');
|
159 |
-
Mage::getSingleton('adminhtml/session')->addError($request_result->getMessage());
|
160 |
-
return false;
|
161 |
-
}
|
162 |
-
$order->addStatusHistoryComment('Vertex SMB Invoice refunded successfully. Amount: $'.$request_result->InvoiceResponse->TotalTax->_, false)->save();
|
163 |
-
return true;
|
164 |
-
}
|
165 |
-
|
166 |
-
|
167 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/TaxQuote.php
DELETED
@@ -1,126 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_TaxQuote extends Mage_Core_Model_Abstract {
|
9 |
-
|
10 |
-
public function _construct()
|
11 |
-
{
|
12 |
-
$this->_init('taxce/taxquote');
|
13 |
-
}
|
14 |
-
|
15 |
-
public function getHelper() {
|
16 |
-
return Mage::helper('taxce');
|
17 |
-
}
|
18 |
-
|
19 |
-
public function getTaxQuote($information) {
|
20 |
-
|
21 |
-
/*@todo check it*/
|
22 |
-
/* Prevent multiple query when id updated */
|
23 |
-
if (!$information['tax_area_id'] && !$this->getHelper()->AllowCartQuote())
|
24 |
-
return false;
|
25 |
-
/* @todo compare with tax model seems dublicate*/
|
26 |
-
/* Automatically determine tax area id */
|
27 |
-
|
28 |
-
if ($this->getHelper()->getSourcePath()=='cart_checkout_index' || $this->getHelper()->getSourcePath()=='cart_checkout_couponPost') {
|
29 |
-
$information['tax_area_id']='';
|
30 |
-
$information['customer_street1']='';
|
31 |
-
$information['customer_street2']='';
|
32 |
-
}
|
33 |
-
|
34 |
-
/* Quotation Request Array*/
|
35 |
-
$information['request_type']='QuotationRequest';
|
36 |
-
$request=Mage::getModel('taxce/requestItem')->setData($information)->exportAsArray();
|
37 |
-
/* Quotation Request Array*/
|
38 |
-
|
39 |
-
$tax_quote_result=Mage::getModel('taxce/vertexSMB')->SendApiRequest($request,null,'quote');
|
40 |
-
if ($tax_quote_result instanceof Exception) {
|
41 |
-
/*@info error handles for different page types */
|
42 |
-
if (Mage::app()->getRequest()->getControllerName()=='onepage' || Mage::app()->getRequest()->getControllerName()=='sales_order_create') {
|
43 |
-
Mage::log("Quote Request Error: ".$tax_quote_result->getMessage()."Controller: ".$this->getHelper()->getSourcePath(), null, 'vertexsmb.log');
|
44 |
-
$result=array('error' => 1, 'message' => "Tax calculation request error. Please check your address");
|
45 |
-
echo Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
46 |
-
exit();
|
47 |
-
}
|
48 |
-
if ($this->getHelper()->getSourcePath()=='cart_checkout_index' || $this->getHelper()->getSourcePath()=='cart_checkout_couponPost')
|
49 |
-
$this->getHelper()->getSession()->addError(Mage::helper('core')->escapeHtml("Tax Calculation Request Error. Please check your address"));
|
50 |
-
|
51 |
-
return false;
|
52 |
-
}
|
53 |
-
/*beta*/
|
54 |
-
$ResponseModel=Mage::getModel('taxce/TaxQuoteResponse')->parseResponse($tax_quote_result);
|
55 |
-
$this->setResponse($ResponseModel);
|
56 |
-
|
57 |
-
$items_tax=$ResponseModel->getTaxLineItems();
|
58 |
-
$quote_taxed_items=$ResponseModel->getQuoteTaxedItems();
|
59 |
-
|
60 |
-
return $quote_taxed_items;
|
61 |
-
/* beta */
|
62 |
-
|
63 |
-
}
|
64 |
-
|
65 |
-
/* Collect Quote Information */
|
66 |
-
public function collectQuotedata(Mage_Sales_Model_Quote_Address $address) {
|
67 |
-
|
68 |
-
$information = array();
|
69 |
-
$information=$this->getHelper()->AddSellerInformation($information);
|
70 |
-
|
71 |
-
$customer_class_name =$this->getHelper()->TaxClassNameByClassId($address->getQuote()->getCustomerTaxClassId());
|
72 |
-
$customer_code = $this->getHelper()->getCustomerCodeById($address->getQuote()->getCustomer()->getId());
|
73 |
-
|
74 |
-
$information['customer_code'] = $customer_code;
|
75 |
-
$information['customer_class'] = $customer_class_name;
|
76 |
-
|
77 |
-
$information=$this->getHelper()->AddAddressInformation($information, $address);
|
78 |
-
|
79 |
-
$information['store_id'] = $address->getQuote()->getStore()->getId();
|
80 |
-
$date=date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
|
81 |
-
$information['posting_date']=$date;
|
82 |
-
$information['document_date']=$date;
|
83 |
-
|
84 |
-
$information['order_items'] = array();
|
85 |
-
$items = $address->getAllNonNominalItems();
|
86 |
-
foreach ($items as $item) {
|
87 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_CatalogPermissions' )
|
88 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_CatalogPermissions' )->is('active', 'true'))
|
89 |
-
if ($item->getDisableAddToCart() && !$item->isDeleted())
|
90 |
-
continue;
|
91 |
-
|
92 |
-
if ($item->getParentItem())
|
93 |
-
continue;
|
94 |
-
|
95 |
-
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
|
96 |
-
foreach ($item->getChildren() as $child) {
|
97 |
-
$information['order_items'][$child->getId()] = $this->getHelper()->PrepareItem($child,'quote');
|
98 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )
|
99 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )->is('active', 'true') && $child->getGwId())
|
100 |
-
$information['order_items']['gift_wrap_'.$child->getId()] = $this->getHelper()->PrepareGiftWrapItem($child,'quote');
|
101 |
-
}
|
102 |
-
} else {
|
103 |
-
$information['order_items'][$item->getId()] = $this->getHelper()->PrepareItem($item,'quote');
|
104 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )
|
105 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )->is('active', 'true') && $item->getGwId())
|
106 |
-
$information['order_items']['gift_wrap_'.$item->getId()] = $this->getHelper()->PrepareGiftWrapItem($item,'quote');
|
107 |
-
}
|
108 |
-
}
|
109 |
-
if(count($this->getHelper()->AddShippingInfo($address)))
|
110 |
-
$information['order_items']['shipping']=$this->getHelper()->AddShippingInfo($address);
|
111 |
-
|
112 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )
|
113 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_GiftWrapping' )->is('active', 'true')) {
|
114 |
-
if ($address->getGwPrice())
|
115 |
-
$information['order_items']['gift_wrapping']=$this->getHelper()->AddOrderGiftWrap($address);
|
116 |
-
if ($address->getGwCardPrice())
|
117 |
-
$information['order_items']['gift_print_card']=$this->getHelper()->AddOrderPrintCard($address);
|
118 |
-
}
|
119 |
-
|
120 |
-
/* return new Varien_Object($information); */
|
121 |
-
return $information;
|
122 |
-
}
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/TaxQuoteResponse.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_TaxQuoteResponse extends Mage_Core_Model_Abstract {
|
9 |
-
|
10 |
-
|
11 |
-
public function parseResponse($response_object){
|
12 |
-
if (is_array($response_object->QuotationResponse->LineItem))
|
13 |
-
$TaxLineItems=$response_object->QuotationResponse->LineItem;
|
14 |
-
else
|
15 |
-
$TaxLineItems[]=$response_object->QuotationResponse->LineItem;
|
16 |
-
|
17 |
-
$this->setTaxLineItems($TaxLineItems);
|
18 |
-
$this->setLineItemsCount(count($TaxLineItems));
|
19 |
-
$this->prepareQuoteTaxedItems($TaxLineItems);
|
20 |
-
|
21 |
-
return $this;
|
22 |
-
}
|
23 |
-
|
24 |
-
public function prepareQuoteTaxedItems($items_tax){
|
25 |
-
$quote_taxed_items=array();
|
26 |
-
|
27 |
-
foreach ($items_tax as $item) {
|
28 |
-
$lineItemNumber=$item->lineItemNumber;
|
29 |
-
$ItemTotaltax=$item->TotalTax->_;
|
30 |
-
/* SUMM Percents For Jurisdictions */
|
31 |
-
$TaxPercent=0;
|
32 |
-
foreach ($item->Taxes as $key=>$tax_value)
|
33 |
-
if (is_object($tax_value) && property_exists($tax_value, "EffectiveRate"))
|
34 |
-
$TaxPercent+=(float)$tax_value->EffectiveRate;
|
35 |
-
elseif ($key=="EffectiveRate")
|
36 |
-
$TaxPercent+=(float)$tax_value;
|
37 |
-
|
38 |
-
|
39 |
-
$TaxPercent=$TaxPercent*100;
|
40 |
-
|
41 |
-
$quoite_item_id=$item->lineItemId;
|
42 |
-
$TaxItemInfo=new Varien_Object;
|
43 |
-
$TaxItemInfo->setProductClass($item->Product->productClass);
|
44 |
-
$TaxItemInfo->setProductSku($item->Product->_);
|
45 |
-
$TaxItemInfo->setProductQty($item->Quantity->_);
|
46 |
-
$TaxItemInfo->setUnitPrice($item->UnitPrice->_);
|
47 |
-
$TaxItemInfo->setTaxPercent($TaxPercent);
|
48 |
-
$TaxItemInfo->setBaseTaxAmount($ItemTotaltax);
|
49 |
-
$TaxItemInfo->setTaxAmount($ItemTotaltax);
|
50 |
-
$quote_taxed_items[$quoite_item_id]=$TaxItemInfo;
|
51 |
-
}
|
52 |
-
|
53 |
-
$this->setQuoteTaxedItems($quote_taxed_items);
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/TaxRequest.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_TaxRequest extends Mage_Core_Model_Abstract {
|
9 |
-
|
10 |
-
public function _construct()
|
11 |
-
{
|
12 |
-
$this->_init('taxce/taxRequest');
|
13 |
-
}
|
14 |
-
|
15 |
-
public function getTotalInvoicedTax($orderId){
|
16 |
-
$TotalTax=0;
|
17 |
-
$invoices=$this->getCollection()->addFieldToSelect('total_tax')->addFieldToFilter('order_id',$orderId)->addFieldToFilter('request_type','invoice');
|
18 |
-
foreach ($invoices as $invoice) {
|
19 |
-
|
20 |
-
$TotalTax+=$invoice->getTotalTax();
|
21 |
-
}
|
22 |
-
return $TotalTax;
|
23 |
-
}
|
24 |
-
|
25 |
-
public function RemoveQuotesLookupRequests(){
|
26 |
-
$quotes=$this->getCollection()->addFieldToSelect('request_id')->addFieldToFilter('request_type',array('in'=>array('quote','tax_area_lookup')));
|
27 |
-
|
28 |
-
foreach ($quotes as $quote)
|
29 |
-
$quote->delete();
|
30 |
-
|
31 |
-
return $this;
|
32 |
-
}
|
33 |
-
|
34 |
-
public function RemoveInvoicesforCompletedOrders(){
|
35 |
-
$invoices=$this->getCollection()->addFieldToSelect('order_id')->addFieldToFilter('request_type','invoice');
|
36 |
-
|
37 |
-
$invoices->getSelect()->join( array('order'=> 'sales_flat_order'), 'order.entity_id = main_table.order_id', array('order.state'));
|
38 |
-
$invoices->addFieldToFilter('order.state',array('in'=>array('complete','canceled','closed')));
|
39 |
-
|
40 |
-
$completed_order_ids=array();
|
41 |
-
foreach ($invoices as $invoice)
|
42 |
-
$completed_order_ids[]=$invoice->getOrderId();
|
43 |
-
|
44 |
-
$completed_invoices=$this->getCollection()->addFieldToSelect('request_id')->addFieldToFilter('order_id',array('in'=>$completed_order_ids));
|
45 |
-
foreach ($completed_invoices as $completeted_invoice)
|
46 |
-
$completeted_invoice->delete();
|
47 |
-
|
48 |
-
|
49 |
-
return $this;
|
50 |
-
}
|
51 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/Model/VertexSMB.php
DELETED
@@ -1,144 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_Model_VertexSMB extends Mage_Core_Model_Abstract {
|
9 |
-
|
10 |
-
public function getHelper() {
|
11 |
-
return Mage::helper('taxce');
|
12 |
-
}
|
13 |
-
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @param unknown $request
|
17 |
-
* @param string $order
|
18 |
-
* @param unknown $type
|
19 |
-
* @return Exception|unknown
|
20 |
-
*/
|
21 |
-
public function SendApiRequest($request,$order=null, $type) {
|
22 |
-
|
23 |
-
$object_id=null;
|
24 |
-
if (strpos($type,'invoice')===0)
|
25 |
-
$object_id=$order->getId();
|
26 |
-
elseif ($type=='quote')
|
27 |
-
$object_id=$this->getHelper()->getSession()->getQuote()->getId();
|
28 |
-
elseif ($type=='tax_area_lookup'){
|
29 |
-
$object_id=0;
|
30 |
-
if (is_object($this->getHelper()->getSession()->getQuote()))
|
31 |
-
$object_id=$this->getHelper()->getSession()->getQuote()->getId();
|
32 |
-
}
|
33 |
-
try {
|
34 |
-
$api_url=$this->getHelper()->getVertexHost();
|
35 |
-
if ($type=='tax_area_lookup')
|
36 |
-
$api_url=$this->getHelper()->getVertexAddressHost();
|
37 |
-
|
38 |
-
$client = new SoapClient($api_url, array('connection_timeout' => 300,'trace' => true, 'soap_version' => SOAP_1_1));
|
39 |
-
|
40 |
-
|
41 |
-
if ($type=='tax_area_lookup')
|
42 |
-
$tax_request_result = $client->LookupTaxAreas60($request);
|
43 |
-
else
|
44 |
-
$tax_request_result = $client->calculateTax60($request);
|
45 |
-
} catch (Exception $e) {
|
46 |
-
if ($client instanceof SoapClient)
|
47 |
-
$this->LogRequest($type,$object_id, $client->__getLastRequest(), $client->__getLastResponse());
|
48 |
-
else
|
49 |
-
$this->LogRequest($type,$object_id, $e->getMessage (), $e->getMessage ());
|
50 |
-
return $e;
|
51 |
-
}
|
52 |
-
$Total_Tax=0;
|
53 |
-
$tax_area_id=0;
|
54 |
-
if (strpos($type,'invoice')===0){
|
55 |
-
$Total_Tax=$tax_request_result->InvoiceResponse->TotalTax->_;
|
56 |
-
$line_item=$tax_request_result->InvoiceResponse->LineItem;
|
57 |
-
if (is_array($line_item))
|
58 |
-
$tax_area_id=$line_item[0]->Customer->Destination->taxAreaId;
|
59 |
-
else
|
60 |
-
$tax_area_id=$line_item->Customer->Destination->taxAreaId;
|
61 |
-
} elseif ($type=='quote') {
|
62 |
-
$Total_Tax=$tax_request_result->QuotationResponse->TotalTax->_;
|
63 |
-
$line_item=$tax_request_result->QuotationResponse->LineItem;
|
64 |
-
if (is_array($line_item))
|
65 |
-
$tax_area_id=$line_item[0]->Customer->Destination->taxAreaId;
|
66 |
-
else
|
67 |
-
$tax_area_id=$line_item->Customer->Destination->taxAreaId;
|
68 |
-
}elseif ($type=='tax_area_lookup') {
|
69 |
-
$tax_area_results=$tax_request_result->TaxAreaResponse->TaxAreaResult;
|
70 |
-
if (is_array($tax_area_results)) {
|
71 |
-
$tax_area_res_ids=array();
|
72 |
-
foreach ($tax_area_results as $tax_area_res) {
|
73 |
-
$tax_area_res_ids[]=$tax_area_res->taxAreaId;
|
74 |
-
}
|
75 |
-
$tax_area_id=implode(',',$tax_area_res_ids);
|
76 |
-
}else
|
77 |
-
$tax_area_id=$tax_area_results->taxAreaId;
|
78 |
-
}
|
79 |
-
|
80 |
-
$this->LogRequest($type, $object_id, $client->__getLastRequest(), $client->__getLastResponse(),$Total_Tax,$tax_area_id);
|
81 |
-
|
82 |
-
return $tax_request_result;
|
83 |
-
|
84 |
-
}
|
85 |
-
|
86 |
-
/* Log Save Logic*/
|
87 |
-
/* @todo expand logs and add cron job for cleaning*/
|
88 |
-
public function LogRequest($type,$object_id,$request_xml,$response_xml, $total_tax=0, $tax_area_id=0) {
|
89 |
-
$taxrequest = Mage::getModel('taxce/taxRequest');
|
90 |
-
$taxrequest->setRequestType($type)->setRequestDate(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
|
91 |
-
if (strpos($type,'invoice')===0)
|
92 |
-
$taxrequest->setOrderId($object_id);
|
93 |
-
elseif ($type=='quote' || $type='tax_area_lookup')
|
94 |
-
$taxrequest->setQuoteId($object_id);
|
95 |
-
|
96 |
-
$dom = new DOMDocument;
|
97 |
-
$dom->preserveWhiteSpace = FALSE;
|
98 |
-
$dom->loadXML($request_xml);
|
99 |
-
$dom->formatOutput = TRUE;
|
100 |
-
if ($dom->saveXml())
|
101 |
-
$request_xml=$dom->saveXml();
|
102 |
-
|
103 |
-
$dom->loadXML($response_xml);
|
104 |
-
|
105 |
-
$dom->formatOutput = TRUE;
|
106 |
-
if ($dom->saveXml())
|
107 |
-
$response_xml=$dom->saveXml();
|
108 |
-
|
109 |
-
$TotalNode = $dom->getElementsByTagName('Total');
|
110 |
-
$SubTotalNode = $dom->getElementsByTagName('SubTotal');
|
111 |
-
$LookupResultNode = $dom->getElementsByTagName('Status');
|
112 |
-
$AddressLookupFaultNode = $dom->getElementsByTagName('exceptionType');
|
113 |
-
$Total=0;
|
114 |
-
$SubTotal=0;
|
115 |
-
$LookupResult="";
|
116 |
-
|
117 |
-
if ($TotalNode->length>0)
|
118 |
-
$Total=$TotalNode->item(0)->nodeValue;
|
119 |
-
|
120 |
-
if ($SubTotalNode->length>0)
|
121 |
-
$SubTotal=$SubTotalNode->item(0)->nodeValue;
|
122 |
-
|
123 |
-
if ($LookupResultNode->length>0)
|
124 |
-
$LookupResult=$LookupResultNode->item(0)->getAttribute('lookupResult');
|
125 |
-
|
126 |
-
if (!$LookupResult && $AddressLookupFaultNode->length>0)
|
127 |
-
$LookupResult=$AddressLookupFaultNode->item(0)->nodeValue;
|
128 |
-
|
129 |
-
$source_path=$this->getHelper()->getSourcePath();
|
130 |
-
$taxrequest->setSourcePath($source_path);
|
131 |
-
$taxrequest->setTotalTax($total_tax);
|
132 |
-
$taxrequest->setRequestXml($request_xml);
|
133 |
-
$taxrequest->setResponseXml($response_xml);
|
134 |
-
$taxrequest->setTaxAreaId($tax_area_id);
|
135 |
-
$taxrequest->setTotal($Total);
|
136 |
-
$taxrequest->setSubTotal($SubTotal);
|
137 |
-
$taxrequest->setLookupResult($LookupResult);
|
138 |
-
$taxrequest->save();
|
139 |
-
Mage::log($taxrequest->getData(), null, 'vertexsmb.log');
|
140 |
-
}
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/controllers/OnepageController.php
DELETED
@@ -1,237 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
require Mage::getModuleDir('controllers', 'Mage_Checkout') . DS . 'OnepageController.php';
|
9 |
-
|
10 |
-
class VertexSMB_TaxCE_OnepageController extends Mage_Checkout_OnepageController {
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Shipping address save action
|
14 |
-
*/
|
15 |
-
public function saveShippingAction()
|
16 |
-
{
|
17 |
-
if (!Mage::helper('taxce')->IsVertexSMBActive()) {
|
18 |
-
parent::saveShippingAction();
|
19 |
-
return $this;
|
20 |
-
}
|
21 |
-
if ($this->_expireAjax()) {
|
22 |
-
return;
|
23 |
-
}
|
24 |
-
if ($this->getRequest()->isPost()) {
|
25 |
-
$data = $this->getRequest()->getPost('shipping', array());
|
26 |
-
$customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
|
27 |
-
|
28 |
-
$result = $this->getOnepage()->saveShipping($data, $customerAddressId);
|
29 |
-
|
30 |
-
/*VertexSMB*/
|
31 |
-
$address=$this->getOnepage()->getQuote()->getShippingAddress();
|
32 |
-
/* Save Tax Area & Correct City | Show popup window */
|
33 |
-
if (!$this->saveTaxAreaId($address))
|
34 |
-
return $this;
|
35 |
-
|
36 |
-
$result['goto_section'] = 'shipping_method';
|
37 |
-
$result['update_section'] = array(
|
38 |
-
'name' => 'shipping-method',
|
39 |
-
'html' => $this->_getShippingMethodsHtml()
|
40 |
-
);
|
41 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
public function saveBillingAction()
|
46 |
-
{
|
47 |
-
if (!Mage::helper('taxce')->IsVertexSMBActive()) {
|
48 |
-
parent::saveBillingAction();
|
49 |
-
return $this;
|
50 |
-
}
|
51 |
-
if ($this->_expireAjax()) {
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
if ($this->getRequest()->isPost()) {
|
55 |
-
$data = $this->getRequest()->getPost('billing', array());
|
56 |
-
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
|
57 |
-
|
58 |
-
if (isset($data['email'])) {
|
59 |
-
$data['email'] = trim($data['email']);
|
60 |
-
}
|
61 |
-
|
62 |
-
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
|
63 |
-
|
64 |
-
if (!isset($result['error'])) {
|
65 |
-
if ($this->getOnepage()->getQuote()->isVirtual()) {
|
66 |
-
$result['goto_section'] = 'payment';
|
67 |
-
$result['update_section'] = array(
|
68 |
-
'name' => 'payment-method',
|
69 |
-
'html' => $this->_getPaymentMethodsHtml()
|
70 |
-
);
|
71 |
-
$address=$this->getOnepage()->getQuote()->getBillingAddress();
|
72 |
-
/* Save Tax Area & Correct City | Show popup window */
|
73 |
-
if (!$this->saveTaxAreaId($address))
|
74 |
-
return $this;
|
75 |
-
} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
|
76 |
-
|
77 |
-
|
78 |
-
$result['goto_section'] = 'shipping_method';
|
79 |
-
$result['update_section'] = array(
|
80 |
-
'name' => 'shipping-method',
|
81 |
-
'html' => $this->_getShippingMethodsHtml()
|
82 |
-
);
|
83 |
-
|
84 |
-
$result['allow_sections'] = array('shipping');
|
85 |
-
$result['duplicateBillingInfo'] = 'true';
|
86 |
-
$address=$this->getOnepage()->getQuote()->getShippingAddress();
|
87 |
-
/* Save Tax Area & Correct City | Show popup window */
|
88 |
-
if (!$this->saveTaxAreaId($address))
|
89 |
-
return $this;
|
90 |
-
} else {
|
91 |
-
$result['goto_section'] = 'shipping';
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
public function saveTaxAreaAction()
|
100 |
-
{
|
101 |
-
if ($this->_expireAjax()) {
|
102 |
-
return;
|
103 |
-
}
|
104 |
-
if ($this->getRequest()->isPost()) {
|
105 |
-
$tax_area_id = $this->getRequest()->getPost('tax_area_id', 0);
|
106 |
-
$new_city = $this->getRequest()->getPost('tax_new_city', 0);
|
107 |
-
|
108 |
-
if ($this->getOnepage()->getQuote()->isVirtual()) {
|
109 |
-
$address=$this->getOnepage()->getQuote()->getBillingAddress();
|
110 |
-
$result['goto_section'] = 'payment';
|
111 |
-
$result['update_section'] = array(
|
112 |
-
'name' => 'payment-method',
|
113 |
-
'html' => $this->_getPaymentMethodsHtml()
|
114 |
-
);
|
115 |
-
$shipping_address=$this->getOnepage()->getQuote()->getShippingAddress();
|
116 |
-
$old_city=$shipping_address->getCity();
|
117 |
-
if (strtolower($old_city)!=strtolower($new_city))
|
118 |
-
$shipping_address->setCity($new_city);
|
119 |
-
|
120 |
-
$shipping_address->setTaxAreaId($tax_area_id)->save();
|
121 |
-
} else {
|
122 |
-
$address=$this->getOnepage()->getQuote()->getShippingAddress();
|
123 |
-
$result['goto_section'] = 'shipping_method';
|
124 |
-
$result['update_section'] = array(
|
125 |
-
'name' => 'shipping-method',
|
126 |
-
'html' => $this->_getShippingMethodsHtml()
|
127 |
-
);
|
128 |
-
|
129 |
-
$old_city=$address->getCity();
|
130 |
-
if (strtolower($old_city)!=strtolower($new_city))
|
131 |
-
$address->setCity($new_city);
|
132 |
-
}
|
133 |
-
$address->setTaxAreaId($tax_area_id)->save();
|
134 |
-
$this->getOnepage()->getQuote()->collectTotals()->save();
|
135 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
public function progressAction()
|
140 |
-
{
|
141 |
-
// previous step should never be null. We always start with billing and go forward
|
142 |
-
$prevStep = $this->getRequest()->getParam('prevStep', false);
|
143 |
-
|
144 |
-
if ($this->_expireAjax() || !$prevStep) {
|
145 |
-
return null;
|
146 |
-
}
|
147 |
-
if ($prevStep=='selectaddress')
|
148 |
-
$prevStep='shipping';
|
149 |
-
|
150 |
-
if ($prevStep=='selectaddress' && $this->getOnepage()->getQuote()->isVirtual())
|
151 |
-
$prevStep='billing';
|
152 |
-
|
153 |
-
$layout = $this->getLayout();
|
154 |
-
$update = $layout->getUpdate();
|
155 |
-
/* Load the block belonging to the current step*/
|
156 |
-
$update->load('checkout_onepage_progress_' . $prevStep);
|
157 |
-
$layout->generateXml();
|
158 |
-
$layout->generateBlocks();
|
159 |
-
$output = $layout->getOutput();
|
160 |
-
$this->getResponse()->setBody($output);
|
161 |
-
return $output;
|
162 |
-
}
|
163 |
-
|
164 |
-
public function saveTaxAreaId($address){
|
165 |
-
|
166 |
-
/*Other Countries*/
|
167 |
-
if ($address->getCountryId()!='USA') {
|
168 |
-
return true;
|
169 |
-
}
|
170 |
-
/*Other Countries*/
|
171 |
-
|
172 |
-
$TaxAreaModel=Mage::getModel('taxce/TaxAreaRequest');
|
173 |
-
$request_result=$TaxAreaModel->prepareRequest($address)->taxAreaLookup();
|
174 |
-
$address_changed=false;
|
175 |
-
if ($request_result instanceof Exception) {
|
176 |
-
|
177 |
-
if (Mage::app()->getRequest()->getControllerName()=='onepage' || Mage::app()->getRequest()->getControllerName()=='sales_order_create') {
|
178 |
-
Mage::log("Quote Request Error: ".$request_result->getMessage()."Controller: ".Mage::helper('taxce')->getSourcePath(), null, 'vertexsmb.log');
|
179 |
-
$result=array('error' => 1, 'message' => "Tax Calculation Request Error. Please check your address");
|
180 |
-
echo Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
181 |
-
exit();
|
182 |
-
}
|
183 |
-
|
184 |
-
/*@todo check cart page if we use tax_area_id there*/
|
185 |
-
if (Mage::helper('taxce')->getSourcePath()=='cart_checkout_index' || Mage::helper('taxce')->getSourcePath()=='cart_checkout_couponPost') {
|
186 |
-
Mage::helper('taxce')->getSession()->addError(Mage::helper('core')->escapeHtml("Tax Calculation Request Error. Please check your address"));
|
187 |
-
}
|
188 |
-
return false;
|
189 |
-
}
|
190 |
-
$TaxAreaResposeModel=$TaxAreaModel->getResponse();
|
191 |
-
|
192 |
-
/*beta*/
|
193 |
-
|
194 |
-
if ($TaxAreaResposeModel->getResultsCount()>1 && Mage::helper('taxce')->ShowPopup()) {
|
195 |
-
$block=Mage::app()->getLayout()->createBlock('core/template')->setTemplate('vertexsmb/popup-content.phtml')
|
196 |
-
->setData('response',$request_result)->toHtml();
|
197 |
-
$result['goto_section'] = 'selectaddress';
|
198 |
-
$result['update_section'] = array(
|
199 |
-
'name' => 'selectaddress',
|
200 |
-
'html' => $block
|
201 |
-
);
|
202 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
203 |
-
return false;
|
204 |
-
}else {
|
205 |
-
$FirstTaxArea=$TaxAreaResposeModel->GetFirstTaxAreaInfo();
|
206 |
-
|
207 |
-
/* @todo modify template for object or address */
|
208 |
-
if ($FirstTaxArea->getCity()) {
|
209 |
-
if (strcmp(strtolower($address->getCity()),strtolower($FirstTaxArea->getCity())) !==0){
|
210 |
-
Mage::log("Original City: ".$address->getCity()." - New City: ".$FirstTaxArea->getCity(), null, 'vertexsmb.log');
|
211 |
-
$address_changed=true;
|
212 |
-
$block_address_update=Mage::app()->getLayout()->createBlock('core/template')->setTemplate('vertexsmb/addresschange-popup-content.phtml')
|
213 |
-
->setOldCity($address->getCity())->setNewCity($FirstTaxArea->getCity())->setTaxAreaId($FirstTaxArea->getTaxAreaId())->toHtml();
|
214 |
-
}
|
215 |
-
$address->setCity($FirstTaxArea->getCity());
|
216 |
-
}
|
217 |
-
$address->setTaxAreaId($FirstTaxArea->getTaxAreaId())->save();
|
218 |
-
$this->getOnepage()->getQuote()->collectTotals()->save();
|
219 |
-
}
|
220 |
-
|
221 |
-
/* @todo find out why should be virtual only*/
|
222 |
-
if ($address_changed /*&& !$this->getOnepage()->getQuote()->isVirtual()*/ ) {
|
223 |
-
$result['goto_section'] = 'selectaddress';
|
224 |
-
$result['update_section'] = array(
|
225 |
-
'name' => 'selectaddress',
|
226 |
-
'html' => $block_address_update
|
227 |
-
);
|
228 |
-
|
229 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
230 |
-
return false;
|
231 |
-
|
232 |
-
}
|
233 |
-
/*beta*/
|
234 |
-
|
235 |
-
return true;
|
236 |
-
}
|
237 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/controllers/VertexSMBController.php
DELETED
@@ -1,150 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
class VertexSMB_TaxCE_VertexSMBController extends Mage_Adminhtml_Controller_Action {
|
9 |
-
|
10 |
-
protected function _construct() {
|
11 |
-
$this->setUsedModuleName('VertexSMB_TaxCE');
|
12 |
-
}
|
13 |
-
|
14 |
-
protected function _isAllowed() {
|
15 |
-
return Mage::getSingleton('admin/session')->isAllowed('sales/order/view');
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Initialize order model instance
|
20 |
-
*
|
21 |
-
* @return Mage_Sales_Model_Order || false
|
22 |
-
*/
|
23 |
-
protected function _initOrder()
|
24 |
-
{
|
25 |
-
$id = $this->getRequest()->getParam('order_id');
|
26 |
-
$order = Mage::getModel('sales/order')->load($id);
|
27 |
-
|
28 |
-
if (!$order->getId()) {
|
29 |
-
$this->_getSession()->addError($this->__('This order no longer exists.'));
|
30 |
-
$this->_redirect('*/*/');
|
31 |
-
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
32 |
-
return false;
|
33 |
-
}
|
34 |
-
Mage::register('sales_order', $order);
|
35 |
-
Mage::register('current_order', $order);
|
36 |
-
return $order;
|
37 |
-
}
|
38 |
-
|
39 |
-
public function InvoicetaxAction() {
|
40 |
-
if ($order = $this->_initOrder()) {
|
41 |
-
$invoice_request_data=Mage::getModel('taxce/taxInvoice')->PrepareInvoiceData($order);
|
42 |
-
if ($invoice_request_data && Mage::getModel('taxce/taxInvoice')->SendInvoiceRequest($invoice_request_data))
|
43 |
-
$this->_getSession()->addSuccess( $this->__('The Vertex SMB invoice has been sent.'));
|
44 |
-
}
|
45 |
-
$this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
|
46 |
-
}
|
47 |
-
|
48 |
-
public function TaxAreaAction(){
|
49 |
-
$orderCreateModel=Mage::getSingleton('adminhtml/sales_order_create');
|
50 |
-
$address_changed=false;
|
51 |
-
|
52 |
-
if ($orderCreateModel->getQuote()->isVirtual() || $orderCreateModel->getQuote()->getShippingAddress()->getSameAsBilling() )
|
53 |
-
$address=$orderCreateModel->getQuote()->getBillingAddress();
|
54 |
-
else
|
55 |
-
$address=$orderCreateModel->getQuote()->getShippingAddress();
|
56 |
-
|
57 |
-
if (!$address->getStreet1() || !$address->getCity() || !$address->getRegion() || !$address->getPostcode() ) {
|
58 |
-
$result['message']='address not completed';
|
59 |
-
echo Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
60 |
-
exit();
|
61 |
-
}
|
62 |
-
|
63 |
-
$order_post=$this->getRequest()->getPost('order');
|
64 |
-
|
65 |
-
/*Other Countries*/
|
66 |
-
if ($address->getCountryId()!='USA') {
|
67 |
-
$result['message']='not_usa_address';
|
68 |
-
echo Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
69 |
-
exit();
|
70 |
-
}
|
71 |
-
|
72 |
-
$TaxAreaModel=Mage::getModel('taxce/TaxAreaRequest');
|
73 |
-
$request_result=$TaxAreaModel->prepareRequest($address)->taxAreaLookup();
|
74 |
-
if ($request_result instanceof Exception) {
|
75 |
-
Mage::log("Admin Tax Area Lookup Error: ".$request_result->getMessage(), null, 'vertexsmb.log');
|
76 |
-
$result['message'] = $request_result->getMessage();
|
77 |
-
$result['error'] =1;
|
78 |
-
echo Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
79 |
-
exit();
|
80 |
-
}
|
81 |
-
|
82 |
-
$TaxAreaResposeModel=$TaxAreaModel->getResponse();
|
83 |
-
|
84 |
-
|
85 |
-
if ($TaxAreaResposeModel->getResultsCount()>1 && Mage::helper('taxce')->ShowPopup()) {
|
86 |
-
$block=Mage::app()->getLayout()->createBlock('page/html')->setTemplate('vertexsmb/popup-content.phtml')
|
87 |
-
->setData('response',$request_result)->toHtml();
|
88 |
-
$result['message'] ="show_popup";
|
89 |
-
$result['html'] =$block;
|
90 |
-
} else {
|
91 |
-
$FirstTaxArea=$TaxAreaResposeModel->GetFirstTaxAreaInfo();
|
92 |
-
if ($FirstTaxArea->getCity()) {
|
93 |
-
$result['message']='tax_area_id_found';
|
94 |
-
/* @todo modify template for object or address */
|
95 |
-
if (strtolower($address->getCity())!=strtolower($FirstTaxArea->getCity())){
|
96 |
-
$address_changed=true;
|
97 |
-
$block_address_update=Mage::app()->getLayout()->createBlock('page/html')->setTemplate('vertexsmb/addresschange-popup-content.phtml')
|
98 |
-
->setOldCity($address->getCity())->setNewCity($FirstTaxArea->getCity())->setTaxAreaId($FirstTaxArea->getTaxAreaId())->toHtml();
|
99 |
-
}
|
100 |
-
$address->setCity($FirstTaxArea->getCity());
|
101 |
-
}
|
102 |
-
$address->setTaxAreaId($FirstTaxArea->getTaxAreaId())->save();
|
103 |
-
$orderCreateModel->saveQuote();
|
104 |
-
}
|
105 |
-
|
106 |
-
if ($address_changed && !$address->getQuote()->isVirtual()) {
|
107 |
-
$result['message'] ="show_popup";
|
108 |
-
$result['html'] =$block_address_update;
|
109 |
-
}
|
110 |
-
|
111 |
-
echo Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
112 |
-
exit();
|
113 |
-
}
|
114 |
-
|
115 |
-
public function saveTaxAreaAction() {
|
116 |
-
$orderCreateModel=Mage::getSingleton('adminhtml/sales_order_create');
|
117 |
-
|
118 |
-
if ($orderCreateModel->getQuote()->isVirtual() || $orderCreateModel->getQuote()->getShippingAddress()->getSameAsBilling() )
|
119 |
-
$address=$orderCreateModel->getQuote()->getBillingAddress();
|
120 |
-
else
|
121 |
-
$address=$orderCreateModel->getQuote()->getShippingAddress();
|
122 |
-
|
123 |
-
$tax_area_id=$this->getRequest()->getParam('tax_area_id');
|
124 |
-
$new_city = $this->getRequest()->getPost('new_city', 0);
|
125 |
-
|
126 |
-
$address->setTaxAreaId($tax_area_id);
|
127 |
-
$old_city=$address->getCity();
|
128 |
-
if (strtolower($old_city)!=strtolower($new_city))
|
129 |
-
$address->setCity($new_city);
|
130 |
-
|
131 |
-
$orderCreateModel->saveQuote();
|
132 |
-
$result['message']='ok';
|
133 |
-
|
134 |
-
echo Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
135 |
-
exit();
|
136 |
-
}
|
137 |
-
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Retrieve adminhtml session model object
|
141 |
-
*
|
142 |
-
* @return Mage_Adminhtml_Model_Session
|
143 |
-
*/
|
144 |
-
protected function _getSession()
|
145 |
-
{
|
146 |
-
return Mage::getSingleton('adminhtml/session');
|
147 |
-
}
|
148 |
-
|
149 |
-
|
150 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/data/taxce_setup/data-install-0.1.1.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @copyright Copyright (c) 2015 Net@Work (http://www.netatwork.com)
|
5 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
6 |
-
* @author Alex Lukyanau
|
7 |
-
*/
|
8 |
-
|
9 |
-
$installer = $this;
|
10 |
-
|
11 |
-
$data = array(
|
12 |
-
array(
|
13 |
-
'class_name' => 'Refund Adjustments',
|
14 |
-
'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT
|
15 |
-
),
|
16 |
-
array(
|
17 |
-
'class_name' => 'Gift Options',
|
18 |
-
'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT
|
19 |
-
)
|
20 |
-
);
|
21 |
-
|
22 |
-
|
23 |
-
foreach ($data as $row) {
|
24 |
-
$installer->getConnection()->insertForce($installer->getTable('tax/tax_class'), $row);
|
25 |
-
}
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/data/taxce_setup/data-upgrade-0.1.4-0.1.5.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @copyright Copyright (c) 2015 Net@Work (http://www.netatwork.com)
|
5 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
6 |
-
* @author Alex Lukyanau
|
7 |
-
*/
|
8 |
-
|
9 |
-
$installer = $this;
|
10 |
-
|
11 |
-
$data = array(
|
12 |
-
array(
|
13 |
-
'class_name' => 'Reward Points',
|
14 |
-
'class_type' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT
|
15 |
-
)
|
16 |
-
);
|
17 |
-
|
18 |
-
if (Mage::getConfig ()->getModuleConfig ( 'Enterprise_Reward' )
|
19 |
-
&& Mage::getConfig ()->getModuleConfig ( 'Enterprise_Reward' )->is('active', 'true')) {
|
20 |
-
foreach ($data as $row) {
|
21 |
-
$installer->getConnection()->insertForce($installer->getTable('tax/tax_class'), $row);
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-install-0.1.1.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
$installer = $this;
|
9 |
-
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) != true) {
|
10 |
-
/**
|
11 |
-
* Create table 'taxce/taxrequest'
|
12 |
-
*/
|
13 |
-
$table = $installer->getConnection()
|
14 |
-
->newTable($installer->getTable('taxce/taxrequest'))
|
15 |
-
->addColumn('request_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
16 |
-
'identity' => true,
|
17 |
-
'nullable' => false,
|
18 |
-
'primary' => true,
|
19 |
-
), 'Request Id')
|
20 |
-
->addColumn('request_type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
21 |
-
'nullable' => false,
|
22 |
-
'default' => NULL,
|
23 |
-
), 'Request Type')
|
24 |
-
->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
25 |
-
'nullable' => false,
|
26 |
-
), 'Quote Id')
|
27 |
-
->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
28 |
-
'nullable' => false,
|
29 |
-
'default' => 0,
|
30 |
-
), 'Order Id')
|
31 |
-
->addColumn('total_tax', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
32 |
-
'nullable' => false,
|
33 |
-
'default' => NULL,
|
34 |
-
), 'Total Tax')
|
35 |
-
->addColumn('request_date', Varien_Db_Ddl_Table::TYPE_DATETIME, 0, array(
|
36 |
-
'nullable' => false
|
37 |
-
), 'Request Date')
|
38 |
-
->addColumn('request_xml', Varien_Db_Ddl_Table::TYPE_TEXT, 0, array(
|
39 |
-
'nullable' => false,
|
40 |
-
'default' => NULL,
|
41 |
-
), 'Request XML')
|
42 |
-
->addColumn('response_xml', Varien_Db_Ddl_Table::TYPE_TEXT, 0, array(
|
43 |
-
'nullable' => false,
|
44 |
-
'default' => NULL,
|
45 |
-
), 'Response XML')
|
46 |
-
->setComment('Log of requests to Vertex SMB');
|
47 |
-
$installer->getConnection()->createTable($table);
|
48 |
-
}
|
49 |
-
/*Customer Attribute*/
|
50 |
-
$entity = $this->getEntityTypeId('customer');
|
51 |
-
if(!$this->attributeExists($entity, 'customer_code'))
|
52 |
-
{
|
53 |
-
$this->addAttribute($entity, 'customer_code', array(
|
54 |
-
'type' => 'text',
|
55 |
-
'label' => 'Vertex SMB Customer Code',
|
56 |
-
'input' => 'text',
|
57 |
-
'visible' => TRUE,
|
58 |
-
'required' => FALSE,
|
59 |
-
'default_value' => '',
|
60 |
-
/* 'adminhtml_only' => '1',*/
|
61 |
-
'user_defined' => true,
|
62 |
-
/* 'used_in_forms' => array('adminhtml_customer')*/
|
63 |
-
));
|
64 |
-
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'customer_code');
|
65 |
-
$attribute->setData('used_in_forms', array('adminhtml_customer'))->save();
|
66 |
-
}
|
67 |
-
|
68 |
-
$this->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.3-0.1.4.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
$installer = $this;
|
9 |
-
$installer->startSetup();
|
10 |
-
|
11 |
-
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) == true) {
|
12 |
-
|
13 |
-
$installer->getConnection()->addColumn($installer->getTable('taxce/taxrequest'),
|
14 |
-
'source_path',
|
15 |
-
array(
|
16 |
-
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
17 |
-
'nullable' => false,
|
18 |
-
'default' => null,
|
19 |
-
'length' => 255,
|
20 |
-
'comment' => 'Source path controller_module_action'
|
21 |
-
)
|
22 |
-
);
|
23 |
-
|
24 |
-
}
|
25 |
-
|
26 |
-
$this->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.6-0.1.7.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
$installer = $this;
|
9 |
-
$installer->startSetup();
|
10 |
-
|
11 |
-
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) == true) {
|
12 |
-
|
13 |
-
$installer->getConnection()->addColumn($installer->getTable('taxce/taxrequest'),
|
14 |
-
'tax_area_id',
|
15 |
-
array(
|
16 |
-
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
17 |
-
'nullable' => false,
|
18 |
-
'default' => null,
|
19 |
-
'length' => 255,
|
20 |
-
'comment' => 'Tax Jurisdictions Id'
|
21 |
-
)
|
22 |
-
);
|
23 |
-
|
24 |
-
}
|
25 |
-
|
26 |
-
$this->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-0.1.7-0.1.8.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
$installer = $this;
|
9 |
-
$installer->startSetup();
|
10 |
-
|
11 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote_address'),
|
12 |
-
'tax_area_id',
|
13 |
-
array(
|
14 |
-
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
15 |
-
'nullable' => false,
|
16 |
-
'default' => null,
|
17 |
-
'length' => 255,
|
18 |
-
'comment' => 'Tax Jurisdiction Id'
|
19 |
-
)
|
20 |
-
);
|
21 |
-
|
22 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order_address'),
|
23 |
-
'tax_area_id',
|
24 |
-
array(
|
25 |
-
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
26 |
-
'nullable' => false,
|
27 |
-
'default' => null,
|
28 |
-
'length' => 255,
|
29 |
-
'comment' => 'Tax Jurisdiction Id'
|
30 |
-
)
|
31 |
-
);
|
32 |
-
|
33 |
-
$this->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/VertexSMB/TaxCE/sql/taxce_setup/mysql4-upgrade-1.1.0-1.1.1.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
|
8 |
-
$installer = $this;
|
9 |
-
$installer->startSetup();
|
10 |
-
|
11 |
-
|
12 |
-
if ($installer->getConnection()->isTableExists($installer->getTable('taxce/taxrequest')) == true) {
|
13 |
-
|
14 |
-
$installer->getConnection()->addColumn($installer->getTable('taxce/taxrequest'),
|
15 |
-
'sub_total',
|
16 |
-
array(
|
17 |
-
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
18 |
-
'nullable' => false,
|
19 |
-
'default' => null,
|
20 |
-
'length' => 255,
|
21 |
-
'comment' => 'Response Subtotal Amount'
|
22 |
-
)
|
23 |
-
);
|
24 |
-
|
25 |
-
$installer->getConnection()->addColumn($installer->getTable('taxce/taxrequest'),
|
26 |
-
'total',
|
27 |
-
array(
|
28 |
-
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
29 |
-
'nullable' => false,
|
30 |
-
'default' => null,
|
31 |
-
'length' => 255,
|
32 |
-
'comment' => 'Response Total Amount'
|
33 |
-
)
|
34 |
-
);
|
35 |
-
|
36 |
-
$installer->getConnection()->addColumn($installer->getTable('taxce/taxrequest'),
|
37 |
-
'lookup_result',
|
38 |
-
array(
|
39 |
-
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
40 |
-
'nullable' => false,
|
41 |
-
'default' => null,
|
42 |
-
'length' => 255,
|
43 |
-
'comment' => 'Tax Area Response Lookup Result'
|
44 |
-
)
|
45 |
-
);
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
$this->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/vertexsmb/addresschange-popup-content.phtml
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
?>
|
8 |
-
|
9 |
-
<?php $old_city = $this->getOldCity(); ?>
|
10 |
-
<?php $new_city = $this->getNewCity(); ?>
|
11 |
-
<?php $tax_area_id=$this->getTaxAreaId(); ?>
|
12 |
-
<div class="selectaddress-container step a-item" >
|
13 |
-
<div lass="col1-set">
|
14 |
-
<h3><?php echo $this->__('Your shipping address has been updated'); ?></h3>
|
15 |
-
<ul class="form-list">
|
16 |
-
|
17 |
-
<li class="control">
|
18 |
-
<label><?php echo $this->__('Original City: %s',ucwords(strtolower($old_city)) ); ?></label>
|
19 |
-
</li>
|
20 |
-
<li class="control">
|
21 |
-
<label><?php echo $this->__('Validated City: %s',ucwords(strtolower($new_city)) ); ?></label>
|
22 |
-
</li>
|
23 |
-
</ul>
|
24 |
-
<div class="buttons-set">
|
25 |
-
<p class="required"> </p>
|
26 |
-
<button onclick="javascript:void(0);" class="button" type="button" id="select-tax-area-button"><span><span><?php echo $this->__('Continue'); ?></span></span></button>
|
27 |
-
</div>
|
28 |
-
</div>
|
29 |
-
</div>
|
30 |
-
|
31 |
-
<script type="text/javascript">
|
32 |
-
$("popup-shadow").style.height=$("html-body").getHeight()+'px';
|
33 |
-
$('select-tax-area-id').style.display = "block";
|
34 |
-
$('popup-shadow').style.display = "block";
|
35 |
-
$('select-tax-area-button').observe('click', select_address);
|
36 |
-
|
37 |
-
function select_address(){
|
38 |
-
var tax_area_id="<?php echo $tax_area_id ?>";
|
39 |
-
if (tax_area_id=="undefined" || tax_area_id.length==0) {
|
40 |
-
alert('Please change address');
|
41 |
-
return false;
|
42 |
-
}
|
43 |
-
var new_city="<?php echo $new_city; ?>";
|
44 |
-
|
45 |
-
$('select-tax-area-id').style.display = "none";
|
46 |
-
$('popup-shadow').style.display = "none";
|
47 |
-
|
48 |
-
var request = new Ajax.Request(
|
49 |
-
'<?php echo Mage::getUrl('*/vertexSMB/saveTaxArea');?>' ,
|
50 |
-
{
|
51 |
-
method:'post',
|
52 |
-
onComplete: SelectAddressComplete,
|
53 |
-
parameters: {tax_area_id:tax_area_id, new_city:new_city},
|
54 |
-
}
|
55 |
-
);
|
56 |
-
|
57 |
-
|
58 |
-
}
|
59 |
-
|
60 |
-
function SelectAddressComplete(){
|
61 |
-
order.loadArea(['totals','shipping_address'], true, {} );
|
62 |
-
}
|
63 |
-
|
64 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/vertexsmb/popup-content.phtml
CHANGED
@@ -1,35 +1,40 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
3 |
* @package VertexSMB_TaxCE
|
|
|
4 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @
|
6 |
*/
|
7 |
?>
|
8 |
-
<?php $
|
9 |
-
<?php $
|
|
|
10 |
<div class="selectaddress-container step a-item" >
|
11 |
<div lass="col1-set">
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
33 |
<div class="buttons-set">
|
34 |
<p class="required"> </p>
|
35 |
<button onclick="javascript:void(0);" class="button" type="button" id="select-tax-area-button"><span><span><?php echo $this->__('Continue'); ?></span></span></button>
|
@@ -44,17 +49,23 @@
|
|
44 |
$('select-tax-area-button').observe('click', select_address);
|
45 |
|
46 |
function select_address(){
|
|
|
47 |
var tax_area_id=$$('input:checked[type="radio"][name="tax_area_id"]').pluck('value');
|
|
|
|
|
|
|
48 |
if (tax_area_id=="undefined" || tax_area_id.length==0) {
|
49 |
alert('Please select address');
|
50 |
return false;
|
51 |
}
|
|
|
52 |
var new_city=$('tax_city_'+tax_area_id).value;
|
53 |
-
|
|
|
|
|
54 |
$('select-tax-area-id').style.display = "none";
|
55 |
$('popup-shadow').style.display = "none";
|
56 |
|
57 |
-
|
58 |
var request = new Ajax.Request(
|
59 |
'<?php echo Mage::getUrl('*/vertexSMB/saveTaxArea');?>' ,
|
60 |
{
|
@@ -62,12 +73,10 @@
|
|
62 |
onComplete: SelectAddressComplete,
|
63 |
parameters: {tax_area_id:tax_area_id, new_city:new_city}
|
64 |
}
|
65 |
-
);
|
66 |
-
/* console.log(tax_area_id); */
|
67 |
}
|
68 |
|
69 |
function SelectAddressComplete(){
|
70 |
order.loadArea(['totals','shipping_address'], true, {} );
|
71 |
-
}
|
72 |
-
|
73 |
</script>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @category VertexSMB
|
4 |
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
*/
|
9 |
?>
|
10 |
+
<?php $responseCollection=$this->getItemsCollection(); ?>
|
11 |
+
<?php $firstItem=$this->getFirstItem();?>
|
12 |
+
<?php $isMultiple=$this->getIsMultiple();?>
|
13 |
<div class="selectaddress-container step a-item" >
|
14 |
<div lass="col1-set">
|
15 |
+
<?php if ($isMultiple): ?>
|
16 |
+
<h3><?php echo $this->__('Please verify your address'); ?></h3>
|
17 |
+
<ul class="form-list">
|
18 |
+
<li class="control"><?php echo $this->__('Your shipping address may be updated according to selection'); ?></li>
|
19 |
+
<?php foreach ($responseCollection as $taxResponse): ?>
|
20 |
+
<li class="control">
|
21 |
+
<input type="radio" class="radio" id="tax_area_id_<?php echo $taxResponse->getTaxAreaId(); ?>" value="<?php echo $taxResponse->getTaxAreaId(); ?>" name="tax_area_id">
|
22 |
+
<label for="tax_area_id_<?php echo $taxResponse->getTaxAreaId(); ?>"><?php echo $this->escapeHtml($taxResponse->getAreaName()); ?></label>
|
23 |
+
<input type="hidden" name="city_<?php echo $this->escapeHtml($taxResponse->getTaxAreaId()); ?>" id="tax_city_<?php echo $this->escapeHtml($taxResponse->getTaxAreaId()); ?>" value="<?php echo $this->escapeHtml($taxResponse->getTaxAreaCity()); ?>" />
|
24 |
+
</li>
|
25 |
+
<?php endforeach; ?>
|
26 |
+
</ul>
|
27 |
+
<?php else: ?>
|
28 |
+
<h3><?php echo $this->__('Your shipping address has been updated'); ?></h3>
|
29 |
+
<ul class="form-list">
|
30 |
+
<li class="control">
|
31 |
+
<label><?php echo $this->__('Original City: %s', $this->escapeHtml($firstItem->getRequestCity())); ?></label>
|
32 |
+
</li>
|
33 |
+
<li class="control">
|
34 |
+
<label><?php echo $this->__('Validated City: %s',$this->escapeHtml($firstItem->getTaxAreaCity())); ?></label>
|
35 |
+
</li>
|
36 |
+
</ul>
|
37 |
+
<?php endif;?>
|
38 |
<div class="buttons-set">
|
39 |
<p class="required"> </p>
|
40 |
<button onclick="javascript:void(0);" class="button" type="button" id="select-tax-area-button"><span><span><?php echo $this->__('Continue'); ?></span></span></button>
|
49 |
$('select-tax-area-button').observe('click', select_address);
|
50 |
|
51 |
function select_address(){
|
52 |
+
<?php if ($isMultiple):?>
|
53 |
var tax_area_id=$$('input:checked[type="radio"][name="tax_area_id"]').pluck('value');
|
54 |
+
<?php else:?>
|
55 |
+
var tax_area_id="<?php echo $firstItem->getTaxAreaId(); ?>";
|
56 |
+
<?php endif;?>
|
57 |
if (tax_area_id=="undefined" || tax_area_id.length==0) {
|
58 |
alert('Please select address');
|
59 |
return false;
|
60 |
}
|
61 |
+
<?php if ($isMultiple):?>
|
62 |
var new_city=$('tax_city_'+tax_area_id).value;
|
63 |
+
<?php else:?>
|
64 |
+
var new_city="<?php echo $this->escapeHtml($firstItem->getTaxAreaCity()); ?>";
|
65 |
+
<?php endif;?>
|
66 |
$('select-tax-area-id').style.display = "none";
|
67 |
$('popup-shadow').style.display = "none";
|
68 |
|
|
|
69 |
var request = new Ajax.Request(
|
70 |
'<?php echo Mage::getUrl('*/vertexSMB/saveTaxArea');?>' ,
|
71 |
{
|
73 |
onComplete: SelectAddressComplete,
|
74 |
parameters: {tax_area_id:tax_area_id, new_city:new_city}
|
75 |
}
|
76 |
+
);
|
|
|
77 |
}
|
78 |
|
79 |
function SelectAddressComplete(){
|
80 |
order.loadArea(['totals','shipping_address'], true, {} );
|
81 |
+
}
|
|
|
82 |
</script>
|
app/design/adminhtml/default/default/template/vertexsmb/popup.phtml
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
3 |
* @package VertexSMB_TaxCE
|
|
|
4 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @
|
6 |
*/
|
7 |
?>
|
8 |
<?php if (Mage::helper('taxce')->IsVertexSMBActive()): ?>
|
@@ -18,9 +20,7 @@
|
|
18 |
<div id="order-tax-area-load"></div>
|
19 |
</div>
|
20 |
<div id="popup-shadow" class="bg-shadow"> </div>
|
21 |
-
<script type="text/javascript">
|
22 |
-
|
23 |
-
|
24 |
order.loadArea= function(area, indicator, params){
|
25 |
var url = this.loadBaseUrl;
|
26 |
if (area) {
|
@@ -33,8 +33,7 @@
|
|
33 |
if (!this.loadingAreas) this.loadingAreas = [];
|
34 |
|
35 |
if (indicator) {
|
36 |
-
this.loadingAreas = area;
|
37 |
-
|
38 |
new Ajax.Request(url, {
|
39 |
parameters:params,
|
40 |
loaderArea: indicator,
|
@@ -44,8 +43,7 @@
|
|
44 |
|
45 |
}.bind(this),
|
46 |
|
47 |
-
onComplete: function() {
|
48 |
-
/*console.log(params['order[billing_address][city]']); */
|
49 |
if ( ( typeof area === 'string' && area!='header' && area!='totals' ) ||
|
50 |
( typeof area === 'object' && area[0]!='totals' && area[0]!='header' ) ||
|
51 |
(typeof params['order[billing_address][city]']!='undefined' || typeof params['order[shipping_address][city]']!='undefined') )
|
@@ -55,9 +53,7 @@
|
|
55 |
}
|
56 |
else {
|
57 |
new Ajax.Request(url, {parameters:params,loaderArea: indicator,
|
58 |
-
onComplete: function() {
|
59 |
-
|
60 |
-
/* Add more handlers to update tax area depend of parameters shipping & billing*/
|
61 |
if ( ( typeof area === 'string' && area!='header' && area!='totals' ) ||
|
62 |
( typeof area === 'object' && area[0]!='totals' && area[0]!='header' ) ||
|
63 |
(typeof params['order[billing_address][city]']!='undefined' || typeof params['order[shipping_address][city]']!='undefined') ) {
|
@@ -72,23 +68,19 @@
|
|
72 |
productConfigure.clean('quote_items');
|
73 |
}
|
74 |
}
|
75 |
-
|
76 |
-
|
77 |
function getTaxAreaId(params){
|
78 |
var request = new Ajax.Request(
|
79 |
-
'<?php echo Mage::getUrl('*/vertexSMB/
|
80 |
{
|
81 |
-
method:'post',
|
82 |
-
/* onComplete: SelectAddressComplete, */
|
83 |
onSuccess: SelectAddressSucess,
|
84 |
parameters: params
|
85 |
}
|
86 |
-
);
|
87 |
-
|
88 |
}
|
89 |
|
90 |
-
function SelectAddressSucess(transport){
|
91 |
-
|
92 |
if (transport && transport.responseText){
|
93 |
try{
|
94 |
response = eval('(' + transport.responseText + ')');
|
@@ -97,26 +89,19 @@
|
|
97 |
response = {};
|
98 |
}
|
99 |
}
|
100 |
-
|
101 |
if (response.error){
|
102 |
if ((typeof response.message) == 'string') {
|
103 |
alert(response.message);
|
104 |
} else {
|
105 |
alert(response.message.join("\n"));
|
106 |
}
|
107 |
-
|
108 |
return false;
|
109 |
}
|
110 |
-
if (response.message=='show_popup') {
|
111 |
-
|
112 |
-
$('order-tax-area-load').update(response.html);
|
113 |
-
|
114 |
} else {
|
115 |
order.loadArea(['totals','shipping_address'], true, {} );
|
116 |
-
}
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
|
121 |
</script>
|
122 |
<?php endif; ?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @category VertexSMB
|
4 |
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
*/
|
9 |
?>
|
10 |
<?php if (Mage::helper('taxce')->IsVertexSMBActive()): ?>
|
20 |
<div id="order-tax-area-load"></div>
|
21 |
</div>
|
22 |
<div id="popup-shadow" class="bg-shadow"> </div>
|
23 |
+
<script type="text/javascript">
|
|
|
|
|
24 |
order.loadArea= function(area, indicator, params){
|
25 |
var url = this.loadBaseUrl;
|
26 |
if (area) {
|
33 |
if (!this.loadingAreas) this.loadingAreas = [];
|
34 |
|
35 |
if (indicator) {
|
36 |
+
this.loadingAreas = area;
|
|
|
37 |
new Ajax.Request(url, {
|
38 |
parameters:params,
|
39 |
loaderArea: indicator,
|
43 |
|
44 |
}.bind(this),
|
45 |
|
46 |
+
onComplete: function() {
|
|
|
47 |
if ( ( typeof area === 'string' && area!='header' && area!='totals' ) ||
|
48 |
( typeof area === 'object' && area[0]!='totals' && area[0]!='header' ) ||
|
49 |
(typeof params['order[billing_address][city]']!='undefined' || typeof params['order[shipping_address][city]']!='undefined') )
|
53 |
}
|
54 |
else {
|
55 |
new Ajax.Request(url, {parameters:params,loaderArea: indicator,
|
56 |
+
onComplete: function() {
|
|
|
|
|
57 |
if ( ( typeof area === 'string' && area!='header' && area!='totals' ) ||
|
58 |
( typeof area === 'object' && area[0]!='totals' && area[0]!='header' ) ||
|
59 |
(typeof params['order[billing_address][city]']!='undefined' || typeof params['order[shipping_address][city]']!='undefined') ) {
|
68 |
productConfigure.clean('quote_items');
|
69 |
}
|
70 |
}
|
71 |
+
|
|
|
72 |
function getTaxAreaId(params){
|
73 |
var request = new Ajax.Request(
|
74 |
+
'<?php echo Mage::getUrl('*/vertexSMB/taxArea');?>' ,
|
75 |
{
|
76 |
+
method:'post',
|
|
|
77 |
onSuccess: SelectAddressSucess,
|
78 |
parameters: params
|
79 |
}
|
80 |
+
);
|
|
|
81 |
}
|
82 |
|
83 |
+
function SelectAddressSucess(transport){
|
|
|
84 |
if (transport && transport.responseText){
|
85 |
try{
|
86 |
response = eval('(' + transport.responseText + ')');
|
89 |
response = {};
|
90 |
}
|
91 |
}
|
|
|
92 |
if (response.error){
|
93 |
if ((typeof response.message) == 'string') {
|
94 |
alert(response.message);
|
95 |
} else {
|
96 |
alert(response.message.join("\n"));
|
97 |
}
|
|
|
98 |
return false;
|
99 |
}
|
100 |
+
if (response.message=='show_popup') {
|
101 |
+
$('order-tax-area-load').update(response.html);
|
|
|
|
|
102 |
} else {
|
103 |
order.loadArea(['totals','shipping_address'], true, {} );
|
104 |
+
}
|
105 |
+
}
|
|
|
|
|
|
|
106 |
</script>
|
107 |
<?php endif; ?>
|
app/design/frontend/base/default/template/vertexsmb/addresschange-popup-content.phtml
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package VertexSMB_TaxCE
|
4 |
-
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @author Alex Lukyanau
|
6 |
-
*/
|
7 |
-
?>
|
8 |
-
<?php $old_city = $this->getOldCity(); ?>
|
9 |
-
<?php $new_city = $this->getNewCity(); ?>
|
10 |
-
<?php $tax_area_id=$this->getTaxAreaId(); ?>
|
11 |
-
<div class="selectaddress-container step a-item" >
|
12 |
-
<div lass="col1-set">
|
13 |
-
<h3><?php echo $this->__('Your shipping address has been updated'); ?></h3>
|
14 |
-
<ul class="form-list">
|
15 |
-
|
16 |
-
<li class="control">
|
17 |
-
<label><?php echo $this->__('Original City: %s',ucwords(strtolower($old_city)) ); ?></label>
|
18 |
-
</li>
|
19 |
-
<li class="control">
|
20 |
-
<label><?php echo $this->__('Validated City: %s',ucwords(strtolower($new_city)) ); ?></label>
|
21 |
-
</li>
|
22 |
-
</ul>
|
23 |
-
<div class="buttons-set">
|
24 |
-
<p class="required"> </p>
|
25 |
-
<button onclick="javascript:void(0);" class="button" type="button" id="onepage-select-tax-area-button"><span><span><?php echo $this->__('Continue'); ?></span></span></button>
|
26 |
-
</div>
|
27 |
-
</div>
|
28 |
-
</div>
|
29 |
-
|
30 |
-
<script type="text/javascript">
|
31 |
-
|
32 |
-
$('opc-selectaddress').style.display = "block";
|
33 |
-
$('popup-shadow').style.display = "block";
|
34 |
-
$('onepage-select-tax-area-button').observe('click', select_address);
|
35 |
-
|
36 |
-
function select_address(){
|
37 |
-
var tax_area_id="<?php echo $tax_area_id ?>";
|
38 |
-
if (tax_area_id=="undefined" || tax_area_id.length==0) {
|
39 |
-
alert('Please change address');
|
40 |
-
return false;
|
41 |
-
}
|
42 |
-
var new_city="<?php echo $new_city; ?>";
|
43 |
-
|
44 |
-
$('opc-selectaddress').style.display = "none";
|
45 |
-
$('popup-shadow').style.display = "none";
|
46 |
-
if ( typeof shipping !== 'undefined' ) {
|
47 |
-
var success_event=shipping;
|
48 |
-
var form_object=$('co-shipping-form');
|
49 |
-
}else {
|
50 |
-
var success_event=billing;
|
51 |
-
var form_object=$('co-billing-form');
|
52 |
-
}
|
53 |
-
form_object.innerHTML +='<input id="tax_area_id_el" type="hidden" name="tax_area_id" value="'+tax_area_id+'" />\n\
|
54 |
-
<input id="tax_new_city_el" type="hidden" name="tax_new_city" value="'+new_city+'" />';
|
55 |
-
|
56 |
-
|
57 |
-
var request = new Ajax.Request(
|
58 |
-
'<?php echo Mage::getUrl('checkout/onepage/saveTaxArea');?>' ,
|
59 |
-
{
|
60 |
-
method:'post',
|
61 |
-
onComplete: SelectAddressComplete,
|
62 |
-
onSuccess: success_event.onSave,
|
63 |
-
parameters: form_object.serialize(true)
|
64 |
-
}
|
65 |
-
);
|
66 |
-
console.log(tax_area_id);
|
67 |
-
}
|
68 |
-
|
69 |
-
function SelectAddressComplete(){
|
70 |
-
$('tax_area_id_el').remove();
|
71 |
-
$('tax_new_city_el').remove();
|
72 |
-
checkout.reloadProgressBlock('billing');
|
73 |
-
checkout.reloadProgressBlock('shipping');
|
74 |
-
checkout.reloadProgressBlock('shipping_method');
|
75 |
-
checkout.reloadProgressBlock('payment_method');
|
76 |
-
}
|
77 |
-
|
78 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/vertexsmb/popup-content.phtml
CHANGED
@@ -1,35 +1,40 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
3 |
* @package VertexSMB_TaxCE
|
|
|
4 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @
|
6 |
*/
|
7 |
?>
|
8 |
-
<?php $
|
9 |
-
<?php $
|
|
|
10 |
<div class="selectaddress-container step a-item" >
|
11 |
<div lass="col1-set">
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
$
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
33 |
<div class="buttons-set">
|
34 |
<p class="required"> </p>
|
35 |
<button onclick="javascript:void(0);" class="button" type="button" id="onepage-select-tax-area-button"><span><span><?php echo $this->__('Continue'); ?></span></span></button>
|
@@ -37,23 +42,27 @@
|
|
37 |
</div>
|
38 |
</div>
|
39 |
|
40 |
-
<script type="text/javascript">
|
41 |
-
|
42 |
$('opc-selectaddress').style.display = "block";
|
43 |
$('popup-shadow').style.display = "block";
|
44 |
$('onepage-select-tax-area-button').observe('click', select_address);
|
45 |
|
46 |
function select_address(){
|
|
|
47 |
var tax_area_id=$$('input:checked[type="radio"][name="tax_area_id"]').pluck('value');
|
|
|
|
|
|
|
|
|
48 |
if (tax_area_id=="undefined" || tax_area_id.length==0) {
|
49 |
alert('Please select address');
|
50 |
return false;
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
var new_city=$('tax_city_'+tax_area_id).value;
|
55 |
-
|
56 |
-
|
|
|
57 |
$('opc-selectaddress').style.display = "none";
|
58 |
$('popup-shadow').style.display = "none";
|
59 |
if ( typeof shipping !== 'undefined' ) {
|
@@ -66,7 +75,6 @@
|
|
66 |
form_object.innerHTML +='<input id="tax_area_id_el" type="hidden" name="tax_area_id" value="'+tax_area_id+'" />\n\
|
67 |
<input id="tax_new_city_el" type="hidden" name="tax_new_city" value="'+new_city+'" />';
|
68 |
|
69 |
-
|
70 |
var request = new Ajax.Request(
|
71 |
'<?php echo Mage::getUrl('checkout/onepage/saveTaxArea');?>' ,
|
72 |
{
|
@@ -75,8 +83,7 @@
|
|
75 |
onSuccess: success_event.onSave,
|
76 |
parameters: form_object.serialize(true)
|
77 |
}
|
78 |
-
);
|
79 |
-
/* console.log(tax_area_id); */
|
80 |
}
|
81 |
|
82 |
function SelectAddressComplete(){
|
@@ -86,6 +93,5 @@
|
|
86 |
checkout.reloadProgressBlock('shipping');
|
87 |
checkout.reloadProgressBlock('shipping_method');
|
88 |
checkout.reloadProgressBlock('payment_method');
|
89 |
-
}
|
90 |
-
|
91 |
</script>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @category VertexSMB
|
4 |
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
*/
|
9 |
?>
|
10 |
+
<?php $responseCollection=$this->getItemsCollection(); ?>
|
11 |
+
<?php $firstItem=$this->getFirstItem();?>
|
12 |
+
<?php $isMultiple=$this->getIsMultiple();?>
|
13 |
<div class="selectaddress-container step a-item" >
|
14 |
<div lass="col1-set">
|
15 |
+
<?php if ($isMultiple):?>
|
16 |
+
<h3><?php echo $this->__('Please verify your address'); ?></h3>
|
17 |
+
<ul class="form-list">
|
18 |
+
<li class="control"><?php echo $this->__('Your shipping address may be updated according to selection'); ?></li>
|
19 |
+
<?php foreach ($responseCollection as $taxResponse): ?>
|
20 |
+
<li class="control">
|
21 |
+
<input type="radio" class="radio" id="tax_area_id_<?php echo $taxResponse->getTaxAreaId(); ?>" value="<?php echo $taxResponse->getTaxAreaId(); ?>" name="tax_area_id">
|
22 |
+
<label for="tax_area_id_<?php echo $taxResponse->getTaxAreaId(); ?>"><?php echo $this->escapeHtml($taxResponse->getAreaName()); ?></label>
|
23 |
+
<input type="hidden" name="city_<?php echo $this->escapeHtml($taxResponse->getTaxAreaId()); ?>" id="tax_city_<?php echo $this->escapeHtml($taxResponse->getTaxAreaId()); ?>" value="<?php echo $this->escapeHtml($taxResponse->getTaxAreaCity()); ?>" />
|
24 |
+
</li>
|
25 |
+
<?php endforeach; ?>
|
26 |
+
</ul>
|
27 |
+
<?php else: ?>
|
28 |
+
<h3><?php echo $this->__('Your shipping address has been updated'); ?></h3>
|
29 |
+
<ul class="form-list">
|
30 |
+
<li class="control">
|
31 |
+
<label><?php echo $this->__('Original City: %s', $this->escapeHtml($firstItem->getRequestCity())); ?></label>
|
32 |
+
</li>
|
33 |
+
<li class="control">
|
34 |
+
<label><?php echo $this->__('Validated City: %s',$this->escapeHtml($firstItem->getTaxAreaCity())); ?></label>
|
35 |
+
</li>
|
36 |
+
</ul>
|
37 |
+
<?php endif; ?>
|
38 |
<div class="buttons-set">
|
39 |
<p class="required"> </p>
|
40 |
<button onclick="javascript:void(0);" class="button" type="button" id="onepage-select-tax-area-button"><span><span><?php echo $this->__('Continue'); ?></span></span></button>
|
42 |
</div>
|
43 |
</div>
|
44 |
|
45 |
+
<script type="text/javascript">
|
|
|
46 |
$('opc-selectaddress').style.display = "block";
|
47 |
$('popup-shadow').style.display = "block";
|
48 |
$('onepage-select-tax-area-button').observe('click', select_address);
|
49 |
|
50 |
function select_address(){
|
51 |
+
<?php if ($isMultiple):?>
|
52 |
var tax_area_id=$$('input:checked[type="radio"][name="tax_area_id"]').pluck('value');
|
53 |
+
<?php else: ?>
|
54 |
+
var tax_area_id="<?php echo $firstItem->getTaxAreaId(); ?>";
|
55 |
+
<?php endif;?>
|
56 |
+
|
57 |
if (tax_area_id=="undefined" || tax_area_id.length==0) {
|
58 |
alert('Please select address');
|
59 |
return false;
|
60 |
+
}
|
61 |
+
<?php if ($isMultiple):?>
|
|
|
62 |
var new_city=$('tax_city_'+tax_area_id).value;
|
63 |
+
<?php else: ?>
|
64 |
+
var new_city="<?php echo $this->escapeHtml($firstItem->getTaxAreaCity()); ?>";
|
65 |
+
<?php endif;?>
|
66 |
$('opc-selectaddress').style.display = "none";
|
67 |
$('popup-shadow').style.display = "none";
|
68 |
if ( typeof shipping !== 'undefined' ) {
|
75 |
form_object.innerHTML +='<input id="tax_area_id_el" type="hidden" name="tax_area_id" value="'+tax_area_id+'" />\n\
|
76 |
<input id="tax_new_city_el" type="hidden" name="tax_new_city" value="'+new_city+'" />';
|
77 |
|
|
|
78 |
var request = new Ajax.Request(
|
79 |
'<?php echo Mage::getUrl('checkout/onepage/saveTaxArea');?>' ,
|
80 |
{
|
83 |
onSuccess: success_event.onSave,
|
84 |
parameters: form_object.serialize(true)
|
85 |
}
|
86 |
+
);
|
|
|
87 |
}
|
88 |
|
89 |
function SelectAddressComplete(){
|
93 |
checkout.reloadProgressBlock('shipping');
|
94 |
checkout.reloadProgressBlock('shipping_method');
|
95 |
checkout.reloadProgressBlock('payment_method');
|
96 |
+
}
|
|
|
97 |
</script>
|
app/design/frontend/base/default/template/vertexsmb/popup.phtml
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
3 |
* @package VertexSMB_TaxCE
|
|
|
4 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
5 |
-
* @
|
6 |
*/
|
7 |
?>
|
8 |
<?php if (Mage::helper('taxce')->IsVertexSMBActive()): ?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @category VertexSMB
|
4 |
* @package VertexSMB_TaxCE
|
5 |
+
* @author Alex Lukyanau <alukyanau@netatwork.com>
|
6 |
* @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL 3.0)
|
7 |
+
* @link http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-vertex-smb-1.html
|
8 |
*/
|
9 |
?>
|
10 |
<?php if (Mage::helper('taxce')->IsVertexSMBActive()): ?>
|
app/etc/modules/VertexSMB_TaxCE.xml
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
<modules>
|
11 |
<VertexSMB_TaxCE>
|
12 |
<active>true</active>
|
13 |
-
<codePool>
|
14 |
<depends>
|
15 |
<Mage_Core/>
|
16 |
<Mage_Tax/>
|
10 |
<modules>
|
11 |
<VertexSMB_TaxCE>
|
12 |
<active>true</active>
|
13 |
+
<codePool>community</codePool>
|
14 |
<depends>
|
15 |
<Mage_Core/>
|
16 |
<Mage_Tax/>
|
package.xml
CHANGED
@@ -1,24 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>VertexSMB_TaxCE</name>
|
4 |
-
<version>1.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/OSL-3.0">OSL 3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Sales and Use Tax Automation</summary>
|
10 |
<description>Built on industry-leading Vertex software, Vertex SMB offers a proven, accurate, and simple sales and use tax solution for small to medium-sized businesses that integrates directly with Magento. This cloud-based, scalable solution allows customers to manage complex sales and use tax across multiple jurisdictions and states. Vertex SMB runs on a pay-as-you-go pricing model with no upfront fees, and provides tax calculations and returns in one comprehensive solution, resulting in signature-ready PDF returns at no additional charge.</description>
|
11 |
-
<notes>-
|
12 |
-
-
|
13 |
-
-
|
14 |
-
- Tax Jurisdiction request used only for addresses from USA
|
15 |
-
- Added country field for each request
|
16 |
-

|
17 |
-
Please select your country after extension updated at the System->Configuration->Tax->VertexSMB Company Information</notes>
|
18 |
<authors><author><name>Vertex SMB</name><user>VertexSMB</user><email>support@vertexSMB.com</email></author></authors>
|
19 |
-
<date>2015-
|
20 |
-
<time>
|
21 |
-
<contents><target name="
|
22 |
<compatible/>
|
23 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
24 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>VertexSMB_TaxCE</name>
|
4 |
+
<version>1.1.8</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/OSL-3.0">OSL 3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Sales and Use Tax Automation</summary>
|
10 |
<description>Built on industry-leading Vertex software, Vertex SMB offers a proven, accurate, and simple sales and use tax solution for small to medium-sized businesses that integrates directly with Magento. This cloud-based, scalable solution allows customers to manage complex sales and use tax across multiple jurisdictions and states. Vertex SMB runs on a pay-as-you-go pricing model with no upfront fees, and provides tax calculations and returns in one comprehensive solution, resulting in signature-ready PDF returns at no additional charge.</description>
|
11 |
+
<notes>- Fixed issues with shipping outside of US
|
12 |
+
- Added indexes for log table
|
13 |
+
- Code refactor to be compliant with Zend, PSR-2, ECG standards</notes>
|
|
|
|
|
|
|
|
|
14 |
<authors><author><name>Vertex SMB</name><user>VertexSMB</user><email>support@vertexSMB.com</email></author></authors>
|
15 |
+
<date>2015-12-01</date>
|
16 |
+
<time>15:17:46</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="VertexSMB"><dir name="TaxCE"><dir name="Block"><dir name="Adminhtml"><dir name="Order"><file name="View.php" hash="0c71fde0a3381e620010543489bc7d79"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="ShippingCodes.php" hash="5b5966d05967c65d55d4f55e1dd48823"/><file name="VertexSMBStatus.php" hash="fff6183beb7bbbe508e7bc8f1a0975f3"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Config.php" hash="18bbe2b1dd04da3ae9494d210c41e538"/><file name="Data.php" hash="8646cef0f26b117d1a9f8c91bc6c936d"/></dir><dir name="Model"><file name="Observer.php" hash="61789c61234de224ca03fec0bec2f23d"/><file name="RequestItem.php" hash="eeec5694f730b8f4b64975ccf1921aab"/><dir name="Resource"><file name="Setup.php" hash="a759f3530248833b174a03126c8a56e1"/><dir name="TaxRequest"><file name="Collection.php" hash="165352096bcb0d6423a7e1969567342d"/></dir><file name="TaxRequest.php" hash="80bad0a0d1ea1e7f879e454f7abfe5ee"/></dir><dir name="Source"><file name="Taxinvoice.php" hash="391457721cd57ce1b630ade80ce01a14"/></dir><dir name="Tax"><dir name="Sales"><dir name="Total"><dir name="Quote"><file name="Tax.php" hash="70cbf4ec5b4e1fe90c903b6506c120da"/></dir></dir></dir></dir><file name="TaxAreaRequest.php" hash="3b05b4cfd10bbc3f929b51b131a03407"/><file name="TaxAreaResponse.php" hash="21fffd3778f8fca01b37f0453f1bb626"/><file name="TaxInvoice.php" hash="968926fdead75059f2436075862842d7"/><file name="TaxQuote.php" hash="b04c1691d7ac281e2d151e29ebac64d2"/><file name="TaxQuoteResponse.php" hash="171d8efa589f3643f77fe902f7b56d95"/><file name="TaxRequest.php" hash="829e397ee86cd865ce230f92588257cf"/><file name="VertexSMB.php" hash="8cb2eab2e1b9e0471480a072a4c1564c"/></dir><dir name="controllers"><file name="OnepageController.php" hash="e39bb71eaa34ef3294d67e9094ec21cd"/><file name="VertexSMBController.php" hash="00815a28fc261797bdcf1881646c0355"/></dir><dir name="data"><dir name="taxce_setup"><file name="data-install-0.1.1.php" hash="eb0c83abb7468c49e530fb4f68eee7a2"/><file name="data-upgrade-0.1.4-0.1.5.php" hash="5b461f6d051011af5a38289563001f23"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="886d37facaef0fda4a23d3e01c873658"/><file name="config.xml" hash="a71272c32095a362a9cbeb6f31e4adb1"/><file name="system.xml" hash="b3b03c0bfd1f54ee01894fd544622454"/></dir><dir name="sql"><dir name="taxce_setup"><file name="mysql4-install-0.1.1.php" hash="e8d02a78bd7a91c2f8f97f92fcc9af39"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="49f22b8e2d8994c8f1d77ab8058b645b"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="2a47ae37ebaeae5d96e926bb2269289a"/><file name="mysql4-upgrade-0.1.7-0.1.8.php" hash="9a46018ae459daaa5ab496dd6b78868c"/><file name="mysql4-upgrade-1.1.0-1.1.1.php" hash="7a78e8565516cf2964bf1b5da15e423f"/><file name="mysql4-upgrade-1.1.6-1.1.7.php" hash="1b17be0bf1ec6eb443f2b25e347ceed9"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="VertexSMB_TaxCE.xml" hash="c75121be082bfe445f0991cbc75c7e64"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vertexsmb.xml" hash="53772aad58b12196ccd043376f7883fb"/></dir><dir name="template"><dir name="vertexsmb"><file name="popup-content.phtml" hash="2a78f4000216b99bf34914200d50099a"/><file name="popup.phtml" hash="4a8d74fff966850178f78525f292ea5b"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="vertexsmb.xml" hash="3d1acd91ba402257f8ce2b4df89dce9f"/></dir><dir name="template"><dir name="vertexsmb"><file name="popup-content.phtml" hash="064559022bfd41cfe96398bc0470006a"/><file name="popup.phtml" hash="38dc8cdd0f6080cc24a3548e1c77c66e"/></dir></dir></dir></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|