Version Notes
Initial Release.
Download this release
Release Info
Developer | Wolters Kluwer |
Extension | WoltersKluwer_CchSureTax |
Version | 1.0.3 |
Comparing to | |
See all releases |
Version 1.0.3
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Creditmemos/Container.php +26 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Creditmemos/Container/Grid.php +190 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container.php +28 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Edit.php +45 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Edit/Form.php +155 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Grid.php +138 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Select/Container.php +29 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Select/Container/Grid.php +152 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container.php +26 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Edit.php +50 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Edit/Form.php +131 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Grid.php +100 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Select/Container.php +29 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Select/Container/Grid.php +83 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Grid.php +89 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Help/Container.php +179 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Invoices/Container.php +26 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Invoices/Container/Grid.php +193 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig.php +21 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit.php +32 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit/Form.php +23 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit/Tab/Advanced.php +50 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit/Tab/Basic.php +166 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit/Tabs.php +41 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Websitestore/Container.php +21 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Websitestore/Container/Edit.php +30 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Websitestore/Container/Edit/Form.php +273 -0
- app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Websitestore/Container/Grid.php +233 -0
- app/code/community/WoltersKluwer/CchSureTax/Helper/Config.php +417 -0
- app/code/community/WoltersKluwer/CchSureTax/Helper/Constants.php +222 -0
- app/code/community/WoltersKluwer/CchSureTax/Helper/Data.php +72 -0
- app/code/community/WoltersKluwer/CchSureTax/Helper/Env.php +15 -0
- app/code/community/WoltersKluwer/CchSureTax/Helper/Utility.php +1110 -0
- app/code/community/WoltersKluwer/CchSureTax/Helper/WebService.php +2867 -0
- app/code/community/WoltersKluwer/CchSureTax/Helper/WebServiceInterface.php +294 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Creditmemo.php +17 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Customer.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Customergroup.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Info.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Invoice.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Observer.php +323 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Corecustomer/Collection.php +18 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Creditmemo.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Creditmemo/Collection.php +92 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Customer.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Customer/Collection.php +64 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Customergroup.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Customergroup/Collection.php +34 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Info.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Info/Collection.php +17 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Invoice.php +15 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Invoice/Collection.php +99 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Setup.php +12 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Websitestore/Config.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Websitestore/Config/Collection.php +106 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Tax/Sales/Total/Quote/Giftwrap.php +82 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Tax/Sales/Total/Quote/Tax.php +380 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Websitestore/Config.php +16 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Ws/SureTaxAddress.php +124 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Ws/SureTaxClient.php +305 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Ws/SureTaxItem.php +365 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Ws/SureTaxRequest.php +193 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Ws/TaxAdjustmentItem.php +467 -0
- app/code/community/WoltersKluwer/CchSureTax/Model/Ws/TaxAdjustmentRequest.php +194 -0
- app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/ConfigController.php +82 -0
- app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/CreditmemosController.php +274 -0
- app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/CustomerController.php +161 -0
- app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/CustomergroupController.php +152 -0
- app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/HelpController.php +23 -0
- app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/InvoicesController.php +277 -0
- app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/WebsitestoreController.php +136 -0
- app/code/community/WoltersKluwer/CchSureTax/etc/adminhtml.xml +108 -0
- app/code/community/WoltersKluwer/CchSureTax/etc/config.xml +189 -0
- app/code/community/WoltersKluwer/CchSureTax/sql/suretax_setup/install-1.0.0.php +315 -0
- app/design/adminhtml/default/default/layout/cchsuretax.xml +98 -0
- app/etc/modules/WoltersKluwer_CchSureTax.xml +9 -0
- package.xml +18 -0
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Creditmemos/Container.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Credit memo grid container
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Creditmemos_Container extends Mage_Adminhtml_Block_Widget_Grid_Container
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->_objectId = 'creditmemos_id';
|
15 |
+
$this->_blockGroup = 'suretax';
|
16 |
+
$this->_controller = 'adminhtml_creditmemos_container';
|
17 |
+
|
18 |
+
parent::__construct();
|
19 |
+
$this->_removeButton('add');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getHeaderText()
|
23 |
+
{
|
24 |
+
return Mage::helper('suretax')->__('SureTax Credit Memos');
|
25 |
+
}
|
26 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Creditmemos/Container/Grid.php
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Credit memo grid
|
4 |
+
*
|
5 |
+
* Grid displaying all of Magento's credit memo joined with SureTax credit memo
|
6 |
+
* to accurately display which credit memo has been finalized in SureTax.
|
7 |
+
*
|
8 |
+
* @category WoltersKluwer
|
9 |
+
* @package WoltersKluwer_CchSureTax
|
10 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
11 |
+
*/
|
12 |
+
|
13 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Creditmemos_Container_Grid
|
14 |
+
extends WoltersKluwer_CchSureTax_Block_Adminhtml_Grid
|
15 |
+
{
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
$this->setId('suretaxCreditMemosGrid');
|
20 |
+
$this->setDefaultSort('increment_id');
|
21 |
+
$this->setDefaultDir('DESC');
|
22 |
+
$this->setSaveParametersInSession(true);
|
23 |
+
}
|
24 |
+
|
25 |
+
//Load the collection of SureTax Order.
|
26 |
+
protected function _prepareCollection()
|
27 |
+
{
|
28 |
+
$collection = WoltersKluwer_CchSureTax_Model_Resource_Creditmemo_Collection::joinWithCreditmemo();
|
29 |
+
$this->setCollection($collection);
|
30 |
+
return parent::_prepareCollection();
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _prepareMassaction()
|
34 |
+
{
|
35 |
+
$this->setMassactionIdField('main_table.entity_id');
|
36 |
+
$this->getMassactionBlock()->setFormFieldName('creditmemo_ids');
|
37 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
38 |
+
|
39 |
+
$this->getMassactionBlock()->addItem(
|
40 |
+
'suretax_finalize', array(
|
41 |
+
'label'=> Mage::helper('sales')->__('Batch Finalize'),
|
42 |
+
'url' => $this->getUrl('*/*/batchFinalize'),
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _prepareColumns()
|
50 |
+
{
|
51 |
+
$this->addColumn(
|
52 |
+
'increment_id', array(
|
53 |
+
'header' => Mage::helper('suretax')->__('Credit Memo #'),
|
54 |
+
'width' => '100px',
|
55 |
+
'index' => 'increment_id',
|
56 |
+
'filter_index' => 'main_table.increment_id',
|
57 |
+
'type' => 'text'
|
58 |
+
)
|
59 |
+
);
|
60 |
+
|
61 |
+
$this->addColumn(
|
62 |
+
'created_at', array(
|
63 |
+
'header' => Mage::helper('suretax')->__('Created At'),
|
64 |
+
'width' => '150px',
|
65 |
+
'index' => 'created_at',
|
66 |
+
'filter_index' => 'main_table.created_at',
|
67 |
+
'type' => 'datetime'
|
68 |
+
)
|
69 |
+
);
|
70 |
+
|
71 |
+
$this->addColumn(
|
72 |
+
'order_number', array(
|
73 |
+
'header' => Mage::helper('suretax')->__('Order #'),
|
74 |
+
'width' => '100px',
|
75 |
+
'index' => 'order_number',
|
76 |
+
'filter_index' => 'order.increment_id',
|
77 |
+
'type' => 'text'
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
$this->addColumn(
|
82 |
+
'tax_amount', array(
|
83 |
+
'header' => Mage::helper('suretax')->__('Magento Tax Refunded'),
|
84 |
+
'index' => 'tax_amount',
|
85 |
+
'filter_index' => 'main_table.tax_amount',
|
86 |
+
'type' => 'currency',
|
87 |
+
'currency' => 'order_currency_code'
|
88 |
+
)
|
89 |
+
);
|
90 |
+
|
91 |
+
$this->addColumn(
|
92 |
+
'tax', array(
|
93 |
+
'header' => Mage::helper('suretax')->__('SureTax Refunded Tax'),
|
94 |
+
'width' => '100',
|
95 |
+
'index' => 'tax',
|
96 |
+
'filter_index' => 'sure.tax',
|
97 |
+
'type' => 'currency',
|
98 |
+
'currency' => 'order_currency_code'
|
99 |
+
)
|
100 |
+
);
|
101 |
+
|
102 |
+
$this->addColumn(
|
103 |
+
'tax_difference', array(
|
104 |
+
'header' => Mage::helper('suretax')->__('Difference'),
|
105 |
+
'width' => '100',
|
106 |
+
'index' => 'tax_difference',
|
107 |
+
'filter' => false,
|
108 |
+
'type' => 'currency',
|
109 |
+
'currency' => 'order_currency_code'
|
110 |
+
)
|
111 |
+
);
|
112 |
+
|
113 |
+
$this->addColumn(
|
114 |
+
'trans_id', array(
|
115 |
+
'header' => Mage::helper('suretax')->__('SureTax Trans ID'),
|
116 |
+
'width' => '100px',
|
117 |
+
'index' => 'trans_id',
|
118 |
+
'filter_index' => 'sure.trans_id',
|
119 |
+
'type' => 'text'
|
120 |
+
)
|
121 |
+
);
|
122 |
+
|
123 |
+
$this->addColumn(
|
124 |
+
'client_tracking', array(
|
125 |
+
'header' => Mage::helper('suretax')->__('Client Tracking'),
|
126 |
+
'index' => 'client_tracking',
|
127 |
+
'filter_index' => 'sure.client_tracking',
|
128 |
+
'type' => 'text'
|
129 |
+
)
|
130 |
+
);
|
131 |
+
|
132 |
+
$this->addColumn(
|
133 |
+
'status', array(
|
134 |
+
'header' => Mage::helper('suretax')->__('SureTax Status'),
|
135 |
+
'index' => 'status',
|
136 |
+
'filter_index' => 'sure.status',
|
137 |
+
'type' => 'options',
|
138 |
+
'options' => WoltersKluwer_CchSureTax_Helper_Constants::$SURETAX_STATUS
|
139 |
+
)
|
140 |
+
);
|
141 |
+
|
142 |
+
$this->addColumn(
|
143 |
+
'notes', array(
|
144 |
+
'header' => Mage::helper('suretax')->__('Notes'),
|
145 |
+
'width' => '200px',
|
146 |
+
'index' => 'notes',
|
147 |
+
'filter_index' => 'sure.notes',
|
148 |
+
'type' => 'text'
|
149 |
+
)
|
150 |
+
);
|
151 |
+
|
152 |
+
$this->addColumn(
|
153 |
+
'action',
|
154 |
+
array(
|
155 |
+
'header' => Mage::helper('sales')->__('Action'),
|
156 |
+
'width' => '50px',
|
157 |
+
'type' => 'action',
|
158 |
+
'getter' => 'getId',
|
159 |
+
'actions' => array(
|
160 |
+
array(
|
161 |
+
'caption' => Mage::helper('sales')->__('View'),
|
162 |
+
'url' => array('base'=>'*/sales_creditmemo/view'),
|
163 |
+
'field' => 'creditmemo_id'
|
164 |
+
)
|
165 |
+
),
|
166 |
+
'filter' => false,
|
167 |
+
'sortable' => false,
|
168 |
+
'is_system' => true
|
169 |
+
)
|
170 |
+
);
|
171 |
+
|
172 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('suretax')->__('CSV'));
|
173 |
+
$this->addExportType('*/*/exportXml', Mage::helper('suretax')->__('Excel XML'));
|
174 |
+
return parent::_prepareColumns();
|
175 |
+
}
|
176 |
+
|
177 |
+
public function getRowUrl($row)
|
178 |
+
{
|
179 |
+
if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/creditmemo')) {
|
180 |
+
return false;
|
181 |
+
}
|
182 |
+
|
183 |
+
return $this->getUrl(
|
184 |
+
'*/sales_creditmemo/view',
|
185 |
+
array(
|
186 |
+
'creditmemo_id'=> $row->getId(),
|
187 |
+
)
|
188 |
+
);
|
189 |
+
}
|
190 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Grid container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customer_Container extends Mage_Adminhtml_Block_Widget_Grid_Container
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->_objectId = 'customer_id';
|
15 |
+
$this->_blockGroup = 'suretax';
|
16 |
+
$this->_controller = 'adminhtml_customer_container';
|
17 |
+
parent::__construct();
|
18 |
+
|
19 |
+
$this->_updateButton('add', 'label', Mage::helper('suretax')->__('Add Customer Configuration'));
|
20 |
+
$this->_updateButton('add', 'id', 'customer_save_button');
|
21 |
+
$this->_updateButton('add', 'onclick', 'setLocation(\''.$this->getUrl('*/*/selectCustomer/').'\')');
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getHeaderText()
|
25 |
+
{
|
26 |
+
return Mage::helper('suretax')->__('SureTax Configurations For Customer');
|
27 |
+
}
|
28 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer form edit container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customer_Container_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->_objectId = 'suretaxId';
|
15 |
+
parent::__construct();
|
16 |
+
$this->_blockGroup = 'suretax';
|
17 |
+
$this->_controller = 'adminhtml_customer_container';
|
18 |
+
$this->_updateButton('save', 'label', Mage::helper('suretax')->__('Save Customer Configuration'));
|
19 |
+
$this->_updateButton('back', 'label', Mage::helper('suretax')->__('Cancel'));
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getHeaderText()
|
23 |
+
{
|
24 |
+
$customerConfig = Mage::registry('customerConfig');
|
25 |
+
$nm = $customerConfig['name'];
|
26 |
+
$suretaxCustomerId = $customerConfig['suretaxCustId'];
|
27 |
+
|
28 |
+
if (!($suretaxCustomerId === null)) {
|
29 |
+
return Mage::helper('suretax')->__('Edit SureTax Configuration For Customer ' . $nm);
|
30 |
+
} else {
|
31 |
+
return Mage::helper('suretax')->__('Create SureTax Configuration For Customer ' . $nm);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getFormActionUrl()
|
36 |
+
{
|
37 |
+
return $this->getUrl('*/suretax_customer/save/');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getDeleteUrl()
|
41 |
+
{
|
42 |
+
$customerConfig = Mage::registry('customerConfig');
|
43 |
+
return $this->getUrl('*/suretax_customer/delete/', array('suretaxId'=>$customerConfig['suretaxCustId']));
|
44 |
+
}
|
45 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Edit/Form.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Edit Form.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
|
11 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customer_Container_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
12 |
+
{
|
13 |
+
public function _prepareForm()
|
14 |
+
{
|
15 |
+
$form = new Varien_Data_Form(
|
16 |
+
array(
|
17 |
+
'id'=>'edit_form',
|
18 |
+
'action'=>$this->getData('action'),
|
19 |
+
'method'=>'post'
|
20 |
+
)
|
21 |
+
);
|
22 |
+
|
23 |
+
$customerConfig = Mage::registry('customerConfig');
|
24 |
+
$customerId = $customerConfig['customerId'];
|
25 |
+
$customerGroupId = $customerConfig['customerGroupId'];
|
26 |
+
|
27 |
+
$suretaxCustomer = Mage::getModel(Constants::CUST_TBL)
|
28 |
+
->load($customerId, 'suretax_customer_id');
|
29 |
+
|
30 |
+
$salesTypeCode = $customerConfig['sales_type_code'];
|
31 |
+
$exemptionCode = $customerConfig['exemption_code'];
|
32 |
+
$exemptionReason = $customerConfig['exemption_reason'];
|
33 |
+
|
34 |
+
if (!($customerGroupId === null)) {
|
35 |
+
$custId = $suretaxCustomer->getId();
|
36 |
+
|
37 |
+
if (empty($custId)) {
|
38 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
39 |
+
'inside with customer group id ' . $customerGroupId
|
40 |
+
. 'use customer group settings',
|
41 |
+
Zend_Log::DEBUG
|
42 |
+
);
|
43 |
+
|
44 |
+
$sureTaxCustomerGroup = Mage::getModel(Constants::CUST_GRP_TBL)
|
45 |
+
->load($customerGroupId, 'suretax_customer_group_id');
|
46 |
+
$sureTaxCustomerGroupId = $sureTaxCustomerGroup->getId();
|
47 |
+
|
48 |
+
if (!empty($sureTaxCustomerGroupId)) {
|
49 |
+
$salesTypeCode = $sureTaxCustomerGroup->getSalesTypeCode();
|
50 |
+
$exemptionCode = $sureTaxCustomerGroup->getExemptionCode();
|
51 |
+
$exemptionReason = $sureTaxCustomerGroup->getExemptionReasonCode();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
$fieldset = $form->addFieldset(
|
57 |
+
'suretax_fieldset', array(
|
58 |
+
'legend' => Mage::helper('customer')->__('SureTax Information')
|
59 |
+
)
|
60 |
+
);
|
61 |
+
|
62 |
+
$fieldset->addField(
|
63 |
+
'sales_type_code', 'select', array(
|
64 |
+
'name' => 'sales_type_code',
|
65 |
+
'label' => Mage::helper('customer')->__('Sales Type Code'),
|
66 |
+
'title' => Mage::helper('customer')->__('Sales Type Code'),
|
67 |
+
'class' => 'required-entry',
|
68 |
+
'required' => true,
|
69 |
+
'value' => isset($salesTypeCode) ? $salesTypeCode : $this->__('Residential customer'),
|
70 |
+
'values' => Constants::$SALES_TYPE_CODES
|
71 |
+
)
|
72 |
+
);
|
73 |
+
|
74 |
+
$disable = false;
|
75 |
+
if (isset($exemptionCode)) {
|
76 |
+
if ($exemptionCode == 'None') {
|
77 |
+
$disable = true;
|
78 |
+
}
|
79 |
+
} else {
|
80 |
+
$disable = true;
|
81 |
+
}
|
82 |
+
|
83 |
+
$exemptionCodeSet = $fieldset->addField(
|
84 |
+
'exemption_code', 'select', array(
|
85 |
+
'name' => 'exemption_code',
|
86 |
+
'label' => Mage::helper('customer')->__('Exemption Code'),
|
87 |
+
'title' => Mage::helper('customer')->__('Exemption Code'),
|
88 |
+
'class' => 'required-entry',
|
89 |
+
'onchange'=>'getExemptionReason(this)',
|
90 |
+
'required' => true,
|
91 |
+
'value' => $exemptionCode,
|
92 |
+
'values' => Constants::$EXEMPTION_TYPE_CODES
|
93 |
+
)
|
94 |
+
);
|
95 |
+
|
96 |
+
$fieldset->addField(
|
97 |
+
'exemption_reason', 'select', array(
|
98 |
+
'name' => 'exemption_reason',
|
99 |
+
'label' => Mage::helper('customer')->__('Exemption Reason'),
|
100 |
+
'title' => Mage::helper('customer')->__('Exemption Reason'),
|
101 |
+
'class' => 'required-entry',
|
102 |
+
'required' => true,
|
103 |
+
'disabled' => $disable,
|
104 |
+
'value' => $exemptionReason,
|
105 |
+
'values' => Constants::$EXEMPTION_REASON_CODES
|
106 |
+
)
|
107 |
+
);
|
108 |
+
|
109 |
+
$exemptionCodeSet->setAfterElementHtml(
|
110 |
+
"<script type = \"text/javascript\">
|
111 |
+
|
112 |
+
function getExemptionReason(selectElement) {
|
113 |
+
if(selectElement.value == 'None') {
|
114 |
+
$('exemption_reason').value = 'None';
|
115 |
+
$('exemption_reason').disabled = true;
|
116 |
+
}else {
|
117 |
+
$('exemption_reason').disabled = false;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
</script>"
|
121 |
+
);
|
122 |
+
|
123 |
+
if (!($suretaxCustomer->getId() === null)) {
|
124 |
+
$form->addField(
|
125 |
+
'suretaxCustomerId', 'hidden', array(
|
126 |
+
'name' => 'suretaxCustomerId',
|
127 |
+
'value' => $suretaxCustomer->getId(),
|
128 |
+
)
|
129 |
+
);
|
130 |
+
}
|
131 |
+
|
132 |
+
if (!($customerId === null)) {
|
133 |
+
$form->addField(
|
134 |
+
'customerId', 'hidden', array(
|
135 |
+
'name' => 'id',
|
136 |
+
'value' => $customerId,
|
137 |
+
)
|
138 |
+
);
|
139 |
+
}
|
140 |
+
|
141 |
+
if (!($customerGroupId === null)) {
|
142 |
+
$form->addField(
|
143 |
+
'customerGroupId', 'hidden', array(
|
144 |
+
'name' => 'customerGroupId',
|
145 |
+
'value' => $customerGroupId,
|
146 |
+
)
|
147 |
+
);
|
148 |
+
}
|
149 |
+
|
150 |
+
$form->setUseContainer(true);
|
151 |
+
$this->setForm($form);
|
152 |
+
|
153 |
+
return parent::_prepareForm();
|
154 |
+
}
|
155 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Grid.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer grid.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customer_Container_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->setUseAjax(true);
|
15 |
+
parent::__construct();
|
16 |
+
$this->setId('sureTaxCustomerGrid');
|
17 |
+
$this->setDefaultSort('entity_id');
|
18 |
+
$this->setSaveParametersInSession(true);
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareCollection()
|
22 |
+
{
|
23 |
+
$collection = WoltersKluwer_CchSureTax_Model_Resource_Customer_Collection::joinWithCustomer();
|
24 |
+
$this->setCollection($collection);
|
25 |
+
return parent::_prepareCollection();
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _prepareColumns()
|
29 |
+
{
|
30 |
+
$this->addColumn(
|
31 |
+
'entity_id', array(
|
32 |
+
'header' => Mage::helper('suretax')->__('ID'),
|
33 |
+
'width' => '50px',
|
34 |
+
'index' => 'entity_id',
|
35 |
+
'type' => 'number',
|
36 |
+
)
|
37 |
+
);
|
38 |
+
|
39 |
+
$this->addColumn(
|
40 |
+
'name', array(
|
41 |
+
'header' => Mage::helper('suretax')->__('Name'),
|
42 |
+
'index' => 'name'
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
$this->addColumn(
|
47 |
+
'email', array(
|
48 |
+
'header' => Mage::helper('suretax')->__('Email'),
|
49 |
+
'width' => '150',
|
50 |
+
'index' => 'email'
|
51 |
+
)
|
52 |
+
);
|
53 |
+
|
54 |
+
$groups = Mage::getResourceModel('customer/group_collection')
|
55 |
+
->addFieldToFilter('customer_group_id', array('gt'=> 0))
|
56 |
+
->load()
|
57 |
+
->toOptionHash();
|
58 |
+
|
59 |
+
$this->addColumn(
|
60 |
+
'group', array(
|
61 |
+
'header' => Mage::helper('suretax')->__('Group'),
|
62 |
+
'width' => '100',
|
63 |
+
'index' => 'group_id',
|
64 |
+
'type' => 'options',
|
65 |
+
'options' => $groups,
|
66 |
+
)
|
67 |
+
);
|
68 |
+
$ar = array($this, '_filterSalesTypeConditionCallback');
|
69 |
+
$this->addColumn(
|
70 |
+
'sales_type_desc', array(
|
71 |
+
'header' => Mage::helper('customer')->__('Sales Type Code'),
|
72 |
+
'width' => '150',
|
73 |
+
'index' => 'sales_type_code',
|
74 |
+
'filter_index' => 'sales_type_code',
|
75 |
+
'filter_condition_callback' => $ar
|
76 |
+
)
|
77 |
+
);
|
78 |
+
|
79 |
+
$this->addColumn(
|
80 |
+
'exemption_desc', array(
|
81 |
+
'header' => Mage::helper('customer')->__('Exemption Code'),
|
82 |
+
'index' => 'exemption_code',
|
83 |
+
'filter_index' => 'exemption_code',
|
84 |
+
'filter_condition_callback' => $ar
|
85 |
+
)
|
86 |
+
);
|
87 |
+
|
88 |
+
$this->addColumn(
|
89 |
+
'exemption_reason', array(
|
90 |
+
'header' => Mage::helper('customer')->__('Exemption Reason'),
|
91 |
+
'width' => '150',
|
92 |
+
'index' => 'exemption_reason_code',
|
93 |
+
'filter_index' => 'exemption_reason_code',
|
94 |
+
'filter_condition_callback' => $ar
|
95 |
+
)
|
96 |
+
);
|
97 |
+
|
98 |
+
$this->addColumn(
|
99 |
+
'suretaxId', array(
|
100 |
+
'header' => Mage::helper('customer')->__('Sure Tax ID'),
|
101 |
+
'width' => '10',
|
102 |
+
'index' => 'id',
|
103 |
+
'column_css_class'=>'no-display',
|
104 |
+
'header_css_class'=>'no-display',
|
105 |
+
)
|
106 |
+
);
|
107 |
+
return parent::_prepareColumns();
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getRowUrl($row)
|
111 |
+
{
|
112 |
+
return $this->getUrl(
|
113 |
+
'*/*/edit',
|
114 |
+
array('id'=>$row->getEntityId(),'suretaxId'=>$row->getData('id'))
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
protected function _filterSalesTypeConditionCallback($collection, $column)
|
119 |
+
{
|
120 |
+
if (!$column->getFilter()->getCondition()) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
$columnName = '';
|
124 |
+
$columnId = $column->getId();
|
125 |
+
switch ($columnId) {
|
126 |
+
case 'sales_type_desc' :
|
127 |
+
$columnName = 'sales_type_code';
|
128 |
+
break;
|
129 |
+
case 'exemption_desc' :
|
130 |
+
$columnName = 'exemption_code';
|
131 |
+
break;
|
132 |
+
case 'exemption_reason' :
|
133 |
+
$columnName = 'exemption_reason_code';
|
134 |
+
break;
|
135 |
+
}
|
136 |
+
$collection->filterBasedOnExemptionFields($columnName, $column->getFilter()->getCondition());
|
137 |
+
}
|
138 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Select/Container.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Grid container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customer_Container_Select_Container
|
11 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
12 |
+
{
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
$this->_objectId = 'customer_id';
|
17 |
+
$this->_blockGroup = 'suretax';
|
18 |
+
$this->_controller = 'adminhtml_customer_container_select_container';
|
19 |
+
|
20 |
+
$this->_removeButton('add');
|
21 |
+
$this->_addBackButton();
|
22 |
+
$this->_updateButton('back', 'onclick', 'setLocation(\''.$this->getUrl('*/suretax_customer/index/').'\')');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getHeaderText()
|
26 |
+
{
|
27 |
+
return Mage::helper('suretax')->__('Select Customer For Configuration');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customer/Container/Select/Container/Grid.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Grid.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customer_Container_Select_Container_Grid
|
11 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
12 |
+
{
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
$this->_controller = 'adminhtml_customer_container';
|
16 |
+
$this->setId('customer_exceptions_create_customer_grid');
|
17 |
+
$this->setUseAjax(true);
|
18 |
+
parent::__construct();
|
19 |
+
$this->setDefaultSort('entity_id');
|
20 |
+
$this->setEmptyText(Mage::helper('suretax')->__('No records found'));
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareCollection()
|
24 |
+
{
|
25 |
+
$suretaxCustomerIds = Mage::getResourceModel('wolterskluwer_cchsuretax/customer_collection')
|
26 |
+
->addFieldToSelect('suretax_customer_id')
|
27 |
+
->load();
|
28 |
+
$customerIds = array();
|
29 |
+
|
30 |
+
foreach ($suretaxCustomerIds as $suretaxCustomer) {
|
31 |
+
array_push($customerIds, $suretaxCustomer->getSuretaxCustomerId());
|
32 |
+
}
|
33 |
+
|
34 |
+
if (count($customerIds) > 0) {
|
35 |
+
$collection = Mage::getResourceModel('customer/customer_collection')
|
36 |
+
->addNameToSelect()
|
37 |
+
->addAttributeToSelect('email')
|
38 |
+
->addAttributeToSelect('created_at')
|
39 |
+
->addAttributeToSelect('group_id')
|
40 |
+
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
|
41 |
+
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
|
42 |
+
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
|
43 |
+
->joinAttribute('billing_regione', 'customer_address/region', 'default_billing', null, 'left')
|
44 |
+
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
|
45 |
+
->addAttributeToFilter('entity_id', array('nin' => $customerIds));
|
46 |
+
} else {
|
47 |
+
$collection = Mage::getResourceModel('customer/customer_collection')
|
48 |
+
->addNameToSelect()
|
49 |
+
->addAttributeToSelect('email')
|
50 |
+
->addAttributeToSelect('created_at')
|
51 |
+
->addAttributeToSelect('group_id')
|
52 |
+
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
|
53 |
+
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
|
54 |
+
->joinAttribute('biling_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
|
55 |
+
->joinAttribute('billing_regione', 'customer_address/region', 'default_billing', null, 'left')
|
56 |
+
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
|
57 |
+
}
|
58 |
+
$this->setCollection($collection);
|
59 |
+
|
60 |
+
return parent::_prepareCollection();
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function _prepareColumns()
|
64 |
+
{
|
65 |
+
$this->addColumn(
|
66 |
+
'entity_id', array(
|
67 |
+
'header' =>Mage::helper('suretax')->__('ID'),
|
68 |
+
'width' =>'50px',
|
69 |
+
'index' =>'entity_id',
|
70 |
+
'align' => 'right',
|
71 |
+
)
|
72 |
+
);
|
73 |
+
|
74 |
+
$this->addColumn(
|
75 |
+
'name', array(
|
76 |
+
'header' =>Mage::helper('suretax')->__('Name'),
|
77 |
+
'index' =>'name'
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
$this->addColumn(
|
82 |
+
'email', array(
|
83 |
+
'header' =>Mage::helper('suretax')->__('Email'),
|
84 |
+
'width' =>'150px',
|
85 |
+
'index' =>'email'
|
86 |
+
)
|
87 |
+
);
|
88 |
+
|
89 |
+
$this->addColumn(
|
90 |
+
'Telephone', array(
|
91 |
+
'header' =>Mage::helper('suretax')->__('Telephone'),
|
92 |
+
'width' =>'100px',
|
93 |
+
'index' =>'billing_telephone'
|
94 |
+
)
|
95 |
+
);
|
96 |
+
|
97 |
+
$groups = Mage::getResourceModel('customer/group_collection')
|
98 |
+
->addFieldToFilter('customer_group_id', array('gt'=>0))
|
99 |
+
->load()
|
100 |
+
->toOptionHash();
|
101 |
+
|
102 |
+
$this->addColumn(
|
103 |
+
'group', array(
|
104 |
+
'header' => Mage::helper('suretax')->__('Group'),
|
105 |
+
'width' => '100',
|
106 |
+
'index' => 'group_id',
|
107 |
+
'type' => 'options',
|
108 |
+
'options'=> $groups,
|
109 |
+
)
|
110 |
+
);
|
111 |
+
|
112 |
+
$this->addColumn(
|
113 |
+
'billing_postcode', array(
|
114 |
+
'header' =>Mage::helper('suretax')->__('ZIP/Post Code'),
|
115 |
+
'width' =>'120px',
|
116 |
+
'index' =>'billing_postcode',
|
117 |
+
)
|
118 |
+
);
|
119 |
+
|
120 |
+
$this->addColumn(
|
121 |
+
'billing_country_id', array(
|
122 |
+
'header' =>Mage::helper('suretax')->__('Country'),
|
123 |
+
'width' =>'100px',
|
124 |
+
'type' =>'country',
|
125 |
+
'index' =>'billing_country_id',
|
126 |
+
)
|
127 |
+
);
|
128 |
+
|
129 |
+
$this->addColumn(
|
130 |
+
'billing_regione', array(
|
131 |
+
'header' =>Mage::helper('suretax')->__('State/Province'),
|
132 |
+
'width' =>'100px',
|
133 |
+
'index' =>'billing_regione',
|
134 |
+
)
|
135 |
+
);
|
136 |
+
|
137 |
+
return parent::_prepareColumns();
|
138 |
+
}
|
139 |
+
|
140 |
+
public function getRowId($row)
|
141 |
+
{
|
142 |
+
return $row->getId();
|
143 |
+
}
|
144 |
+
|
145 |
+
public function getRowUrl($row)
|
146 |
+
{
|
147 |
+
return $this->getUrl(
|
148 |
+
'*/*/edit',
|
149 |
+
array('id'=>$row->getEntityId())
|
150 |
+
);
|
151 |
+
}
|
152 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group Grid container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customergroup_Container extends Mage_Adminhtml_Block_Widget_Grid_Container
|
10 |
+
{
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
$this->_objectId = 'customergroup_id';
|
14 |
+
$this->_blockGroup = 'suretax';
|
15 |
+
$this->_controller = 'adminhtml_customergroup_container';
|
16 |
+
parent::__construct();
|
17 |
+
$this->_updateButton('add', 'label', Mage::helper('suretax')->__('Add Group Configuration'));
|
18 |
+
$this->_updateButton('add', 'id', 'customergroup_save_button');
|
19 |
+
$this->_updateButton('add', 'onclick', 'setLocation(\''.$this->getUrl('*/*/select/').'\')');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getHeaderText()
|
23 |
+
{
|
24 |
+
return Mage::helper('suretax')->__('SureTax Configurations For Customer Group');
|
25 |
+
}
|
26 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Edit.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group form edit container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customergroup_Container_Edit
|
11 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
12 |
+
{
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
$this->_objectId = 'suretaxId';
|
16 |
+
parent::__construct();
|
17 |
+
|
18 |
+
$this->_blockGroup = 'suretax';
|
19 |
+
$this->_controller = 'adminhtml_customergroup_container';
|
20 |
+
$this->_updateButton('save', 'label', Mage::helper('suretax')->__('Save Group Configuration'));
|
21 |
+
$this->_updateButton('back', 'label', Mage::helper('suretax')->__('Cancel'));
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getHeaderText()
|
26 |
+
{
|
27 |
+
$customerConfig = Mage::registry('custGrpConfig');
|
28 |
+
$nm = $customerConfig['grpName'];
|
29 |
+
$suretaxGrpId = $customerConfig['suretaxGrpId'];
|
30 |
+
|
31 |
+
if (!($suretaxGrpId === null)) {
|
32 |
+
$str = Mage::helper('suretax')->__('Edit SureTax Configuration For Customer Group ' . $nm);
|
33 |
+
} else {
|
34 |
+
$str = Mage::helper('suretax')->__('Create SureTax Configuration For Customer Group ' . $nm);
|
35 |
+
}
|
36 |
+
|
37 |
+
return $str;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getFormActionUrl()
|
41 |
+
{
|
42 |
+
return $this->getUrl('*/suretax_customergroup/save/');
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getDeleteUrl()
|
46 |
+
{
|
47 |
+
$groupConfig = Mage::registry('custGrpConfig');
|
48 |
+
return $this->getUrl('*/suretax_customergroup/delete/', array('suretaxId'=>$groupConfig['suretaxGrpId']));
|
49 |
+
}
|
50 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Edit/Form.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group Edit Form.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customergroup_Container_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
11 |
+
{
|
12 |
+
public function _prepareForm()
|
13 |
+
{
|
14 |
+
$form = new Varien_Data_Form(
|
15 |
+
array(
|
16 |
+
'id'=>'edit_form',
|
17 |
+
'action'=>$this->getData('action'),
|
18 |
+
'method'=>'post'
|
19 |
+
)
|
20 |
+
);
|
21 |
+
|
22 |
+
$customerConfig = Mage::registry('custGrpConfig');
|
23 |
+
|
24 |
+
$groupId = $customerConfig['groupId'];
|
25 |
+
$suretaxGroupId = $customerConfig['suretaxGrpId'];
|
26 |
+
|
27 |
+
$salesTypeCode = $customerConfig['sales_type_code'];
|
28 |
+
$exemptionCode = $customerConfig['exemption_code'];
|
29 |
+
$exemptionReason = $customerConfig['exemption_reason'];
|
30 |
+
|
31 |
+
$fieldset = $form->addFieldset(
|
32 |
+
'suretax_fieldset', array(
|
33 |
+
'legend' => Mage::helper('customer')->__('SureTax Information')
|
34 |
+
)
|
35 |
+
);
|
36 |
+
|
37 |
+
$fieldset->addField(
|
38 |
+
'sales_type_code', 'select', array(
|
39 |
+
'name' => 'sales_type_code',
|
40 |
+
'label' => Mage::helper('suretax')->__('Sales Type Code'),
|
41 |
+
'title' => Mage::helper('suretax')->__('Sales Type Code'),
|
42 |
+
'class' => 'required-entry',
|
43 |
+
'required' => true,
|
44 |
+
'value' => isset($salesTypeCode) ? $salesTypeCode : $this->__('Residential customer'),
|
45 |
+
'values' => WoltersKluwer_CchSureTax_Helper_Constants::$SALES_TYPE_CODES
|
46 |
+
)
|
47 |
+
);
|
48 |
+
|
49 |
+
$exemptionCodeSet = $fieldset->addField(
|
50 |
+
'exemption_code', 'select', array(
|
51 |
+
'name' => 'exemption_code',
|
52 |
+
'label' => Mage::helper('suretax')->__('Exemption Code'),
|
53 |
+
'title' => Mage::helper('suretax')->__('Exemption Code'),
|
54 |
+
'class' => 'required-entry',
|
55 |
+
'onchange'=>'getExemptionReason(this)',
|
56 |
+
'required' => true,
|
57 |
+
'value' => $exemptionCode,
|
58 |
+
'values' => WoltersKluwer_CchSureTax_Helper_Constants::$EXEMPTION_TYPE_CODES
|
59 |
+
)
|
60 |
+
);
|
61 |
+
|
62 |
+
$disable = false;
|
63 |
+
if (isset($exemptionCode)) {
|
64 |
+
if ($exemptionCode == 'None') {
|
65 |
+
$disable = true;
|
66 |
+
}
|
67 |
+
} else {
|
68 |
+
$disable = true;
|
69 |
+
}
|
70 |
+
|
71 |
+
$exemptionReasonCodeSet = $fieldset->addField(
|
72 |
+
'exemption_reason', 'select', array(
|
73 |
+
'name' => 'exemption_reason',
|
74 |
+
'label' => Mage::helper('suretax')->__('Exemption Reason'),
|
75 |
+
'title' => Mage::helper('suretax')->__('Exemption Reason'),
|
76 |
+
'class' => 'required-entry',
|
77 |
+
'required' => true,
|
78 |
+
'disabled' => $disable,
|
79 |
+
'value' => $exemptionReason,
|
80 |
+
'values' => WoltersKluwer_CchSureTax_Helper_Constants::$EXEMPTION_REASON_CODES
|
81 |
+
)
|
82 |
+
);
|
83 |
+
|
84 |
+
$exemptionReasonCodeSet->setAfterElementHtml(
|
85 |
+
"<script type=\"text/javascript\">
|
86 |
+
|
87 |
+
if(($('exemption_code').value == 'None') )){
|
88 |
+
$('exemption_reason').disabled = true;
|
89 |
+
} else {
|
90 |
+
$('exemption_reason').disabled = false;
|
91 |
+
}
|
92 |
+
</script>"
|
93 |
+
);
|
94 |
+
|
95 |
+
$exemptionCodeSet->setAfterElementHtml(
|
96 |
+
"<script type = \"text/javascript\">
|
97 |
+
|
98 |
+
function getExemptionReason(selectElement) {
|
99 |
+
|
100 |
+
if(selectElement.value == 'None') {
|
101 |
+
$('exemption_reason').value = 'None';
|
102 |
+
$('exemption_reason').disabled = true;
|
103 |
+
}else {
|
104 |
+
$('exemption_reason').disabled = false;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
</script>"
|
108 |
+
);
|
109 |
+
|
110 |
+
if (!($groupId === null)) {
|
111 |
+
$form->addField(
|
112 |
+
'customerGroupId', 'hidden', array(
|
113 |
+
'name' => 'customerGroupId',
|
114 |
+
'value' => $groupId,
|
115 |
+
)
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
if (!($suretaxGroupId === null)) {
|
120 |
+
$form->addField(
|
121 |
+
'suretaxGroupId', 'hidden', array(
|
122 |
+
'name' =>'suretaxGrpId', 'value'=>$suretaxGroupId
|
123 |
+
)
|
124 |
+
);
|
125 |
+
}
|
126 |
+
|
127 |
+
$form->setUseContainer(true);
|
128 |
+
$this->setForm($form);
|
129 |
+
return parent::_prepareForm();
|
130 |
+
}
|
131 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Grid.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group Grid.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customergroup_Container_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->setUseAjax(true);
|
15 |
+
parent::__construct();
|
16 |
+
$this->setId('sureTaxCustomerGrid');
|
17 |
+
$this->setDefaultSort('entity_id');
|
18 |
+
$this->setSaveParametersInSession(true);
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareCollection()
|
22 |
+
{
|
23 |
+
$collection = WoltersKluwer_CchSureTax_Model_Resource_Customergroup_Collection::joinWithCustomerGroup();
|
24 |
+
$this->setCollection($collection);
|
25 |
+
|
26 |
+
return parent::_prepareCollection();
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareColumns()
|
30 |
+
{
|
31 |
+
$this->addColumn(
|
32 |
+
'time', array(
|
33 |
+
'header' => Mage::helper('suretax')->__('ID'),
|
34 |
+
'width' => '50',
|
35 |
+
'align' => 'right',
|
36 |
+
'index' => 'customer_group_id',
|
37 |
+
)
|
38 |
+
);
|
39 |
+
|
40 |
+
$this->addColumn(
|
41 |
+
'type', array(
|
42 |
+
'header' => Mage::helper('suretax')->__('Group Name'),
|
43 |
+
'index' => 'customer_group_code',
|
44 |
+
)
|
45 |
+
);
|
46 |
+
|
47 |
+
$this->addColumn(
|
48 |
+
'class_name', array(
|
49 |
+
'header' => Mage::helper('suretax')->__('Tax Class'),
|
50 |
+
'index' => 'class_name',
|
51 |
+
)
|
52 |
+
);
|
53 |
+
|
54 |
+
$this->addColumn(
|
55 |
+
'sales_type_desc', array(
|
56 |
+
'header' => Mage::helper('customer')->__('Sales Type Code'),
|
57 |
+
'width' => '150',
|
58 |
+
'index' => 'sales_type_code',
|
59 |
+
'filter_index'=> 'sales_type_code'
|
60 |
+
)
|
61 |
+
);
|
62 |
+
|
63 |
+
$this->addColumn(
|
64 |
+
'exemption_desc', array(
|
65 |
+
'header' => Mage::helper('customer')->__('Exemption Code'),
|
66 |
+
'width' => '150',
|
67 |
+
'index' => 'exemption_code',
|
68 |
+
'filter_index' => 'exemption_code'
|
69 |
+
)
|
70 |
+
);
|
71 |
+
|
72 |
+
$this->addColumn(
|
73 |
+
'exemption_reason', array(
|
74 |
+
'header' => Mage::helper('customer')->__('Exemption Reason'),
|
75 |
+
'width' => '150',
|
76 |
+
'index' => 'exemption_reason_code',
|
77 |
+
'filter_index' => 'exemption_reason_code'
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
$this->addColumn(
|
82 |
+
'suretaxId', array(
|
83 |
+
'header' => Mage::helper('customer')->__('Sure Tax ID'),
|
84 |
+
'width' => '10',
|
85 |
+
'index' => 'id',
|
86 |
+
'column_css_class'=>'no-display',
|
87 |
+
'header_css_class'=>'no-display',
|
88 |
+
)
|
89 |
+
);
|
90 |
+
return parent::_prepareColumns();
|
91 |
+
}
|
92 |
+
|
93 |
+
public function getRowUrl($row)
|
94 |
+
{
|
95 |
+
return $this->getUrl(
|
96 |
+
'*/*/edit',
|
97 |
+
array('id'=>$row->getCustomerGroupId(),'suretaxId'=>$row->getData('id'))
|
98 |
+
);
|
99 |
+
}
|
100 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Select/Container.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group Grid container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customergroup_Container_Select_Container
|
11 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
12 |
+
{
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
$this->_objectId = 'customer_id';
|
17 |
+
$this->_blockGroup = 'suretax';
|
18 |
+
$this->_controller = 'adminhtml_customergroup_container_select_container';
|
19 |
+
|
20 |
+
$this->_removeButton('add');
|
21 |
+
$this->_addBackButton();
|
22 |
+
$this->_updateButton('back', 'onclick', 'setLocation(\''.$this->getUrl('*/suretax_customergroup/index/').'\')');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getHeaderText()
|
26 |
+
{
|
27 |
+
return Mage::helper('suretax')->__('Select Customer Group For Configuration');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Customergroup/Container/Select/Container/Grid.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group Grid.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Customergroup_Container_Select_Container_Grid
|
10 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->_controller = 'adminhtml_customergroup_container';
|
15 |
+
$this->setUseAjax(true);
|
16 |
+
parent::__construct();
|
17 |
+
$this->setId('group_exceptions_create_customer_grid');
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _prepareCollection()
|
21 |
+
{
|
22 |
+
$suretaxCustomerGroupIds = Mage::getResourceModel('wolterskluwer_cchsuretax/customergroup_collection')
|
23 |
+
->addFieldToSelect('suretax_customer_group_id')
|
24 |
+
->load();
|
25 |
+
|
26 |
+
$customerIds = array();
|
27 |
+
|
28 |
+
foreach ($suretaxCustomerGroupIds as $suretaxCustomerGroup) {
|
29 |
+
array_push($customerIds, $suretaxCustomerGroup->getData('suretax_customer_group_id'));
|
30 |
+
}
|
31 |
+
|
32 |
+
$collection = Mage::getResourceModel('customer/group_collection')
|
33 |
+
->addTaxClass();
|
34 |
+
|
35 |
+
if (!empty($customerIds)) {
|
36 |
+
$collection->addFieldToFilter('customer_group_id', array('nin' => $customerIds));
|
37 |
+
}
|
38 |
+
|
39 |
+
$this->setCollection($collection);
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _prepareColumns()
|
44 |
+
{
|
45 |
+
$this->addColumn(
|
46 |
+
'time', array(
|
47 |
+
'header' => Mage::helper('suretax')->__('ID'),
|
48 |
+
'width' =>'100',
|
49 |
+
'align' => 'right',
|
50 |
+
'index' => 'customer_group_id',
|
51 |
+
)
|
52 |
+
);
|
53 |
+
|
54 |
+
$this->addColumn(
|
55 |
+
'type', array(
|
56 |
+
'header' => Mage::helper('suretax')->__('Group Name'),
|
57 |
+
'index' => 'customer_group_code'
|
58 |
+
)
|
59 |
+
);
|
60 |
+
|
61 |
+
$this->addColumn(
|
62 |
+
'class_name', array(
|
63 |
+
'header' => Mage::helper('suretax')->__('Tax Class'),
|
64 |
+
'index' => 'class_name'
|
65 |
+
)
|
66 |
+
);
|
67 |
+
|
68 |
+
return parent::_prepareColumns();
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getRowId($row)
|
72 |
+
{
|
73 |
+
return $row->getId();
|
74 |
+
}
|
75 |
+
|
76 |
+
public function getRowUrl($row)
|
77 |
+
{
|
78 |
+
return $this->getUrl(
|
79 |
+
'*/*/edit',
|
80 |
+
array('id'=>$row->getId())
|
81 |
+
);
|
82 |
+
}
|
83 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Grid.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax grid for which we have proper filtering.
|
4 |
+
*
|
5 |
+
* Grid displaying all of Magento's credit memo joined with SureTax credit memo
|
6 |
+
* to accurately display which credit memo has been finalized in SureTax.
|
7 |
+
*
|
8 |
+
* @category WoltersKluwer
|
9 |
+
* @package WoltersKluwer_CchSureTax
|
10 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
11 |
+
*/
|
12 |
+
|
13 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
14 |
+
{
|
15 |
+
|
16 |
+
protected function _setFilterValues($data)
|
17 |
+
{
|
18 |
+
foreach ($this->getColumns() as $columnId => $column) {
|
19 |
+
if (isset($data[$columnId])
|
20 |
+
&& (!empty($data[$columnId]) || strlen($data[$columnId]) > 0)
|
21 |
+
&& $column->getFilter()
|
22 |
+
) {
|
23 |
+
$column->getFilter()->setValue($data[$columnId]);
|
24 |
+
|
25 |
+
if ($this->isNA($data[$columnId])
|
26 |
+
&& ($columnId === 'client_tracking'
|
27 |
+
|| $columnId === 'notes'
|
28 |
+
|| $columnId === 'status'
|
29 |
+
|| $columnId === 'stan'
|
30 |
+
|| $columnId === 'trans_id')
|
31 |
+
) {
|
32 |
+
|
33 |
+
$this->_addColumnFilterToCollectionWithNA($column);
|
34 |
+
|
35 |
+
} else {
|
36 |
+
$this->_addColumnFilterToCollection($column);
|
37 |
+
}
|
38 |
+
|
39 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
40 |
+
'SureTax Grid filter select : ' .
|
41 |
+
(string)$this->getCollection()->getSelect(), Zend_Log::DEBUG
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _addColumnFilterToCollectionWithNA($column)
|
49 |
+
{
|
50 |
+
if ($this->getCollection()) {
|
51 |
+
$field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
|
52 |
+
if ($column->getFilterConditionCallback()) {
|
53 |
+
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
|
54 |
+
} else {
|
55 |
+
$cond = $column->getFilter()->getCondition();
|
56 |
+
if ($field && isset($cond)) {
|
57 |
+
$this->getCollection()->addFieldToFilter(
|
58 |
+
$field,
|
59 |
+
array(array('null' => true), $cond)
|
60 |
+
);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* For use when filtering in the Suretax invoice grid or credit memo grid.
|
69 |
+
*
|
70 |
+
* @param string $value
|
71 |
+
* @return boolean
|
72 |
+
*/
|
73 |
+
public function isNA($value)
|
74 |
+
{
|
75 |
+
if (is_array($value)) {
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
if (strcasecmp($value, 'n') == 0
|
79 |
+
|| strcasecmp($value, '/') == 0
|
80 |
+
|| strcasecmp($value, 'a') == 0
|
81 |
+
|| strcasecmp($value, 'n/') == 0
|
82 |
+
|| strcasecmp($value, '/a') == 0
|
83 |
+
|| strcasecmp($value, 'n/a') == 0
|
84 |
+
) {
|
85 |
+
return true;
|
86 |
+
}
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Help/Container.php
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Help Screen.
|
4 |
+
*
|
5 |
+
* Detailing all the needed information to configure SureTax for tax calculation.
|
6 |
+
*
|
7 |
+
* @category WoltersKluwer
|
8 |
+
* @package WoltersKluwer_CchSureTax
|
9 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
10 |
+
*/
|
11 |
+
|
12 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Help_Container extends Mage_Adminhtml_Block_Widget_Container
|
13 |
+
{
|
14 |
+
public function _toHtml()
|
15 |
+
{
|
16 |
+
return $this->getHelpHtml() . parent::_toHtml();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getHelpHtml()
|
20 |
+
{
|
21 |
+
|
22 |
+
$helpHtml = <<< INFO_HTML
|
23 |
+
<div class="entry-edit">
|
24 |
+
<div class="entry-edit-head">
|
25 |
+
<h4 class="icon-head head-account">Quick Start</h4>
|
26 |
+
</div>
|
27 |
+
<div class="fieldset">
|
28 |
+
<ul>
|
29 |
+
<li class="messages">The global information of the CCH SureTax configuration contains information that is applicable across the Magento installation.</li>
|
30 |
+
<br/>
|
31 |
+
<li>To configure global settings, select <strong>SureTax > Global</strong> on the Admin page.
|
32 |
+
When you save the configuration, the connection to CCH SureTax is tested using the URL, client number, and validation key entered.
|
33 |
+
All configuration values are saved, but if an error occurs, you are notified.</li>
|
34 |
+
<br/>
|
35 |
+
<li>• Enable SureTax Calculation. Activate the extension for the entire Magento installation by selecting Yes.</li>
|
36 |
+
<br/>
|
37 |
+
<li>• Client Number. Your CCH SureTax client number, which you get from your CCH SureTax representative. Validated when the configuration settings are saved.</li>
|
38 |
+
<br/>
|
39 |
+
<li>• SureTax Webservice URL. Most people will only need the <a href="https://api.taxrating.net/Services/V07/SureTax.asmx">Production URL</a>. If you have a development account, you can use <a href="https://testapi.taxrating.net/Services/V07/SureTax.asmx">Demo URL</a> for testing. Validated when the configuration settings are saved.</li>
|
40 |
+
<br/>
|
41 |
+
<li>• Validation Key. Your SureTax company validation key, which you get from your CCH SureTax representative. Validated when the configuration settings are saved.</li>
|
42 |
+
<br/>
|
43 |
+
<li>• Global Business Unit. The business unit that will be sent to CCH SureTax for all transactions from the
|
44 |
+
Magento installation unless a specific business unit is specified for a website or store. The maximum length of business unit is 20 characters.
|
45 |
+
Reporting within CCH SureTax allows filtering by business unit.</li>
|
46 |
+
<br/>
|
47 |
+
<li>• Provider Type. The type of business that will be sent to CCH SureTax for all transactions.</li>
|
48 |
+
<br/>
|
49 |
+
<li>• Tax Class for Shipping. The Magento product tax class that is mapped in CCH SureTax to the appropriate shipping SKU. This product tax class is used as the transaction type code for all shipping and handling costs.</li>
|
50 |
+
<br/>
|
51 |
+
<li>• Tax Class for Gift Options. The Magento product tax class that is mapped in CCH SureTax to the appropriate gift wrapping SKU. This product tax class is used as the transaction type code for all gift wrapping and printed card costs.</li>
|
52 |
+
<br/>
|
53 |
+
<li>• Enable Debug Logging. Activate the debugging logging for the entire Magento installation by selecting Yes. The log file is named suretax.log and is located in the var/log directory of the Magento file structure.</li>
|
54 |
+
|
55 |
+
</ul>
|
56 |
+
</div>
|
57 |
+
</div>
|
58 |
+
|
59 |
+
<div class="entry-edit">
|
60 |
+
<div class="entry-edit-head">
|
61 |
+
<h4 class="icon-head head-account">Ship From Setting</h4>
|
62 |
+
</div>
|
63 |
+
<div class="fieldset">
|
64 |
+
<ul>
|
65 |
+
<li>
|
66 |
+
The ship from address is sent to CCH SureTax for each transaction. The ship from address can be specified for individual stores, websites, or the entire Magento installation.
|
67 |
+
When sending a sales order to CCH SureTax, the address is first obtained from the configuration for the store. If the store does not specify an address,
|
68 |
+
then the address for the website is obtained. If the website does not specify an address, then the address of the installation is sent to CCH SureTax.
|
69 |
+
</li> <br/>
|
70 |
+
<li>• To configure the ship from address for a website or store, select <strong>SureTax > Website/Store.</strong> Select the store or website to configure.
|
71 |
+
Enter an address or choose to use the default ship from address.
|
72 |
+
When configuring a store, this is the ship from address specified for the website.
|
73 |
+
When configuring a website, this is the default ship from address for the Magento installation.</li><br/>
|
74 |
+
<li>• To configure the default ship from address for the Magento installation, select <strong>System > Configuration > Sales/Shipping Settings</strong> on the Admin page.
|
75 |
+
Open the Origin accordion and fill in all fields for the address. </li>
|
76 |
+
</ul>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
|
80 |
+
<div class="entry-edit">
|
81 |
+
<div class="entry-edit-head">
|
82 |
+
<h4 class="icon-head head-account">Magento Product Tax Class</h4>
|
83 |
+
</div>
|
84 |
+
<div class="fieldset">
|
85 |
+
<ul>
|
86 |
+
<li>
|
87 |
+
• The product tax class in Magento is sent to CCH SureTax as the transaction type indicator. These values determine the taxability of products.
|
88 |
+
</li><br/>
|
89 |
+
<li>
|
90 |
+
• Within the Magento Admin, select <strong>Sales > Tax > Product Tax Classes</strong>. Verify that each product tax class in the list has a SKU/Product mapping in CCH SureTax.
|
91 |
+
</li>
|
92 |
+
</ul>
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
|
96 |
+
|
97 |
+
<div class="entry-edit">
|
98 |
+
<div class="entry-edit-head">
|
99 |
+
<h4 class="icon-head head-account">Customer / Customer Group Setting</h4>
|
100 |
+
</div>
|
101 |
+
<div class="fieldset">
|
102 |
+
<ul>
|
103 |
+
<li>
|
104 |
+
There are settings for the CCH SureTax extension that are customer specific. These settings can be specified for a group of customers or for individual customers.
|
105 |
+
By default, an individual customer is configured the same as the group to which the customer belongs. In this case, the settings of the customer group will be sent to CCH SureTax.
|
106 |
+
If a customer is configured differently than the group to which the customer belongs, then the settings of the customer will be sent to CCH SureTax.
|
107 |
+
</li><br/>
|
108 |
+
<li>The following fields are configured for customers and customer groups:</li>
|
109 |
+
<li>• <strong>Sales Type Code</strong>. The type of customer that is purchasing each item. </li>
|
110 |
+
<li>• <strong>Exemption Code</strong>. Specify whether the customer qualifies as tax-exempt. </li>
|
111 |
+
<li>• <strong>Exemption Reason</strong>. The reason that the customer qualifies as tax-exempt.</li>
|
112 |
+
<br/>
|
113 |
+
<li>To view existing SureTax configuration settings for customer groups, select <strong>SureTax > Customer Groups</strong> from the Admin page.
|
114 |
+
Select a customer group in list to edit the existing SureTax Information fields. Or click on the Add Group Configuration button and
|
115 |
+
select a customer group to create SureTax Information fields for the customer group. Click Save Group Configuration button.</li>
|
116 |
+
<br/>
|
117 |
+
<li>To view existing SureTax configuration settings for customers, select <strong>SureTax > Customers</strong> from the Admin page. Any values specified for a customer are sent to
|
118 |
+
CCH SureTax instead of the values specified for the customer group. Select a customer in list to edit the SureTax Information fields.
|
119 |
+
Or click on the Add Customer Configuration button and select a customer to create SureTax Information fields for the customer.
|
120 |
+
Click Save Customer Configuration button.</li>
|
121 |
+
</ul>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
|
125 |
+
<div class="entry-edit">
|
126 |
+
<div class="entry-edit-head">
|
127 |
+
<h4 class="icon-head head-account">Finalizing Transactions</h4>
|
128 |
+
</div>
|
129 |
+
<div class="fieldset">
|
130 |
+
<ul>
|
131 |
+
<li>
|
132 |
+
If the CCH SureTax extension is enabled, taxes are recorded in CCH SureTax when an invoice or credit memo is created.
|
133 |
+
If there is a problem connecting to CCH SureTax at the time of creation, a group of invoices or credit memos that have not been processed by
|
134 |
+
CCH SureTax can be sent for processing from the SureTax transaction report.
|
135 |
+
</li>
|
136 |
+
<br/>
|
137 |
+
<li>
|
138 |
+
Within the Magento Admin, select <strong>SureTax > Transaction Report > Invoices</strong> to view the invoices and information about their status in CCH SureTax.
|
139 |
+
<ul>
|
140 |
+
<li>• Check any invoices you wish to send to CCH SureTax that do not display a CCH SureTax identifier.</li>
|
141 |
+
<li>• Click on the Actions drop-down menu and select Batch Finalize.</li>
|
142 |
+
<li>• Click Submit.</li>
|
143 |
+
</ul>
|
144 |
+
</li>
|
145 |
+
<br/>
|
146 |
+
<li>
|
147 |
+
Within the Magento Admin, select <strong>SureTax > Transaction Report > Credit Memos</strong> to view the credit memos and information about their status in CCH SureTax.
|
148 |
+
<ul>
|
149 |
+
<li>• Check any credit memos you wish to send to CCH SureTax that do not display a CCH SureTax identifier.</li>
|
150 |
+
<li>• Click on the Actions drop-down menu and select Batch Finalize.</li>
|
151 |
+
<li>• Click Submit.</li>
|
152 |
+
</ul>
|
153 |
+
</li>
|
154 |
+
</ul>
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
|
158 |
+
<div class="entry-edit">
|
159 |
+
<div class="entry-edit-head">
|
160 |
+
<h4 class="icon-head head-account">Logging Settings</h4>
|
161 |
+
</div>
|
162 |
+
<div class="fieldset">
|
163 |
+
<ul>
|
164 |
+
<li>
|
165 |
+
The CCH SureTax extension provides two levels of logging. Configuration of logging is located in the SureTax > Global menu. The log file is named suretax.log and is located in the var/log directory of the Magento file structure.
|
166 |
+
</li>
|
167 |
+
<li>
|
168 |
+
• If the debug logging is enabled, all debug and info level messages will be logged along with API request response.
|
169 |
+
</li>
|
170 |
+
<li>
|
171 |
+
• If the debug logging is not enabled, errors, warnings, and exceptions will be logged.
|
172 |
+
</li>
|
173 |
+
</ul>
|
174 |
+
</div>
|
175 |
+
</div>
|
176 |
+
INFO_HTML;
|
177 |
+
return $helpHtml;
|
178 |
+
}
|
179 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Invoices/Container.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Invoices grid container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Invoices_Container extends Mage_Adminhtml_Block_Widget_Grid_Container
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->_objectId = 'invoices_id';
|
15 |
+
$this->_blockGroup = 'suretax';
|
16 |
+
$this->_controller = 'adminhtml_invoices_container';
|
17 |
+
|
18 |
+
parent::__construct();
|
19 |
+
$this->_removeButton('add');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getHeaderText()
|
23 |
+
{
|
24 |
+
return Mage::helper('suretax')->__('SureTax Invoices');
|
25 |
+
}
|
26 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Invoices/Container/Grid.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Invoices grid
|
4 |
+
*
|
5 |
+
* Grid displaying all of Magento's invoices joined with SureTax invoice table.
|
6 |
+
* Display which invoice had been finalized in SureTax.
|
7 |
+
*
|
8 |
+
* @category WoltersKluwer
|
9 |
+
* @package WoltersKluwer_CchSureTax
|
10 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
11 |
+
*/
|
12 |
+
|
13 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Invoices_Container_Grid extends WoltersKluwer_CchSureTax_Block_Adminhtml_Grid
|
14 |
+
{
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
$this->setId('suretaxInvoicesGrid');
|
19 |
+
$this->setDefaultSort('increment_id');
|
20 |
+
$this->setDefaultDir('DESC');
|
21 |
+
$this->setSaveParametersInSession(true);
|
22 |
+
}
|
23 |
+
|
24 |
+
//Load the collection of Suretax Invoice.
|
25 |
+
protected function _prepareCollection()
|
26 |
+
{
|
27 |
+
$collection = WoltersKluwer_CchSureTax_Model_Resource_Invoice_Collection::joinInvoiceWithSelf();
|
28 |
+
$this->setCollection($collection);
|
29 |
+
return parent::_prepareCollection();
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _prepareMassaction()
|
33 |
+
{
|
34 |
+
$this->setMassactionIdField('main_table.entity_id');
|
35 |
+
$this->getMassactionBlock()->setFormFieldName('invoice_Ids');
|
36 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
37 |
+
|
38 |
+
$this->getMassactionBlock()->addItem(
|
39 |
+
'suretax_finalize', array(
|
40 |
+
'label'=> Mage::helper('sales')->__('Batch Finalize'),
|
41 |
+
'url' => $this->getUrl('*/*/batchFinalize'),
|
42 |
+
)
|
43 |
+
);
|
44 |
+
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _prepareColumns()
|
49 |
+
{
|
50 |
+
$this->addColumn(
|
51 |
+
'increment_id', array(
|
52 |
+
'header' => Mage::helper('suretax')->__('Invoice #'),
|
53 |
+
'width' => '100',
|
54 |
+
'index' => 'increment_id',
|
55 |
+
'filter_index' => 'main_table.increment_id',
|
56 |
+
'type' => 'text'
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$this->addColumn(
|
61 |
+
'order_increment_id', array(
|
62 |
+
'header' => Mage::helper('suretax')->__('Order #'),
|
63 |
+
'width' => '100',
|
64 |
+
'index' => 'order_increment_id',
|
65 |
+
'filter_index' => 'order.increment_id',
|
66 |
+
'type' => 'text'
|
67 |
+
)
|
68 |
+
);
|
69 |
+
|
70 |
+
$this->addColumn(
|
71 |
+
'created_at', array(
|
72 |
+
'header' => Mage::helper('suretax')->__('Date'),
|
73 |
+
'width' => '100',
|
74 |
+
'index' => 'created_at',
|
75 |
+
'filter_index' => 'main_table.created_at',
|
76 |
+
'type' => 'datetime'
|
77 |
+
)
|
78 |
+
);
|
79 |
+
|
80 |
+
$this->addColumn(
|
81 |
+
'tax_amount', array(
|
82 |
+
'header' => Mage::helper('suretax')->__('Magento Collected Tax'),
|
83 |
+
'width' => '100',
|
84 |
+
'index' => 'tax_amount',
|
85 |
+
'filter_index' => 'main_table.tax_amount',
|
86 |
+
'type' => 'currency',
|
87 |
+
'currency' => 'order_currency_code'
|
88 |
+
)
|
89 |
+
);
|
90 |
+
|
91 |
+
$this->addColumn(
|
92 |
+
'sure_tax_amount', array(
|
93 |
+
'header' => Mage::helper('suretax')->__('SureTax Calculated Tax'),
|
94 |
+
'width' => '100',
|
95 |
+
'index' => 'tax',
|
96 |
+
'filter_index' => 'sure.tax',
|
97 |
+
'type' => 'currency',
|
98 |
+
'currency' => 'order_currency_code'
|
99 |
+
)
|
100 |
+
);
|
101 |
+
|
102 |
+
$this->addColumn(
|
103 |
+
'tax_difference', array(
|
104 |
+
'header' => Mage::helper('suretax')->__('Difference'),
|
105 |
+
'width' => '100',
|
106 |
+
'index' => 'tax_difference',
|
107 |
+
'filter' => false,
|
108 |
+
'type' => 'currency',
|
109 |
+
'currency' => 'order_currency_code'
|
110 |
+
)
|
111 |
+
);
|
112 |
+
|
113 |
+
$this->addColumn(
|
114 |
+
'trans_id', array(
|
115 |
+
'header' => Mage::helper('suretax')->__('SureTax Trans ID'),
|
116 |
+
'width' => '100',
|
117 |
+
'index' => 'trans_id',
|
118 |
+
'filter_index' => 'sure.trans_id',
|
119 |
+
'type' => 'text'
|
120 |
+
)
|
121 |
+
);
|
122 |
+
|
123 |
+
$this->addColumn(
|
124 |
+
'client_tracking', array(
|
125 |
+
'header' => Mage::helper('suretax')->__('Client Tracking'),
|
126 |
+
'width' => '100',
|
127 |
+
'index' => 'client_tracking',
|
128 |
+
'filter_index' => 'sure.client_tracking',
|
129 |
+
'type' => 'text'
|
130 |
+
)
|
131 |
+
);
|
132 |
+
|
133 |
+
$this->addColumn(
|
134 |
+
'status', array(
|
135 |
+
'header' => Mage::helper('suretax')->__('SureTax Status'),
|
136 |
+
'width' => '100',
|
137 |
+
'index' => 'status',
|
138 |
+
'filter_index' => 'sure.status',
|
139 |
+
'type' => 'options',
|
140 |
+
'options' => WoltersKluwer_CchSureTax_Helper_Constants::$SURETAX_STATUS
|
141 |
+
)
|
142 |
+
);
|
143 |
+
|
144 |
+
$this->addColumn(
|
145 |
+
'notes', array(
|
146 |
+
'header' => Mage::helper('suretax')->__('Notes'),
|
147 |
+
'width' => '200',
|
148 |
+
'index' => 'notes',
|
149 |
+
'filter_index' => 'sure.notes',
|
150 |
+
'type' => 'text'
|
151 |
+
)
|
152 |
+
);
|
153 |
+
|
154 |
+
$this->addColumn(
|
155 |
+
'action', array(
|
156 |
+
'header' => Mage::helper('sales')->__('Action'),
|
157 |
+
'width' => '50px',
|
158 |
+
'type' => 'action',
|
159 |
+
'getter' => 'getId',
|
160 |
+
'actions' => array(
|
161 |
+
array(
|
162 |
+
'caption' => Mage::helper('sales')->__('View'),
|
163 |
+
'url' => array('base'=>'*/sales_invoice/view'),
|
164 |
+
'field' => 'invoice_id',
|
165 |
+
'data-column' => 'action',
|
166 |
+
)
|
167 |
+
),
|
168 |
+
'filter' => false,
|
169 |
+
'sortable' => false,
|
170 |
+
'index' => 'stores',
|
171 |
+
'is_system' => true,
|
172 |
+
)
|
173 |
+
);
|
174 |
+
|
175 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('suretax')->__('CSV'));
|
176 |
+
$this->addExportType('*/*/exportXml', Mage::helper('suretax')->__('Excel XML'));
|
177 |
+
return parent::_prepareColumns();
|
178 |
+
}
|
179 |
+
|
180 |
+
public function getRowUrl($row)
|
181 |
+
{
|
182 |
+
if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/invoice')) {
|
183 |
+
return false;
|
184 |
+
}
|
185 |
+
|
186 |
+
return $this->getUrl(
|
187 |
+
'*/sales_invoice/view',
|
188 |
+
array(
|
189 |
+
'invoice_id'=> $row->getId(),
|
190 |
+
)
|
191 |
+
);
|
192 |
+
}
|
193 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax configuration Grid Container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
//Is this even used? Remove this class before release.
|
11 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Suretaxconfig extends Mage_Adminhtml_Block_Widget_Grid_Container
|
12 |
+
{
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
$this->_blockGroup = 'suretax';
|
16 |
+
$this->_controller = 'adminhtml_suretaxconfig';
|
17 |
+
$this->_headerText = Mage::helper('suretax')->__('Info');
|
18 |
+
$this->_addButtonLabel = Mage::helper('suretax')->__('Add New Info');
|
19 |
+
parent::__construct();
|
20 |
+
}
|
21 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Global configuration Edit form container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_SuretaxConfig_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->_objectId = 'info_id';
|
15 |
+
$this->_blockGroup = 'suretax';
|
16 |
+
$this->_controller = 'adminhtml_suretaxconfig';
|
17 |
+
parent::__construct();
|
18 |
+
|
19 |
+
$this->_removeButton('reset');
|
20 |
+
$this->_removeButton('back');
|
21 |
+
}
|
22 |
+
|
23 |
+
public function getHeaderText()
|
24 |
+
{
|
25 |
+
return Mage::helper('suretax')->__('SureTax Global Configuration');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getFormActionUrl()
|
29 |
+
{
|
30 |
+
return $this->getUrl('*/suretax_config/save');
|
31 |
+
}
|
32 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit/Form.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Global configuration form.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_SuretaxConfig_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
11 |
+
{
|
12 |
+
protected function _prepareForm()
|
13 |
+
{
|
14 |
+
$form = new Varien_Data_Form(
|
15 |
+
array('id'=>'edit_form', 'action'=>$this->getData('action'), 'method'=>'post')
|
16 |
+
);
|
17 |
+
|
18 |
+
$form->setUseContainer(true);
|
19 |
+
$this->setForm($form);
|
20 |
+
|
21 |
+
return parent::_prepareForm();
|
22 |
+
}
|
23 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit/Tab/Advanced.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Advanced section in the Global configuration.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_SuretaxConfig_Edit_Tab_Advanced extends Mage_Adminhtml_Block_Widget_Form
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* This is the Advanced section of SureTax General
|
14 |
+
*/
|
15 |
+
protected function _prepareForm()
|
16 |
+
{
|
17 |
+
$form = new Varien_Data_Form();
|
18 |
+
|
19 |
+
$fieldset = $form->addFieldset(
|
20 |
+
'base_fieldset', array(
|
21 |
+
'legend'=>Mage::helper('suretax')->__('Advanced Information'),
|
22 |
+
'class'=>'fieldset-wide'
|
23 |
+
)
|
24 |
+
);
|
25 |
+
|
26 |
+
$fieldset->addField(
|
27 |
+
'finalized_location', 'select', array(
|
28 |
+
'name' => 'finalized_location',
|
29 |
+
'label' => Mage::helper('suretax')->__('Finalize Transaction at '),
|
30 |
+
'title' => Mage::helper('suretax')->__('Finalize Transaction at '),
|
31 |
+
'values' => array('0'=>'Place Order','1' => 'Order is set to Complete'),
|
32 |
+
'required' => true
|
33 |
+
)
|
34 |
+
);
|
35 |
+
|
36 |
+
$fieldset->addField(
|
37 |
+
'tax_situs', 'select', array(
|
38 |
+
'name' => 'tax_situs',
|
39 |
+
'label' => Mage::helper('suretax')->__('Tax Calculation Based On '),
|
40 |
+
'title' => Mage::helper('suretax')->__('Tax Calculation Based On '),
|
41 |
+
'values' => array('0'=>'Shipping Address','1' => 'Billing Address', '2' => 'Shipping Origin'),
|
42 |
+
'required' => false
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
$this->setForm($form);
|
47 |
+
|
48 |
+
return parent::_prepareForm();
|
49 |
+
}
|
50 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit/Tab/Basic.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Basic Section in the Global configuration.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_SuretaxConfig_Edit_Tab_Basic extends Mage_Adminhtml_Block_Widget_Form
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* This is the Basic section of SureTax General Configuration
|
14 |
+
*/
|
15 |
+
protected function _prepareForm()
|
16 |
+
{
|
17 |
+
$form = new Varien_Data_Form();
|
18 |
+
|
19 |
+
$suretaxConfigData = WoltersKluwer_CchSureTax_Helper_Utility::getSureTaxConfigData();
|
20 |
+
|
21 |
+
$allProductTaxClass = Mage::getModel('tax/class_source_product')->toOptionArray();
|
22 |
+
|
23 |
+
$fieldset = $form->addFieldset(
|
24 |
+
'base_fieldset', array(
|
25 |
+
'legend'=>Mage::helper('suretax')->__('Basic Information'),
|
26 |
+
'class'=>'fieldset'
|
27 |
+
)
|
28 |
+
);
|
29 |
+
|
30 |
+
$fieldset->addField(
|
31 |
+
'enable_suretax', 'select', array(
|
32 |
+
'label' => Mage::helper('suretax')->__('Enable SureTax Calculation'),
|
33 |
+
'class' => 'required-entry',
|
34 |
+
'required' => true,
|
35 |
+
'name' => 'is_suretax_enabled',
|
36 |
+
'onclick' => "",
|
37 |
+
'onchange' => "",
|
38 |
+
'value' => isset($suretaxConfigData['is_suretax_enabled']) ?
|
39 |
+
$suretaxConfigData['is_suretax_enabled'] : '0',
|
40 |
+
'values' => array('0'=>'No','1' => 'Yes'),
|
41 |
+
'disabled' => false,
|
42 |
+
'readonly' => false,
|
43 |
+
'after_element_html' => '<td class="scope-label">[GLOBAL]</td>',
|
44 |
+
'tabindex' => 0
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
$fieldset->addField(
|
49 |
+
'clientnumber', 'text', array(
|
50 |
+
'name' => 'clientnumber',
|
51 |
+
'label' => Mage::helper('suretax')->__('Client Number'),
|
52 |
+
'title' => Mage::helper('suretax')->__('Client Number'),
|
53 |
+
'required' => true,
|
54 |
+
'value' => isset($suretaxConfigData['clientnumber']) ?
|
55 |
+
$suretaxConfigData['clientnumber'] : '',
|
56 |
+
'note' => $this->__('<small>Enter Client Number Provided by SureTax</small>')
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$fieldset->addField(
|
61 |
+
'suretaxurl', 'text', array(
|
62 |
+
'name' => 'suretaxurl',
|
63 |
+
'label' => Mage::helper('suretax')->__('SureTax Webservice URL'),
|
64 |
+
'title' => Mage::helper('suretax')->__('SureTax Webservice URL'),
|
65 |
+
'required' => true,
|
66 |
+
'value' => isset($suretaxConfigData['suretaxurl']) ?
|
67 |
+
$suretaxConfigData['suretaxurl'] : '',
|
68 |
+
'note' => $this->__('<small>Enter SureTax URL to connect to API</small>')
|
69 |
+
)
|
70 |
+
);
|
71 |
+
|
72 |
+
$fieldset->addField(
|
73 |
+
'validationkey', 'password', array(
|
74 |
+
'name' => 'validationkey',
|
75 |
+
'label' => Mage::helper('suretax')->__('Validation Key'),
|
76 |
+
'title' => Mage::helper('suretax')->__('Validation Key'),
|
77 |
+
'required' => true,
|
78 |
+
'value' => isset($suretaxConfigData['validationkey']) ?
|
79 |
+
$suretaxConfigData['validationkey'] : '',
|
80 |
+
'note' => $this->__('<small>Enter Company Validation Key Provided by SureTax</small>')
|
81 |
+
)
|
82 |
+
);
|
83 |
+
|
84 |
+
$fieldset->addField(
|
85 |
+
'defaultbusinessunit', 'text', array(
|
86 |
+
'name' => 'defaultbusinessunit',
|
87 |
+
'label' => Mage::helper('suretax')->__('Global Business Unit'),
|
88 |
+
'title' => Mage::helper('suretax')->__('Global Business Unit'),
|
89 |
+
'required' => false,
|
90 |
+
'maxlength' => WoltersKluwer_CchSureTax_Helper_Constants::BUSINESS_UNIT_MAX_LENGTH,
|
91 |
+
'value' => isset($suretaxConfigData['defaultbusinessunit']) ?
|
92 |
+
$suretaxConfigData['defaultbusinessunit'] : '',
|
93 |
+
'note' => $this->__('<small>Enter the Business Unit for transactions</small>')
|
94 |
+
)
|
95 |
+
);
|
96 |
+
|
97 |
+
$fieldset->addField(
|
98 |
+
'select_provider_type', 'select', array(
|
99 |
+
'label' => Mage::helper('suretax')->__('Provider Type'),
|
100 |
+
'class' => 'required-entry',
|
101 |
+
'required' => true,
|
102 |
+
'name' => 'providertype',
|
103 |
+
'onclick' => "",
|
104 |
+
'onchange' => "",
|
105 |
+
'value' => isset($suretaxConfigData['providertype']) ?
|
106 |
+
$suretaxConfigData['providertype'] : '70',
|
107 |
+
'values' => array('70' => '70 - Retail', '99' => '99 - Default'),
|
108 |
+
'disabled' => false,
|
109 |
+
'readonly' => false,
|
110 |
+
'tabindex' => 1
|
111 |
+
)
|
112 |
+
);
|
113 |
+
|
114 |
+
$fieldset->addField(
|
115 |
+
'shipping_tax_class', 'select', array(
|
116 |
+
'label' => Mage::helper('suretax')->__('Tax Class for Shipping'),
|
117 |
+
'class' => 'required-entry',
|
118 |
+
'required' => false,
|
119 |
+
'name' => 'shipping_tax_class',
|
120 |
+
'values' => $allProductTaxClass,
|
121 |
+
'value' => isset($suretaxConfigData['shipping_tax_class']) ?
|
122 |
+
$suretaxConfigData['shipping_tax_class'] : '1',
|
123 |
+
'disabled' => false,
|
124 |
+
'readonly' => false,
|
125 |
+
'tabindex' => 1
|
126 |
+
)
|
127 |
+
);
|
128 |
+
|
129 |
+
$fieldset->addField(
|
130 |
+
'gift_wrap_tax_class', 'select', array(
|
131 |
+
'label' => Mage::helper('suretax')->__('Tax Class for Gift Options'),
|
132 |
+
'class' => 'required-entry',
|
133 |
+
'required' => false,
|
134 |
+
'name' => 'gift_wrap_tax_class',
|
135 |
+
'values' => $allProductTaxClass,
|
136 |
+
'value' => isset($suretaxConfigData['gift_wrap_tax_class']) ?
|
137 |
+
$suretaxConfigData['gift_wrap_tax_class'] : '1',
|
138 |
+
'disabled' => false,
|
139 |
+
'readonly' => false,
|
140 |
+
'tabindex' => 1
|
141 |
+
)
|
142 |
+
);
|
143 |
+
|
144 |
+
$fieldset->addField(
|
145 |
+
'logging', 'select', array(
|
146 |
+
'label' => Mage::helper('suretax')->__('Enable Debug Logging'),
|
147 |
+
'class' => 'required-entry',
|
148 |
+
'required' => true,
|
149 |
+
'name' => 'is_logging_enabled',
|
150 |
+
'value' => isset($suretaxConfigData['is_logging_enabled']) ?
|
151 |
+
$suretaxConfigData['is_logging_enabled'] : '0',
|
152 |
+
'values' => array('0'=>'No','1' => 'Yes'),
|
153 |
+
'disabled' => false,
|
154 |
+
'readonly' => false,
|
155 |
+
'note' => $this->__(
|
156 |
+
'<small>DEBUG and INFO level logging including API '
|
157 |
+
. 'requests and responses will be logged.</small>'
|
158 |
+
),
|
159 |
+
'tabindex' => 0
|
160 |
+
)
|
161 |
+
);
|
162 |
+
|
163 |
+
$this->setForm($form);
|
164 |
+
return parent::_prepareForm();
|
165 |
+
}
|
166 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Suretaxconfig/Edit/Tabs.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Tabs in the Global configuration.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_SuretaxConfig_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Initialize Tabs
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
parent::_construct();
|
20 |
+
|
21 |
+
$this->setId('wk_suretax_tabs');
|
22 |
+
$this->setDestElementId('edit_form');
|
23 |
+
$this->setTitle(Mage::helper('suretax')->__('Global'));
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _prepareLayout()
|
27 |
+
{
|
28 |
+
$this->addTab(
|
29 |
+
'basic_section', array(
|
30 |
+
'label' => Mage::helper('suretax')->__('Basic'),
|
31 |
+
'title' => Mage::helper('suretax')->__('Basic Configuration'),
|
32 |
+
'content' => $this->getLayout()->createBlock('suretax/adminhtml_suretaxconfig_edit_tab_basic')->toHtml(),
|
33 |
+
'active' => true
|
34 |
+
)
|
35 |
+
);
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
return parent::_prepareLayout();
|
40 |
+
}
|
41 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Websitestore/Container.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Website/store configuration Grid Container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Websitestore_Container extends Mage_Adminhtml_Block_Widget_Grid_Container
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->_blockGroup = 'suretax';
|
15 |
+
$this->_controller = 'adminhtml_websitestore_container';
|
16 |
+
$this->_headerText = Mage::helper('suretax')->__('SureTax Website/Store');
|
17 |
+
|
18 |
+
parent::__construct();
|
19 |
+
$this->_removeButton('add');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Websitestore/Container/Edit.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Website/store configuration edit container.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Websitestore_Container_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->_objectId = 'edit';
|
15 |
+
$this->_blockGroup = 'suretax';
|
16 |
+
$this->_controller = 'adminhtml_websitestore_container';
|
17 |
+
parent::__construct();
|
18 |
+
$this->_removeButton('reset');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getHeaderText()
|
22 |
+
{
|
23 |
+
return Mage::helper('suretax')->__('SureTax Website/Store Configuration');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getFormActionUrl()
|
27 |
+
{
|
28 |
+
return $this->getUrl('*/suretax_websitestore/save');
|
29 |
+
}
|
30 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Websitestore/Container/Edit/Form.php
ADDED
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Website/Store configuration form.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Websitestore_Container_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
11 |
+
{
|
12 |
+
protected function _prepareForm()
|
13 |
+
{
|
14 |
+
$config = Mage::registry('config');
|
15 |
+
$websiteId = $config['websiteId'];
|
16 |
+
$storeId = $config['storeId'];
|
17 |
+
|
18 |
+
if ($storeId == 0) {
|
19 |
+
$name = 'Website : '.$config['name'];
|
20 |
+
$isWebsite = true;
|
21 |
+
|
22 |
+
$row = Mage::getModel(WoltersKluwer_CchSureTax_Helper_Constants::WS_CONFIG_TBL)
|
23 |
+
->getCollection()
|
24 |
+
->loadWebsiteConfig($websiteId);
|
25 |
+
|
26 |
+
$scope = '<td class="scope-label">[WEBSITE]</td>';
|
27 |
+
|
28 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
29 |
+
'Form loaded for Website : ' .
|
30 |
+
$config['name'],
|
31 |
+
Zend_Log::DEBUG
|
32 |
+
);
|
33 |
+
} else {
|
34 |
+
$name = 'Store : '.$config['name'];
|
35 |
+
$isWebsite = false;
|
36 |
+
|
37 |
+
$row = Mage::getModel(WoltersKluwer_CchSureTax_Helper_Constants::WS_CONFIG_TBL)
|
38 |
+
->getCollection()
|
39 |
+
->loadStoreConfig($websiteId, $storeId);
|
40 |
+
|
41 |
+
$scope = '<td class="scope-label">[STORE GROUP]</td>';
|
42 |
+
|
43 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
44 |
+
'Form loaded for Store : ' .
|
45 |
+
$config['name'],
|
46 |
+
Zend_Log::DEBUG
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
$enableFlag = $row->getIsEnableCalc();
|
51 |
+
$useDefaultBusinessUnit = $row->getUseBusinessUnit();
|
52 |
+
$businessUnit = $row->getBusinessUnit();
|
53 |
+
$useDefaultAddressFlag = $row->getUseDefaultAddress();
|
54 |
+
$streetAddress1 = $row->getStreetAddress1();
|
55 |
+
$streetAddress2 = $row->getStreetAddress2();
|
56 |
+
$city = $row->getCity();
|
57 |
+
$country = $row->getCountry();
|
58 |
+
$stateProv = $row->getStateProvince();
|
59 |
+
$zipPostal = $row->getZipPostal();
|
60 |
+
|
61 |
+
$form = new Varien_Data_Form(
|
62 |
+
array(
|
63 |
+
'id'=>'edit_form',
|
64 |
+
'action'=>$this->getData('action'),
|
65 |
+
'method'=>'post'
|
66 |
+
)
|
67 |
+
);
|
68 |
+
|
69 |
+
$fieldset = $form->addFieldset(
|
70 |
+
'base_fieldset', array(
|
71 |
+
'legend'=>Mage::helper('suretax')->__($name),
|
72 |
+
'class'=>'fieldset'
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
$fieldset->addField(
|
77 |
+
'website_id', 'hidden', array(
|
78 |
+
'name' => 'website_id',
|
79 |
+
'value' => $websiteId
|
80 |
+
)
|
81 |
+
);
|
82 |
+
|
83 |
+
$fieldset->addField(
|
84 |
+
'store_id', 'hidden', array(
|
85 |
+
'name' => 'store_id',
|
86 |
+
'value' => $storeId
|
87 |
+
)
|
88 |
+
);
|
89 |
+
|
90 |
+
$labelKey = $isWebsite ?
|
91 |
+
WoltersKluwer_CchSureTax_Helper_Constants::USE_GLOBAL_SETTINGS :
|
92 |
+
WoltersKluwer_CchSureTax_Helper_Constants::USE_WEBSITE_SETTINGS;
|
93 |
+
$label = $isWebsite ? 'Use Global Settings' : 'Use Website Settings';
|
94 |
+
|
95 |
+
$fieldset->addField(
|
96 |
+
'is_enable_calc', 'select', array(
|
97 |
+
'label' => Mage::helper('suretax')->__('Enable SureTax Calculation'),
|
98 |
+
'class' => 'required-entry',
|
99 |
+
'required' => true,
|
100 |
+
'name' => 'is_enable_calc',
|
101 |
+
'onclick' => "",
|
102 |
+
'onchange' => "",
|
103 |
+
'value' => isset($enableFlag) ? $enableFlag : $labelKey,
|
104 |
+
'values' => array($labelKey=>$label, WoltersKluwer_CchSureTax_Helper_Constants::NO=>'No',
|
105 |
+
WoltersKluwer_CchSureTax_Helper_Constants::YES => 'Yes'),
|
106 |
+
'disabled' => false,
|
107 |
+
'readonly' => false,
|
108 |
+
'tabindex' => 0,
|
109 |
+
'after_element_html' => $scope
|
110 |
+
)
|
111 |
+
);
|
112 |
+
|
113 |
+
$notes = $isWebsite ? $this->__('Business Unit is pulled from the Global Settings') :
|
114 |
+
$this->__('Business Unit is pulled from the Website Settings');
|
115 |
+
|
116 |
+
$fieldset->addField(
|
117 |
+
'use_business_unit', 'select', array(
|
118 |
+
'name' => 'use_business_unit',
|
119 |
+
'label' => Mage::helper('suretax')->__('Use Default Business Unit'),
|
120 |
+
'title' => Mage::helper('suretax')->__('Use Default Business Unit'),
|
121 |
+
'required' => true,
|
122 |
+
'maxlength' => WoltersKluwer_CchSureTax_Helper_Constants::BUSINESS_UNIT_MAX_LENGTH,
|
123 |
+
'value' => isset($useDefaultBusinessUnit) ? $useDefaultBusinessUnit : 1,
|
124 |
+
'values' => array('0'=>'No','1' => 'Yes'),
|
125 |
+
'note' => '<small>'.$notes.'</small>'
|
126 |
+
)
|
127 |
+
);
|
128 |
+
|
129 |
+
$fieldset->addField(
|
130 |
+
'business_unit', 'text', array(
|
131 |
+
'name' => 'business_unit',
|
132 |
+
'label' => Mage::helper('suretax')->__('Business Unit'),
|
133 |
+
'title' => Mage::helper('suretax')->__('Business Unit'),
|
134 |
+
'required' => false,
|
135 |
+
'value' => isset($businessUnit) ? $businessUnit : '',
|
136 |
+
'note' => $this->__('<small>Enter the SureTax business unit for transactions</small>')
|
137 |
+
)
|
138 |
+
);
|
139 |
+
|
140 |
+
$fieldset2 = $form->addFieldset(
|
141 |
+
'shipping_fieldset', array(
|
142 |
+
'legend'=>Mage::helper('suretax')->__('Ship From Address'),
|
143 |
+
'class'=>'fieldset'
|
144 |
+
)
|
145 |
+
);
|
146 |
+
|
147 |
+
$notes = $isWebsite ? $this->__('Ship From Address is pulled from System->Configuration->Shipping Settings->Origin') :
|
148 |
+
$this->__('Ship From Address is pulled from the Website Settings');
|
149 |
+
|
150 |
+
$fieldset2->addField(
|
151 |
+
'use_default_address',
|
152 |
+
'select',
|
153 |
+
array(
|
154 |
+
'name' => 'use_default_address',
|
155 |
+
'label' => Mage::helper('suretax')->__('Use Default Ship From Address'),
|
156 |
+
'title' => Mage::helper('suretax')->__('Use Default Ship From Address'),
|
157 |
+
'value' => isset($useDefaultAddressFlag) ? $useDefaultAddressFlag : 1,
|
158 |
+
'values' => array('0'=>'No','1' => 'Yes'),
|
159 |
+
'required' => true,
|
160 |
+
'note' => '<small>'.$notes.'</small>'
|
161 |
+
)
|
162 |
+
);
|
163 |
+
|
164 |
+
$fieldset2->addField(
|
165 |
+
'ship_from_address1',
|
166 |
+
'text',
|
167 |
+
array(
|
168 |
+
'name' => 'ship_from_address1',
|
169 |
+
'label' => Mage::helper('suretax')->__('Street Address'),
|
170 |
+
'title' => Mage::helper('suretax')->__('Street Address'),
|
171 |
+
'value' => isset($streetAddress1) ? $streetAddress1 : '',
|
172 |
+
'required' => true
|
173 |
+
)
|
174 |
+
);
|
175 |
+
|
176 |
+
$fieldset2->addField(
|
177 |
+
'ship_from_address2',
|
178 |
+
'text',
|
179 |
+
array(
|
180 |
+
'name' => 'ship_from_address2',
|
181 |
+
'value' => isset($streetAddress2) ? $streetAddress2 : '',
|
182 |
+
'required' => false
|
183 |
+
)
|
184 |
+
);
|
185 |
+
|
186 |
+
$fieldset2->addField(
|
187 |
+
'ship_from_city',
|
188 |
+
'text',
|
189 |
+
array(
|
190 |
+
'name' => 'ship_from_city',
|
191 |
+
'label' => Mage::helper('suretax')->__('City'),
|
192 |
+
'title' => Mage::helper('suretax')->__('City'),
|
193 |
+
'value' => isset($city) ? $city : '',
|
194 |
+
'required' => true
|
195 |
+
)
|
196 |
+
);
|
197 |
+
|
198 |
+
$countryCollection = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray();
|
199 |
+
|
200 |
+
$fieldset2->addField(
|
201 |
+
'ship_from_country',
|
202 |
+
'select',
|
203 |
+
array(
|
204 |
+
'name' => 'ship_from_country',
|
205 |
+
'class' => 'required-entry',
|
206 |
+
'label' => Mage::helper('suretax')->__('Country'),
|
207 |
+
'title' => Mage::helper('suretax')->__('Country'),
|
208 |
+
'values' => $countryCollection,
|
209 |
+
'value' => isset($country) ? $country : '0',
|
210 |
+
'onchange' => 'getstate(this)',
|
211 |
+
'required' => true
|
212 |
+
)
|
213 |
+
);
|
214 |
+
|
215 |
+
$stateCollection = Mage::getModel('directory/country')->load('US')->getRegions()->toOptionArray();
|
216 |
+
|
217 |
+
$fieldset2->addField(
|
218 |
+
'ship_from_state',
|
219 |
+
'select',
|
220 |
+
array(
|
221 |
+
'name' => 'ship_from_state',
|
222 |
+
'label' => Mage::helper('suretax')->__('State/Province'),
|
223 |
+
'title' => Mage::helper('suretax')->__('State/Province'),
|
224 |
+
'values' => $stateCollection,
|
225 |
+
'value' => isset($stateProv) ? $stateProv : '',
|
226 |
+
'required' => true
|
227 |
+
)
|
228 |
+
);
|
229 |
+
|
230 |
+
$fieldset2->addField(
|
231 |
+
'ship_from_zip',
|
232 |
+
'text',
|
233 |
+
array(
|
234 |
+
'name' => 'ship_from_zip',
|
235 |
+
'label' => Mage::helper('suretax')->__('Zip/Postal Code'),
|
236 |
+
'title' => Mage::helper('suretax')->__('Zip/Postal Code'),
|
237 |
+
'value' => isset($zipPostal) ? $zipPostal : '',
|
238 |
+
'required' => true
|
239 |
+
)
|
240 |
+
);
|
241 |
+
|
242 |
+
$form->setUseContainer(true);
|
243 |
+
$this->setForm($form);
|
244 |
+
|
245 |
+
return parent::_prepareForm();
|
246 |
+
}
|
247 |
+
|
248 |
+
//Allows the Ship From Address Fieldset be dependent on the "Use default ship from address" opening and closing.
|
249 |
+
protected function _toHtml()
|
250 |
+
{
|
251 |
+
$dependencyBlock = $this->getLayout()
|
252 |
+
->createBlock('adminhtml/widget_form_element_dependence')
|
253 |
+
->addFieldMap('use_default_address', 'use_default_address')
|
254 |
+
->addFieldMap('ship_from_address1', 'ship_from_address1')
|
255 |
+
->addFieldMap('ship_from_address2', 'ship_from_address2')
|
256 |
+
->addFieldMap('ship_from_city', 'ship_from_city')
|
257 |
+
->addFieldMap('ship_from_country', 'ship_from_country')
|
258 |
+
->addFieldMap('ship_from_state', 'ship_from_state')
|
259 |
+
->addFieldMap('ship_from_zip', 'ship_from_zip')
|
260 |
+
->addFieldMap('use_business_unit', 'use_business_unit')
|
261 |
+
->addFieldMap('business_unit', 'business_unit')
|
262 |
+
|
263 |
+
->addFieldDependence('ship_from_address1', 'use_default_address', '0')
|
264 |
+
->addFieldDependence('ship_from_address2', 'use_default_address', '0')
|
265 |
+
->addFieldDependence('ship_from_city', 'use_default_address', '0')
|
266 |
+
->addFieldDependence('ship_from_country', 'use_default_address', '0')
|
267 |
+
->addFieldDependence('ship_from_state', 'use_default_address', '0')
|
268 |
+
->addFieldDependence('ship_from_zip', 'use_default_address', '0')
|
269 |
+
->addFieldDependence('business_unit', 'use_business_unit', '0');
|
270 |
+
|
271 |
+
return parent::_toHtml() . $dependencyBlock->toHtml();
|
272 |
+
}
|
273 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Block/Adminhtml/Websitestore/Container/Grid.php
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Website/Store configuration grid.
|
4 |
+
*
|
5 |
+
* Grid displaying configuration per Website and store group only.
|
6 |
+
*
|
7 |
+
* @category WoltersKluwer
|
8 |
+
* @package WoltersKluwer_CchSureTax
|
9 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
10 |
+
*/
|
11 |
+
|
12 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
13 |
+
|
14 |
+
class WoltersKluwer_CchSureTax_Block_Adminhtml_Websitestore_Container_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
15 |
+
{
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
$this->setUseAjax(true);
|
19 |
+
parent::__construct();
|
20 |
+
$this->setId('sureTaxWebsiteGrid');
|
21 |
+
$this->setDefaultSort('website_id');
|
22 |
+
$this->setSaveParametersInSession(true);
|
23 |
+
}
|
24 |
+
|
25 |
+
//Load the collection of Website/Stores and their SureTax configuration into the Grid.
|
26 |
+
//Create a default configuration for a store or website if it doesn't already have one.
|
27 |
+
protected function _prepareCollection()
|
28 |
+
{
|
29 |
+
$websites = Mage::app()->getWebsites();
|
30 |
+
$allgroups = Mage::app()->getGroups();
|
31 |
+
$resourceTransaction = Mage::getModel('core/resource_transaction');
|
32 |
+
|
33 |
+
$websiteConfigCollection = Mage::getModel(Constants::WS_CONFIG_TBL)
|
34 |
+
->getCollection()
|
35 |
+
->loadAllWebsiteConfig();
|
36 |
+
|
37 |
+
$storeConfigCollection = Mage::getModel(Constants::WS_CONFIG_TBL)
|
38 |
+
->getCollection()
|
39 |
+
->loadAllStoreConfig();
|
40 |
+
|
41 |
+
$websiteIDs = array();
|
42 |
+
foreach ($websiteConfigCollection as $config) {
|
43 |
+
array_push($websiteIDs, $config->getWebsiteId());
|
44 |
+
}
|
45 |
+
|
46 |
+
foreach ($websites as $website) {
|
47 |
+
$found = in_array($website->getId(), $websiteIDs);
|
48 |
+
|
49 |
+
if (!$found) {
|
50 |
+
$row = Mage::getModel(Constants::WS_CONFIG_TBL);
|
51 |
+
$row->setData(
|
52 |
+
array(
|
53 |
+
'website_id' => $website->getId(),
|
54 |
+
'store_id' => 0,
|
55 |
+
'is_enable_calc' => Constants::USE_GLOBAL_SETTINGS,
|
56 |
+
'use_business_unit' => Constants::YES,
|
57 |
+
'business_unit' => '',
|
58 |
+
'use_default_address' => Constants::YES,
|
59 |
+
'street_address1' => null,
|
60 |
+
'street_address2' => null,
|
61 |
+
'city' => null,
|
62 |
+
'country' => null,
|
63 |
+
'state_province' => null,
|
64 |
+
'zip_postal' => null
|
65 |
+
)
|
66 |
+
);
|
67 |
+
$resourceTransaction->addObject($row);
|
68 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
69 |
+
'Saving Default Website Configuration for website : ' .
|
70 |
+
$website->getName(),
|
71 |
+
Zend_Log::DEBUG
|
72 |
+
);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
$groupIDs = array();
|
77 |
+
foreach ($storeConfigCollection as $config) {
|
78 |
+
array_push($groupIDs, $config->getStoreId());
|
79 |
+
}
|
80 |
+
|
81 |
+
foreach ($allgroups as $group) {
|
82 |
+
$found = in_array($group->getId(), $groupIDs);
|
83 |
+
if (!$found) {
|
84 |
+
$row = Mage::getModel(Constants::WS_CONFIG_TBL);
|
85 |
+
$row->setData(
|
86 |
+
array(
|
87 |
+
'website_id' => $group->getWebsiteId(),
|
88 |
+
'store_id' => $group->getId(),
|
89 |
+
'is_enable_calc' => Constants::USE_WEBSITE_SETTINGS,
|
90 |
+
'use_business_unit' => Constants::YES,
|
91 |
+
'business_unit' => '',
|
92 |
+
'use_default_address' => Constants::YES,
|
93 |
+
'street_address1' => null,
|
94 |
+
'street_address2' => null,
|
95 |
+
'city' => null,
|
96 |
+
'country' => null,
|
97 |
+
'state_province' => null,
|
98 |
+
'zip_postal' => null
|
99 |
+
)
|
100 |
+
);
|
101 |
+
$resourceTransaction->addObject($row);
|
102 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
103 |
+
'Saving Default Store Configuration for Store : ' .
|
104 |
+
$group->getName(),
|
105 |
+
Zend_Log::DEBUG
|
106 |
+
);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
$resourceTransaction->save();
|
111 |
+
|
112 |
+
$collection = Mage::getModel(Constants::WS_CONFIG_TBL)->getCollection();
|
113 |
+
|
114 |
+
$collection->joinWebsite()->joinStore();
|
115 |
+
|
116 |
+
|
117 |
+
$this->setCollection($collection);
|
118 |
+
|
119 |
+
return parent::_prepareCollection();
|
120 |
+
}
|
121 |
+
|
122 |
+
protected function _prepareColumns()
|
123 |
+
{
|
124 |
+
$this->addColumn(
|
125 |
+
'website_id', array(
|
126 |
+
'header' => Mage::helper('suretax')->__('Website ID'),
|
127 |
+
'width' => '100',
|
128 |
+
'index' => 'website_id',
|
129 |
+
'filter_index' => 'main_table.website_id',
|
130 |
+
'type' => 'number'
|
131 |
+
)
|
132 |
+
);
|
133 |
+
|
134 |
+
$websites = $websites = Mage::app()->getWebsites();
|
135 |
+
foreach ($websites as $website) {
|
136 |
+
$ws[$website->getName()] = $website->getName();
|
137 |
+
}
|
138 |
+
|
139 |
+
$allGroups = Mage::app()->getGroups();
|
140 |
+
foreach ($allGroups as $group) {
|
141 |
+
$stores[$group->getName()] = $group->getName();
|
142 |
+
}
|
143 |
+
$this->addColumn(
|
144 |
+
'website', array(
|
145 |
+
'header' => Mage::helper('suretax')->__('Website'),
|
146 |
+
'width' => '100',
|
147 |
+
'index' => 'website',
|
148 |
+
'filter_index' => 'wb.name',
|
149 |
+
'type' => 'options',
|
150 |
+
'options' => $ws
|
151 |
+
)
|
152 |
+
);
|
153 |
+
|
154 |
+
$this->addColumn(
|
155 |
+
'store_id', array(
|
156 |
+
'header' => Mage::helper('suretax')->__('Store ID'),
|
157 |
+
'width' => '100',
|
158 |
+
'index' => 'store_id',
|
159 |
+
'filter_index' => 'main_table.store_id',
|
160 |
+
'type' => 'number'
|
161 |
+
)
|
162 |
+
);
|
163 |
+
|
164 |
+
$this->addColumn(
|
165 |
+
'store', array(
|
166 |
+
'header' => Mage::helper('suretax')->__('Store'),
|
167 |
+
'width' => '100',
|
168 |
+
'index' => 'store',
|
169 |
+
'filter_index' => 'grp.name',
|
170 |
+
'type' => 'options',
|
171 |
+
'options' => $stores
|
172 |
+
)
|
173 |
+
);
|
174 |
+
|
175 |
+
$this->addColumn(
|
176 |
+
'is_enable_calc', array(
|
177 |
+
'header' => Mage::helper('suretax')->__('Enable SureTax Calculation'),
|
178 |
+
'width' => '75',
|
179 |
+
'index' => 'is_enable_calc',
|
180 |
+
'type' => 'options',
|
181 |
+
'options' => array(Constants::USE_WEBSITE_SETTINGS => 'Use Website Settings',
|
182 |
+
Constants::USE_GLOBAL_SETTINGS => 'Use Global Settings',
|
183 |
+
Constants::NO => 'No',
|
184 |
+
Constants::YES => 'Yes')
|
185 |
+
)
|
186 |
+
);
|
187 |
+
|
188 |
+
$this->addColumn(
|
189 |
+
'use_business_unit', array(
|
190 |
+
'header' => Mage::helper('suretax')->__('Use Default Business Unit'),
|
191 |
+
'width' => '75',
|
192 |
+
'index' => 'use_business_unit',
|
193 |
+
'type' => 'options',
|
194 |
+
'options' => array(Constants::NO => 'No',
|
195 |
+
Constants::YES => 'Yes')
|
196 |
+
)
|
197 |
+
);
|
198 |
+
|
199 |
+
$this->addColumn(
|
200 |
+
'business_unit', array(
|
201 |
+
'header' => Mage::helper('suretax')->__('Business Unit'),
|
202 |
+
'width' => '200',
|
203 |
+
'index' => 'business_unit'
|
204 |
+
)
|
205 |
+
);
|
206 |
+
|
207 |
+
$this->addColumn(
|
208 |
+
'use_default_address', array(
|
209 |
+
'header' => Mage::helper('suretax')->__('Use Default Ship From Address'),
|
210 |
+
'width' => '75',
|
211 |
+
'index' => 'use_default_address',
|
212 |
+
'type' => 'options',
|
213 |
+
'options' => array(Constants::NO => 'No',
|
214 |
+
Constants::YES => 'Yes'),
|
215 |
+
)
|
216 |
+
);
|
217 |
+
|
218 |
+
return parent::_prepareColumns();
|
219 |
+
}
|
220 |
+
|
221 |
+
public function getRowUrl($row)
|
222 |
+
{
|
223 |
+
$name = $row->getStoreId() == 0 ? $row->getWebsite() : $row->getStore();
|
224 |
+
|
225 |
+
return $this->getUrl(
|
226 |
+
'*/*/edit', array(
|
227 |
+
'websiteId'=>$row->getWebsiteId(),
|
228 |
+
'storeId'=>$row->getStoreId(),
|
229 |
+
'name'=>$name
|
230 |
+
)
|
231 |
+
);
|
232 |
+
}
|
233 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Helper/Config.php
ADDED
@@ -0,0 +1,417 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Complete configuration used for all SureTax call processing.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
11 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
12 |
+
|
13 |
+
class WoltersKluwer_CchSureTax_Helper_Config extends Mage_Core_Helper_Abstract
|
14 |
+
{
|
15 |
+
protected static $_handle = null;
|
16 |
+
|
17 |
+
const REQUEST_TIMEOUT = 600;
|
18 |
+
const UNIT_TYPE = "00"; // 00 default
|
19 |
+
const AUX_REVENUE_TYPE = "01"; // 01 - freight (only value)
|
20 |
+
|
21 |
+
const WSDL_CACHING = 'WSDL_CACHE_MEMORY';
|
22 |
+
|
23 |
+
protected $_defaultShippingClass = Constants::DEFAULT_TRANS_TYPE_CODE_SHIPPING;
|
24 |
+
protected $_defaultGiftWrapClass = Constants::DEFAULT_TRANS_TYPE_CODE_GIFT_WRAP;
|
25 |
+
protected $_isDebug = false;
|
26 |
+
// set this to DEBUG
|
27 |
+
protected $_isProfiling = true;
|
28 |
+
// global setting
|
29 |
+
protected $_isSuretaxEnabled = 0;
|
30 |
+
|
31 |
+
// holds endpoint URL
|
32 |
+
protected $_endpointUrl = '';
|
33 |
+
|
34 |
+
// no need for wsdl url setter, it's auto set by endpoint url setter
|
35 |
+
protected $_wsdlUrl = '';
|
36 |
+
protected $_clientNumber = '';
|
37 |
+
protected $_businessUnit = '';
|
38 |
+
protected $_validationKey = '';
|
39 |
+
/**
|
40 |
+
* Use 03, don't expect to change this
|
41 |
+
* 03 Tax grouped by State + Customer Number + Invoice Number (Default)
|
42 |
+
*/
|
43 |
+
protected $_responseGroup = "03";
|
44 |
+
// detailed 4 decimal places
|
45 |
+
protected $_responseType = "D4";
|
46 |
+
// 70 retail, 99 default
|
47 |
+
protected $_regulatoryCode = "70";
|
48 |
+
// 23, 24 can be valid for general sales (Origin vs Destination)
|
49 |
+
protected $_taxSitusRule = '22';
|
50 |
+
protected $_providerType = '99';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* must call init before using this
|
54 |
+
*
|
55 |
+
* @return self
|
56 |
+
*/
|
57 |
+
public static function get()
|
58 |
+
{
|
59 |
+
$timeStart = microtime(true);
|
60 |
+
|
61 |
+
if (isset(self::$_handle) == false || self::$_handle === null) {
|
62 |
+
/* @var $_handle WoltersKluwer_CchSureTax_Helper_Config*/
|
63 |
+
self::$_handle = Mage::helper('suretax/config');
|
64 |
+
if (self::$_handle->isProfiling()) {
|
65 |
+
Utility::doProfile($timeStart, 'Config Init ');
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
return self::$_handle;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function __construct()
|
73 |
+
{
|
74 |
+
try {
|
75 |
+
$suretaxConfigData = Utility::getSureTaxConfigData();
|
76 |
+
$endpointUrl = $suretaxConfigData['suretaxurl'];
|
77 |
+
// wsdl url auto set by this
|
78 |
+
$this->setEndpointUrl($endpointUrl);
|
79 |
+
|
80 |
+
$clientNumber = $suretaxConfigData['clientnumber'];
|
81 |
+
$this->setClientNumber($clientNumber);
|
82 |
+
|
83 |
+
$validationKey = $suretaxConfigData['validationkey'];
|
84 |
+
$this->setValidationKey($validationKey);
|
85 |
+
|
86 |
+
$this->setProviderType($suretaxConfigData['providertype']);
|
87 |
+
|
88 |
+
//default is NONE
|
89 |
+
$prodClassId = array_key_exists(
|
90 |
+
'shipping_tax_class',
|
91 |
+
$suretaxConfigData
|
92 |
+
) ? $suretaxConfigData['shipping_tax_class'] : 0;
|
93 |
+
$defShipObj = Mage::getModel('tax/class')->load($prodClassId);
|
94 |
+
$defShip = $defShipObj->getClassName();
|
95 |
+
$this->setDefaultShippingClass($defShip);
|
96 |
+
|
97 |
+
//default is NONE
|
98 |
+
$prodClassIdGift = array_key_exists('gift_wrap_tax_class', $suretaxConfigData)
|
99 |
+
? $suretaxConfigData['gift_wrap_tax_class'] : 0;
|
100 |
+
$defGiftWrapObj = Mage::getModel('tax/class')->load($prodClassIdGift);
|
101 |
+
$defGiftWrap = $defGiftWrapObj->getClassName();
|
102 |
+
$this->setDefaulGiftWrapClass($defGiftWrap);
|
103 |
+
|
104 |
+
$isD = array_key_exists('is_logging_enabled', $suretaxConfigData)
|
105 |
+
? $suretaxConfigData['is_logging_enabled'] == '1' : true;
|
106 |
+
$this->setDebug($isD);
|
107 |
+
|
108 |
+
// default values, but can have site/store specific values
|
109 |
+
$this->setBusinessUnit($suretaxConfigData['defaultbusinessunit']);
|
110 |
+
|
111 |
+
$this->setSuretaxEnabled($suretaxConfigData['is_suretax_enabled']);
|
112 |
+
|
113 |
+
// min requirements for web service calls
|
114 |
+
if ($clientNumber == null
|
115 |
+
|| $validationKey == null
|
116 |
+
|| $endpointUrl == null
|
117 |
+
) {
|
118 |
+
throw new InvalidArgumentException(
|
119 |
+
Constants::MESSAGE_CONFIG_MISSING_ARGUMENTS
|
120 |
+
);
|
121 |
+
}
|
122 |
+
} catch (Exception $exe) {
|
123 |
+
Utility::logCatch($exe, 'Issue with initializing Config');
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
*
|
129 |
+
* @param int $websiteId
|
130 |
+
* @param int $storeId
|
131 |
+
*
|
132 |
+
* @return int
|
133 |
+
*/
|
134 |
+
public static function isSureTaxEnabledForWebsiteStore($websiteId, $storeId)
|
135 |
+
{
|
136 |
+
$sureTaxConfig = self::get();
|
137 |
+
$defaultFlag = $sureTaxConfig->isSuretaxEnabled();
|
138 |
+
|
139 |
+
$row = Mage::getModel(Constants::WS_CONFIG_TBL)
|
140 |
+
->getCollection()
|
141 |
+
->loadWebsiteConfig($websiteId);
|
142 |
+
if (!($row->getIsEnableCalc() === null)) {
|
143 |
+
$websiteFlag = $row->getIsEnableCalc();
|
144 |
+
} else {
|
145 |
+
$websiteFlag = $defaultFlag;
|
146 |
+
}
|
147 |
+
|
148 |
+
$row = Mage::getModel(Constants::WS_CONFIG_TBL)
|
149 |
+
->getCollection()
|
150 |
+
->loadStoreConfig($websiteId, $storeId);
|
151 |
+
if (!($row->getIsEnableCalc() === null)) {
|
152 |
+
$storeFlag = $row->getIsEnableCalc();
|
153 |
+
} else {
|
154 |
+
$storeFlag = $websiteFlag;
|
155 |
+
}
|
156 |
+
|
157 |
+
if ($storeFlag != Constants::USE_WEBSITE_SETTINGS) {
|
158 |
+
return $storeFlag;
|
159 |
+
} elseif ($websiteFlag != Constants::USE_GLOBAL_SETTINGS) {
|
160 |
+
return $websiteFlag;
|
161 |
+
} else {
|
162 |
+
return $defaultFlag;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
*
|
168 |
+
* @return array Array of all the website/store configuration customers have set up.
|
169 |
+
*/
|
170 |
+
public static function getWebsiteStoreConfig()
|
171 |
+
{
|
172 |
+
$wsConfigCollection = Mage::getModel(Constants::WS_CONFIG_TBL)->getCollection();
|
173 |
+
$wsConfigArray = array();
|
174 |
+
foreach ($wsConfigCollection as $wsConfig) {
|
175 |
+
$arrayIndex = $wsConfig->getData('website_id').':'.$wsConfig->getData('store_id');
|
176 |
+
$wsConfigArray[$arrayIndex] = $wsConfig->__toArray();
|
177 |
+
}
|
178 |
+
return $wsConfigArray;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* @param int $websiteId websiteId
|
183 |
+
* @param int $storeId store id
|
184 |
+
* @param array $wsConfigArray entire ws config array
|
185 |
+
* @return int
|
186 |
+
*/
|
187 |
+
public static function isSureTaxEnabledForWebsiteStoreConfig($websiteId, $storeId, $wsConfigArray)
|
188 |
+
{
|
189 |
+
$sureTaxConfig = self::get();
|
190 |
+
$defaultFlag = $sureTaxConfig->isSuretaxEnabled();
|
191 |
+
$websiteFlag = $wsConfigArray[$websiteId.':0'][Constants::ENABLE_CALC];
|
192 |
+
$storeFlag = $wsConfigArray[$websiteId.':'.$storeId][Constants::ENABLE_CALC];
|
193 |
+
if ($storeFlag != Constants::USE_WEBSITE_SETTINGS) {
|
194 |
+
return $storeFlag;
|
195 |
+
} elseif ($websiteFlag != Constants::USE_GLOBAL_SETTINGS) {
|
196 |
+
return $websiteFlag;
|
197 |
+
} else {
|
198 |
+
return $defaultFlag;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @param int $storeId store id
|
204 |
+
* @param array $wsConfigArray entire ws config array
|
205 |
+
* @return int
|
206 |
+
*/
|
207 |
+
public static function isSureTaxEnabledFromStore($storeId, $wsConfigArray)
|
208 |
+
{
|
209 |
+
$sureTaxConfig = self::get();
|
210 |
+
$defaultFlag = $sureTaxConfig->isSuretaxEnabled();
|
211 |
+
$websiteFlag = 0;
|
212 |
+
$storeFlag = 0;
|
213 |
+
foreach ($wsConfigArray as $key => $value) {
|
214 |
+
$keySplit = explode(":", $key);
|
215 |
+
if (in_array($storeId, $keySplit)) {
|
216 |
+
$websiteId = $keySplit[0];
|
217 |
+
$storeFlag = $value[Constants::ENABLE_CALC];
|
218 |
+
$websiteFlag = $wsConfigArray[$websiteId.':0'][Constants::ENABLE_CALC];
|
219 |
+
}
|
220 |
+
}
|
221 |
+
if ($storeFlag != Constants::USE_WEBSITE_SETTINGS) {
|
222 |
+
return $storeFlag;
|
223 |
+
} elseif ($websiteFlag != Constants::USE_GLOBAL_SETTINGS) {
|
224 |
+
return $websiteFlag;
|
225 |
+
} else {
|
226 |
+
return $defaultFlag;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
public function isSuretaxEnabled()
|
231 |
+
{
|
232 |
+
return $this->_isSuretaxEnabled;
|
233 |
+
}
|
234 |
+
|
235 |
+
public function isDebug()
|
236 |
+
{
|
237 |
+
return $this->_isDebug;
|
238 |
+
}
|
239 |
+
|
240 |
+
public function isProfiling()
|
241 |
+
{
|
242 |
+
return $this->_isProfiling;
|
243 |
+
}
|
244 |
+
|
245 |
+
public function getEndpointUrl()
|
246 |
+
{
|
247 |
+
return $this->_endpointUrl;
|
248 |
+
}
|
249 |
+
|
250 |
+
public function getWsdlUrl()
|
251 |
+
{
|
252 |
+
return $this->_wsdlUrl;
|
253 |
+
}
|
254 |
+
|
255 |
+
public function getClientNumber()
|
256 |
+
{
|
257 |
+
return $this->_clientNumber;
|
258 |
+
}
|
259 |
+
|
260 |
+
public function getBusinessUnit()
|
261 |
+
{
|
262 |
+
return $this->_businessUnit;
|
263 |
+
}
|
264 |
+
|
265 |
+
public function getValidationKey()
|
266 |
+
{
|
267 |
+
return $this->_validationKey;
|
268 |
+
}
|
269 |
+
|
270 |
+
public function getRegulatoryCode()
|
271 |
+
{
|
272 |
+
return $this->_regulatoryCode;
|
273 |
+
}
|
274 |
+
|
275 |
+
public function getResponseGroup()
|
276 |
+
{
|
277 |
+
return $this->_responseGroup;
|
278 |
+
}
|
279 |
+
|
280 |
+
public function getResponseType()
|
281 |
+
{
|
282 |
+
return $this->_responseType;
|
283 |
+
}
|
284 |
+
|
285 |
+
public function getUnitType()
|
286 |
+
{
|
287 |
+
return self::UNIT_TYPE;
|
288 |
+
}
|
289 |
+
|
290 |
+
public function getAuxRevenueType()
|
291 |
+
{
|
292 |
+
return self::AUX_REVENUE_TYPE;
|
293 |
+
}
|
294 |
+
|
295 |
+
public function getWsdlCaching()
|
296 |
+
{
|
297 |
+
return self::WSDL_CACHING;
|
298 |
+
}
|
299 |
+
|
300 |
+
public function getDefaultShippingClass()
|
301 |
+
{
|
302 |
+
return $this->_defaultShippingClass;
|
303 |
+
}
|
304 |
+
|
305 |
+
public function getDefaulGiftWrapClass()
|
306 |
+
{
|
307 |
+
return $this->_defaultGiftWrapClass;
|
308 |
+
}
|
309 |
+
|
310 |
+
public function setDefaulGiftWrapClass($defaultGiftWrapClass)
|
311 |
+
{
|
312 |
+
if ($defaultGiftWrapClass != null) {
|
313 |
+
$this->_defaultGiftWrapClass = $defaultGiftWrapClass;
|
314 |
+
} else {
|
315 |
+
Utility::log(
|
316 |
+
Constants::MESSAGE_INVALID_GIFT_WRAP_CLASS .
|
317 |
+
$defaultGiftWrapClass,
|
318 |
+
Zend_Log::INFO,
|
319 |
+
$this->isDebug()
|
320 |
+
);
|
321 |
+
$this->_defaultGiftWrapClass = Constants::DEFAULT_TRANS_TYPE_CODE_GIFT_WRAP;
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
public function setDefaultShippingClass($defaultShippingClass)
|
326 |
+
{
|
327 |
+
if ($defaultShippingClass != null) {
|
328 |
+
$this->_defaultShippingClass = $defaultShippingClass;
|
329 |
+
} else {
|
330 |
+
Utility::log(
|
331 |
+
$this->__(
|
332 |
+
Constants::MESSAGE_INVALID_SHIPPING_CLASS .
|
333 |
+
$defaultShippingClass
|
334 |
+
),
|
335 |
+
Zend_Log::INFO,
|
336 |
+
$this->isDebug()
|
337 |
+
);
|
338 |
+
$this->_defaultShippingClass = Constants
|
339 |
+
::DEFAULT_TRANS_TYPE_CODE_SHIPPING;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
public function setSuretaxEnabled($isSuretaxEnabled)
|
344 |
+
{
|
345 |
+
$this->_isSuretaxEnabled = $isSuretaxEnabled;
|
346 |
+
}
|
347 |
+
public function setDebug($trueOrFalse)
|
348 |
+
{
|
349 |
+
$this->_isDebug = $trueOrFalse;
|
350 |
+
}
|
351 |
+
|
352 |
+
public function setEndpointUrl($theUrlString)
|
353 |
+
{
|
354 |
+
$this->_endpointUrl = $theUrlString;
|
355 |
+
$this->_wsdlUrl = $this->_endpointUrl . '?wsdl';
|
356 |
+
}
|
357 |
+
|
358 |
+
public function setClientNumber($clientNumber)
|
359 |
+
{
|
360 |
+
$this->_clientNumber = $clientNumber;
|
361 |
+
}
|
362 |
+
|
363 |
+
public function setBusinessUnit($businessUnit)
|
364 |
+
{
|
365 |
+
$this->_businessUnit = $businessUnit;
|
366 |
+
}
|
367 |
+
|
368 |
+
public function setValidationKey($validationKey)
|
369 |
+
{
|
370 |
+
$this->_validationKey = $validationKey;
|
371 |
+
}
|
372 |
+
|
373 |
+
public function setResponseGroup($responseGroup)
|
374 |
+
{
|
375 |
+
$this->_responseGroup = $responseGroup;
|
376 |
+
}
|
377 |
+
|
378 |
+
public function setResponseType($responseType)
|
379 |
+
{
|
380 |
+
$this->_responseType = $responseType;
|
381 |
+
}
|
382 |
+
|
383 |
+
public function setRegulatoryCode($regulatoryCode)
|
384 |
+
{
|
385 |
+
$this->_regulatoryCode = $regulatoryCode;
|
386 |
+
}
|
387 |
+
|
388 |
+
public function getRequestTimeout()
|
389 |
+
{
|
390 |
+
return self::REQUEST_TIMEOUT;
|
391 |
+
}
|
392 |
+
|
393 |
+
public function setProfiling($PRO)
|
394 |
+
{
|
395 |
+
$this->_isProfiling = $PRO;
|
396 |
+
}
|
397 |
+
|
398 |
+
public function getTaxSitusRule()
|
399 |
+
{
|
400 |
+
return $this->_taxSitusRule;
|
401 |
+
}
|
402 |
+
|
403 |
+
public function setTaxSitusRule($taxSitusRule)
|
404 |
+
{
|
405 |
+
$this->_taxSitusRule = $taxSitusRule;
|
406 |
+
}
|
407 |
+
|
408 |
+
public function getProviderType()
|
409 |
+
{
|
410 |
+
return $this->_providerType;
|
411 |
+
}
|
412 |
+
|
413 |
+
public function setProviderType($providerType)
|
414 |
+
{
|
415 |
+
$this->_providerType = $providerType;
|
416 |
+
}
|
417 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Helper/Constants.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Holds all constants for central access.
|
4 |
+
* Include messages.
|
5 |
+
*
|
6 |
+
* @category WoltersKluwer
|
7 |
+
* @package WoltersKluwer_CchSureTax
|
8 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
9 |
+
*/
|
10 |
+
|
11 |
+
class WoltersKluwer_CchSureTax_Helper_Constants extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
// names
|
14 |
+
const LOG_FILENAME = 'suretax.log';
|
15 |
+
|
16 |
+
const SOAP_CALL_TIMEOUT = 60;
|
17 |
+
|
18 |
+
// data constants
|
19 |
+
// 990101 is General Sales Trans Type Code
|
20 |
+
const DEFAULT_TRANS_TYPE_CODE = '990101';
|
21 |
+
const DEFAULT_TRANS_TYPE_CODE_SHIPPING = '990101';
|
22 |
+
const DEFAULT_TRANS_TYPE_CODE_GIFT_WRAP = '990101';
|
23 |
+
const PRECISION_DIGITS_FOR_DISPLAY = 4;
|
24 |
+
const PRECISION_DIGITS = 8;
|
25 |
+
|
26 |
+
// for UDF field
|
27 |
+
const DEFAULT_SHIPPING_SKU_NAME = 'Shipping';
|
28 |
+
const DEFAULT_GW_SKU_NAME = 'Gift Wrap';
|
29 |
+
const DEFAULT_GW_CARD_SKU_NAME = 'Gift Wrap Card';
|
30 |
+
const DEFAULT_SHIPPING_LINE_NUMBER = 'Shipping';
|
31 |
+
const DEFAULT_GW_LINE_NUMBER_PREPEND = "GWRAP";
|
32 |
+
const DEFAULT_GW_CARD_LINE_NUMBER = "GWCARD";
|
33 |
+
const DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL = "GIFTORDER";
|
34 |
+
const DEFAULT_SITUS = '22';
|
35 |
+
const DEFAULT_SITUS_DESTINATION = '23';
|
36 |
+
const DEFAULT_SITUS_ORIGIN = '24';
|
37 |
+
|
38 |
+
//Tax Summary Names
|
39 |
+
const SHIPPING_TAX = 'Shipping & Handling Tax';
|
40 |
+
const GW_ORDER_TAX = 'Gift Wrap Order Tax';
|
41 |
+
const GW_ITEMS_TAX = 'Gift Wrap Items Tax';
|
42 |
+
const GW_CARD_TAX = 'Gift Card Tax';
|
43 |
+
|
44 |
+
public static $TAX_SUMMARY_ARRAY = array(
|
45 |
+
'Shipping & Handling Tax',
|
46 |
+
'Gift Wrap Order Tax',
|
47 |
+
'Gift Wrap Items Tax',
|
48 |
+
'Gift Card Tax'
|
49 |
+
);
|
50 |
+
|
51 |
+
// API related
|
52 |
+
// line numbers start with 1, 2, ...
|
53 |
+
const LINE_NUMBER_START_INDEX = 1;
|
54 |
+
const API_RESPONSE_CODE_SUCCESS = '9999';
|
55 |
+
|
56 |
+
// ws constants
|
57 |
+
const VALIDATE_CONFIG_INFO = 'Validate Configuration';
|
58 |
+
|
59 |
+
// messages
|
60 |
+
const MESSAGE_INVALID_SHIPPING_CLASS = 'SureTax: Shipping class is invalid or not set, shipping class reset to default (General Sales). Shipping class value: ';
|
61 |
+
const MESSAGE_INVALID_GIFT_WRAP_CLASS = 'SureTax: Gift Wrap class is invalid or not set, Gift Wrap class reset to default (General Sales). Gift Wrap class value: ';
|
62 |
+
const MESSAGE_CONFIG_MISSING_ARGUMENTS = 'SureTax: Config Missing Arguments: client number, validation key, or endpoint URL.';
|
63 |
+
const MESSAGE_PHP_NOT_CONFIGURED_SOAP = 'SureTax Error: Your PHP configuration (php.ini) must have the following PHP extension enabled: soap (php_soap.dll). See http://www.php.net/ for details.';
|
64 |
+
const MESSAGE_PHP_NOT_CONFIGURED_SSL = 'SureTax Error: Your PHP configuration must have SSL enabled. Typically, this is done by enabling openssl extension (php_openssel.ddl) in your PHP configuration file (php.ini). See http://www.php.net/ for details.';
|
65 |
+
const MESSAGE_CANT_SAVE_CREDIT = 'SureTax Error: Cannot save credit memo.';
|
66 |
+
const MESSAGE_SURETAX_NOT_CONFIGURED = 'SureTax Error: Unable to validate configuration: Please check SureTax URL, Client Number, and Validation Key';
|
67 |
+
// tables
|
68 |
+
const GEN_CONFIG_TBL = 'wolterskluwer_cchsuretax/info';
|
69 |
+
const WS_CONFIG_TBL = 'wolterskluwer_cchsuretax/websitestore_config';
|
70 |
+
const ORDER_TBL = 'wolterskluwer_cchsuretax/order';
|
71 |
+
const INVOICE_TBL = 'wolterskluwer_cchsuretax/invoice';
|
72 |
+
const CREDIT_TBL = 'wolterskluwer_cchsuretax/creditmemo';
|
73 |
+
|
74 |
+
const CUST_TBL = 'wolterskluwer_cchsuretax/customer';
|
75 |
+
const CUST_GRP_TBL = 'wolterskluwer_cchsuretax/customergroup';
|
76 |
+
|
77 |
+
// considered constant
|
78 |
+
// Batch Finalize Allowed Status
|
79 |
+
public static $BATCH_STATUS_ALLOW = array(
|
80 |
+
'Finalize_Fail', 'Cancel_Fail'
|
81 |
+
);
|
82 |
+
|
83 |
+
const USE_WEBSITE_SETTINGS = -2;
|
84 |
+
const USE_GLOBAL_SETTINGS = -1;
|
85 |
+
const NO = 0;
|
86 |
+
const YES = 1;
|
87 |
+
|
88 |
+
const ENABLE_CALC = 'is_enable_calc';
|
89 |
+
const WEBSITE_ID = 'website_id';
|
90 |
+
const STORE_ID = 'store_id';
|
91 |
+
const USE_BUSINESS_UNIT = 'use_business_unit';
|
92 |
+
const BUSINESS_UNIT = 'business_unit';
|
93 |
+
const USE_DEFAULT_ADDRESS = 'use_default_address';
|
94 |
+
const STREET_ADDRESS_1 = 'street_address1';
|
95 |
+
const STREET_ADDRESS_2 = 'street_address2';
|
96 |
+
const CITY = 'city';
|
97 |
+
const COUNTRY = 'country';
|
98 |
+
const STATE_PROVINCE = 'state_province';
|
99 |
+
const ZIP_POSTAL = 'zip_postal';
|
100 |
+
|
101 |
+
const BUSINESS_UNIT_MAX_LENGTH = 20;
|
102 |
+
|
103 |
+
// considered constant
|
104 |
+
public static $SALES_TYPE_CODES = array(
|
105 |
+
'Residential customer' => 'Residential customer',
|
106 |
+
'Business customer' => 'Business customer',
|
107 |
+
'Industrial customer' => 'Industrial customer',
|
108 |
+
'Lifeline customer' => 'Lifeline customer'
|
109 |
+
);
|
110 |
+
|
111 |
+
// considered constant
|
112 |
+
public static $EXEMPTION_TYPE_CODES = array(
|
113 |
+
'None' => 'None',
|
114 |
+
'All Taxes Exempt – Apply no tax or fees' =>
|
115 |
+
'All Taxes Exempt – Apply no tax or fees'
|
116 |
+
);
|
117 |
+
|
118 |
+
// considered constant
|
119 |
+
public static $EXEMPTION_REASON_CODES = array(
|
120 |
+
'None' => 'None',
|
121 |
+
'Federal government' => 'Federal government',
|
122 |
+
'State or local government' => 'State or local government',
|
123 |
+
'Tribal government' => 'Tribal government',
|
124 |
+
'Foreign diplomat' => 'Foreign diplomat',
|
125 |
+
'Charitable organization' => 'Charitable organization',
|
126 |
+
'Religious or educational organization' =>
|
127 |
+
'Religious or educational organization',
|
128 |
+
'Resale' => 'Resale',
|
129 |
+
'Agricultural production' => 'Agricultural production',
|
130 |
+
'Industrial production/manufacturing' =>
|
131 |
+
'Industrial production/manufacturing',
|
132 |
+
'Direct pay permit' => 'Direct pay permit',
|
133 |
+
'Direct mail' => 'Direct mail',
|
134 |
+
'Other' => 'Other'
|
135 |
+
);
|
136 |
+
|
137 |
+
// considered constant
|
138 |
+
public static $SALES_TYPE_CODES_VALUES = array(
|
139 |
+
'Residential customer' => 'R',
|
140 |
+
'Business customer' => 'B',
|
141 |
+
'Industrial customer' => 'I',
|
142 |
+
'Lifeline customer' => 'L'
|
143 |
+
);
|
144 |
+
|
145 |
+
// considered constant
|
146 |
+
public static $EXEMPTION_TYPE_CODES_VALUES = array(
|
147 |
+
'None' => '',
|
148 |
+
'All Taxes Exempt – Apply no tax or fees' => '99'
|
149 |
+
);
|
150 |
+
|
151 |
+
// considered constant
|
152 |
+
public static $EXEMPTION_REASON_CODES_VALUES = array(
|
153 |
+
'None' => '',
|
154 |
+
'Federal government' => '01',
|
155 |
+
'State or local government' => '02',
|
156 |
+
'Tribal government' => '03',
|
157 |
+
'Foreign diplomat' => '04',
|
158 |
+
'Charitable organization' => '05',
|
159 |
+
'Religious or educational organization' => '06',
|
160 |
+
'Resale' => '07',
|
161 |
+
'Agricultural production' => '08',
|
162 |
+
'Industrial production/manufacturing' => '09',
|
163 |
+
'Direct pay permit' => '10',
|
164 |
+
'Direct mail' => '11',
|
165 |
+
'Other' => '12'
|
166 |
+
);
|
167 |
+
|
168 |
+
// considered constant
|
169 |
+
// holds supported countries in 2 digit ISO code, only supported countries
|
170 |
+
// should be in here
|
171 |
+
public static $MAP_COUNTRIES_SUPPORTED = array (
|
172 |
+
'US' => true,
|
173 |
+
'CA' => true,
|
174 |
+
'PR' => true,
|
175 |
+
'VI' => true,
|
176 |
+
'AS' => true,
|
177 |
+
'FM' => true,
|
178 |
+
'GU' => true,
|
179 |
+
'MH' => true,
|
180 |
+
'MP' => true,
|
181 |
+
'PW' => true,
|
182 |
+
);
|
183 |
+
|
184 |
+
const DEFAULT_SALES_TYPE_CODE = 'Residential customer';
|
185 |
+
const DEFAULT_EXEMPTION_CODE = 'None';
|
186 |
+
const DEFAULT_EXEMPTION_REASON_CODE = 'None';
|
187 |
+
|
188 |
+
const SALES_TYPE_CODE_KEY = 'SalesTypeCode';
|
189 |
+
const EXEMPTION_TYPE_CODE_KEY = 'ExemptionCode';
|
190 |
+
const EXEMPTION_REASON_CODE_KEY = 'ExemptionReasonCode';
|
191 |
+
|
192 |
+
const MAXIMUM_NUMBER_OF_ORDERS_TO_PROCESS = 20;
|
193 |
+
const MAXIMUM_NUMBER_OF_INVOICES_TO_PROCESS = 20;
|
194 |
+
|
195 |
+
const FINALIZED_STATUS = 'Finalized';
|
196 |
+
const FINALIZE_FAIL_STATUS = 'Finalize_Fail';
|
197 |
+
const FINALIZE_ADJUSTED = 'Finalize_Adjusted';
|
198 |
+
const FINALIZE_PAYMENT_REQUIRED = 'Finalize_Payment_Required';
|
199 |
+
const ADJUSTMENT_FAIL = 'Adjustment_Fail';
|
200 |
+
|
201 |
+
public static $SURETAX_STATUS = array (
|
202 |
+
'N/A'=>'N/A',
|
203 |
+
self::FINALIZED_STATUS => self::FINALIZED_STATUS,
|
204 |
+
self::FINALIZE_FAIL_STATUS => self::FINALIZE_FAIL_STATUS,
|
205 |
+
self::FINALIZE_ADJUSTED => self::FINALIZE_ADJUSTED,
|
206 |
+
self::FINALIZE_PAYMENT_REQUIRED => self::FINALIZE_PAYMENT_REQUIRED,
|
207 |
+
self::ADJUSTMENT_FAIL => self::ADJUSTMENT_FAIL
|
208 |
+
);
|
209 |
+
|
210 |
+
const RESP_CODE_CANCEL_GT_60 = '1510';
|
211 |
+
|
212 |
+
public static function generateGiftWrapLineNumber($num)
|
213 |
+
{
|
214 |
+
return WoltersKluwer_CchSureTax_Helper_Constants::
|
215 |
+
DEFAULT_GW_LINE_NUMBER_PREPEND . $num;
|
216 |
+
}
|
217 |
+
|
218 |
+
// string keys
|
219 |
+
const CONF_VALIDATION_KEY = 'validationkey';
|
220 |
+
|
221 |
+
const SURETAX_CONFIG_PATH = 'wk/cch/suretax/global/config';
|
222 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Helper/Data.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Required or extension will not install
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
class WoltersKluwer_CchSureTax_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Returns customer exemption info
|
14 |
+
* customer exemption can inherit from customer group if
|
15 |
+
* there is no exemption for the customer, but the group
|
16 |
+
* has exemptions.
|
17 |
+
*
|
18 |
+
* @param int $customerId
|
19 |
+
* @param int $suretaxCustomerId
|
20 |
+
* @return array with following:
|
21 |
+
* 'salesTypeCode' => $salesTypeCode,
|
22 |
+
* 'exemptionCode' => $exemptionCode,
|
23 |
+
* 'exemptionReason' => $exemptionReason,
|
24 |
+
* 'groupName' => $groupName,
|
25 |
+
* 'group' => $group,
|
26 |
+
* 'email' => $email,
|
27 |
+
* 'name' => $name
|
28 |
+
*/
|
29 |
+
public static function getCustomerExemptionInfo($customerId = 0, $suretaxCustomerId = null)
|
30 |
+
{
|
31 |
+
$salesTypeCode = Constants::DEFAULT_SALES_TYPE_CODE;
|
32 |
+
$exemptionCode = Constants::DEFAULT_EXEMPTION_CODE;
|
33 |
+
$exemptionReason = Constants::DEFAULT_EXEMPTION_REASON_CODE;
|
34 |
+
|
35 |
+
// load customer and customer group above where customer belongs to.
|
36 |
+
$customerItem = Mage::getModel(Constants::CUST_TBL)
|
37 |
+
->getCollection()
|
38 |
+
->loadCustomerForExemption($customerId);
|
39 |
+
|
40 |
+
$name = $customerItem->getName();
|
41 |
+
$email = $customerItem->getEmail();
|
42 |
+
$group = $customerItem->getGroupId();
|
43 |
+
$groupName = $customerItem->getCustomerGroupCode();
|
44 |
+
|
45 |
+
// if there's a customer Id
|
46 |
+
if ($suretaxCustomerId !== null) {
|
47 |
+
$suretaxCustomer = Mage::getModel(Constants::CUST_TBL)
|
48 |
+
->load($suretaxCustomerId);
|
49 |
+
$salesTypeCode = $suretaxCustomer->getSalesTypeCode();
|
50 |
+
$exemptionCode = $suretaxCustomer->getExemptionCode();
|
51 |
+
$exemptionReason = $suretaxCustomer->getExemptionReasonCode();
|
52 |
+
} else {
|
53 |
+
$suretaxCustomerGroup = Mage::getModel(Constants::CUST_GRP_TBL)
|
54 |
+
->load($group, 'suretax_customer_group_id');
|
55 |
+
if ($suretaxCustomerGroup !== null) {
|
56 |
+
$salesTypeCode = $suretaxCustomerGroup->getSalesTypeCode();
|
57 |
+
$exemptionCode = $suretaxCustomerGroup->getExemptionCode();
|
58 |
+
$exemptionReason = $suretaxCustomerGroup->getExemptionReasonCode();
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
return array(
|
63 |
+
'salesTypeCode' => $salesTypeCode,
|
64 |
+
'exemptionCode' => $exemptionCode,
|
65 |
+
'exemptionReason' => $exemptionReason,
|
66 |
+
'groupName' => $groupName,
|
67 |
+
'group' => $group,
|
68 |
+
'email' => $email,
|
69 |
+
'name' => $name
|
70 |
+
);
|
71 |
+
}
|
72 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Helper/Env.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* ENV should be '' for production.
|
4 |
+
* set ENV to other value if in multi-dev environment using SureTax
|
5 |
+
* test servers
|
6 |
+
*
|
7 |
+
* @category WoltersKluwer
|
8 |
+
* @package WoltersKluwer_CchSureTax
|
9 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
10 |
+
*/
|
11 |
+
|
12 |
+
class WoltersKluwer_CchSureTax_Helper_Env extends Mage_Core_Helper_Abstract
|
13 |
+
{
|
14 |
+
const ENV = '';
|
15 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Helper/Utility.php
ADDED
@@ -0,0 +1,1110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Utility and commonly used methods
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
|
11 |
+
class WoltersKluwer_CchSureTax_Helper_Utility extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
// Call by isEnterprise() static method, don't use this directly
|
15 |
+
public static $version;
|
16 |
+
protected static $_isEnterprise;
|
17 |
+
/**
|
18 |
+
* log levels:
|
19 |
+
* e.g. Zend_Log::DEBUG
|
20 |
+
* const EMERG = 0; // Emergency: system is unusable
|
21 |
+
* const ALERT = 1; // Alert: action must be taken immediately
|
22 |
+
* const CRIT = 2; // Critical: critical conditions
|
23 |
+
* const ERR = 3; // Error: error conditions
|
24 |
+
* const WARN = 4; // Warning: warning conditions
|
25 |
+
* const NOTICE = 5; // Notice: normal but significant condition
|
26 |
+
* const INFO = 6; // Informational: informational messages
|
27 |
+
* const DEBUG = 7; // Debug: debug messages
|
28 |
+
*
|
29 |
+
* @param string $logMessage
|
30 |
+
* @param int $logLevel Magento's log levels see above
|
31 |
+
* @param boolean $isDebug true or false - if true, then log every level.
|
32 |
+
* if false, log level 0 - 5 if false, log level
|
33 |
+
* 0 - 5
|
34 |
+
* if false, log level 0 - 5
|
35 |
+
*/
|
36 |
+
public static function log($logMessage, $logLevel, $isDebug)
|
37 |
+
{
|
38 |
+
if ($isDebug == true || $logLevel < Zend_Log::INFO) {
|
39 |
+
Mage::log($logMessage, $logLevel, Constants::LOG_FILENAME);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param string $logMessage
|
45 |
+
* @param int $logLevel Magento's log levels see above
|
46 |
+
*/
|
47 |
+
public static function logMessage($logMessage, $logLevel)
|
48 |
+
{
|
49 |
+
$isDebug = false;
|
50 |
+
if (isset($logLevel) && $logLevel < Zend_Log::INFO) {
|
51 |
+
$isDebug = true;
|
52 |
+
}
|
53 |
+
// don't do this level is high enough already
|
54 |
+
if ($isDebug === false) {
|
55 |
+
$sureTaxConfig = WoltersKluwer_CchSureTax_Helper_Config::get();
|
56 |
+
$isDebug = $sureTaxConfig->isSuretaxEnabled();
|
57 |
+
}
|
58 |
+
|
59 |
+
if ($isDebug == true) {
|
60 |
+
Mage::log($logMessage, $logLevel, Constants::LOG_FILENAME);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Validate the Global configuration using SoapRequest with sample data.
|
66 |
+
*
|
67 |
+
* @param array $suretaxConfigData
|
68 |
+
* @return null|string warning messages if invalid. Null if valid
|
69 |
+
*/
|
70 |
+
public static function validateConfiguration($suretaxConfigData)
|
71 |
+
{
|
72 |
+
try {
|
73 |
+
$clientNumber = trim($suretaxConfigData['clientnumber']);
|
74 |
+
$url = trim($suretaxConfigData['suretaxurl']);
|
75 |
+
$validationKey = trim($suretaxConfigData['validationkey']);
|
76 |
+
$businessUnit = trim($suretaxConfigData['defaultbusinessunit']);
|
77 |
+
|
78 |
+
$client = new SoapClient(
|
79 |
+
$url.'?WSDL',
|
80 |
+
array(
|
81 |
+
'trace' => 1,
|
82 |
+
'connection_timeout' => Constants::SOAP_CALL_TIMEOUT,
|
83 |
+
'exceptions' => true,
|
84 |
+
'cache_wsdl' => WSDL_CACHE_NONE,
|
85 |
+
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
|
86 |
+
)
|
87 |
+
);
|
88 |
+
|
89 |
+
$address = array(
|
90 |
+
'PrimaryAddressLine'=>'',
|
91 |
+
'SecondaryAddressLine'=>'',
|
92 |
+
'City'=>'Torrance',
|
93 |
+
'State'=>'CA',
|
94 |
+
'PostalCode'=>'90502',
|
95 |
+
'Country'=>'US',
|
96 |
+
'Plus4'=>"",
|
97 |
+
'VerifyAddress'=>'false'
|
98 |
+
);
|
99 |
+
|
100 |
+
$item =
|
101 |
+
array(
|
102 |
+
'LineNumber'=>'1',
|
103 |
+
'InvoiceNumber'=>'1',
|
104 |
+
'CustomerNumber'=>'',
|
105 |
+
'OrigNumber'=>'',
|
106 |
+
'TermNumber'=>'',
|
107 |
+
'BillToNumber'=>'',
|
108 |
+
'TransDate'=>date('Y-m-d').'T00:00:00',
|
109 |
+
'Revenue'=>1,
|
110 |
+
'AuxRevenue'=>0,
|
111 |
+
'Units'=>1,
|
112 |
+
'UnitType'=>'00',
|
113 |
+
'Seconds'=>'0',
|
114 |
+
'ShipFromPOB'=>1,
|
115 |
+
'MailOrder'=>1,
|
116 |
+
'CommonCarrier'=>1,
|
117 |
+
'TaxIncludedCode'=>'0',
|
118 |
+
'BillingDaysInPeriod'=>'',
|
119 |
+
'TaxSitusRule'=>'22',
|
120 |
+
'TransTypeCode'=> Constants::DEFAULT_TRANS_TYPE_CODE,
|
121 |
+
'SalesTypeCode'=>'R',
|
122 |
+
'RegulatoryCode'=>'99',
|
123 |
+
'ShipToAddress'=>$address,
|
124 |
+
'ShipFromAddress'=>$address
|
125 |
+
);
|
126 |
+
|
127 |
+
$soapCalcRequest=
|
128 |
+
array('request'
|
129 |
+
=>array(
|
130 |
+
'ClientNumber'=> $clientNumber,
|
131 |
+
'BusinessUnit'=>isset($businessUnit) ? $businessUnit : '',
|
132 |
+
'ValidationKey'=>$validationKey,
|
133 |
+
'DataYear'=>date('Y'),
|
134 |
+
'DataMonth'=>date('m'),
|
135 |
+
'TotalRevenue'=>1,
|
136 |
+
'ReturnFileCode'=>'Q',
|
137 |
+
'ClientTracking'=>Constants::VALIDATE_CONFIG_INFO,
|
138 |
+
'STAN'=>'',
|
139 |
+
'MasterTransId'=>'',
|
140 |
+
'ResponseType'=>'D5',
|
141 |
+
'ResponseGroup'=>'03',
|
142 |
+
'ItemList'=>array($item)
|
143 |
+
)
|
144 |
+
);
|
145 |
+
|
146 |
+
$soapResult = $client->SoapRequest($soapCalcRequest);
|
147 |
+
$isSuccessful = $soapResult->SoapRequestResult->Successful;
|
148 |
+
|
149 |
+
if ($isSuccessful == 'Y') {
|
150 |
+
return null;
|
151 |
+
} else {
|
152 |
+
self::log(
|
153 |
+
'Configuration Validation Issue : Invalid : ' .
|
154 |
+
$soapResult->SoapRequestResult->HeaderMessage,
|
155 |
+
Zend_Log::ERR,
|
156 |
+
true
|
157 |
+
);
|
158 |
+
return 'Invalid : ' . $soapResult->SoapRequestResult->HeaderMessage;
|
159 |
+
}
|
160 |
+
} catch (Exception $ere) {
|
161 |
+
|
162 |
+
$isPhpConfigured = self::isPhpConfigured();
|
163 |
+
if ($isPhpConfigured !== true) {
|
164 |
+
self::log($isPhpConfigured, Zend_Log::ERR, true);
|
165 |
+
return $isPhpConfigured;
|
166 |
+
} else {
|
167 |
+
self::log(
|
168 |
+
'Configuration Validation Error : ' . $ere->getMessage(),
|
169 |
+
Zend_Log::ERR,
|
170 |
+
true
|
171 |
+
);
|
172 |
+
}
|
173 |
+
|
174 |
+
return Constants::MESSAGE_SURETAX_NOT_CONFIGURED;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
*
|
180 |
+
* @param mixed $timeStart must be microtime(true)
|
181 |
+
* @param string $messagePrepend string describing what time elapsed is for
|
182 |
+
*/
|
183 |
+
public static function doProfile($timeStart, $messagePrepend)
|
184 |
+
{
|
185 |
+
self::log(
|
186 |
+
"Time elapsed (seconds) - $messagePrepend:" .
|
187 |
+
(microtime(true) - $timeStart), Zend_Log::INFO, true
|
188 |
+
);
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @param Exception $ex
|
193 |
+
* @param string $prependString
|
194 |
+
*/
|
195 |
+
public static function logCatch($ex, $prependString)
|
196 |
+
{
|
197 |
+
// always log exceptions
|
198 |
+
self::log(
|
199 |
+
$prependString . '. LogCatch: ' .
|
200 |
+
$ex->getMessage() . '. TRACE: ' .
|
201 |
+
$ex->getTraceAsString(), Zend_Log::ERR, true
|
202 |
+
);
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
*
|
207 |
+
* @return array GLOBAL configuration in array form.
|
208 |
+
*/
|
209 |
+
public static function getSureTaxConfigData()
|
210 |
+
{
|
211 |
+
$suretaxConfigData = Mage::getStoreConfig(Constants::SURETAX_CONFIG_PATH);
|
212 |
+
$value = Mage::helper('core')->decrypt($suretaxConfigData['validationkey']);
|
213 |
+
$suretaxConfigData['validationkey'] = $value;
|
214 |
+
return $suretaxConfigData;
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Returns default ship from or website/store specific ship from
|
220 |
+
*
|
221 |
+
* @param int $websiteId
|
222 |
+
* @param int $storeId
|
223 |
+
*
|
224 |
+
* @return array string holding ship from address info
|
225 |
+
*/
|
226 |
+
public static function getShipFromAddress($websiteId, $storeId)
|
227 |
+
{
|
228 |
+
$webRow = Mage::getModel(Constants::WS_CONFIG_TBL)
|
229 |
+
->getCollection()
|
230 |
+
->loadWebsiteConfig($websiteId);
|
231 |
+
if (!($webRow->getUseDefaultAddress() === null)) {
|
232 |
+
$websiteFlag = $webRow->getUseDefaultAddress();
|
233 |
+
} else {
|
234 |
+
$websiteFlag = 1;
|
235 |
+
}
|
236 |
+
|
237 |
+
$storeRow = Mage::getModel(Constants::WS_CONFIG_TBL)
|
238 |
+
->getCollection()
|
239 |
+
->loadStoreConfig($websiteId, $storeId);
|
240 |
+
if (!($storeRow->getUseDefaultAddress() === null)) {
|
241 |
+
$storeFlag = $storeRow->getUseDefaultAddress();
|
242 |
+
} else {
|
243 |
+
$storeFlag = 1;
|
244 |
+
}
|
245 |
+
|
246 |
+
if ($storeFlag == 0) {
|
247 |
+
$country = $storeRow->getCountry();
|
248 |
+
$shipFromState = $storeRow->getStateProvince();
|
249 |
+
$shipFromPostcode = $storeRow->getZipPostal();
|
250 |
+
$shipFromAddressLine1 = $storeRow->getStreetAddress1();
|
251 |
+
$shipFromAddressLine2 = $storeRow->getStreetAddress2();
|
252 |
+
$shipFromCity = $storeRow->getCity();
|
253 |
+
|
254 |
+
} else if ($websiteFlag == 0) {
|
255 |
+
$country = $webRow->getCountry();
|
256 |
+
$shipFromState = $webRow->getStateProvince();
|
257 |
+
$shipFromPostcode = $webRow->getZipPostal();
|
258 |
+
$shipFromAddressLine1 = $webRow->getStreetAddress1();
|
259 |
+
$shipFromAddressLine2 = $webRow->getStreetAddress2();
|
260 |
+
$shipFromCity = $webRow->getCity();
|
261 |
+
|
262 |
+
} else {
|
263 |
+
// get default ship-from-address from system
|
264 |
+
$regionId = Mage::getStoreConfig('shipping/origin/region_id');
|
265 |
+
// should be 2 digit iso code
|
266 |
+
$country = Mage::getStoreConfig('shipping/origin/country_id');
|
267 |
+
$shipFromState = self::getStateCodeFromRegionId($regionId);
|
268 |
+
$shipFromPostcode = Mage::getStoreConfig('shipping/origin/postcode');
|
269 |
+
$shipFromAddressLine1 = Mage::getStoreConfig('shipping/origin/street_line1');
|
270 |
+
$shipFromAddressLine2 = Mage::getStoreConfig('shipping/origin/street_line2');
|
271 |
+
$shipFromCity = Mage::getStoreConfig('shipping/origin/city');
|
272 |
+
}
|
273 |
+
|
274 |
+
// ship from is always scrubbed
|
275 |
+
$verifyAddress = true;
|
276 |
+
if (isset($country) && strcasecmp($country, 'US') !== 0) {
|
277 |
+
$verifyAddress = false;
|
278 |
+
}
|
279 |
+
|
280 |
+
$shipFromAddress = array(
|
281 |
+
'PrimaryAddressLine'=>$shipFromAddressLine1,
|
282 |
+
'SecondaryAddressLine'=>$shipFromAddressLine2,
|
283 |
+
'City'=>$shipFromCity,
|
284 |
+
'State'=>$shipFromState,
|
285 |
+
'PostalCode'=>$shipFromPostcode,
|
286 |
+
'Plus4'=>"",
|
287 |
+
'Country'=>$country,
|
288 |
+
'VerifyAddress'=>$verifyAddress
|
289 |
+
);
|
290 |
+
|
291 |
+
return $shipFromAddress;
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* Returns default ship from or website/store specific ship from
|
296 |
+
*
|
297 |
+
* @param int $websiteId
|
298 |
+
* @param int $storeId
|
299 |
+
* @param array $wsConfigArray
|
300 |
+
*
|
301 |
+
* @return array string holding ship from address info
|
302 |
+
*/
|
303 |
+
public static function getShipFromAddressFromConfig($websiteId, $storeId, $wsConfigArray)
|
304 |
+
{
|
305 |
+
$websiteFlag = $wsConfigArray[$websiteId.':0'][Constants::USE_DEFAULT_ADDRESS];
|
306 |
+
$storeFlag = $wsConfigArray[$websiteId.':'.$storeId][Constants::USE_DEFAULT_ADDRESS];
|
307 |
+
|
308 |
+
if ($storeFlag == 0) {
|
309 |
+
$country = $wsConfigArray[$websiteId.':'.$storeId][Constants::COUNTRY];
|
310 |
+
$shipFromState = $wsConfigArray[$websiteId.':'.$storeId][Constants::STATE_PROVINCE];
|
311 |
+
$shipFromPostcode = $wsConfigArray[$websiteId.':'.$storeId][Constants::ZIP_POSTAL];
|
312 |
+
$shipFromAddressLine1 = $wsConfigArray[$websiteId.':'.$storeId][Constants::STREET_ADDRESS_1];
|
313 |
+
$shipFromAddressLine2 = $wsConfigArray[$websiteId.':'.$storeId][Constants::STREET_ADDRESS_2];
|
314 |
+
$shipFromCity = $wsConfigArray[$websiteId.':'.$storeId][Constants::CITY];
|
315 |
+
|
316 |
+
} else if ($websiteFlag == 0) {
|
317 |
+
$country = $wsConfigArray[$websiteId.':0'][Constants::COUNTRY];
|
318 |
+
$shipFromState = $wsConfigArray[$websiteId.':0'][Constants::STATE_PROVINCE];
|
319 |
+
$shipFromPostcode = $wsConfigArray[$websiteId.':0'][Constants::ZIP_POSTAL];
|
320 |
+
$shipFromAddressLine1 = $wsConfigArray[$websiteId.':0'][Constants::STREET_ADDRESS_1];
|
321 |
+
$shipFromAddressLine2 = $wsConfigArray[$websiteId.':0'][Constants::STREET_ADDRESS_2];
|
322 |
+
$shipFromCity = $wsConfigArray[$websiteId.':0'][Constants::CITY];
|
323 |
+
|
324 |
+
} else {
|
325 |
+
// get default ship-from-address from system
|
326 |
+
$regionId = Mage::getStoreConfig('shipping/origin/region_id');
|
327 |
+
// should be 2 digit iso code
|
328 |
+
$country = Mage::getStoreConfig('shipping/origin/country_id');
|
329 |
+
$shipFromState = self::getStateCodeFromRegionId($regionId);
|
330 |
+
$shipFromPostcode = Mage::getStoreConfig('shipping/origin/postcode');
|
331 |
+
$shipFromAddressLine1 = Mage::getStoreConfig('shipping/origin/street_line1');
|
332 |
+
$shipFromAddressLine2 = Mage::getStoreConfig('shipping/origin/street_line2');
|
333 |
+
$shipFromCity = Mage::getStoreConfig('shipping/origin/city');
|
334 |
+
}
|
335 |
+
|
336 |
+
// ship from is always scrubbed
|
337 |
+
$verifyAddress = true;
|
338 |
+
if (isset($country) && strcasecmp($country, 'US') !== 0) {
|
339 |
+
$verifyAddress = false;
|
340 |
+
}
|
341 |
+
|
342 |
+
$shipFromAddress = array(
|
343 |
+
'PrimaryAddressLine'=>$shipFromAddressLine1,
|
344 |
+
'SecondaryAddressLine'=>$shipFromAddressLine2,
|
345 |
+
'City'=>$shipFromCity,
|
346 |
+
'State'=>$shipFromState,
|
347 |
+
'PostalCode'=>$shipFromPostcode,
|
348 |
+
'Plus4'=>"",
|
349 |
+
'Country'=>$country,
|
350 |
+
'VerifyAddress'=>$verifyAddress
|
351 |
+
);
|
352 |
+
|
353 |
+
return $shipFromAddress;
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* @param string $regionId
|
358 |
+
* @return string
|
359 |
+
*/
|
360 |
+
public static function getStateCodeFromRegionId($regionId)
|
361 |
+
{
|
362 |
+
$shipFromState = "";
|
363 |
+
if ($regionId) {
|
364 |
+
$region = Mage::getModel('directory/region')->load($regionId);
|
365 |
+
$shipFromState = $region->getCode();
|
366 |
+
}
|
367 |
+
return $shipFromState;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest $request
|
372 |
+
* @param type $response
|
373 |
+
*
|
374 |
+
* @return array
|
375 |
+
*/
|
376 |
+
public static function getLineItemLevelTaxByResponseWithRequest($request, $response)
|
377 |
+
{
|
378 |
+
$groups = isset($response->SoapRequestResult->GroupList->Group);
|
379 |
+
// if not set, we have no tax.
|
380 |
+
if (!$groups) {
|
381 |
+
return null;
|
382 |
+
}
|
383 |
+
$groups = $response->SoapRequestResult->GroupList->Group;
|
384 |
+
|
385 |
+
$items = $request->getItemList();
|
386 |
+
|
387 |
+
$lineItemTaxArray = array();
|
388 |
+
if (count($groups) > 0) {
|
389 |
+
foreach ($groups as $group) {
|
390 |
+
$jurisdictionArray = $group->TaxList->Tax;
|
391 |
+
$taxAmount = 0;
|
392 |
+
$revBase = 0;
|
393 |
+
$rev = 0;
|
394 |
+
foreach ($jurisdictionArray as $jurisdiction) {
|
395 |
+
$taxAmount = $taxAmount + $jurisdiction->TaxAmount;
|
396 |
+
|
397 |
+
if ($revBase == 0) {
|
398 |
+
$revBase = $jurisdiction->RevenueBase;
|
399 |
+
}
|
400 |
+
|
401 |
+
if ($rev == 0) {
|
402 |
+
$rev = $jurisdiction->Revenue;
|
403 |
+
}
|
404 |
+
}
|
405 |
+
$lineItemNumber = $group->LineNumber;
|
406 |
+
$stateCode = $group->StateCode;
|
407 |
+
$lineItemTaxArray[$lineItemNumber] = array(
|
408 |
+
'StateCode'=>$stateCode,
|
409 |
+
'RevenueBase'=>$revBase,
|
410 |
+
'Revenue'=>$rev,
|
411 |
+
'LineItemNumber'=>$lineItemNumber,
|
412 |
+
'LineItemTax'=>$taxAmount
|
413 |
+
);
|
414 |
+
}
|
415 |
+
} else {
|
416 |
+
|
417 |
+
foreach ($items as $item) {
|
418 |
+
$rev = $item->Revenue;
|
419 |
+
$lineItemTaxArray[$item->LineNumber] = array(
|
420 |
+
'RevenueBase'=>$rev,
|
421 |
+
'Revenue'=>$rev,
|
422 |
+
'LineItemNumber'=>$item->LineNumber,
|
423 |
+
'LineItemTax'=>0
|
424 |
+
);
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
return $lineItemTaxArray;
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* for makeSureTaxRequestFromOrder() this returns an error
|
433 |
+
* if Mage_Sales_Model_Quote_Address is used in method
|
434 |
+
* declaration.
|
435 |
+
*
|
436 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
437 |
+
* @return array with address data
|
438 |
+
*/
|
439 |
+
public static function getShipToAddress($address)
|
440 |
+
{
|
441 |
+
$addressLine1 = "";
|
442 |
+
if (array_key_exists(0, $address->getStreet(0))) {
|
443 |
+
$addressLine1 = $address->getStreet(0)[0];
|
444 |
+
}
|
445 |
+
$addressLine2 = "";
|
446 |
+
if (array_key_exists(1, $address->getStreet(0))) {
|
447 |
+
$addressLine2 = $address->getStreet(0)[1];
|
448 |
+
}
|
449 |
+
$city = $address->getCity();
|
450 |
+
$stateCode = $address->getRegionCode();
|
451 |
+
|
452 |
+
$zip = $address->getPostcode();
|
453 |
+
|
454 |
+
$country = $address->getCountryModel()->getIso2Code();
|
455 |
+
|
456 |
+
// if we only have state + zip, then don't verify address.
|
457 |
+
$tStateCode = trim($stateCode);
|
458 |
+
$tZip = trim($zip);
|
459 |
+
$verifyAddress =
|
460 |
+
(
|
461 |
+
(trim($addressLine1) == false)
|
462 |
+
&& (trim($city) == false)
|
463 |
+
&& (trim($addressLine2) == false)
|
464 |
+
&& ($tStateCode != false)
|
465 |
+
&& ($tZip != false && strlen($tZip) == 5)
|
466 |
+
) == true ? false : true;
|
467 |
+
if (isset($country) && strcasecmp($country, 'US') !== 0) {
|
468 |
+
$verifyAddress = false;
|
469 |
+
}
|
470 |
+
|
471 |
+
$estimatedAddress = array(
|
472 |
+
'PrimaryAddressLine'=>$addressLine1,
|
473 |
+
'SecondaryAddressLine'=>$addressLine2,
|
474 |
+
'City'=>$city,
|
475 |
+
'State'=>$stateCode,
|
476 |
+
'PostalCode'=>$zip,
|
477 |
+
'Plus4'=>"",
|
478 |
+
'Country'=>$country,
|
479 |
+
'VerifyAddress'=>$verifyAddress);
|
480 |
+
|
481 |
+
return $estimatedAddress;
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* @param string $street
|
486 |
+
* @param string $city
|
487 |
+
* @param string $zip
|
488 |
+
* @param string $stateCode
|
489 |
+
* @param string $country
|
490 |
+
*
|
491 |
+
* @return array $estimatedAddress
|
492 |
+
*/
|
493 |
+
public static function getAddress($street, $city, $zip, $stateCode, $country)
|
494 |
+
{
|
495 |
+
$addressLine1 = "";
|
496 |
+
$streetArray = array();
|
497 |
+
if (!empty($street)) {
|
498 |
+
$streetArray = explode("\n", $street);
|
499 |
+
}
|
500 |
+
if (array_key_exists(0, $streetArray)) {
|
501 |
+
$addressLine1 = $streetArray[0];
|
502 |
+
}
|
503 |
+
$addressLine2 = "";
|
504 |
+
if (array_key_exists(1, $streetArray)) {
|
505 |
+
$addressLine2 = $streetArray[1];
|
506 |
+
}
|
507 |
+
// if we only have state + zip, then don't verify address.
|
508 |
+
$tStateCode = trim($stateCode);
|
509 |
+
$tZip = trim($zip);
|
510 |
+
$verifyAddress =
|
511 |
+
(
|
512 |
+
(trim($addressLine1) == false)
|
513 |
+
&& (trim($city) == false)
|
514 |
+
&& (trim($addressLine2) == false)
|
515 |
+
&& ($tStateCode != false)
|
516 |
+
&& ($tZip != false && strlen($tZip) == 5)
|
517 |
+
) == true ? false : true;
|
518 |
+
if (isset($country) && strcasecmp($country, 'US') !== 0) {
|
519 |
+
$verifyAddress = false;
|
520 |
+
}
|
521 |
+
|
522 |
+
$estimatedAddress = array(
|
523 |
+
'PrimaryAddressLine'=>$addressLine1,
|
524 |
+
'SecondaryAddressLine'=>$addressLine2,
|
525 |
+
'City'=>$city,
|
526 |
+
'State'=>$stateCode,
|
527 |
+
'PostalCode'=>$zip,
|
528 |
+
'Plus4'=>"",
|
529 |
+
'Country'=>$country,
|
530 |
+
'VerifyAddress'=>$verifyAddress);
|
531 |
+
|
532 |
+
return $estimatedAddress;
|
533 |
+
}
|
534 |
+
|
535 |
+
/**
|
536 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
537 |
+
* @return array
|
538 |
+
*/
|
539 |
+
public static function getCustomerBillingAddress($address)
|
540 |
+
{
|
541 |
+
$billingAddressQuote = $address->getQuote()->getBillingAddress();
|
542 |
+
$addressLine1 = "";
|
543 |
+
if (array_key_exists(0, $billingAddressQuote->getStreet(0))) {
|
544 |
+
$addressLine1 = $billingAddressQuote->getStreet(0)[0];
|
545 |
+
}
|
546 |
+
$addressLine2 = "";
|
547 |
+
if (array_key_exists(1, $billingAddressQuote->getStreet(0))) {
|
548 |
+
$addressLine2 = $billingAddressQuote->getStreet(0)[1];
|
549 |
+
}
|
550 |
+
$city = $billingAddressQuote->getCity();
|
551 |
+
$stateCode = $billingAddressQuote->getRegionCode();
|
552 |
+
$zip = $billingAddressQuote->getPostcode();
|
553 |
+
$country = $address->getCountryModel()->getIso2Code();
|
554 |
+
$tStateCode = trim($stateCode);
|
555 |
+
$tZip = trim($zip);
|
556 |
+
$verifyAddress =
|
557 |
+
(
|
558 |
+
(trim($addressLine1) == false)
|
559 |
+
&& (trim($city) == false)
|
560 |
+
&& (trim($addressLine2) == false)
|
561 |
+
&& ($tStateCode != false)
|
562 |
+
&& ($tZip != false && strlen($tZip) == 5)
|
563 |
+
) == true ? false : true;
|
564 |
+
if (isset($country) && strcasecmp($country, 'US') !== 0) {
|
565 |
+
$verifyAddress = false;
|
566 |
+
}
|
567 |
+
|
568 |
+
$billingAddress = array(
|
569 |
+
'PrimaryAddressLine'=>$addressLine1,
|
570 |
+
'SecondaryAddressLine'=>$addressLine2,
|
571 |
+
'City'=>$city,
|
572 |
+
'State'=>$stateCode,
|
573 |
+
'PostalCode'=>$zip,
|
574 |
+
'Plus4'=>"",
|
575 |
+
'Country'=>$country,
|
576 |
+
'VerifyAddress'=>$verifyAddress);
|
577 |
+
|
578 |
+
return $billingAddress;
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
*
|
583 |
+
* @param int $websiteId
|
584 |
+
* @param int $storeId
|
585 |
+
*
|
586 |
+
* @return int
|
587 |
+
*/
|
588 |
+
public static function isSureTaxEnabled($websiteId, $storeId)
|
589 |
+
{
|
590 |
+
$sureTaxConfig = WoltersKluwer_CchSureTax_Helper_Config::get();
|
591 |
+
$defaultFlag = $sureTaxConfig->isSuretaxEnabled();
|
592 |
+
|
593 |
+
$row = Mage::getModel('wolterskluwer_cchsuretax/websitestore_config')
|
594 |
+
->getCollection()
|
595 |
+
->loadWebsiteConfig($websiteId);
|
596 |
+
$websiteFlag = $row->getIsEnableCalc();
|
597 |
+
|
598 |
+
$row = Mage::getModel('wolterskluwer_cchsuretax/websitestore_config')
|
599 |
+
->getCollection()
|
600 |
+
->loadStoreConfig($websiteId, $storeId);
|
601 |
+
$storeFlag = $row->getIsEnableCalc();
|
602 |
+
|
603 |
+
if ($storeFlag !=Constants::USE_WEBSITE_SETTINGS
|
604 |
+
) {
|
605 |
+
return $storeFlag;
|
606 |
+
} else if ($websiteFlag !=Constants::USE_GLOBAL_SETTINGS
|
607 |
+
) {
|
608 |
+
return $websiteFlag;
|
609 |
+
} else {
|
610 |
+
return $defaultFlag;
|
611 |
+
}
|
612 |
+
}
|
613 |
+
|
614 |
+
/**
|
615 |
+
* Check to see if SoapClient is configured.
|
616 |
+
*
|
617 |
+
* @returns boolean | string
|
618 |
+
*/
|
619 |
+
public static function isPhpConfigured()
|
620 |
+
{
|
621 |
+
if (!class_exists('SoapClient')) {
|
622 |
+
return Constants::MESSAGE_PHP_NOT_CONFIGURED_SOAP;
|
623 |
+
}
|
624 |
+
if (!extension_loaded('openssl')) {
|
625 |
+
return Constants::MESSAGE_PHP_NOT_CONFIGURED_SSL;
|
626 |
+
}
|
627 |
+
return true;
|
628 |
+
}
|
629 |
+
|
630 |
+
/**
|
631 |
+
* SureTax supports USA and CANADA
|
632 |
+
*
|
633 |
+
* @param string $country 2 digit ISO uppercase + trimmed country code
|
634 |
+
*
|
635 |
+
* @returns boolean true if supported country, else false
|
636 |
+
*/
|
637 |
+
public static function isSureTaxSupportedCountry($country = null)
|
638 |
+
{
|
639 |
+
if ($country && array_key_exists(
|
640 |
+
$country,
|
641 |
+
Constants::$MAP_COUNTRIES_SUPPORTED
|
642 |
+
)) {
|
643 |
+
return true;
|
644 |
+
}
|
645 |
+
return false;
|
646 |
+
}
|
647 |
+
|
648 |
+
/**
|
649 |
+
* Print out all incrementIds in the array separated by commas.
|
650 |
+
*
|
651 |
+
* @param array $incrementIds
|
652 |
+
*
|
653 |
+
* @return string
|
654 |
+
*/
|
655 |
+
public static function displayIncrementIds($incrementIds)
|
656 |
+
{
|
657 |
+
return implode(", ", $incrementIds);
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* @param type $response
|
662 |
+
*
|
663 |
+
* @return array
|
664 |
+
*/
|
665 |
+
public static function getJurisdictionLevelTaxesFromSureTaxResponse($response)
|
666 |
+
{
|
667 |
+
$jurisdictionArray = array();
|
668 |
+
|
669 |
+
if (!isset($response->SoapRequestResult->GroupList->Group) ) {
|
670 |
+
return $jurisdictionArray;
|
671 |
+
}
|
672 |
+
|
673 |
+
$groups = $response->SoapRequestResult->GroupList->Group;
|
674 |
+
|
675 |
+
foreach ($groups as $group) {
|
676 |
+
$lineNumber = $group->LineNumber;
|
677 |
+
$taxArray = $group->TaxList->Tax;
|
678 |
+
$taxRate = 0.00;
|
679 |
+
foreach ($taxArray as $jurisdiction) {
|
680 |
+
$taxTypeCode = $jurisdiction->TaxTypeCode;
|
681 |
+
$taxTypeDesc = $jurisdiction->TaxTypeDesc;
|
682 |
+
|
683 |
+
if (is_numeric($lineNumber)) {
|
684 |
+
$taxRate = $jurisdiction->TaxRate;
|
685 |
+
} else {
|
686 |
+
$taxRate = $taxRate + $jurisdiction->TaxRate;
|
687 |
+
}
|
688 |
+
|
689 |
+
$taxAuthorityName = $jurisdiction->TaxAuthorityName;
|
690 |
+
$theKey = self::generateJurisdictionTitle(
|
691 |
+
$taxTypeDesc,
|
692 |
+
$taxAuthorityName,
|
693 |
+
$taxTypeCode
|
694 |
+
);
|
695 |
+
if (!array_key_exists($theKey, $jurisdictionArray)) {
|
696 |
+
$jurisdictionArray[$theKey] = $taxRate * 100;
|
697 |
+
}
|
698 |
+
}
|
699 |
+
}
|
700 |
+
return $jurisdictionArray;
|
701 |
+
}
|
702 |
+
|
703 |
+
/**
|
704 |
+
* @param string $arrayKeys
|
705 |
+
* @param string $id
|
706 |
+
*
|
707 |
+
* @return string
|
708 |
+
*/
|
709 |
+
public static function checkIfIdExistsInArray($arrayKeys, $id)
|
710 |
+
{
|
711 |
+
foreach ($arrayKeys as $value) {
|
712 |
+
if (strpos($value, $id) !== false) {
|
713 |
+
return $value;
|
714 |
+
} else {
|
715 |
+
continue;
|
716 |
+
}
|
717 |
+
}
|
718 |
+
return 'false';
|
719 |
+
}
|
720 |
+
|
721 |
+
/**
|
722 |
+
* @param string $haystack
|
723 |
+
* @param string $needle
|
724 |
+
*
|
725 |
+
* @return string
|
726 |
+
*/
|
727 |
+
public static function startsWith($haystack, $needle)
|
728 |
+
{
|
729 |
+
return 0 === strpos($haystack, $needle);
|
730 |
+
}
|
731 |
+
|
732 |
+
/**
|
733 |
+
*
|
734 |
+
* @param Mage_Sales_Model_Order | Mage_Sales_Model_Order_Creditmemo |
|
735 |
+
* Mage_Sales_Model_Quote_Address $object
|
736 |
+
* @return boolean
|
737 |
+
*/
|
738 |
+
public static function isGiftWrap($object)
|
739 |
+
{
|
740 |
+
if (self::isEnterprise() && $object->getGwBasePrice()) {
|
741 |
+
return true;
|
742 |
+
}
|
743 |
+
return false;
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Quote, Address, Order, and Credit memos
|
748 |
+
* not at line item level
|
749 |
+
*
|
750 |
+
* @param type $object
|
751 |
+
* @return boolean
|
752 |
+
*/
|
753 |
+
public static function isGiftWrapCard($object)
|
754 |
+
{
|
755 |
+
if (self::isEnterprise() && $object->getGwCardBasePrice()) {
|
756 |
+
return true;
|
757 |
+
}
|
758 |
+
return false;
|
759 |
+
}
|
760 |
+
|
761 |
+
/**
|
762 |
+
* Assumes only 1 unique jurisdction (TaxAuth and Taxtype combo) per line
|
763 |
+
*
|
764 |
+
* Totals taxes for each jurisdiction level
|
765 |
+
*
|
766 |
+
* @param $response SureTax SOAPRequest method's API response
|
767 |
+
* @return array
|
768 |
+
* index are from generateJurisdictionKey() method
|
769 |
+
* each index holds:
|
770 |
+
* TaxTypeCode
|
771 |
+
* TaxTypeDesc
|
772 |
+
* TaxAmount
|
773 |
+
* TaxRate
|
774 |
+
* TaxAuthorityName
|
775 |
+
* RevenueBase
|
776 |
+
* Revenue
|
777 |
+
*/
|
778 |
+
public static function getJurisdictionLevelTaxesTotaledFromResponse($response)
|
779 |
+
{
|
780 |
+
$jurisdictionArray = array();
|
781 |
+
if (!isset($response->SoapRequestResult->GroupList->Group) ) {
|
782 |
+
return $jurisdictionArray;
|
783 |
+
}
|
784 |
+
|
785 |
+
$groups = $response->SoapRequestResult->GroupList->Group;
|
786 |
+
|
787 |
+
foreach ($groups as $group) {
|
788 |
+
$lineNumber = $group->LineNumber;
|
789 |
+
$taxArray = $group->TaxList->Tax;
|
790 |
+
|
791 |
+
foreach ($taxArray as $jurisdiction) {
|
792 |
+
$taxTypeCode = $jurisdiction->TaxTypeCode;
|
793 |
+
$taxAuthId = $jurisdiction->TaxAuthorityID;
|
794 |
+
$taxTypeDesc = $jurisdiction->TaxTypeDesc;
|
795 |
+
$taxAmount = $jurisdiction->TaxAmount;
|
796 |
+
$taxAuthorityName = $jurisdiction->TaxAuthorityName;
|
797 |
+
$revenue = $jurisdiction->Revenue;
|
798 |
+
$taxRate = $jurisdiction->TaxRate;
|
799 |
+
|
800 |
+
$calcRate = round(
|
801 |
+
($taxAmount / $revenue),
|
802 |
+
Constants::PRECISION_DIGITS,
|
803 |
+
PHP_ROUND_HALF_UP
|
804 |
+
);
|
805 |
+
if ($calcRate != $taxRate ) {
|
806 |
+
$taxRate = $taxAmount / $revenue;
|
807 |
+
}
|
808 |
+
$taxRate *= 100;
|
809 |
+
$theKey = self::generateJurisdictionKey($taxAuthId, $taxTypeCode);
|
810 |
+
if (array_key_exists($theKey, $jurisdictionArray)) {
|
811 |
+
$currentJ = $jurisdictionArray[$theKey];
|
812 |
+
$revenue += $currentJ['Revenue'];
|
813 |
+
$taxAmount += $currentJ['TaxAmount'];
|
814 |
+
if ($taxRate != $currentJ['TaxRate']) {
|
815 |
+
$taxRate = (round(
|
816 |
+
($taxAmount / $revenue),
|
817 |
+
Constants::PRECISION_DIGITS,
|
818 |
+
PHP_ROUND_HALF_UP
|
819 |
+
)) * 100;
|
820 |
+
}
|
821 |
+
$jurisdictionArray[$theKey]['TaxAmount'] = $taxAmount;
|
822 |
+
$jurisdictionArray[$theKey]['TaxRate'] = $taxRate;
|
823 |
+
$jurisdictionArray[$theKey]['Revenue'] = $revenue;
|
824 |
+
} else {
|
825 |
+
$jurisdictionArray[$theKey] = array(
|
826 |
+
'LineNumber'=>$lineNumber,
|
827 |
+
'TaxTypeCode'=>$taxTypeCode,
|
828 |
+
'TaxTypeDesc'=>$taxTypeDesc,
|
829 |
+
'TaxAmount'=>$taxAmount,
|
830 |
+
'TaxRate'=>$taxRate,
|
831 |
+
'TaxAuthorityID'=>$taxAuthId,
|
832 |
+
'TaxAuthorityName'=>$taxAuthorityName,
|
833 |
+
'Revenue'=>$revenue
|
834 |
+
);
|
835 |
+
}
|
836 |
+
}
|
837 |
+
}
|
838 |
+
return $jurisdictionArray;
|
839 |
+
}
|
840 |
+
|
841 |
+
public static function generateJurisdictionKey($taxAuthId, $taxTypeCode)
|
842 |
+
{
|
843 |
+
return $taxAuthId . ':' . $taxTypeCode;
|
844 |
+
}
|
845 |
+
|
846 |
+
/**
|
847 |
+
*
|
848 |
+
* @param $taxTypeDesc
|
849 |
+
* @param $taxAuthorityName
|
850 |
+
* @param $taxTypeCode
|
851 |
+
*
|
852 |
+
* above are from SOAP response
|
853 |
+
* TaxTypeCode
|
854 |
+
* TaxTypeDesc
|
855 |
+
* TaxAuthorityName
|
856 |
+
*
|
857 |
+
* @return string
|
858 |
+
*/
|
859 |
+
public static function generateJurisdictionTitle($taxTypeDesc = '',
|
860 |
+
$taxAuthorityName = '', $taxTypeCode = ''
|
861 |
+
) {
|
862 |
+
|
863 |
+
|
864 |
+
$taxTypeAppend = ', ' . $taxTypeDesc;
|
865 |
+
if (!$taxTypeDesc) {
|
866 |
+
$taxTypeAppend = ' (TaxType: ' . $taxTypeCode . ')';
|
867 |
+
}
|
868 |
+
return self::getShortTaxAuthNameForTitle($taxAuthorityName) .
|
869 |
+
$taxTypeAppend;
|
870 |
+
}
|
871 |
+
|
872 |
+
/**
|
873 |
+
* tax authority names are typically in this format:
|
874 |
+
* <NAME>, <something> Of
|
875 |
+
* knowing the above, we can shorten this by using the 1st token using ','
|
876 |
+
*
|
877 |
+
* @param $taxAuthName
|
878 |
+
* @return string
|
879 |
+
*/
|
880 |
+
public static function getShortTaxAuthNameForTitle($taxAuthName = null)
|
881 |
+
{
|
882 |
+
$retval = strtok($taxAuthName, ",");
|
883 |
+
return (($retval == null) ? 'Unknown' : ($retval));
|
884 |
+
}
|
885 |
+
|
886 |
+
/**
|
887 |
+
* @param array $jurisdictionsArray array
|
888 |
+
* generated by
|
889 |
+
* self::getJurisdictionLevelTaxesTotaledFromResponse()
|
890 |
+
* @param Mage_Core_Model_Store $store
|
891 |
+
* @return applied taxes array used to display taxes details
|
892 |
+
* (e.g. jurisdiction level)
|
893 |
+
*/
|
894 |
+
public static function generateAppliedTaxesArray($jurisdictionsArray, $store)
|
895 |
+
{
|
896 |
+
$appliedTaxesArray = null;
|
897 |
+
if (self::isEnabledTaxDisplay()) {
|
898 |
+
foreach ($jurisdictionsArray as $jRate) {
|
899 |
+
// 1 jursdiction tax
|
900 |
+
$taxAmount = $jRate['TaxAmount'];
|
901 |
+
$taxAmountStore = $store->convertPrice($taxAmount);
|
902 |
+
$taxRate = round(
|
903 |
+
$jRate['TaxRate'],
|
904 |
+
Constants::PRECISION_DIGITS_FOR_DISPLAY,
|
905 |
+
PHP_ROUND_HALF_UP
|
906 |
+
);
|
907 |
+
$title = self::generateJurisdictionTitle(
|
908 |
+
$jRate['TaxTypeDesc'],
|
909 |
+
$jRate['TaxAuthorityName'],
|
910 |
+
$jRate['TaxTypeCode']
|
911 |
+
);
|
912 |
+
|
913 |
+
$oneRate = array(
|
914 |
+
'code' => $title,
|
915 |
+
'title' => $title,
|
916 |
+
'percent' => $taxRate,
|
917 |
+
'position' => '0',
|
918 |
+
'priority' => '0',
|
919 |
+
'amount'=> $taxAmountStore,
|
920 |
+
'base_amount' => $taxAmount,
|
921 |
+
'rule_id' => '',
|
922 |
+
'hidden' => 0
|
923 |
+
);
|
924 |
+
|
925 |
+
$appliedTaxesArray[] = array(
|
926 |
+
'amount' => $taxAmountStore,
|
927 |
+
'id' => '',
|
928 |
+
'process' => '',
|
929 |
+
'percent' => $taxRate,
|
930 |
+
'base_amount' => $taxAmount,
|
931 |
+
'base_real_amount' => $taxAmount,
|
932 |
+
'rates' =>array( $oneRate) );
|
933 |
+
}
|
934 |
+
}
|
935 |
+
return $appliedTaxesArray;
|
936 |
+
}
|
937 |
+
|
938 |
+
public static function isEnabledTaxDisplay()
|
939 |
+
{
|
940 |
+
return Mage::getStoreConfigFlag('tax/sales_display/full_summary');
|
941 |
+
// if (Mage::getStoreConfig('tax/sales_display/full_summary')) {
|
942 |
+
// return true;
|
943 |
+
// } else {
|
944 |
+
// return false;
|
945 |
+
// }
|
946 |
+
}
|
947 |
+
|
948 |
+
public static function isEnterprise()
|
949 |
+
{
|
950 |
+
if (!isset(self::$_isEnterprise)) {
|
951 |
+
self::$_isEnterprise = Mage::helper('core')
|
952 |
+
->isModuleEnabled('Enterprise_Enterprise');
|
953 |
+
// only for CE 1.7+
|
954 |
+
}
|
955 |
+
return self::$_isEnterprise;
|
956 |
+
}
|
957 |
+
|
958 |
+
public static function getVersionString()
|
959 |
+
{
|
960 |
+
if (!isset(self::$version)) {
|
961 |
+
$eeS = (self::isEnterprise() ? 'EE ' : 'CE ');
|
962 |
+
self::$version = 'Magento ' . $eeS .
|
963 |
+
Mage::getVersion() .
|
964 |
+
' Extension v ' .
|
965 |
+
((string)Mage::getConfig()
|
966 |
+
->getNode()->modules->WoltersKluwer_CchSureTax->version);
|
967 |
+
}
|
968 |
+
return self::$version;
|
969 |
+
}
|
970 |
+
|
971 |
+
// Admin utils
|
972 |
+
public static function addSuccessAdmin($theNum, $appendMsg)
|
973 |
+
{
|
974 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
975 |
+
count($theNum) . $appendMsg .
|
976 |
+
self::displayIncrementIds($theNum)
|
977 |
+
);
|
978 |
+
|
979 |
+
}
|
980 |
+
|
981 |
+
public static function addNoticeAdmin($theNum, $appendMsg)
|
982 |
+
{
|
983 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
984 |
+
count($theNum) . $appendMsg .
|
985 |
+
self::displayIncrementIds($theNum)
|
986 |
+
);
|
987 |
+
|
988 |
+
}
|
989 |
+
|
990 |
+
public static function addErrorAdmin($theNum, $appendMsg)
|
991 |
+
{
|
992 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
993 |
+
count($theNum) . $appendMsg .
|
994 |
+
self::displayIncrementIds($theNum)
|
995 |
+
);
|
996 |
+
|
997 |
+
}
|
998 |
+
|
999 |
+
public static function processAdminMessagesForOrder($successSuretaxOrderIds,
|
1000 |
+
$successCanceledSuretaxOrderIds, $suretaxConfigDisabledForIds,
|
1001 |
+
$noticeSuretaxOrderIds, $noticeCanceledSuretaxOrderIds,
|
1002 |
+
$errorSuretaxOrderIds, $errorCanceledSuretaxOrderIds,
|
1003 |
+
$outofUSAndCANOrderIds
|
1004 |
+
) {
|
1005 |
+
|
1006 |
+
|
1007 |
+
if (count($successSuretaxOrderIds)) {
|
1008 |
+
self::addSuccessAdmin(
|
1009 |
+
$successSuretaxOrderIds,
|
1010 |
+
' order(s) have been successfully finalized : '
|
1011 |
+
);
|
1012 |
+
}
|
1013 |
+
if (count($successCanceledSuretaxOrderIds)) {
|
1014 |
+
self::addSuccessAdmin(
|
1015 |
+
$successCanceledSuretaxOrderIds,
|
1016 |
+
' order(s) have been successfully canceled : '
|
1017 |
+
);
|
1018 |
+
}
|
1019 |
+
if (count($suretaxConfigDisabledForIds)) {
|
1020 |
+
self::addNoticeAdmin(
|
1021 |
+
$suretaxConfigDisabledForIds,
|
1022 |
+
" order(s) cannot be finalized because SureTax calculation is disabled : "
|
1023 |
+
);
|
1024 |
+
}
|
1025 |
+
if (count($noticeSuretaxOrderIds)) {
|
1026 |
+
self::addNoticeAdmin(
|
1027 |
+
$noticeSuretaxOrderIds,
|
1028 |
+
" order(s) are already finalized : "
|
1029 |
+
);
|
1030 |
+
}
|
1031 |
+
if (count($noticeCanceledSuretaxOrderIds)) {
|
1032 |
+
self::addNoticeAdmin(
|
1033 |
+
$noticeCanceledSuretaxOrderIds,
|
1034 |
+
" order(s) are already canceled : "
|
1035 |
+
);
|
1036 |
+
}
|
1037 |
+
if (count($errorSuretaxOrderIds)) {
|
1038 |
+
self::addErrorAdmin(
|
1039 |
+
$errorSuretaxOrderIds,
|
1040 |
+
" order(s) cannot be finalized due to an error from SureTax : "
|
1041 |
+
);
|
1042 |
+
}
|
1043 |
+
if (count($errorCanceledSuretaxOrderIds)) {
|
1044 |
+
self::addErrorAdmin(
|
1045 |
+
$errorCanceledSuretaxOrderIds,
|
1046 |
+
" order(s) cannot be canceled due to an error from SureTax : "
|
1047 |
+
);
|
1048 |
+
}
|
1049 |
+
if (count($outofUSAndCANOrderIds)) {
|
1050 |
+
self::addErrorAdmin(
|
1051 |
+
$outofUSAndCANOrderIds,
|
1052 |
+
" order(s) cannot be finalized as SureTax does not support its ship-to-address country : "
|
1053 |
+
);
|
1054 |
+
}
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
/**
|
1058 |
+
*
|
1059 |
+
* @param array $wsConfigArray
|
1060 |
+
* @param int $websiteId
|
1061 |
+
* @param i $storeId
|
1062 |
+
* @return array
|
1063 |
+
*/
|
1064 |
+
public static function filterWebsiteStoreArray($wsConfigArray, $websiteId, $storeId)
|
1065 |
+
{
|
1066 |
+
$wsConfigFilteredArray[$websiteId.':0'] = $wsConfigArray[$websiteId.':0'];
|
1067 |
+
$wsConfigFilteredArray[$websiteId.':'.$storeId] = $wsConfigArray[$websiteId.':'.$storeId];
|
1068 |
+
return $wsConfigFilteredArray;
|
1069 |
+
}
|
1070 |
+
/**
|
1071 |
+
*
|
1072 |
+
* @param WoltersKluwer_CchSureTax_Helper_Config $config
|
1073 |
+
* @param int $websiteId
|
1074 |
+
* @param int $storeId
|
1075 |
+
* @param array $wsConfigArray
|
1076 |
+
* @return int
|
1077 |
+
*/
|
1078 |
+
public static function getBusinessUnit($config, $websiteId, $storeId, $wsConfigArray)
|
1079 |
+
{
|
1080 |
+
$defaultBusinessUnit = $config->getBusinessUnit();
|
1081 |
+
$websiteFlag = $wsConfigArray[$websiteId.':0'][Constants::USE_BUSINESS_UNIT];
|
1082 |
+
$websiteBusinessUnit = $wsConfigArray[$websiteId.':0'][Constants::BUSINESS_UNIT];
|
1083 |
+
$storeFlag = $wsConfigArray[$websiteId.':'.$storeId][Constants::USE_BUSINESS_UNIT];
|
1084 |
+
$storeBusinessUnit = $wsConfigArray[$websiteId.':'.$storeId][Constants::BUSINESS_UNIT];
|
1085 |
+
|
1086 |
+
if ($storeFlag == 0) {
|
1087 |
+
return isset($storeBusinessUnit) ? $storeBusinessUnit : '';
|
1088 |
+
} else if ($websiteFlag == 0) {
|
1089 |
+
return isset($websiteBusinessUnit) ? $websiteBusinessUnit : '';
|
1090 |
+
} else {
|
1091 |
+
return isset($defaultBusinessUnit) ? $defaultBusinessUnit : '';
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
|
1095 |
+
/**
|
1096 |
+
*
|
1097 |
+
* @param int $storeId
|
1098 |
+
* @param array $wsConfigArray
|
1099 |
+
* @return string
|
1100 |
+
*/
|
1101 |
+
public static function getWebsiteIdFromStoreId($storeId, $wsConfigArray)
|
1102 |
+
{
|
1103 |
+
foreach ($wsConfigArray as $key => $value) {
|
1104 |
+
$keySplit = explode(":", $key);
|
1105 |
+
if (in_array($storeId, $keySplit)) {
|
1106 |
+
return $keySplit[0];
|
1107 |
+
}
|
1108 |
+
}
|
1109 |
+
}
|
1110 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Helper/WebService.php
ADDED
@@ -0,0 +1,2867 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Access SureTax web services (API)
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Env as Env;
|
11 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
12 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
13 |
+
use WoltersKluwer_CchSureTax_Helper_Config as Config;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* This class makes all the web service requests necessary to get taxes
|
17 |
+
*/
|
18 |
+
class WoltersKluwer_CchSureTax_Helper_WebService
|
19 |
+
extends Mage_Core_Helper_Abstract
|
20 |
+
implements WoltersKluwer_CchSureTax_Helper_WebServiceInterface
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Jurisdiction array to fill the order tax table.
|
24 |
+
*/
|
25 |
+
protected $_jurisdictionArray = array();
|
26 |
+
|
27 |
+
/**
|
28 |
+
* For use to get discount with tax. - should be base amount.
|
29 |
+
*/
|
30 |
+
protected $_totalDiscountWithTax = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* To store all tax class name ID => Class Name.
|
34 |
+
*/
|
35 |
+
protected $_taxClassNameArray = null;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* $address is array of following format:
|
39 |
+
* 'PrimaryAddressLine'=>$addressLine1,
|
40 |
+
* 'SecondaryAddressLine'=>$addressLine2,
|
41 |
+
* 'City'=>$city,
|
42 |
+
* 'State'=>$stateCode,
|
43 |
+
* 'PostalCode'=>$zip,
|
44 |
+
* 'Plus4'=>$plus4,
|
45 |
+
* 'Country'=>$country
|
46 |
+
* 'VerifyAddress'=>"");
|
47 |
+
*
|
48 |
+
* @param array $addressAsArray
|
49 |
+
* @return WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress
|
50 |
+
*/
|
51 |
+
public function convertToSureTaxAddress($addressAsArray)
|
52 |
+
{
|
53 |
+
$retAddress = Mage::getModel(
|
54 |
+
'wolterskluwer_cchsuretax/ws_sureTaxAddress',
|
55 |
+
$addressAsArray
|
56 |
+
);
|
57 |
+
|
58 |
+
return $retAddress;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @param WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress $address
|
63 |
+
* @return WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress
|
64 |
+
*/
|
65 |
+
public function copySureTaxAddress($address)
|
66 |
+
{
|
67 |
+
if (!isset($address) || $address == null) {
|
68 |
+
return null;
|
69 |
+
}
|
70 |
+
|
71 |
+
$retAddress = Mage::getModel(
|
72 |
+
'wolterskluwer_cchsuretax/ws_sureTaxAddress',
|
73 |
+
array (
|
74 |
+
'PrimaryAddressLine' => $address->PrimaryAddressLine,
|
75 |
+
'SecondaryAddressLine' => $address->SecondaryAddressLine,
|
76 |
+
'County' => $address->County,
|
77 |
+
'City' => $address->City,
|
78 |
+
'State' => $address->State,
|
79 |
+
'PostalCode' => $address->PostalCode,
|
80 |
+
'Plus4' => $address->Plus4,
|
81 |
+
'Country' => $address->Country,
|
82 |
+
'Geocode' => $address->Geocode,
|
83 |
+
'VerifyAddress' => $address->VerifyAddress
|
84 |
+
)
|
85 |
+
);
|
86 |
+
|
87 |
+
return $retAddress;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* STAN is unique ID for SureTax
|
92 |
+
*
|
93 |
+
* @param string $theId magento's order Id
|
94 |
+
* @return string
|
95 |
+
*/
|
96 |
+
public function generateUniqueId($theId)
|
97 |
+
{
|
98 |
+
return $theId . Env::ENV;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
*
|
103 |
+
* @param string $theId magento's creditmemo Id
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
public function generateUniqueIdForCreditMemo($theId)
|
107 |
+
{
|
108 |
+
return 'CR_' . $theId . Env::ENV;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function createSureTaxRequestFromQuoteAddress(
|
112 |
+
Mage_Sales_Model_Quote_Address $address,
|
113 |
+
$estimatedAddress = null
|
114 |
+
) {
|
115 |
+
try {
|
116 |
+
$config = Config::get();
|
117 |
+
$store = $address->getQuote()->getStore();
|
118 |
+
$businessUnit = $this->getBusinessUnit(
|
119 |
+
$config,
|
120 |
+
$store->getWebsiteId(),
|
121 |
+
$store->getGroupId()
|
122 |
+
);
|
123 |
+
|
124 |
+
$returnFileCode = 'Q'; // for Query
|
125 |
+
$sTAN = ''; // never set this, we only have an address
|
126 |
+
|
127 |
+
$currentClientTracking = 'Quote';
|
128 |
+
|
129 |
+
// get ship to ship from
|
130 |
+
$shipToAddress = null;
|
131 |
+
if ($estimatedAddress != null) {
|
132 |
+
$shipToAddress = $this->convertToSureTaxAddress($estimatedAddress);
|
133 |
+
} else {
|
134 |
+
$shipToAddress = $this->convertToSureTaxAddress(
|
135 |
+
Utility::getShipToAddress($address)
|
136 |
+
);
|
137 |
+
}
|
138 |
+
|
139 |
+
// don't need billing address for quote, we might want to send a
|
140 |
+
// blank address
|
141 |
+
$billingAddress = null;
|
142 |
+
$totalRevenue = 0;
|
143 |
+
|
144 |
+
$shipFromAddress = $this->convertToSureTaxAddress(
|
145 |
+
Utility::getShipFromAddress(
|
146 |
+
$store->getWebsiteId(),
|
147 |
+
$store->getGroupId()
|
148 |
+
)
|
149 |
+
);
|
150 |
+
|
151 |
+
$trxDate = date_format(new DateTime(), 'Y-m-d H:i:s');
|
152 |
+
|
153 |
+
/*Use Quote Items on single address transactions. For Multiple
|
154 |
+
Addresses, use addressItems */
|
155 |
+
$isMultiShipping = $address->getQuote()->getIsMultiShipping();
|
156 |
+
if ($isMultiShipping) {
|
157 |
+
$itemsCollection = $address->getItemsCollection();
|
158 |
+
} else {
|
159 |
+
$itemsCollection = $address->getQuote()->getItemsCollection();
|
160 |
+
}
|
161 |
+
|
162 |
+
// if this is from 'ESTIMATE' from the website don't verify ship to
|
163 |
+
$shipToAddress->VerifyAddress = false;
|
164 |
+
$quote = $address->getQuote();
|
165 |
+
$customerId = $address->getCustomerId();
|
166 |
+
$customerFields = $this->getCustomerFields(
|
167 |
+
$customerId,
|
168 |
+
$quote->getCustomerGroupId()
|
169 |
+
);
|
170 |
+
|
171 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
172 |
+
foreach ($itemsCollection as $item) {
|
173 |
+
$lineItem = $this->getLineItem(
|
174 |
+
$i,
|
175 |
+
$item,
|
176 |
+
$billingAddress,
|
177 |
+
$shipToAddress,
|
178 |
+
$shipFromAddress,
|
179 |
+
$trxDate,
|
180 |
+
0,
|
181 |
+
false,
|
182 |
+
$config->getProviderType(),
|
183 |
+
false,
|
184 |
+
$config,
|
185 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
186 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
187 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
188 |
+
$customerId
|
189 |
+
);
|
190 |
+
$lineItemArray[] = $lineItem;
|
191 |
+
$totalRevenue += $lineItem->Revenue;
|
192 |
+
|
193 |
+
// If gift wrap supported and we have it for this line item, add to suretax line items
|
194 |
+
$lineItemGift = $this->getLineItem(
|
195 |
+
Constants::generateGiftWrapLineNumber($i),
|
196 |
+
$item,
|
197 |
+
$billingAddress,
|
198 |
+
$shipToAddress,
|
199 |
+
$shipFromAddress,
|
200 |
+
$trxDate,
|
201 |
+
0,
|
202 |
+
false,
|
203 |
+
$config->getProviderType(),
|
204 |
+
false,
|
205 |
+
$config,
|
206 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
207 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
208 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
209 |
+
$customerId
|
210 |
+
);
|
211 |
+
if ($lineItemGift !== null) {
|
212 |
+
$lineItemArray[] = $lineItemGift;
|
213 |
+
$totalRevenue += $lineItemGift->Revenue;
|
214 |
+
}
|
215 |
+
|
216 |
+
$i++;
|
217 |
+
}
|
218 |
+
|
219 |
+
/* Try to see if there's an order level gift option, gift wrap is
|
220 |
+
from $address for quotes, otherwise it accumulates gw and gw card
|
221 |
+
prices */
|
222 |
+
$orderLevelGift = $this->getLineItem(
|
223 |
+
Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL,
|
224 |
+
$address,
|
225 |
+
$billingAddress,
|
226 |
+
$shipToAddress,
|
227 |
+
$shipFromAddress,
|
228 |
+
$trxDate,
|
229 |
+
0,
|
230 |
+
true,
|
231 |
+
$config->getProviderType(),
|
232 |
+
false,
|
233 |
+
$config,
|
234 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
235 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
236 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
237 |
+
$customerId
|
238 |
+
);
|
239 |
+
if ($orderLevelGift !== null) {
|
240 |
+
$lineItemArray[] = $orderLevelGift;
|
241 |
+
$totalRevenue += $orderLevelGift->Revenue;
|
242 |
+
}
|
243 |
+
|
244 |
+
$orderLevelGiftCard = $this->getLineItem(
|
245 |
+
Constants::DEFAULT_GW_CARD_LINE_NUMBER,
|
246 |
+
$address,
|
247 |
+
$billingAddress,
|
248 |
+
$shipToAddress,
|
249 |
+
$shipFromAddress,
|
250 |
+
$trxDate,
|
251 |
+
0,
|
252 |
+
true,
|
253 |
+
$config->getProviderType(),
|
254 |
+
false,
|
255 |
+
$config,
|
256 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
257 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
258 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
259 |
+
$customerId
|
260 |
+
);
|
261 |
+
if ($orderLevelGiftCard !== null) {
|
262 |
+
$lineItemArray[] = $orderLevelGiftCard;
|
263 |
+
$totalRevenue += $orderLevelGiftCard->Revenue;
|
264 |
+
}
|
265 |
+
|
266 |
+
//Base Shipping Discount amount is a positive number.
|
267 |
+
$shippingAfterDiscount = $address->getBaseShippingAmount() -
|
268 |
+
$address->getBaseShippingDiscountAmount();
|
269 |
+
|
270 |
+
if ($shippingAfterDiscount) {
|
271 |
+
$shippingLineItem = $this->getLineItem(
|
272 |
+
$i,
|
273 |
+
$item,
|
274 |
+
$billingAddress,
|
275 |
+
$shipToAddress,
|
276 |
+
$shipFromAddress,
|
277 |
+
$trxDate,
|
278 |
+
$shippingAfterDiscount,
|
279 |
+
false,
|
280 |
+
$config->getProviderType(),
|
281 |
+
false,
|
282 |
+
$config,
|
283 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
284 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
285 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
286 |
+
$customerId
|
287 |
+
);
|
288 |
+
$lineItemArray[] = $shippingLineItem;
|
289 |
+
$totalRevenue += $shippingLineItem->Revenue;
|
290 |
+
}
|
291 |
+
|
292 |
+
// Create the SureTaxRequest
|
293 |
+
|
294 |
+
/* @var $requestData WoltersKluwer_CchSureTax_Model_Ws_SureTaxRequest*/
|
295 |
+
$requestData = Mage::getModel(
|
296 |
+
'wolterskluwer_cchsuretax/ws_sureTaxRequest',
|
297 |
+
array (
|
298 |
+
'ClientNumber' => $config->getClientNumber(),
|
299 |
+
'BusinessUnit' => $businessUnit,
|
300 |
+
'ValidationKey' => $config->getValidationKey(),
|
301 |
+
'DataYear' => date('Y'),
|
302 |
+
'DataMonth' => date('m'),
|
303 |
+
'CmplDataYear' => date('Y'),
|
304 |
+
'CmplDataMonth' => date('m'),
|
305 |
+
'TotalRevenue' => $totalRevenue,
|
306 |
+
'ClientTracking' => $currentClientTracking,
|
307 |
+
'ResponseType' => $config->getResponseType(),
|
308 |
+
'ResponseGroup' => $config->getResponseGroup(),
|
309 |
+
'ReturnFileCode' => $returnFileCode,
|
310 |
+
'STAN' => $sTAN,
|
311 |
+
'MasterTransId' => '0',
|
312 |
+
'ShipToAddress' => $shipToAddress,
|
313 |
+
'ShipFromAddress' => $shipFromAddress,
|
314 |
+
'ItemList' => $lineItemArray
|
315 |
+
)
|
316 |
+
);
|
317 |
+
|
318 |
+
return $requestData;
|
319 |
+
} catch (Exception $exe) {
|
320 |
+
Utility::logCatch(
|
321 |
+
$exe,
|
322 |
+
'Quote::Exception at createSureTaxRequestFromQuoteAddress'
|
323 |
+
);
|
324 |
+
throw $exe;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
public function makeSureTaxRequestFromQuoteAddress($requestData)
|
329 |
+
{
|
330 |
+
try {
|
331 |
+
$config = Config::get();
|
332 |
+
/* @var $client WoltersKluwer_CchSureTax_Model_Ws_SureTaxClient*/
|
333 |
+
$client = Mage::getModel(
|
334 |
+
'wolterskluwer_cchsuretax/ws_sureTaxClient',
|
335 |
+
array('Config' => $config)
|
336 |
+
);
|
337 |
+
|
338 |
+
$soapCalcRequestResult = $client->callSoapRequest($requestData);
|
339 |
+
return $soapCalcRequestResult;
|
340 |
+
} catch (Exception $exe) {
|
341 |
+
Utility::logCatch(
|
342 |
+
$exe,
|
343 |
+
'Quote::Exception with makeSureTaxRequestFromQuoteAddress'
|
344 |
+
);
|
345 |
+
throw $exe;
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
public function createSureTaxRequestFromInvoice($invoice, $shipToAddressArray)
|
350 |
+
{
|
351 |
+
try {
|
352 |
+
$config = Config::get();
|
353 |
+
$order = $invoice->getOrder();
|
354 |
+
|
355 |
+
$returnFileCode = '0';
|
356 |
+
$uniqueId = $this->generateUniqueId($invoice->getIncrementId());
|
357 |
+
$sTAN = $uniqueId;
|
358 |
+
$currentClientTracking = $uniqueId;
|
359 |
+
$store = $order->getStore();
|
360 |
+
$businessUnit = $this->getBusinessUnit(
|
361 |
+
$config,
|
362 |
+
$store->getWebsiteId(),
|
363 |
+
$store->getGroupId()
|
364 |
+
);
|
365 |
+
|
366 |
+
$shipToAddress = $this->convertToSureTaxAddress($shipToAddressArray);
|
367 |
+
|
368 |
+
$billingAddress = null;
|
369 |
+
|
370 |
+
$shipFromAddress = $this->convertToSureTaxAddress(
|
371 |
+
Utility::getShipFromAddress(
|
372 |
+
$store->getWebsiteId(),
|
373 |
+
$store->getGroupId()
|
374 |
+
)
|
375 |
+
);
|
376 |
+
|
377 |
+
$totalRevenue = 0;
|
378 |
+
|
379 |
+
$ordCreationDate = $order->getCreatedAt();
|
380 |
+
$invCreationDate = $invoice->getCreatedAt();
|
381 |
+
$customerId = $order->getCustomerId();
|
382 |
+
$customerFields = $this->getCustomerFields(
|
383 |
+
$customerId,
|
384 |
+
$order->getCustomerGroupId()
|
385 |
+
);
|
386 |
+
|
387 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
388 |
+
$allItems = $invoice->getAllItems();
|
389 |
+
|
390 |
+
foreach ($allItems as $item) {
|
391 |
+
$lineItem = $this->getLineItem(
|
392 |
+
$i,
|
393 |
+
$item,
|
394 |
+
$billingAddress,
|
395 |
+
$shipToAddress,
|
396 |
+
$shipFromAddress,
|
397 |
+
$ordCreationDate,
|
398 |
+
0,
|
399 |
+
false,
|
400 |
+
$config->getProviderType(),
|
401 |
+
false,
|
402 |
+
$config,
|
403 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
404 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
405 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
406 |
+
$customerId
|
407 |
+
);
|
408 |
+
|
409 |
+
$lineItemArray[] = $lineItem;
|
410 |
+
$totalRevenue += $lineItem->Revenue;
|
411 |
+
|
412 |
+
// if gift wrap supported and we have it for this line item,
|
413 |
+
// add to suretax line items
|
414 |
+
$lineItemGift = $this->getLineItem(
|
415 |
+
Constants::generateGiftWrapLineNumber($i),
|
416 |
+
$item,
|
417 |
+
$billingAddress,
|
418 |
+
$shipToAddress,
|
419 |
+
$shipFromAddress,
|
420 |
+
$ordCreationDate,
|
421 |
+
0,
|
422 |
+
false,
|
423 |
+
$config->getProviderType(),
|
424 |
+
false,
|
425 |
+
$config,
|
426 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
427 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
428 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
429 |
+
$customerId
|
430 |
+
);
|
431 |
+
|
432 |
+
if ($lineItemGift !== null) {
|
433 |
+
$lineItemArray[] = $lineItemGift;
|
434 |
+
$totalRevenue += $lineItemGift->Revenue;
|
435 |
+
}
|
436 |
+
$i++;
|
437 |
+
}
|
438 |
+
|
439 |
+
// try to see if there's an order level gift option
|
440 |
+
if (null !== $invoice->getGwBasePrice() && $invoice->getGwBasePrice() > 0) {
|
441 |
+
//This condition is only to check if its 1st or only invoice and set
|
442 |
+
//Order level GW and Print card to line items
|
443 |
+
$orderLevelGift = $this->getLineItem(
|
444 |
+
Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL,
|
445 |
+
$order,
|
446 |
+
$billingAddress,
|
447 |
+
$shipToAddress,
|
448 |
+
$shipFromAddress,
|
449 |
+
$ordCreationDate,
|
450 |
+
0,
|
451 |
+
true,
|
452 |
+
$config->getProviderType(),
|
453 |
+
false,
|
454 |
+
$config,
|
455 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
456 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
457 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
458 |
+
$customerId
|
459 |
+
);
|
460 |
+
|
461 |
+
if ($orderLevelGift !== null) {
|
462 |
+
$lineItemArray[] = $orderLevelGift;
|
463 |
+
$totalRevenue += $orderLevelGift->Revenue;
|
464 |
+
}
|
465 |
+
}
|
466 |
+
if (null !== $invoice->getGwCardBasePrice() && $invoice->getGwCardBasePrice() > 0) {
|
467 |
+
$invoiceLevelGiftCard = $this->getLineItem(
|
468 |
+
Constants::DEFAULT_GW_CARD_LINE_NUMBER,
|
469 |
+
$order,
|
470 |
+
$billingAddress,
|
471 |
+
$shipToAddress,
|
472 |
+
$shipFromAddress,
|
473 |
+
$ordCreationDate,
|
474 |
+
0,
|
475 |
+
true,
|
476 |
+
$config->getProviderType(),
|
477 |
+
false,
|
478 |
+
$config,
|
479 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
480 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
481 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
482 |
+
$customerId
|
483 |
+
);
|
484 |
+
|
485 |
+
if ($invoiceLevelGiftCard !== null) {
|
486 |
+
$lineItemArray[] = $invoiceLevelGiftCard;
|
487 |
+
$totalRevenue += $invoiceLevelGiftCard->Revenue;
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
$shippingAfterDiscount = $invoice->getBaseShippingAmount();
|
492 |
+
|
493 |
+
if (isset($shippingAfterDiscount) && $shippingAfterDiscount > 0) {
|
494 |
+
$shippingAfterDiscount -= $order->getBaseShippingDiscountAmount();
|
495 |
+
|
496 |
+
$shippingLineItem = $this->getLineItem(
|
497 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER,
|
498 |
+
$item,
|
499 |
+
$billingAddress,
|
500 |
+
$shipToAddress,
|
501 |
+
$shipFromAddress,
|
502 |
+
$ordCreationDate,
|
503 |
+
$shippingAfterDiscount,
|
504 |
+
false,
|
505 |
+
$config->getProviderType(),
|
506 |
+
false,
|
507 |
+
$config,
|
508 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
509 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
510 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
511 |
+
$customerId
|
512 |
+
);
|
513 |
+
|
514 |
+
$lineItemArray[] = $shippingLineItem;
|
515 |
+
$totalRevenue += $shippingLineItem->Revenue;
|
516 |
+
}
|
517 |
+
|
518 |
+
// create a SureTaxRequest object
|
519 |
+
|
520 |
+
/* @var $requestData WoltersKluwer_CchSureTax_Model_Ws_SureTaxRequest*/
|
521 |
+
$requestData = Mage::getModel(
|
522 |
+
'wolterskluwer_cchsuretax/ws_sureTaxRequest',
|
523 |
+
array (
|
524 |
+
'ClientNumber' => $config->getClientNumber(),
|
525 |
+
'BusinessUnit' => $businessUnit,
|
526 |
+
'ValidationKey' => $config->getValidationKey(),
|
527 |
+
'DataYear' => date_parse($ordCreationDate)['year'],
|
528 |
+
'DataMonth' => date_parse($ordCreationDate)['month'],
|
529 |
+
'CmplDataYear' => date_parse($invCreationDate)['year'],
|
530 |
+
'CmplDataMonth' => date_parse($invCreationDate)['month'],
|
531 |
+
'TotalRevenue' => $totalRevenue,
|
532 |
+
'ClientTracking' => $currentClientTracking,
|
533 |
+
'ResponseType' => $config->getResponseType(),
|
534 |
+
'ResponseGroup' => $config->getResponseGroup(),
|
535 |
+
'ReturnFileCode' => $returnFileCode,
|
536 |
+
'STAN' => $sTAN,
|
537 |
+
'MasterTransId' => '0',
|
538 |
+
'ShipToAddress' => $shipToAddress,
|
539 |
+
'ShipFromAddress' => $shipFromAddress,
|
540 |
+
'ItemList' => $lineItemArray
|
541 |
+
)
|
542 |
+
);
|
543 |
+
|
544 |
+
return $requestData;
|
545 |
+
} catch (Exception $exe) {
|
546 |
+
Utility::logCatch(
|
547 |
+
$exe,
|
548 |
+
'Invoice::Exception with createSureTaxRequestFromInvoice'
|
549 |
+
);
|
550 |
+
|
551 |
+
throw $exe;
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
public function createSureTaxRequestFromBatchInvoice(
|
556 |
+
$invoice,
|
557 |
+
$shipToAddressArray,
|
558 |
+
$wsConfigArray
|
559 |
+
) {
|
560 |
+
try {
|
561 |
+
$config = Config::get();
|
562 |
+
$returnFileCode = '0';
|
563 |
+
$uniqueId = $this->generateUniqueId($invoice->getIncrementId());
|
564 |
+
$sTAN = $uniqueId;
|
565 |
+
$currentClientTracking = $uniqueId;
|
566 |
+
$websiteId = $invoice->getWebsiteId();
|
567 |
+
$storeId = $invoice->getGroupId();
|
568 |
+
$businessUnit = Utility::getBusinessUnit(
|
569 |
+
$config,
|
570 |
+
$websiteId,
|
571 |
+
$storeId,
|
572 |
+
$wsConfigArray
|
573 |
+
);
|
574 |
+
|
575 |
+
$shipToAddress = $this->convertToSureTaxAddress($shipToAddressArray);
|
576 |
+
|
577 |
+
$billingAddress = null;
|
578 |
+
|
579 |
+
$shipFromAddress = $this->convertToSureTaxAddress(
|
580 |
+
Utility::getShipFromAddressFromConfig(
|
581 |
+
$invoice->getWebsiteId(),
|
582 |
+
$invoice->getGroupId(),
|
583 |
+
$wsConfigArray
|
584 |
+
)
|
585 |
+
);
|
586 |
+
|
587 |
+
$totalRevenue = 0;
|
588 |
+
|
589 |
+
$ordCreationDate = $invoice->getOrderCreatedAt();
|
590 |
+
$invCreationDate = $invoice->getCreatedAt();
|
591 |
+
$customerId = $invoice->getCustomerId();
|
592 |
+
$customerFields = $this->getCustomerFieldsFromInvoiceOrCreditMemo($invoice);
|
593 |
+
|
594 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
595 |
+
$allItems = $invoice->getAllItems();
|
596 |
+
|
597 |
+
foreach ($allItems as $item) {
|
598 |
+
$lineItem = $this->getLineItem(
|
599 |
+
$i,
|
600 |
+
$item,
|
601 |
+
$billingAddress,
|
602 |
+
$shipToAddress,
|
603 |
+
$shipFromAddress,
|
604 |
+
$ordCreationDate,
|
605 |
+
0,
|
606 |
+
false,
|
607 |
+
$config->getProviderType(),
|
608 |
+
false,
|
609 |
+
$config,
|
610 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
611 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
612 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
613 |
+
$customerId
|
614 |
+
);
|
615 |
+
|
616 |
+
$lineItemArray[] = $lineItem;
|
617 |
+
$totalRevenue += $lineItem->Revenue;
|
618 |
+
|
619 |
+
// if gift wrap supported and we have it for this line item,
|
620 |
+
// add to suretax line items
|
621 |
+
$lineItemGift = $this->getLineItem(
|
622 |
+
Constants::generateGiftWrapLineNumber($i),
|
623 |
+
$item,
|
624 |
+
$billingAddress,
|
625 |
+
$shipToAddress,
|
626 |
+
$shipFromAddress,
|
627 |
+
$ordCreationDate,
|
628 |
+
0,
|
629 |
+
false,
|
630 |
+
$config->getProviderType(),
|
631 |
+
false,
|
632 |
+
$config,
|
633 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
634 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
635 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
636 |
+
$customerId
|
637 |
+
);
|
638 |
+
|
639 |
+
if ($lineItemGift !== null) {
|
640 |
+
$lineItemArray[] = $lineItemGift;
|
641 |
+
$totalRevenue += $lineItemGift->Revenue;
|
642 |
+
}
|
643 |
+
$i++;
|
644 |
+
}
|
645 |
+
|
646 |
+
// try to see if there's an order level gift option
|
647 |
+
if (null !== $invoice->getGwBasePrice() && $invoice->getGwBasePrice() > 0) {
|
648 |
+
//This condition is only to check if its 1st or only invoice and set
|
649 |
+
//Order level GW and Print card to line items
|
650 |
+
$orderLevelGift = $this->getLineItem(
|
651 |
+
Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL,
|
652 |
+
$invoice,
|
653 |
+
$billingAddress,
|
654 |
+
$shipToAddress,
|
655 |
+
$shipFromAddress,
|
656 |
+
$ordCreationDate,
|
657 |
+
0,
|
658 |
+
false,
|
659 |
+
$config->getProviderType(),
|
660 |
+
false,
|
661 |
+
$config,
|
662 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
663 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
664 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
665 |
+
$customerId
|
666 |
+
);
|
667 |
+
|
668 |
+
if ($orderLevelGift !== null) {
|
669 |
+
$lineItemArray[] = $orderLevelGift;
|
670 |
+
$totalRevenue += $orderLevelGift->Revenue;
|
671 |
+
}
|
672 |
+
}
|
673 |
+
|
674 |
+
if (null !== $invoice->getGwCardBasePrice() && $invoice->getGwCardBasePrice() > 0) {
|
675 |
+
$invoiceLevelGiftCard = $this->getLineItem(
|
676 |
+
Constants::DEFAULT_GW_CARD_LINE_NUMBER,
|
677 |
+
$invoice,
|
678 |
+
$billingAddress,
|
679 |
+
$shipToAddress,
|
680 |
+
$shipFromAddress,
|
681 |
+
$ordCreationDate,
|
682 |
+
0,
|
683 |
+
false,
|
684 |
+
$config->getProviderType(),
|
685 |
+
false,
|
686 |
+
$config,
|
687 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
688 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
689 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
690 |
+
$customerId
|
691 |
+
);
|
692 |
+
|
693 |
+
if ($invoiceLevelGiftCard !== null) {
|
694 |
+
$lineItemArray[] = $invoiceLevelGiftCard;
|
695 |
+
$totalRevenue += $invoiceLevelGiftCard->Revenue;
|
696 |
+
}
|
697 |
+
}
|
698 |
+
|
699 |
+
$shippingAfterDiscount = $invoice->getBaseShippingAmount();
|
700 |
+
|
701 |
+
if (isset($shippingAfterDiscount) && $shippingAfterDiscount > 0) {
|
702 |
+
$shippingAfterDiscount -= $invoice->getBaseShippingDiscountAmount();
|
703 |
+
|
704 |
+
$shippingLineItem = $this->getLineItem(
|
705 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER,
|
706 |
+
$item,
|
707 |
+
$billingAddress,
|
708 |
+
$shipToAddress,
|
709 |
+
$shipFromAddress,
|
710 |
+
$ordCreationDate,
|
711 |
+
$shippingAfterDiscount,
|
712 |
+
false,
|
713 |
+
$config->getProviderType(),
|
714 |
+
false,
|
715 |
+
$config,
|
716 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
717 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
718 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
719 |
+
$customerId
|
720 |
+
);
|
721 |
+
|
722 |
+
$lineItemArray[] = $shippingLineItem;
|
723 |
+
$totalRevenue += $shippingLineItem->Revenue;
|
724 |
+
}
|
725 |
+
|
726 |
+
// create a SureTaxRequest object
|
727 |
+
|
728 |
+
/* @var $requestData WoltersKluwer_CchSureTax_Model_Ws_SureTaxRequest*/
|
729 |
+
$requestData = Mage::getModel(
|
730 |
+
'wolterskluwer_cchsuretax/ws_sureTaxRequest',
|
731 |
+
array (
|
732 |
+
'ClientNumber' => $config->getClientNumber(),
|
733 |
+
'BusinessUnit' => $businessUnit,
|
734 |
+
'ValidationKey' => $config->getValidationKey(),
|
735 |
+
'DataYear' => date_parse($ordCreationDate)['year'],
|
736 |
+
'DataMonth' => date_parse($ordCreationDate)['month'],
|
737 |
+
'CmplDataYear' => date_parse($invCreationDate)['year'],
|
738 |
+
'CmplDataMonth' => date_parse($invCreationDate)['month'],
|
739 |
+
'TotalRevenue' => $totalRevenue,
|
740 |
+
'ClientTracking' => $currentClientTracking,
|
741 |
+
'ResponseType' => $config->getResponseType(),
|
742 |
+
'ResponseGroup' => $config->getResponseGroup(),
|
743 |
+
'ReturnFileCode' => $returnFileCode,
|
744 |
+
'STAN' => $sTAN,
|
745 |
+
'MasterTransId' => '0',
|
746 |
+
'ShipToAddress' => $shipToAddress,
|
747 |
+
'ShipFromAddress' => $shipFromAddress,
|
748 |
+
'ItemList' => $lineItemArray
|
749 |
+
)
|
750 |
+
);
|
751 |
+
|
752 |
+
return $requestData;
|
753 |
+
} catch (Exception $exe) {
|
754 |
+
Utility::logCatch(
|
755 |
+
$exe,
|
756 |
+
'Invoice::Exception with createSureTaxRequestFromInvoice'
|
757 |
+
);
|
758 |
+
|
759 |
+
throw $exe;
|
760 |
+
}
|
761 |
+
}
|
762 |
+
|
763 |
+
public function createSureTaxRequestFromOrder(
|
764 |
+
Mage_Sales_Model_Order $order,
|
765 |
+
$isFinalize,
|
766 |
+
$shipToAddressArray
|
767 |
+
) {
|
768 |
+
|
769 |
+
try {
|
770 |
+
$config = Config::get();
|
771 |
+
|
772 |
+
$store = $order->getStore();
|
773 |
+
$uniqueId = $this->generateUniqueId($order->getIncrementId());
|
774 |
+
$returnFileCode = 'Q'; // for Query
|
775 |
+
$sTAN = '';
|
776 |
+
|
777 |
+
$currentClientTracking = $uniqueId;
|
778 |
+
if ($isFinalize == true) {
|
779 |
+
$returnFileCode = '0';
|
780 |
+
$sTAN = $uniqueId;
|
781 |
+
}
|
782 |
+
|
783 |
+
$businessUnit = $this->getBusinessUnit(
|
784 |
+
$config,
|
785 |
+
$store->getWebsiteId(),
|
786 |
+
$store->getGroupId()
|
787 |
+
);
|
788 |
+
|
789 |
+
$shipToAddress = $this->convertToSureTaxAddress($shipToAddressArray);
|
790 |
+
|
791 |
+
$billingAddress = $this->convertToSureTaxAddress(
|
792 |
+
Utility::getShipToAddress(
|
793 |
+
Mage::getModel('sales/order_address')
|
794 |
+
->load($order->getBillingAddress()->getId())
|
795 |
+
)
|
796 |
+
);
|
797 |
+
|
798 |
+
$shipFromAddress = $this->convertToSureTaxAddress(
|
799 |
+
Utility::getShipFromAddress(
|
800 |
+
$store->getWebsiteId(),
|
801 |
+
$store->getGroupId()
|
802 |
+
)
|
803 |
+
);
|
804 |
+
|
805 |
+
$totalRevenue = 0;
|
806 |
+
$trxDate = $order->getCreatedAt();
|
807 |
+
$customerId = $order->getCustomerId();
|
808 |
+
$customerFields = $this->getCustomerFields(
|
809 |
+
$customerId,
|
810 |
+
$order->getCustomerGroupId()
|
811 |
+
);
|
812 |
+
|
813 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
814 |
+
foreach ($order->getAllItems() as $itemId => $item) {
|
815 |
+
$lineItem = $this->getLineItem(
|
816 |
+
$i,
|
817 |
+
$item,
|
818 |
+
$billingAddress,
|
819 |
+
$shipToAddress,
|
820 |
+
$shipFromAddress,
|
821 |
+
$trxDate,
|
822 |
+
0,
|
823 |
+
true,
|
824 |
+
$config->getProviderType(),
|
825 |
+
false,
|
826 |
+
$config,
|
827 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
828 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
829 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
830 |
+
$customerId
|
831 |
+
);
|
832 |
+
|
833 |
+
$lineItemArray[] = $lineItem;
|
834 |
+
$totalRevenue += $lineItem->Revenue;
|
835 |
+
|
836 |
+
// if gift wrap supported and we have it for this line item,
|
837 |
+
// add to suretax line items
|
838 |
+
$lineItemGift = $this->getLineItem(
|
839 |
+
Constants::generateGiftWrapLineNumber($i),
|
840 |
+
$item,
|
841 |
+
$billingAddress,
|
842 |
+
$shipToAddress,
|
843 |
+
$shipFromAddress,
|
844 |
+
$trxDate,
|
845 |
+
0,
|
846 |
+
true,
|
847 |
+
$config->getProviderType(),
|
848 |
+
false,
|
849 |
+
$config,
|
850 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
851 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
852 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
853 |
+
$customerId
|
854 |
+
);
|
855 |
+
if ($lineItemGift !== null) {
|
856 |
+
$lineItemArray[] = $lineItemGift;
|
857 |
+
$totalRevenue += $lineItemGift->Revenue;
|
858 |
+
}
|
859 |
+
$i++;
|
860 |
+
}
|
861 |
+
|
862 |
+
// try to see if there's an order level gift option
|
863 |
+
$orderLevelGift = $this->getLineItem(
|
864 |
+
Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL,
|
865 |
+
$order,
|
866 |
+
$billingAddress,
|
867 |
+
$shipToAddress,
|
868 |
+
$shipFromAddress,
|
869 |
+
$trxDate,
|
870 |
+
0,
|
871 |
+
true,
|
872 |
+
$config->getProviderType(),
|
873 |
+
false,
|
874 |
+
$config,
|
875 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
876 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
877 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
878 |
+
$customerId
|
879 |
+
);
|
880 |
+
if ($orderLevelGift !== null) {
|
881 |
+
$lineItemArray[] = $orderLevelGift;
|
882 |
+
$totalRevenue += $orderLevelGift->Revenue;
|
883 |
+
}
|
884 |
+
|
885 |
+
$orderLevelGiftCard = $this->getLineItem(
|
886 |
+
Constants::DEFAULT_GW_CARD_LINE_NUMBER,
|
887 |
+
$order,
|
888 |
+
$billingAddress,
|
889 |
+
$shipToAddress,
|
890 |
+
$shipFromAddress,
|
891 |
+
$trxDate,
|
892 |
+
0,
|
893 |
+
true,
|
894 |
+
$config->getProviderType(),
|
895 |
+
false,
|
896 |
+
$config,
|
897 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
898 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
899 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
900 |
+
$customerId
|
901 |
+
);
|
902 |
+
if ($orderLevelGiftCard !== null) {
|
903 |
+
$lineItemArray[] = $orderLevelGiftCard;
|
904 |
+
$totalRevenue += $orderLevelGiftCard->Revenue;
|
905 |
+
}
|
906 |
+
|
907 |
+
$shippingAfterDiscount = $order->getBaseShippingAmount() -
|
908 |
+
$order->getBaseShippingDiscountAmount();
|
909 |
+
|
910 |
+
if ($shippingAfterDiscount) {
|
911 |
+
$shippingLineItem = $this->getLineItem(
|
912 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER,
|
913 |
+
$item,
|
914 |
+
$billingAddress,
|
915 |
+
$shipToAddress,
|
916 |
+
$shipFromAddress,
|
917 |
+
$trxDate,
|
918 |
+
$shippingAfterDiscount,
|
919 |
+
true,
|
920 |
+
$config->getProviderType(),
|
921 |
+
false,
|
922 |
+
$config,
|
923 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
924 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
925 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
926 |
+
$customerId
|
927 |
+
);
|
928 |
+
$lineItemArray[] = $shippingLineItem;
|
929 |
+
$totalRevenue += $shippingLineItem->Revenue;
|
930 |
+
}
|
931 |
+
|
932 |
+
// create a SureTaxRequest object
|
933 |
+
|
934 |
+
/* @var $requestData WoltersKluwer_CchSureTax_Model_Ws_SureTaxRequest*/
|
935 |
+
$requestData = Mage::getModel(
|
936 |
+
'wolterskluwer_cchsuretax/ws_sureTaxRequest',
|
937 |
+
array (
|
938 |
+
'ClientNumber' => $config->getClientNumber(),
|
939 |
+
'BusinessUnit' => $businessUnit,
|
940 |
+
'ValidationKey' => $config->getValidationKey(),
|
941 |
+
'DataYear' => date_parse($trxDate)['year'],
|
942 |
+
'DataMonth' => date_parse($trxDate)['month'],
|
943 |
+
'CmplDataYear' => date_parse($trxDate)['year'],
|
944 |
+
'CmplDataMonth' => date_parse($trxDate)['month'],
|
945 |
+
'TotalRevenue' => $totalRevenue,
|
946 |
+
'ClientTracking' => $currentClientTracking,
|
947 |
+
'ResponseType' => $config->getResponseType(),
|
948 |
+
'ResponseGroup' => $config->getResponseGroup(),
|
949 |
+
'ReturnFileCode' => $returnFileCode,
|
950 |
+
'STAN' => $sTAN,
|
951 |
+
'MasterTransId' => '0',
|
952 |
+
'ShipToAddress' => $shipToAddress,
|
953 |
+
'ShipFromAddress' => $shipFromAddress,
|
954 |
+
'ItemList' => $lineItemArray
|
955 |
+
)
|
956 |
+
);
|
957 |
+
|
958 |
+
return $requestData;
|
959 |
+
} catch (Exception $exe) {
|
960 |
+
Utility::logCatch(
|
961 |
+
$exe,
|
962 |
+
'Order createSureTaxRequestFromOrder '
|
963 |
+
);
|
964 |
+
throw $exe;
|
965 |
+
}
|
966 |
+
}
|
967 |
+
|
968 |
+
public function makeSureTaxRequestFromOrder($requestData)
|
969 |
+
{
|
970 |
+
try {
|
971 |
+
$config = Config::get();
|
972 |
+
$client = Mage::getModel(
|
973 |
+
'wolterskluwer_cchsuretax/ws_sureTaxClient',
|
974 |
+
array('Config' => $config)
|
975 |
+
);
|
976 |
+
|
977 |
+
$soapCalcRequestResult = $client->callSoapRequest($requestData);
|
978 |
+
return $soapCalcRequestResult;
|
979 |
+
} catch (Exception $exe) {
|
980 |
+
Utility::logCatch(
|
981 |
+
$exe,
|
982 |
+
'Order::Exception with makeSureTaxRequestFromOrder'
|
983 |
+
);
|
984 |
+
throw $exe;
|
985 |
+
}
|
986 |
+
}
|
987 |
+
|
988 |
+
public function makeSureTaxRequest($requestData)
|
989 |
+
{
|
990 |
+
try {
|
991 |
+
$config = Config::get();
|
992 |
+
$client = Mage::getModel(
|
993 |
+
'wolterskluwer_cchsuretax/ws_sureTaxClient',
|
994 |
+
array('Config' => $config)
|
995 |
+
);
|
996 |
+
|
997 |
+
$soapCalcRequestResult = $client->callSoapRequest($requestData);
|
998 |
+
return $soapCalcRequestResult;
|
999 |
+
} catch (Exception $exe) {
|
1000 |
+
Utility::logCatch(
|
1001 |
+
$exe,
|
1002 |
+
'Invoice: Exception with makeSureTaxRequest'
|
1003 |
+
);
|
1004 |
+
throw $exe;
|
1005 |
+
}
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
public function makeSureTaxBatchRequest($requestDataArray)
|
1009 |
+
{
|
1010 |
+
try {
|
1011 |
+
$config = Config::get();
|
1012 |
+
$client = Mage::getModel(
|
1013 |
+
'wolterskluwer_cchsuretax/ws_sureTaxClient',
|
1014 |
+
array('Config' => $config)
|
1015 |
+
);
|
1016 |
+
|
1017 |
+
$soapBatchCalcRequestResult = $client->callSoapRequestBatch($requestDataArray);
|
1018 |
+
return $soapBatchCalcRequestResult;
|
1019 |
+
} catch (Exception $exe) {
|
1020 |
+
Utility::logCatch(
|
1021 |
+
$exe,
|
1022 |
+
'Invoice: Exception with makeSureTaxBatchRequest'
|
1023 |
+
);
|
1024 |
+
throw $exe;
|
1025 |
+
}
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
/**
|
1029 |
+
* Get Customer Fields in array form.
|
1030 |
+
*
|
1031 |
+
* @param int $customerId
|
1032 |
+
* @param int $customerGroupId
|
1033 |
+
* @return array
|
1034 |
+
*/
|
1035 |
+
protected function getCustomerFields($customerId, $customerGroupId)
|
1036 |
+
{
|
1037 |
+
$customer = Mage::getModel(Constants::CUST_TBL)
|
1038 |
+
->load($customerId, 'suretax_customer_id');
|
1039 |
+
$salesTypeCodeDesc = Constants::DEFAULT_SALES_TYPE_CODE;
|
1040 |
+
$exemptionCodeDesc = Constants::DEFAULT_EXEMPTION_CODE;
|
1041 |
+
$exemptionReasonDesc = Constants::DEFAULT_EXEMPTION_REASON_CODE;
|
1042 |
+
$theId = $customer->getId();
|
1043 |
+
if (empty($theId)) {
|
1044 |
+
$customerGroup = Mage::getModel(Constants::CUST_GRP_TBL)
|
1045 |
+
->load($customerGroupId, 'suretax_customer_group_id');
|
1046 |
+
$theGroupId = $customerGroup->getId();
|
1047 |
+
if (!empty($theGroupId)) {
|
1048 |
+
$salesTypeCodeDesc = $customerGroup->getSalesTypeCode();
|
1049 |
+
$exemptionCodeDesc = $customerGroup->getExemptionCode();
|
1050 |
+
$exemptionReasonDesc = $customerGroup->getExemptionReasonCode();
|
1051 |
+
}
|
1052 |
+
} else {
|
1053 |
+
$salesTypeCodeDesc = $customer->getSalesTypeCode();
|
1054 |
+
$exemptionCodeDesc = $customer->getExemptionCode();
|
1055 |
+
$exemptionReasonDesc = $customer->getExemptionReasonCode();
|
1056 |
+
}
|
1057 |
+
try {
|
1058 |
+
$salesTypeCode
|
1059 |
+
= Constants::$SALES_TYPE_CODES_VALUES[$salesTypeCodeDesc];
|
1060 |
+
$exemptionCode
|
1061 |
+
= Constants::$EXEMPTION_TYPE_CODES_VALUES[$exemptionCodeDesc];
|
1062 |
+
$exemptionReasonCode
|
1063 |
+
= Constants::$EXEMPTION_REASON_CODES_VALUES[$exemptionReasonDesc];
|
1064 |
+
} catch (Exception $e) {
|
1065 |
+
Utility::logCatch($e, 'WebService: getCustomerFields');
|
1066 |
+
}
|
1067 |
+
return array(
|
1068 |
+
Constants::SALES_TYPE_CODE_KEY => $salesTypeCode,
|
1069 |
+
Constants::EXEMPTION_TYPE_CODE_KEY => $exemptionCode,
|
1070 |
+
Constants::EXEMPTION_REASON_CODE_KEY => $exemptionReasonCode
|
1071 |
+
);
|
1072 |
+
}
|
1073 |
+
|
1074 |
+
/**
|
1075 |
+
* Get Customer Fields in array form.
|
1076 |
+
*
|
1077 |
+
* @param object $invoice
|
1078 |
+
* @param int $customerGroupId
|
1079 |
+
* @return array
|
1080 |
+
*/
|
1081 |
+
protected function getCustomerFieldsFromInvoiceOrCreditMemo($object)
|
1082 |
+
{
|
1083 |
+
$salesTypeCodeDesc = Constants::DEFAULT_SALES_TYPE_CODE;
|
1084 |
+
$exemptionCodeDesc = Constants::DEFAULT_EXEMPTION_CODE;
|
1085 |
+
$exemptionReasonDesc = Constants::DEFAULT_EXEMPTION_REASON_CODE;
|
1086 |
+
if (empty($object->getCustomerExemptionCode())) {
|
1087 |
+
if (!empty($object->getCustomerGroupExemptionCode())) {
|
1088 |
+
$salesTypeCodeDesc = $object->getCustomerGroupSalesTypeCode();
|
1089 |
+
$exemptionCodeDesc = $object->getCustomerGroupExemptionCode();
|
1090 |
+
$exemptionReasonDesc = $object->getCustomerGroupExemptionReasonCode();
|
1091 |
+
}
|
1092 |
+
} else {
|
1093 |
+
$salesTypeCodeDesc = $object->getCustomerSalesTypeCode();
|
1094 |
+
$exemptionCodeDesc = $object->getCustomerExemptionCode();
|
1095 |
+
$exemptionReasonDesc = $object->getCustomerExemptionReasonCode();
|
1096 |
+
}
|
1097 |
+
try {
|
1098 |
+
$salesTypeCode
|
1099 |
+
= Constants::$SALES_TYPE_CODES_VALUES[$salesTypeCodeDesc];
|
1100 |
+
$exemptionCode
|
1101 |
+
= Constants::$EXEMPTION_TYPE_CODES_VALUES[$exemptionCodeDesc];
|
1102 |
+
$exemptionReasonCode
|
1103 |
+
= Constants::$EXEMPTION_REASON_CODES_VALUES[$exemptionReasonDesc];
|
1104 |
+
} catch (Exception $e) {
|
1105 |
+
Utility::logCatch($e, 'WebService: getCustomerFieldsFromInvoiceOrCreditMemo');
|
1106 |
+
}
|
1107 |
+
return array(
|
1108 |
+
Constants::SALES_TYPE_CODE_KEY => $salesTypeCode,
|
1109 |
+
Constants::EXEMPTION_TYPE_CODE_KEY => $exemptionCode,
|
1110 |
+
Constants::EXEMPTION_REASON_CODE_KEY => $exemptionReasonCode
|
1111 |
+
);
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
public function sendPing()
|
1115 |
+
{
|
1116 |
+
try {
|
1117 |
+
$config = Config::get();
|
1118 |
+
$client = Mage::getModel(
|
1119 |
+
'wolterskluwer_cchsuretax/ws_sureTaxClient',
|
1120 |
+
array('Config' => $config)
|
1121 |
+
);
|
1122 |
+
|
1123 |
+
$client->callHealthMonitor();
|
1124 |
+
} catch (Exception $exe) {
|
1125 |
+
Utility::logCatch($exe, 'Exception with sendPing');
|
1126 |
+
}
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
public function makeCancelRequest($order)
|
1130 |
+
{
|
1131 |
+
try {
|
1132 |
+
$config = Config::get();
|
1133 |
+
$client = Mage::getModel(
|
1134 |
+
'wolterskluwer_cchsuretax/ws_sureTaxClient',
|
1135 |
+
array('Config' => $config)
|
1136 |
+
);
|
1137 |
+
|
1138 |
+
$theId = $this->generateUniqueId($order->getIncrementId());
|
1139 |
+
|
1140 |
+
$clientTracking = 'Cancel ' . $order->getIncrementId();
|
1141 |
+
$soapCancelRequestResult = $client->callCancelSoapRequestWithSTAN($theId, $clientTracking);
|
1142 |
+
|
1143 |
+
return $soapCancelRequestResult;
|
1144 |
+
} catch (Exception $ere) {
|
1145 |
+
Utility::logCatch($ere, 'Cancel: Exception with makeCancelRequest');
|
1146 |
+
throw $ere;
|
1147 |
+
}
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
public function createSureTaxRequestFromCreditmemo(
|
1151 |
+
Mage_Sales_Model_Order_Creditmemo $creditMemo,
|
1152 |
+
$shipToAddressArray
|
1153 |
+
) {
|
1154 |
+
|
1155 |
+
try {
|
1156 |
+
$config = Config::get();
|
1157 |
+
$order = $creditMemo->getOrder();
|
1158 |
+
$store = $order->getStore();
|
1159 |
+
$ordCreationDate = $order->getCreatedAt();
|
1160 |
+
$creditmemoCreationDate = $creditMemo->getCreatedAt();
|
1161 |
+
|
1162 |
+
$masterTransId = '0';
|
1163 |
+
$returnFileCode = 0;
|
1164 |
+
|
1165 |
+
$businessUnit = $this->getBusinessUnit(
|
1166 |
+
$config,
|
1167 |
+
$store->getWebsiteId(),
|
1168 |
+
$store->getGroupId()
|
1169 |
+
);
|
1170 |
+
|
1171 |
+
$uniqueId = $this->generateUniqueIdForCreditMemo(
|
1172 |
+
$creditMemo->getIncrementId()
|
1173 |
+
);
|
1174 |
+
|
1175 |
+
$currentClientTracking = $this->generateUniqueId(
|
1176 |
+
$creditMemo->getOrderIncrementId()
|
1177 |
+
. 'CT'
|
1178 |
+
. $creditMemo->getIncrementId()
|
1179 |
+
);
|
1180 |
+
$defaultProviderType = $config->getProviderType();
|
1181 |
+
|
1182 |
+
$shipToAddress = $this->convertToSureTaxAddress($shipToAddressArray);
|
1183 |
+
|
1184 |
+
$billingAddress = null;
|
1185 |
+
$this->convertToSureTaxAddress(
|
1186 |
+
Utility::getShipToAddress(
|
1187 |
+
Mage::getModel('sales/order_address')
|
1188 |
+
->load($order->getBillingAddress()->getId())
|
1189 |
+
)
|
1190 |
+
);
|
1191 |
+
|
1192 |
+
$shipFromAddress = $this->convertToSureTaxAddress(
|
1193 |
+
Utility::getShipFromAddress(
|
1194 |
+
$store->getWebsiteId(),
|
1195 |
+
$store->getGroupId()
|
1196 |
+
)
|
1197 |
+
);
|
1198 |
+
|
1199 |
+
$totalRevenue = 0;
|
1200 |
+
$customerId = $order->getCustomerId();
|
1201 |
+
$customerFields = $this->getCustomerFields(
|
1202 |
+
$customerId,
|
1203 |
+
$order->getCustomerGroupId()
|
1204 |
+
);
|
1205 |
+
|
1206 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
1207 |
+
$allItems = $creditMemo->getAllItems();
|
1208 |
+
|
1209 |
+
foreach ($allItems as $item) {
|
1210 |
+
$lineItem = $this->getLineItem(
|
1211 |
+
$i,
|
1212 |
+
$item,
|
1213 |
+
$billingAddress,
|
1214 |
+
$shipToAddress,
|
1215 |
+
$shipFromAddress,
|
1216 |
+
$ordCreationDate,
|
1217 |
+
0,
|
1218 |
+
false,
|
1219 |
+
$defaultProviderType,
|
1220 |
+
true,
|
1221 |
+
$config,
|
1222 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1223 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1224 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1225 |
+
$customerId
|
1226 |
+
);
|
1227 |
+
$lineItemArray[] = $lineItem;
|
1228 |
+
$totalRevenue += $lineItem->Revenue;
|
1229 |
+
|
1230 |
+
$lineItemGift = $this->getLineItem(
|
1231 |
+
Constants::generateGiftWrapLineNumber($i),
|
1232 |
+
$item,
|
1233 |
+
$billingAddress,
|
1234 |
+
$shipToAddress,
|
1235 |
+
$shipFromAddress,
|
1236 |
+
$ordCreationDate,
|
1237 |
+
0,
|
1238 |
+
false,
|
1239 |
+
$config->getProviderType(),
|
1240 |
+
true,
|
1241 |
+
$config,
|
1242 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1243 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1244 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1245 |
+
$customerId
|
1246 |
+
);
|
1247 |
+
if ($lineItemGift !== null) {
|
1248 |
+
$lineItemArray[] = $lineItemGift;
|
1249 |
+
$totalRevenue += $lineItemGift->Revenue;
|
1250 |
+
}
|
1251 |
+
$i++;
|
1252 |
+
}
|
1253 |
+
|
1254 |
+
if (null !== $creditMemo->getGwBasePrice() && $creditMemo->getGwBasePrice() > 0) {
|
1255 |
+
$orderLevelGift = $this->getLineItem(
|
1256 |
+
Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL,
|
1257 |
+
$order,
|
1258 |
+
$billingAddress,
|
1259 |
+
$shipToAddress,
|
1260 |
+
$shipFromAddress,
|
1261 |
+
$ordCreationDate,
|
1262 |
+
0,
|
1263 |
+
true,
|
1264 |
+
$config->getProviderType(),
|
1265 |
+
true,
|
1266 |
+
$config,
|
1267 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1268 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1269 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1270 |
+
$customerId
|
1271 |
+
);
|
1272 |
+
if ($orderLevelGift !== null) {
|
1273 |
+
$lineItemArray[] = $orderLevelGift;
|
1274 |
+
$totalRevenue += $orderLevelGift->Revenue;
|
1275 |
+
}
|
1276 |
+
}
|
1277 |
+
if (null !== $creditMemo->getGwCardBasePrice() && $creditMemo->getGwCardBasePrice() > 0) {
|
1278 |
+
$orderLevelGiftCard = $this->getLineItem(
|
1279 |
+
Constants::DEFAULT_GW_CARD_LINE_NUMBER,
|
1280 |
+
$order,
|
1281 |
+
$billingAddress,
|
1282 |
+
$shipToAddress,
|
1283 |
+
$shipFromAddress,
|
1284 |
+
$ordCreationDate,
|
1285 |
+
0,
|
1286 |
+
true,
|
1287 |
+
$config->getProviderType(),
|
1288 |
+
true,
|
1289 |
+
$config,
|
1290 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1291 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1292 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1293 |
+
$customerId
|
1294 |
+
);
|
1295 |
+
if ($orderLevelGiftCard != null) {
|
1296 |
+
$lineItemArray[] = $orderLevelGiftCard;
|
1297 |
+
$totalRevenue += $orderLevelGiftCard->Revenue;
|
1298 |
+
}
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
$shippingAmount = $creditMemo->getBaseShippingAmount();
|
1302 |
+
|
1303 |
+
if (isset($shippingAmount) && $shippingAmount > 0) {
|
1304 |
+
$shippingLineItem = $this->getLineItem(
|
1305 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER,
|
1306 |
+
$item,
|
1307 |
+
$billingAddress,
|
1308 |
+
$shipToAddress,
|
1309 |
+
$shipFromAddress,
|
1310 |
+
$ordCreationDate,
|
1311 |
+
$shippingAmount,
|
1312 |
+
false,
|
1313 |
+
$defaultProviderType,
|
1314 |
+
true,
|
1315 |
+
$config,
|
1316 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1317 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1318 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1319 |
+
$customerId
|
1320 |
+
);
|
1321 |
+
$lineItemArray[] = $shippingLineItem;
|
1322 |
+
$totalRevenue += $shippingLineItem->Revenue;
|
1323 |
+
}
|
1324 |
+
|
1325 |
+
$stan = $uniqueId;
|
1326 |
+
$requestData = Mage::getModel(
|
1327 |
+
'wolterskluwer_cchsuretax/ws_sureTaxRequest',
|
1328 |
+
array (
|
1329 |
+
'ClientNumber' => $config->getClientNumber(),
|
1330 |
+
'BusinessUnit' => $businessUnit,
|
1331 |
+
'ValidationKey' => $config->getValidationKey(),
|
1332 |
+
'DataYear' => date_parse($ordCreationDate)['year'],
|
1333 |
+
'DataMonth' => date_parse($ordCreationDate)['month'],
|
1334 |
+
'CmplDataYear' => date_parse($creditmemoCreationDate)['year'],
|
1335 |
+
'CmplDataMonth' => date_parse($creditmemoCreationDate)['month'],
|
1336 |
+
'TotalRevenue' => $totalRevenue,
|
1337 |
+
'ClientTracking' => $currentClientTracking,
|
1338 |
+
'ResponseType' => $config->getResponseType(),
|
1339 |
+
'ResponseGroup' => $config->getResponseGroup(),
|
1340 |
+
'ReturnFileCode' => $returnFileCode,
|
1341 |
+
'STAN' => $stan,
|
1342 |
+
'MasterTransId' => $masterTransId,
|
1343 |
+
'ShipToAddress' => $shipToAddress,
|
1344 |
+
'ShipFromAddress' => $shipFromAddress,
|
1345 |
+
'ItemList' => $lineItemArray
|
1346 |
+
)
|
1347 |
+
);
|
1348 |
+
|
1349 |
+
return $requestData;
|
1350 |
+
} catch (Exception $ere) {
|
1351 |
+
Utility::logCatch(
|
1352 |
+
$ere,
|
1353 |
+
'CreditMemo: Exception with createSureTaxRequestFromCreditmemo'
|
1354 |
+
);
|
1355 |
+
throw $ere;
|
1356 |
+
}
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
public function createSureTaxRequestFromBatchCreditmemo(
|
1360 |
+
Mage_Sales_Model_Order_Creditmemo $creditMemo,
|
1361 |
+
$shipToAddressArray,
|
1362 |
+
$wsConfigArray
|
1363 |
+
) {
|
1364 |
+
|
1365 |
+
try {
|
1366 |
+
$config = Config::get();
|
1367 |
+
|
1368 |
+
$ordCreationDate = $creditMemo->getOrderCreatedAt();
|
1369 |
+
$creditmemoCreationDate = $creditMemo->getCreatedAt();
|
1370 |
+
|
1371 |
+
$websiteId = $creditMemo->getWebsiteId();
|
1372 |
+
$storeId = $creditMemo->getGroupId();
|
1373 |
+
|
1374 |
+
$masterTransId = '0';
|
1375 |
+
$returnFileCode = 0;
|
1376 |
+
|
1377 |
+
$businessUnit = $this->getBusinessUnit(
|
1378 |
+
$config,
|
1379 |
+
$websiteId,
|
1380 |
+
$storeId,
|
1381 |
+
$wsConfigArray
|
1382 |
+
);
|
1383 |
+
|
1384 |
+
$uniqueId = $this->generateUniqueIdForCreditMemo(
|
1385 |
+
$creditMemo->getIncrementId()
|
1386 |
+
);
|
1387 |
+
|
1388 |
+
$currentClientTracking = $this->generateUniqueId(
|
1389 |
+
$creditMemo->getOrderIncrementId()
|
1390 |
+
.'CT'
|
1391 |
+
.$creditMemo->getIncrementId()
|
1392 |
+
);
|
1393 |
+
$defaultProviderType = $config->getProviderType();
|
1394 |
+
|
1395 |
+
$shipToAddress = $this->convertToSureTaxAddress($shipToAddressArray);
|
1396 |
+
|
1397 |
+
$billingAddress = null;
|
1398 |
+
|
1399 |
+
$shipFromAddress = $this->convertToSureTaxAddress(
|
1400 |
+
Utility::getShipFromAddressFromConfig(
|
1401 |
+
$websiteId,
|
1402 |
+
$storeId,
|
1403 |
+
$wsConfigArray
|
1404 |
+
)
|
1405 |
+
);
|
1406 |
+
|
1407 |
+
$totalRevenue = 0;
|
1408 |
+
$customerId = $creditMemo->getCustomerId();
|
1409 |
+
$customerFields = $this->getCustomerFieldsFromInvoiceOrCreditMemo(
|
1410 |
+
$creditMemo
|
1411 |
+
);
|
1412 |
+
|
1413 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
1414 |
+
$allItems = $creditMemo->getAllItems();
|
1415 |
+
|
1416 |
+
foreach ($allItems as $item) {
|
1417 |
+
$lineItem = $this->getLineItem(
|
1418 |
+
$i,
|
1419 |
+
$item,
|
1420 |
+
$billingAddress,
|
1421 |
+
$shipToAddress,
|
1422 |
+
$shipFromAddress,
|
1423 |
+
$ordCreationDate,
|
1424 |
+
0,
|
1425 |
+
false,
|
1426 |
+
$defaultProviderType,
|
1427 |
+
true,
|
1428 |
+
$config,
|
1429 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1430 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1431 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1432 |
+
$customerId
|
1433 |
+
);
|
1434 |
+
$lineItemArray[] = $lineItem;
|
1435 |
+
$totalRevenue += $lineItem->Revenue;
|
1436 |
+
|
1437 |
+
$lineItemGift = $this->getLineItem(
|
1438 |
+
Constants::generateGiftWrapLineNumber($i),
|
1439 |
+
$item,
|
1440 |
+
$billingAddress,
|
1441 |
+
$shipToAddress,
|
1442 |
+
$shipFromAddress,
|
1443 |
+
$ordCreationDate,
|
1444 |
+
0,
|
1445 |
+
false,
|
1446 |
+
$config->getProviderType(),
|
1447 |
+
true,
|
1448 |
+
$config,
|
1449 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1450 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1451 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1452 |
+
$customerId
|
1453 |
+
);
|
1454 |
+
if ($lineItemGift != null) {
|
1455 |
+
$lineItemArray[] = $lineItemGift;
|
1456 |
+
$totalRevenue += $lineItemGift->Revenue;
|
1457 |
+
}
|
1458 |
+
$i++;
|
1459 |
+
}
|
1460 |
+
|
1461 |
+
if (null !== $creditMemo->getGwBasePrice() && $creditMemo->getGwBasePrice() > 0) {
|
1462 |
+
$orderLevelGift = $this->getLineItem(
|
1463 |
+
Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL,
|
1464 |
+
$creditMemo,
|
1465 |
+
$billingAddress,
|
1466 |
+
$shipToAddress,
|
1467 |
+
$shipFromAddress,
|
1468 |
+
$ordCreationDate,
|
1469 |
+
0,
|
1470 |
+
false,
|
1471 |
+
$config->getProviderType(),
|
1472 |
+
true,
|
1473 |
+
$config,
|
1474 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1475 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1476 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1477 |
+
$customerId
|
1478 |
+
);
|
1479 |
+
if ($orderLevelGift !== null) {
|
1480 |
+
$lineItemArray[] = $orderLevelGift;
|
1481 |
+
$totalRevenue += $orderLevelGift->Revenue;
|
1482 |
+
}
|
1483 |
+
}
|
1484 |
+
if (null !== $creditMemo->getGwCardBasePrice() && $creditMemo->getGwCardBasePrice() > 0) {
|
1485 |
+
$orderLevelGiftCard = $this->getLineItem(
|
1486 |
+
Constants::DEFAULT_GW_CARD_LINE_NUMBER,
|
1487 |
+
$creditMemo,
|
1488 |
+
$billingAddress,
|
1489 |
+
$shipToAddress,
|
1490 |
+
$shipFromAddress,
|
1491 |
+
$ordCreationDate,
|
1492 |
+
0,
|
1493 |
+
false,
|
1494 |
+
$config->getProviderType(),
|
1495 |
+
true,
|
1496 |
+
$config,
|
1497 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1498 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1499 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1500 |
+
$customerId
|
1501 |
+
);
|
1502 |
+
if ($orderLevelGiftCard !== null) {
|
1503 |
+
$lineItemArray[] = $orderLevelGiftCard;
|
1504 |
+
$totalRevenue += $orderLevelGiftCard->Revenue;
|
1505 |
+
}
|
1506 |
+
}
|
1507 |
+
|
1508 |
+
$shippingAmount = $creditMemo->getBaseShippingAmount();
|
1509 |
+
|
1510 |
+
if (isset($shippingAmount) && $shippingAmount > 0) {
|
1511 |
+
$shippingLineItem = $this->getLineItem(
|
1512 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER,
|
1513 |
+
$item,
|
1514 |
+
$billingAddress,
|
1515 |
+
$shipToAddress,
|
1516 |
+
$shipFromAddress,
|
1517 |
+
$ordCreationDate,
|
1518 |
+
$shippingAmount,
|
1519 |
+
false,
|
1520 |
+
$defaultProviderType,
|
1521 |
+
true,
|
1522 |
+
$config,
|
1523 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
1524 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
1525 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
1526 |
+
$customerId
|
1527 |
+
);
|
1528 |
+
$lineItemArray[] = $shippingLineItem;
|
1529 |
+
$totalRevenue += $shippingLineItem->Revenue;
|
1530 |
+
}
|
1531 |
+
|
1532 |
+
$stan = $uniqueId;
|
1533 |
+
$requestData = Mage::getModel(
|
1534 |
+
'wolterskluwer_cchsuretax/ws_sureTaxRequest',
|
1535 |
+
array (
|
1536 |
+
'ClientNumber' => $config->getClientNumber(),
|
1537 |
+
'BusinessUnit' => $businessUnit,
|
1538 |
+
'ValidationKey' => $config->getValidationKey(),
|
1539 |
+
'DataYear' => date_parse($ordCreationDate)['year'],
|
1540 |
+
'DataMonth' => date_parse($ordCreationDate)['month'],
|
1541 |
+
'CmplDataYear' => date_parse($creditmemoCreationDate)['year'],
|
1542 |
+
'CmplDataMonth' => date_parse($creditmemoCreationDate)['month'],
|
1543 |
+
'TotalRevenue' => $totalRevenue,
|
1544 |
+
'ClientTracking' => $currentClientTracking,
|
1545 |
+
'ResponseType' => $config->getResponseType(),
|
1546 |
+
'ResponseGroup' => $config->getResponseGroup(),
|
1547 |
+
'ReturnFileCode' => $returnFileCode,
|
1548 |
+
'STAN' => $stan,
|
1549 |
+
'MasterTransId' => $masterTransId,
|
1550 |
+
'ShipToAddress' => $shipToAddress,
|
1551 |
+
'ShipFromAddress' => $shipFromAddress,
|
1552 |
+
'ItemList' => $lineItemArray
|
1553 |
+
)
|
1554 |
+
);
|
1555 |
+
|
1556 |
+
return $requestData;
|
1557 |
+
} catch (Exception $ere) {
|
1558 |
+
Utility::logCatch(
|
1559 |
+
$ere,
|
1560 |
+
'CreditMemo: Exception with createSureTaxRequestFromCreditmemo'
|
1561 |
+
);
|
1562 |
+
throw $ere;
|
1563 |
+
}
|
1564 |
+
}
|
1565 |
+
|
1566 |
+
public function makeCreditRequest($requestData)
|
1567 |
+
{
|
1568 |
+
try {
|
1569 |
+
$config = Config::get();
|
1570 |
+
$client = Mage::getModel(
|
1571 |
+
'wolterskluwer_cchsuretax/ws_sureTaxClient',
|
1572 |
+
array('Config' => $config)
|
1573 |
+
);
|
1574 |
+
|
1575 |
+
$soapReturnRequestResult = $client->callSoapRequest($requestData);
|
1576 |
+
return $soapReturnRequestResult;
|
1577 |
+
} catch (Exception $ere) {
|
1578 |
+
Utility::logCatch($ere, 'CreditMemo: Exception with makeCreditRequest');
|
1579 |
+
throw $ere;
|
1580 |
+
}
|
1581 |
+
}
|
1582 |
+
|
1583 |
+
public function getTotalTaxFromResponse($response)
|
1584 |
+
{
|
1585 |
+
return $response->SoapRequestResult->TotalTax;
|
1586 |
+
}
|
1587 |
+
|
1588 |
+
/**
|
1589 |
+
* Create Line item array that needs to be attached to the request
|
1590 |
+
*
|
1591 |
+
* @param int $i
|
1592 |
+
* @param Mage_Sales_Model_Quote_Item|
|
1593 |
+
* Mage_Sales_Model_Order_Invoice_Item|
|
1594 |
+
* Mage_Sales_Model_Order_Item|
|
1595 |
+
* Mage_Sales_Model_Order_Creditmemo_Item $item
|
1596 |
+
* @param WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress $billingAddress
|
1597 |
+
* @param WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress $shipToAddress
|
1598 |
+
* @param WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress $shipFromAddress
|
1599 |
+
* @param string $trxDate
|
1600 |
+
* @param float $shippingCharges
|
1601 |
+
* @param boolean $isOrderObject
|
1602 |
+
* @param string $providerType
|
1603 |
+
* @param boolean $isCredit
|
1604 |
+
* @param WoltersKluwer_CchSureTax_Helper_Config $config
|
1605 |
+
* @param string $salesTypeCode
|
1606 |
+
* @param string $exemptionCode
|
1607 |
+
* @param string $exemptionReason
|
1608 |
+
* @param int $customerId
|
1609 |
+
* @return null|
|
1610 |
+
* WoltersKluwer_CchSureTax_Model_Ws_SureTaxItem SureTaxItem
|
1611 |
+
* OR null if no line item created (e.g. gift wrap not supported)
|
1612 |
+
* SureTaxItem or null if no line item created (e.g. gift wrap not
|
1613 |
+
* supported)
|
1614 |
+
*/
|
1615 |
+
public function getLineItem($i, $item, $billingAddress, $shipToAddress,
|
1616 |
+
$shipFromAddress, $trxDate, $shippingCharges, $isOrderObject,
|
1617 |
+
$providerType, $isCredit, $config, $salesTypeCode, $exemptionCode,
|
1618 |
+
$exemptionReason, $customerId
|
1619 |
+
) {
|
1620 |
+
$isGift = Utility::startsWith(
|
1621 |
+
$i,
|
1622 |
+
Constants::DEFAULT_GW_LINE_NUMBER_PREPEND
|
1623 |
+
);
|
1624 |
+
$isGiftOrder = (
|
1625 |
+
strcmp(Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL, $i) == 0
|
1626 |
+
);
|
1627 |
+
|
1628 |
+
$itemToCheck = $item;
|
1629 |
+
if ($item instanceof Mage_Sales_Model_Order_Invoice_Item
|
1630 |
+
|| $item instanceof Mage_Sales_Model_Order_Creditmemo_Item
|
1631 |
+
) {
|
1632 |
+
$itemToCheck = $item->getOrderItem();
|
1633 |
+
}
|
1634 |
+
|
1635 |
+
// is gift supported (ee vs ce)?
|
1636 |
+
if (($isGift || $isGiftOrder) && !Utility::isGiftWrap($itemToCheck)) {
|
1637 |
+
return null;
|
1638 |
+
}
|
1639 |
+
|
1640 |
+
// gift card is only at quote/order level
|
1641 |
+
$isGiftWrapCard = (
|
1642 |
+
strcmp(Constants::DEFAULT_GW_CARD_LINE_NUMBER, $i) == 0
|
1643 |
+
);
|
1644 |
+
|
1645 |
+
if ($isGiftWrapCard && !Utility::isGiftWrapCard($itemToCheck)) {
|
1646 |
+
return null;
|
1647 |
+
}
|
1648 |
+
|
1649 |
+
$qty = 1;
|
1650 |
+
$lineNumber = $i;
|
1651 |
+
//get it from a method by passing SKU and get tax class of the SKU
|
1652 |
+
$transTypeCode = Constants::DEFAULT_TRANS_TYPE_CODE;
|
1653 |
+
$sku = '';
|
1654 |
+
|
1655 |
+
if ($isGift) {
|
1656 |
+
$qty = $isOrderObject ? $item->getQtyOrdered() : $item->getQty();
|
1657 |
+
$transTypeCode = $config->getDefaulGiftWrapClass();
|
1658 |
+
$rowTotal = $itemToCheck->getGwBasePrice() * $qty;
|
1659 |
+
$sku = Constants::DEFAULT_GW_SKU_NAME;
|
1660 |
+
} elseif ($isGiftOrder) {
|
1661 |
+
$qty = 1;
|
1662 |
+
$transTypeCode = $config->getDefaulGiftWrapClass();
|
1663 |
+
$rowTotal = $item->getGwBasePrice();
|
1664 |
+
$sku = Constants::DEFAULT_GW_SKU_NAME;
|
1665 |
+
} elseif ($isGiftWrapCard) {
|
1666 |
+
$qty = 1;
|
1667 |
+
$transTypeCode = $config->getDefaulGiftWrapClass();
|
1668 |
+
$rowTotal = $item->getGwCardBasePrice();
|
1669 |
+
$sku = Constants::DEFAULT_GW_CARD_SKU_NAME;
|
1670 |
+
} elseif ($shippingCharges != 0) {
|
1671 |
+
$rowTotal = $shippingCharges;
|
1672 |
+
$transTypeCode = $config->getDefaultShippingClass();
|
1673 |
+
$lineNumber = Constants::DEFAULT_SHIPPING_LINE_NUMBER;
|
1674 |
+
$sku = Constants::DEFAULT_SHIPPING_SKU_NAME;
|
1675 |
+
} else {
|
1676 |
+
$rowTotal = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
|
1677 |
+
$qty = $isOrderObject ? $item->getQtyOrdered() : $item->getQty();
|
1678 |
+
|
1679 |
+
try {
|
1680 |
+
$sku = $item->getSku();
|
1681 |
+
$transTypeCode = $this->getTransTypeCode($itemToCheck);
|
1682 |
+
} catch (Exception $ex) {
|
1683 |
+
Utility::logCatch($ex, 'WebService get line items');
|
1684 |
+
}
|
1685 |
+
}
|
1686 |
+
$rowTotal = $isCredit ? ($rowTotal * -1) : $rowTotal;
|
1687 |
+
|
1688 |
+
$retItem = Mage::getModel(
|
1689 |
+
'wolterskluwer_cchsuretax/ws_sureTaxItem',
|
1690 |
+
array (
|
1691 |
+
'LineNumber' => $lineNumber,
|
1692 |
+
'InvoiceNumber' => '',
|
1693 |
+
'CustomerNumber' => (($customerId != null) ? $customerId : ''),
|
1694 |
+
'LocationCode' => '',
|
1695 |
+
'BillToNumber' => '',
|
1696 |
+
'OrigNumber' => '',
|
1697 |
+
'TermNumber' => '',
|
1698 |
+
'TransDate' => $trxDate,
|
1699 |
+
'Revenue' => $rowTotal,
|
1700 |
+
'TaxIncludedCode' => '0',
|
1701 |
+
'Units' => empty($qty) ? '1' : $qty,
|
1702 |
+
'UnitType' => $config->getUnitType(),
|
1703 |
+
'TaxSitusRule' => $config->getTaxSitusRule(),
|
1704 |
+
'TransTypeCode' => $transTypeCode,
|
1705 |
+
'SalesTypeCode' => $salesTypeCode,
|
1706 |
+
'RegulatoryCode' => $providerType,
|
1707 |
+
'TaxExemptionCodeList' => array($exemptionCode),
|
1708 |
+
'CostCenter' => '',
|
1709 |
+
'GLAccount' => '',
|
1710 |
+
'ExemptReasonCode' => $exemptionReason,
|
1711 |
+
'BillingAddress' => ((isset($billingAddress) && $billingAddress != null)
|
1712 |
+
? $this->copySureTaxAddress($billingAddress) : ''),
|
1713 |
+
'ShipToAddress' => ((isset($shipToAddress) && $shipToAddress != null)
|
1714 |
+
? $this->copySureTaxAddress($shipToAddress) : ''),
|
1715 |
+
'ShipFromAddress' => ((isset($shipFromAddress) && $shipFromAddress != null)
|
1716 |
+
? $this->copySureTaxAddress($shipFromAddress) : ''),
|
1717 |
+
'UDF' => $sku
|
1718 |
+
)
|
1719 |
+
);
|
1720 |
+
|
1721 |
+
return $retItem;
|
1722 |
+
}
|
1723 |
+
|
1724 |
+
/**
|
1725 |
+
* This method is called for finalizing the order from Observer.php
|
1726 |
+
*
|
1727 |
+
* @param WoltersKluwer_CchSureTax_Helper_Config $config
|
1728 |
+
* @param int $websiteId
|
1729 |
+
* @param int $storeId
|
1730 |
+
*
|
1731 |
+
* @return string
|
1732 |
+
*/
|
1733 |
+
public function getBusinessUnit($config, $websiteId, $storeId)
|
1734 |
+
{
|
1735 |
+
$defaultBusinessUnit = $config->getBusinessUnit();
|
1736 |
+
|
1737 |
+
$row = Mage::getModel(Constants::WS_CONFIG_TBL)
|
1738 |
+
->getCollection()
|
1739 |
+
->loadWebsiteConfig($websiteId);
|
1740 |
+
if ($row->getUseBusinessUnit() !== null) {
|
1741 |
+
$websiteFlag = $row->getUseBusinessUnit();
|
1742 |
+
$websiteBusinessUnit = $row->getBusinessUnit();
|
1743 |
+
} else {
|
1744 |
+
$websiteFlag = 1;
|
1745 |
+
$websiteBusinessUnit = '';
|
1746 |
+
}
|
1747 |
+
|
1748 |
+
$row = Mage::getModel(Constants::WS_CONFIG_TBL)
|
1749 |
+
->getCollection()
|
1750 |
+
->loadStoreConfig($websiteId, $storeId);
|
1751 |
+
if ($row->getUseBusinessUnit() !== null) {
|
1752 |
+
$storeFlag = $row->getUseBusinessUnit();
|
1753 |
+
$storeBusinessUnit = $row->getBusinessUnit();
|
1754 |
+
} else {
|
1755 |
+
$storeFlag = 1;
|
1756 |
+
$storeBusinessUnit = '';
|
1757 |
+
}
|
1758 |
+
|
1759 |
+
if ($storeFlag == 0) {
|
1760 |
+
return isset($storeBusinessUnit) ? $storeBusinessUnit : '';
|
1761 |
+
} elseif ($websiteFlag == 0) {
|
1762 |
+
return isset($websiteBusinessUnit) ? $websiteBusinessUnit : '';
|
1763 |
+
} else {
|
1764 |
+
return isset($defaultBusinessUnit) ? $defaultBusinessUnit : '';
|
1765 |
+
}
|
1766 |
+
}
|
1767 |
+
|
1768 |
+
/**
|
1769 |
+
*
|
1770 |
+
* @param Mage_Sales_Model_Quote_Item|
|
1771 |
+
* Mage_Sales_Model_Order_Item $item
|
1772 |
+
*
|
1773 |
+
* @return string The trans type code to use.
|
1774 |
+
*/
|
1775 |
+
public function getTransTypeCode($item)
|
1776 |
+
{
|
1777 |
+
$taxClassId = $item->getProduct()->getTaxClassId();
|
1778 |
+
$taxClassName = $this->_getTaxClassName($taxClassId);
|
1779 |
+
return $taxClassName ? $taxClassName : Constants::DEFAULT_TRANS_TYPE_CODE;
|
1780 |
+
}
|
1781 |
+
|
1782 |
+
/**
|
1783 |
+
*
|
1784 |
+
* @param int $id
|
1785 |
+
*
|
1786 |
+
* @return string The tax class name
|
1787 |
+
*/
|
1788 |
+
protected function _getTaxClassName($id)
|
1789 |
+
{
|
1790 |
+
if ($this->_taxClassNameArray === null) {
|
1791 |
+
$temp = Mage::getModel('tax/class_source_product')->toOptionArray();
|
1792 |
+
$this->_taxClassNameArray = array();
|
1793 |
+
foreach ($temp as $a) {
|
1794 |
+
$this->_taxClassNameArray[$a['value']] = $a['label'];
|
1795 |
+
}
|
1796 |
+
}
|
1797 |
+
return $this->_taxClassNameArray[$id];
|
1798 |
+
}
|
1799 |
+
|
1800 |
+
public function sendFinalizeInvoiceToSureTax($invoice, $shipToAddressArray)
|
1801 |
+
{
|
1802 |
+
$totalTax = 0.0;
|
1803 |
+
try {
|
1804 |
+
$requestData = $this->createSureTaxRequestFromInvoice($invoice, $shipToAddressArray);
|
1805 |
+
$soapCalcRequestResult = $this->makeSureTaxRequest($requestData);
|
1806 |
+
|
1807 |
+
$isSuccessful = $soapCalcRequestResult->SoapRequestResult->Successful;
|
1808 |
+
$responseCode = $soapCalcRequestResult->SoapRequestResult->ResponseCode;
|
1809 |
+
$clientTracking = $soapCalcRequestResult->SoapRequestResult->ClientTracking;
|
1810 |
+
$transId = $soapCalcRequestResult->SoapRequestResult->TransId;
|
1811 |
+
|
1812 |
+
if ($isSuccessful == 'Y'
|
1813 |
+
&& (strcmp($responseCode, Constants::API_RESPONSE_CODE_SUCCESS) == 0)
|
1814 |
+
) {
|
1815 |
+
$totalTax = $soapCalcRequestResult->SoapRequestResult->TotalTax;
|
1816 |
+
Utility::logMessage(
|
1817 |
+
'Invoice ' . $invoice->getIncrementId() .
|
1818 |
+
' was successfully posted to SureTax', Zend_Log::DEBUG
|
1819 |
+
);
|
1820 |
+
|
1821 |
+
$status = 'Finalized';
|
1822 |
+
$notes = "Successfully Posted";
|
1823 |
+
|
1824 |
+
$jurisdictionArray = Utility::
|
1825 |
+
getJurisdictionLevelTaxesFromSureTaxResponse($soapCalcRequestResult);
|
1826 |
+
$this->setJurisdictionArray($jurisdictionArray);
|
1827 |
+
$success = true;
|
1828 |
+
} else {
|
1829 |
+
$headerMessage = $soapCalcRequestResult->SoapRequestResult->HeaderMessage;
|
1830 |
+
$responseCode = $soapCalcRequestResult->SoapRequestResult->ResponseCode;
|
1831 |
+
|
1832 |
+
$status = 'Finalize_Fail';
|
1833 |
+
$notes = $isSuccessful . '-' . $responseCode . ' : ' . $headerMessage;
|
1834 |
+
$success = false;
|
1835 |
+
|
1836 |
+
Utility::logMessage(
|
1837 |
+
'API FAILURE for Invoice ' .
|
1838 |
+
$invoice->getIncrementId() .
|
1839 |
+
'. Header: ' . $headerMessage,
|
1840 |
+
Zend_Log::ERR
|
1841 |
+
);
|
1842 |
+
}
|
1843 |
+
} catch (Exception $ere) {
|
1844 |
+
$status = 'Finalize_Fail';
|
1845 |
+
$notes = $ere->getMessage();
|
1846 |
+
$success = false;
|
1847 |
+
|
1848 |
+
Utility::logCatch(
|
1849 |
+
$ere,
|
1850 |
+
'Exception for Invoice ' . $invoice->getIncrementId()
|
1851 |
+
);
|
1852 |
+
}
|
1853 |
+
|
1854 |
+
$data = array(
|
1855 |
+
'client_tracking' => isset($clientTracking) ? $clientTracking : 'N/A',
|
1856 |
+
'trans_id' => $transId,
|
1857 |
+
'status' => $status,
|
1858 |
+
'notes' => $notes,
|
1859 |
+
'total_tax' => $totalTax,
|
1860 |
+
'success' => $success
|
1861 |
+
);
|
1862 |
+
|
1863 |
+
return $data;
|
1864 |
+
}
|
1865 |
+
|
1866 |
+
public function sendBatchFinalizeToSureTax($requestDataArray, $requestType)
|
1867 |
+
{
|
1868 |
+
$totalTax = 0.0;
|
1869 |
+
$returnDataArray = array();
|
1870 |
+
try {
|
1871 |
+
$soapRequestBatchResult = $this->makeSureTaxBatchRequest($requestDataArray);
|
1872 |
+
$responses = $soapRequestBatchResult->SoapRequestBatchResult->Response;
|
1873 |
+
foreach ($responses as $response) {
|
1874 |
+
$isSuccessful = $response->Successful;
|
1875 |
+
$responseCode = $response->ResponseCode;
|
1876 |
+
$clientTracking = $response->ClientTracking;
|
1877 |
+
if ($requestType === 'Invoice') {
|
1878 |
+
$clientTracking = isset($clientTracking) ? $clientTracking : 'N/A';
|
1879 |
+
} else {
|
1880 |
+
$clientTracking = isset($clientTracking) ? $clientTracking : '';
|
1881 |
+
}
|
1882 |
+
$transId = $response->TransId;
|
1883 |
+
$stan = isset($response->STAN) ? $response->STAN : '';
|
1884 |
+
|
1885 |
+
if ($isSuccessful == 'Y'
|
1886 |
+
&& (strcmp($responseCode, Constants::API_RESPONSE_CODE_SUCCESS) == 0)
|
1887 |
+
) {
|
1888 |
+
$totalTax = $response->TotalTax;
|
1889 |
+
Utility::logMessage(
|
1890 |
+
$requestType . $clientTracking .
|
1891 |
+
' was successfully posted to SureTax', Zend_Log::DEBUG
|
1892 |
+
);
|
1893 |
+
|
1894 |
+
$status = 'Finalized';
|
1895 |
+
$notes = "Successfully Posted";
|
1896 |
+
$success = true;
|
1897 |
+
} else {
|
1898 |
+
$headerMessage = $response->HeaderMessage;
|
1899 |
+
$responseCode = $response->ResponseCode;
|
1900 |
+
$status = 'Finalize_Fail';
|
1901 |
+
$notes = $isSuccessful . '-' . $responseCode . ' : ' . $headerMessage;
|
1902 |
+
$success = false;
|
1903 |
+
|
1904 |
+
Utility::logMessage(
|
1905 |
+
'API FAILURE for ' . $requestType .
|
1906 |
+
$clientTracking .
|
1907 |
+
'. Header: ' . $headerMessage,
|
1908 |
+
Zend_Log::ERR
|
1909 |
+
);
|
1910 |
+
}
|
1911 |
+
$data = array(
|
1912 |
+
'client_tracking' => isset($clientTracking) ? $clientTracking : 'N/A',
|
1913 |
+
'trans_id' => $transId,
|
1914 |
+
'status' => $status,
|
1915 |
+
'notes' => $notes,
|
1916 |
+
'total_tax' => $totalTax,
|
1917 |
+
'success' => $success,
|
1918 |
+
'stan' => $stan
|
1919 |
+
);
|
1920 |
+
$returnDataArray[$clientTracking] = $data;
|
1921 |
+
}
|
1922 |
+
} catch (Exception $ex) {
|
1923 |
+
Utility::logCatch($ex, $ex->getMessage());
|
1924 |
+
}
|
1925 |
+
return $returnDataArray;
|
1926 |
+
}
|
1927 |
+
|
1928 |
+
public function sendOrderToSureTax($order, $shipToAddressArray)
|
1929 |
+
{
|
1930 |
+
$totalTax = 0.0;
|
1931 |
+
try {
|
1932 |
+
$soapRequest = $this->createSureTaxRequestFromOrder(
|
1933 |
+
$order,
|
1934 |
+
false,
|
1935 |
+
$shipToAddressArray
|
1936 |
+
);
|
1937 |
+
$soapCalcRequestResult = $this->makeSureTaxRequestFromOrder($soapRequest);
|
1938 |
+
|
1939 |
+
$isSuccessful = $soapCalcRequestResult->SoapRequestResult->Successful;
|
1940 |
+
$clientTracking = $soapCalcRequestResult->SoapRequestResult->ClientTracking;
|
1941 |
+
$transId = $soapCalcRequestResult->SoapRequestResult->TransId;
|
1942 |
+
$responseCode = $soapCalcRequestResult->SoapRequestResult->ResponseCode;
|
1943 |
+
|
1944 |
+
if ($isSuccessful == 'Y'
|
1945 |
+
&& (strcmp($responseCode, Constants::API_RESPONSE_CODE_SUCCESS) == 0)
|
1946 |
+
) {
|
1947 |
+
$totalTax = $soapCalcRequestResult->SoapRequestResult->TotalTax;
|
1948 |
+
|
1949 |
+
$status = 'Finalized';
|
1950 |
+
$notes = "Successfully Posted";
|
1951 |
+
|
1952 |
+
$this->saveOrderTaxesToMagento($order, $soapCalcRequestResult, $soapRequest);
|
1953 |
+
|
1954 |
+
$jurisdictionArray = Utility
|
1955 |
+
::getJurisdictionLevelTaxesTotaledFromResponse($soapCalcRequestResult);
|
1956 |
+
$this->setJurisdictionArray($jurisdictionArray);
|
1957 |
+
|
1958 |
+
$success = true;
|
1959 |
+
} else {
|
1960 |
+
$headerMessage = $soapCalcRequestResult->SoapRequestResult->HeaderMessage;
|
1961 |
+
$responseCode = $soapCalcRequestResult->SoapRequestResult->ResponseCode;
|
1962 |
+
|
1963 |
+
$status = 'Finalize_Fail';
|
1964 |
+
$notes = $isSuccessful . '-' . $responseCode . ' : ' . $headerMessage;
|
1965 |
+
$success = false;
|
1966 |
+
|
1967 |
+
Utility::logMessage(
|
1968 |
+
'Finalize API FAILURE for Order ' .
|
1969 |
+
$order->getIncrementId() .
|
1970 |
+
" Header: $headerMessage",
|
1971 |
+
Zend_Log::ERR
|
1972 |
+
);
|
1973 |
+
}
|
1974 |
+
} catch (Exception $ere) {
|
1975 |
+
$status = 'Finalize_Fail';
|
1976 |
+
$notes = $ere->getMessage();
|
1977 |
+
$success = false;
|
1978 |
+
|
1979 |
+
Utility::logCatch($ere, 'Issue calling Suretax API for Order');
|
1980 |
+
}
|
1981 |
+
$data = array(
|
1982 |
+
'client_tracking' => $clientTracking,
|
1983 |
+
'trans_id' => $transId,
|
1984 |
+
'status' => $status,
|
1985 |
+
'notes' => $notes,
|
1986 |
+
'total_tax' => $totalTax,
|
1987 |
+
'success' => $success
|
1988 |
+
);
|
1989 |
+
return $data;
|
1990 |
+
}
|
1991 |
+
|
1992 |
+
/**
|
1993 |
+
* @return array
|
1994 |
+
*/
|
1995 |
+
public function getJurisdictionArray()
|
1996 |
+
{
|
1997 |
+
return $this->_jurisdictionArray;
|
1998 |
+
}
|
1999 |
+
|
2000 |
+
/**
|
2001 |
+
* @param array
|
2002 |
+
*/
|
2003 |
+
public function setJurisdictionArray($jurisdictionArray)
|
2004 |
+
{
|
2005 |
+
$this->_jurisdictionArray = $jurisdictionArray;
|
2006 |
+
}
|
2007 |
+
|
2008 |
+
public function sendCancelToSureTax($order)
|
2009 |
+
{
|
2010 |
+
try {
|
2011 |
+
$soapCancelRequestResult = $this->makeCancelRequest($order);
|
2012 |
+
$isSuccessful = $soapCancelRequestResult->CancelSoapRequestWithSTANResult->Successful;
|
2013 |
+
$responseCode = $soapCancelRequestResult->SoapRequestResult->ResponseCode;
|
2014 |
+
|
2015 |
+
if ($isSuccessful == 'Y' && (strcmp(
|
2016 |
+
$responseCode,
|
2017 |
+
Constants::API_RESPONSE_CODE_SUCCESS
|
2018 |
+
) == 0)) {
|
2019 |
+
$status = "Canceled";
|
2020 |
+
$notes = "Successfully Canceled";
|
2021 |
+
$success = true;
|
2022 |
+
} else {
|
2023 |
+
$headerMessage = $soapCancelRequestResult->CancelSoapRequestWithSTANResult->HeaderMessage;
|
2024 |
+
$responseCode = $soapCancelRequestResult->CancelSoapRequestWithSTANResult->ResponseCode;
|
2025 |
+
|
2026 |
+
$status = "Cancel_Fail";
|
2027 |
+
$notes = $isSuccessful . '-' . $responseCode . ' : ' . $headerMessage;
|
2028 |
+
$success = false;
|
2029 |
+
|
2030 |
+
Utility::logMessage(
|
2031 |
+
'Cancel Failure for Order ' . $order->getIncrementId(),
|
2032 |
+
Zend_Log::ERR
|
2033 |
+
);
|
2034 |
+
}
|
2035 |
+
} catch (Exception $ere) {
|
2036 |
+
$status = 'Cancel_Fail';
|
2037 |
+
$notes = $ere->getMessage();
|
2038 |
+
$success = false;
|
2039 |
+
|
2040 |
+
Utility::logCatch($ere, 'Cancel for Order ' . $order->getIncrementId());
|
2041 |
+
}
|
2042 |
+
$data = array(
|
2043 |
+
'status' => $status,
|
2044 |
+
'notes' => $notes,
|
2045 |
+
'success' => $success
|
2046 |
+
);
|
2047 |
+
return $data;
|
2048 |
+
}
|
2049 |
+
|
2050 |
+
public function sendCreditMemoToSureTax($creditmemo, $shipToAddressArray)
|
2051 |
+
{
|
2052 |
+
$order = $creditmemo->getOrder();
|
2053 |
+
|
2054 |
+
try {
|
2055 |
+
$soapRequest = $this->createSureTaxRequestFromCreditmemo(
|
2056 |
+
$creditmemo,
|
2057 |
+
$shipToAddressArray
|
2058 |
+
);
|
2059 |
+
$soapReturnResult = $this->makeCreditRequest($soapRequest);
|
2060 |
+
|
2061 |
+
$isSuccessful = $soapReturnResult->SoapRequestResult->Successful;
|
2062 |
+
$transId = $soapReturnResult->SoapRequestResult->TransId;
|
2063 |
+
$clientTracking = (isset($soapReturnResult->SoapRequestResult->ClientTracking))
|
2064 |
+
? $soapReturnResult->SoapRequestResult->ClientTracking : '';
|
2065 |
+
$stan = (isset($soapReturnResult->SoapRequestResult->STAN))
|
2066 |
+
? $soapReturnResult->SoapRequestResult->STAN : '';
|
2067 |
+
$responseCode = $soapReturnResult->SoapRequestResult->ResponseCode;
|
2068 |
+
|
2069 |
+
if ($isSuccessful == 'Y' && (strcmp(
|
2070 |
+
$responseCode,
|
2071 |
+
Constants::API_RESPONSE_CODE_SUCCESS
|
2072 |
+
) == 0)) {
|
2073 |
+
$totalTax = $soapReturnResult->SoapRequestResult->TotalTax;
|
2074 |
+
|
2075 |
+
$status = "Finalized";
|
2076 |
+
$notes = 'Successfully Posted';
|
2077 |
+
$success = true;
|
2078 |
+
} else {
|
2079 |
+
$headerMessage = $soapReturnResult->SoapRequestResult->HeaderMessage;
|
2080 |
+
$responseCode = $soapReturnResult->SoapRequestResult->ResponseCode;
|
2081 |
+
|
2082 |
+
$status = "Finalize_Fail";
|
2083 |
+
$notes = $isSuccessful . '-' . $responseCode . ' : ' . $headerMessage;
|
2084 |
+
$success = false;
|
2085 |
+
|
2086 |
+
Utility::logMessage(
|
2087 |
+
'Credit Memo API result in Failure for Order ' .
|
2088 |
+
$order->getIncrementId() . 'Header : ' . $headerMessage,
|
2089 |
+
Zend_Log::ERR
|
2090 |
+
);
|
2091 |
+
}
|
2092 |
+
} catch (Exception $ere) {
|
2093 |
+
$status = 'Finalize_Fail';
|
2094 |
+
$success = false;
|
2095 |
+
$notes = $ere->getMessage();
|
2096 |
+
Utility::logCatch($ere, 'API Return for Order ' . $order->getIncrementId());
|
2097 |
+
}
|
2098 |
+
|
2099 |
+
$data = array(
|
2100 |
+
'client_tracking' => $clientTracking,
|
2101 |
+
'notes' => $notes,
|
2102 |
+
'status' => $status,
|
2103 |
+
'trans_id' => $transId,
|
2104 |
+
'total_tax' => isset($totalTax) ? $totalTax : 0,
|
2105 |
+
'stan' => isset($stan) ? $stan : '',
|
2106 |
+
'success' => $success
|
2107 |
+
);
|
2108 |
+
return $data;
|
2109 |
+
}
|
2110 |
+
|
2111 |
+
/**
|
2112 |
+
* @param Mage_Sales_Model_Order $order
|
2113 |
+
* @param type $soapResult
|
2114 |
+
* @param type $soapRequest
|
2115 |
+
* @return $this
|
2116 |
+
*/
|
2117 |
+
public function saveOrderTaxesToMagento($order, $soapResult, $soapRequest)
|
2118 |
+
{
|
2119 |
+
$totalTax = $soapResult->SoapRequestResult->TotalTax;
|
2120 |
+
$totalAmount = 0;
|
2121 |
+
$totalLineTax = 0;
|
2122 |
+
$store = $order->getStore();
|
2123 |
+
|
2124 |
+
//Get the LineItem level taxes
|
2125 |
+
$lineItemTaxArray = Utility
|
2126 |
+
::getLineItemLevelTaxByResponseWithRequest($soapRequest, $soapResult);
|
2127 |
+
|
2128 |
+
if (!isset($lineItemTaxArray) || $lineItemTaxArray == null) {
|
2129 |
+
// we have no taxes
|
2130 |
+
$this->saveZeroTaxesForOrder($order);
|
2131 |
+
return;
|
2132 |
+
}
|
2133 |
+
|
2134 |
+
$items = $order->getAllItems();
|
2135 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
2136 |
+
foreach ($items as $itemId => $item) {
|
2137 |
+
if ($lineItemTaxArray[$i]) {
|
2138 |
+
$revenue = $lineItemTaxArray[$i]['Revenue'];
|
2139 |
+
$totalAmount += isset($revenue) ? $revenue : 0;
|
2140 |
+
$this->saveTaxesForOrderItem($item, $lineItemTaxArray[$i]);
|
2141 |
+
$lineTax = $lineItemTaxArray[$i]['LineItemTax'];
|
2142 |
+
$totalLineTax += isset($lineTax) ? $lineTax : 0;
|
2143 |
+
}
|
2144 |
+
$i++;
|
2145 |
+
}
|
2146 |
+
|
2147 |
+
//Order has their discount set as negative numbers
|
2148 |
+
$totalDiscount = $order->getBaseDiscountAmount() * -1;
|
2149 |
+
$totalDiscountTax = array_sum($this->_totalDiscountWithTax);
|
2150 |
+
|
2151 |
+
$order->setTaxAmount($store->convertPrice($totalTax));
|
2152 |
+
$order->setBaseTaxAmount($totalTax);
|
2153 |
+
//save line item level taxes at item level in db
|
2154 |
+
|
2155 |
+
$preShippingTotal = $totalAmount;
|
2156 |
+
|
2157 |
+
$hasShippingLine = array_key_exists(
|
2158 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER,
|
2159 |
+
$lineItemTaxArray
|
2160 |
+
);
|
2161 |
+
|
2162 |
+
if ($hasShippingLine) {
|
2163 |
+
$lineItemNumber = $lineItemTaxArray
|
2164 |
+
[Constants::DEFAULT_SHIPPING_LINE_NUMBER]
|
2165 |
+
['LineItemNumber'];
|
2166 |
+
if (isset($lineItemNumber) && strcmp(
|
2167 |
+
$lineItemNumber,
|
2168 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER == 0
|
2169 |
+
)) {
|
2170 |
+
$this->saveShippingTaxesForOrder(
|
2171 |
+
$order,
|
2172 |
+
$lineItemTaxArray[Constants::DEFAULT_SHIPPING_LINE_NUMBER]
|
2173 |
+
);
|
2174 |
+
}
|
2175 |
+
}
|
2176 |
+
|
2177 |
+
// SUBTOTAL
|
2178 |
+
// The cost of just the products without shipping, taxes, or discounts.
|
2179 |
+
// SUBTOTAL INCLUDING TAX
|
2180 |
+
// This amount of tax that is paid on just the products.
|
2181 |
+
$subtotalInclTax = $preShippingTotal + $totalLineTax +
|
2182 |
+
$totalDiscount + $totalDiscountTax;
|
2183 |
+
$order->setSubtotalInclTax($store->convertPrice($subtotalInclTax));
|
2184 |
+
$order->setBaseSubtotalInclTax($subtotalInclTax);
|
2185 |
+
}
|
2186 |
+
|
2187 |
+
/**
|
2188 |
+
* @param Mage_Sales_Model_Order_Item $item
|
2189 |
+
* @param array $itemArray
|
2190 |
+
*/
|
2191 |
+
public function saveTaxesForOrderItem($item, $itemArray)
|
2192 |
+
{
|
2193 |
+
$store = $item->getOrder()->getStore();
|
2194 |
+
$rev = $itemArray['Revenue'];
|
2195 |
+
$taxT = $itemArray['LineItemTax'];
|
2196 |
+
$item->setTaxAmount($store->convertPrice($taxT));
|
2197 |
+
$item->setBaseTaxAmount($taxT);
|
2198 |
+
$quantity = $item->getQtyOrdered();
|
2199 |
+
|
2200 |
+
// sales_flat_quote_item
|
2201 |
+
// set: tax_percent, price_incl_tax, base_price_incl_tax,
|
2202 |
+
// row_total_incl_tax, base_row_total_incl_tax
|
2203 |
+
$taxPercent = (($rev == 0) ? 0.0 : (($taxT / $rev) * 100.0));
|
2204 |
+
$taxRate = (($rev == 0) ? 0 : ($taxT / $rev));
|
2205 |
+
$item->setData('tax_percent', $taxPercent);
|
2206 |
+
$rowTotal = $rev + $taxT;
|
2207 |
+
$priceInclTax = ($quantity == 0) ? 0 : $rowTotal / $quantity;
|
2208 |
+
|
2209 |
+
// item has their discount set as positive floats.
|
2210 |
+
$discAmount = $item->getBaseDiscountAmount();
|
2211 |
+
|
2212 |
+
// Since calculation is done AFTER discount, we need to add the discount
|
2213 |
+
// (and its taxes) back to the price and row totals to see what the
|
2214 |
+
// result would be before discount.
|
2215 |
+
$temp = ($quantity == 0)
|
2216 |
+
? 0 : (($discAmount + ($discAmount * $taxRate)) / $quantity);
|
2217 |
+
$priceInclTaxBeforeDiscount = $priceInclTax + $temp;
|
2218 |
+
$rowTotalBeforeDiscount = $rowTotal + $discAmount +
|
2219 |
+
($discAmount * $taxRate);
|
2220 |
+
$this->_totalDiscountWithTax[$item->getId()] = $discAmount * $taxRate;
|
2221 |
+
|
2222 |
+
// base -> default store currency
|
2223 |
+
// grand -> currency store currency
|
2224 |
+
// price is for single unit
|
2225 |
+
$item->setPriceInclTax($store->convertPrice($priceInclTaxBeforeDiscount));
|
2226 |
+
$item->setBasePriceInclTax($priceInclTaxBeforeDiscount);
|
2227 |
+
|
2228 |
+
// row totals are unit price * quantity
|
2229 |
+
$rowTot = $rev + $discAmount;
|
2230 |
+
$item->setRowTotal($store->convertPrice($rowTot));
|
2231 |
+
$item->setBaseRowTotal($rowTot);
|
2232 |
+
|
2233 |
+
$item->setRowTotalInclTax($store->convertPrice($rowTotalBeforeDiscount));
|
2234 |
+
$item->setBaseRowTotalInclTax($rowTotalBeforeDiscount);
|
2235 |
+
}
|
2236 |
+
|
2237 |
+
/**
|
2238 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
2239 |
+
* @param $soapResult
|
2240 |
+
* @param array $soapRequest
|
2241 |
+
* @return $this
|
2242 |
+
*/
|
2243 |
+
public function saveInvoiceTaxesToMagento($invoice, $soapResult, $soapRequest)
|
2244 |
+
{
|
2245 |
+
$store = $invoice->getStore();
|
2246 |
+
$totalTax = $soapResult->SoapRequestResult->TotalTax;
|
2247 |
+
|
2248 |
+
$totalAmount = 0;
|
2249 |
+
$totalLineTax = 0;
|
2250 |
+
|
2251 |
+
//Get the LineItem level taxes
|
2252 |
+
$lineItemTaxArray = Utility
|
2253 |
+
::getLineItemLevelTaxByResponseWithRequest($soapRequest, $soapResult);
|
2254 |
+
if (!isset($lineItemTaxArray) || $lineItemTaxArray == null) {
|
2255 |
+
// we have no taxes
|
2256 |
+
return $this;
|
2257 |
+
}
|
2258 |
+
|
2259 |
+
$items = $invoice->getAllItems();
|
2260 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
2261 |
+
foreach ($items as $itemId => $item) {
|
2262 |
+
if ($lineItemTaxArray[$i]) {
|
2263 |
+
$revenue = $lineItemTaxArray[$i]['Revenue'];
|
2264 |
+
$totalAmount += isset($revenue) ? $revenue : 0;
|
2265 |
+
$this->saveTaxesForInvoiceItem($item, $lineItemTaxArray[$i]);
|
2266 |
+
$lineTax = $lineItemTaxArray[$i]['LineItemTax'];
|
2267 |
+
$totalLineTax += isset($lineTax) ? $lineTax : 0;
|
2268 |
+
}
|
2269 |
+
$i++;
|
2270 |
+
}
|
2271 |
+
|
2272 |
+
$totalDiscount = $invoice->getBaseDiscountAmount() * -1;
|
2273 |
+
$totalDiscountTax = array_sum($this->_totalDiscountWithTax);
|
2274 |
+
|
2275 |
+
$invoice->setTaxAmount($store->convertPrice($totalTax));
|
2276 |
+
$invoice->setBaseTaxAmount($totalTax);
|
2277 |
+
|
2278 |
+
$preShippingTotal = $totalAmount;
|
2279 |
+
|
2280 |
+
$hasShippingLine = array_key_exists(
|
2281 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER,
|
2282 |
+
$lineItemTaxArray
|
2283 |
+
);
|
2284 |
+
|
2285 |
+
if ($hasShippingLine) {
|
2286 |
+
$lineItemNumber = $lineItemTaxArray
|
2287 |
+
[Constants::DEFAULT_SHIPPING_LINE_NUMBER]
|
2288 |
+
['LineItemNumber'];
|
2289 |
+
if (isset($lineItemNumber) && strcmp(
|
2290 |
+
$lineItemNumber,
|
2291 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER == 0
|
2292 |
+
)) {
|
2293 |
+
$this->saveShippingTaxesForInvoice(
|
2294 |
+
$invoice,
|
2295 |
+
$lineItemTaxArray[Constants::DEFAULT_SHIPPING_LINE_NUMBER]
|
2296 |
+
);
|
2297 |
+
}
|
2298 |
+
}
|
2299 |
+
$subtotalincltax = $preShippingTotal + $totalLineTax +
|
2300 |
+
$totalDiscount + $totalDiscountTax;
|
2301 |
+
|
2302 |
+
$invoice->setData('subtotal_incl_tax', $store->convertPrice($subtotalincltax));
|
2303 |
+
$invoice->setData('base_subtotal_incl_tax', $subtotalincltax);
|
2304 |
+
}
|
2305 |
+
|
2306 |
+
/**
|
2307 |
+
* @param Mage_Sales_Model_Order_Invoice_Item $item
|
2308 |
+
* @param array $itemArray
|
2309 |
+
*/
|
2310 |
+
public function saveTaxesForInvoiceItem($item, $itemArray)
|
2311 |
+
{
|
2312 |
+
$store = $item->getInvoice()->getStore();
|
2313 |
+
$rev = $itemArray['Revenue'];
|
2314 |
+
$taxT = $itemArray['LineItemTax'];
|
2315 |
+
$item->setTaxAmount($store->convertPrice($taxT));
|
2316 |
+
$item->setBaseTaxAmount($taxT);
|
2317 |
+
$quantity = $item->getQty();
|
2318 |
+
|
2319 |
+
$taxPercent = (($rev == 0) ? 0.0 : (($taxT / $rev) * 100.0));
|
2320 |
+
$taxRate = (($rev == 0) ? 0.0 : ($taxT / $rev));
|
2321 |
+
$item->setData('tax_percent', $taxPercent);
|
2322 |
+
$rowTotal = $rev + $taxT;
|
2323 |
+
$priceInclTax = ($quantity == 0) ? 0 : $rowTotal / $quantity;
|
2324 |
+
|
2325 |
+
//item has their discount set as positive floats.
|
2326 |
+
$discAmount = $item->getBaseDiscountAmount();
|
2327 |
+
|
2328 |
+
// Since calculation is done AFTER discount, we need to add the discount
|
2329 |
+
// (and its taxes) back to the price and row totals to see what the
|
2330 |
+
// result would be before discount.
|
2331 |
+
$temp = ($quantity == 0)
|
2332 |
+
? 0 : (($discAmount + ($discAmount * $taxRate)) / $quantity);
|
2333 |
+
$priceInclTaxBeforeDiscount = $priceInclTax + $temp;
|
2334 |
+
$rowTotalBeforeDiscount = $rowTotal + $discAmount +
|
2335 |
+
($discAmount * $taxRate);
|
2336 |
+
$this->_totalDiscountWithTax[$item->getId()] = $discAmount * $taxRate;
|
2337 |
+
|
2338 |
+
// price is for single unit
|
2339 |
+
$item->setPriceInclTax($store->convertPrice($priceInclTaxBeforeDiscount));
|
2340 |
+
$item->setBasePriceInclTax($priceInclTaxBeforeDiscount);
|
2341 |
+
|
2342 |
+
// row totals are unit price * quantity
|
2343 |
+
$rowT = $rev + $discAmount;
|
2344 |
+
$item->setRowTotal($store->convertPrice($rowT));
|
2345 |
+
$item->setBaseRowTotal($rowT);
|
2346 |
+
|
2347 |
+
$item->setRowTotalInclTax($store->convertPrice($rowTotalBeforeDiscount));
|
2348 |
+
$item->setRowTotal($rowTotalBeforeDiscount);
|
2349 |
+
}
|
2350 |
+
|
2351 |
+
public function saveCreditMemoTaxesToMagento($creditMemo, $soapResult, $soapRequest)
|
2352 |
+
{
|
2353 |
+
|
2354 |
+
$store = $creditMemo->getStore();
|
2355 |
+
$totalTax = $soapResult->SoapRequestResult->TotalTax;
|
2356 |
+
$totalTax *= -1;
|
2357 |
+
$creditMemo->setTaxAmount($store->convertPrice($totalTax));
|
2358 |
+
$creditMemo->setBaseTaxAmount($totalTax);
|
2359 |
+
$totalAmount = 0;
|
2360 |
+
|
2361 |
+
//Get the LineItem level taxes
|
2362 |
+
$lineItemTaxArray = Utility::
|
2363 |
+
getLineItemLevelTaxByResponseWithRequest($soapRequest, $soapResult);
|
2364 |
+
if (!isset($lineItemTaxArray) || $lineItemTaxArray == null) {
|
2365 |
+
// we have no taxes
|
2366 |
+
return $this;
|
2367 |
+
}
|
2368 |
+
|
2369 |
+
$items = $creditMemo->getAllItems();
|
2370 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
2371 |
+
foreach ($items as $itemId => $item) {
|
2372 |
+
$rev = $lineItemTaxArray[$i]['Revenue'];
|
2373 |
+
if (isset($rev)) {
|
2374 |
+
$rev *= -1;
|
2375 |
+
$totalAmount += $rev;
|
2376 |
+
}
|
2377 |
+
$this->saveTaxesForCreditMemoItem($item, $lineItemTaxArray[$i]);
|
2378 |
+
$i++;
|
2379 |
+
}
|
2380 |
+
|
2381 |
+
$rev = $lineItemTaxArray[$i]['Revenue'];
|
2382 |
+
$rev *= -1;
|
2383 |
+
$preShippingTotal = $totalAmount;
|
2384 |
+
$shipT = 0.0;
|
2385 |
+
if (isset($rev)) {
|
2386 |
+
$totalAmount += $rev;
|
2387 |
+
}
|
2388 |
+
|
2389 |
+
$lineItemNumber = $lineItemTaxArray[$i]['LineItemNumber'];
|
2390 |
+
if (isset($lineItemNumber) && strcmp(
|
2391 |
+
$lineItemNumber,
|
2392 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER == 0
|
2393 |
+
)) {
|
2394 |
+
$shipT = $this->saveShippingTaxesForCreditMemo(
|
2395 |
+
$creditMemo,
|
2396 |
+
$lineItemTaxArray[$i]
|
2397 |
+
);
|
2398 |
+
}
|
2399 |
+
|
2400 |
+
// SUBTOTAL
|
2401 |
+
// The cost of just the products without shipping, taxes, or discounts.
|
2402 |
+
// SUBTOTAL INCLUDING TAX
|
2403 |
+
// This amount of tax that is paid on just the products.
|
2404 |
+
$taxWithoutShip = $totalTax - $shipT;
|
2405 |
+
$preShippingTotal += $taxWithoutShip;
|
2406 |
+
$totalAmount += $totalTax;
|
2407 |
+
$creditMemo->setSubtotalInclTax($store->convertPrice($preShippingTotal));
|
2408 |
+
$creditMemo->setBaseSubtotalInclTax($preShippingTotal);
|
2409 |
+
|
2410 |
+
$creditMemo->setGrandTotal($store->convertPrice($totalAmount));
|
2411 |
+
$creditMemo->setBaseGrandTotal($totalAmount);
|
2412 |
+
}
|
2413 |
+
|
2414 |
+
public function saveTaxesForCreditMemoItem($item, $itemArray)
|
2415 |
+
{
|
2416 |
+
$store = $item->getCreditmemo()->getStore();
|
2417 |
+
$lineItemNumber = $itemArray['LineItemNumber'];
|
2418 |
+
// should not get here, but shipping doesn't get saved here
|
2419 |
+
if (strcmp($lineItemNumber, Constants::DEFAULT_SHIPPING_LINE_NUMBER) === 0) {
|
2420 |
+
return;
|
2421 |
+
}
|
2422 |
+
|
2423 |
+
$rev = $itemArray['Revenue'] * -1;
|
2424 |
+
|
2425 |
+
$taxT = $itemArray['LineItemTax'] * -1;
|
2426 |
+
|
2427 |
+
$item->setTaxAmount($store->convertPrice($taxT));
|
2428 |
+
$item->setBaseTaxAmount($taxT);
|
2429 |
+
$quantity = $item->getQty();
|
2430 |
+
|
2431 |
+
// sales_flat_quote_item
|
2432 |
+
// set: tax_percent, price_incl_tax, base_price_incl_tax,
|
2433 |
+
// row_total_incl_tax, base_row_total_incl_tax
|
2434 |
+
// Credit memo doesn't have tax percent.
|
2435 |
+
$rowTotal = $rev + $taxT;
|
2436 |
+
|
2437 |
+
$priceInclTax = ($quantity == 0) ? 0 : $rowTotal / $quantity;
|
2438 |
+
|
2439 |
+
// base -> default store currency
|
2440 |
+
// grand -> currency store currency
|
2441 |
+
// price is for single unit
|
2442 |
+
$item->setPriceInclTax($store->convertPrice($priceInclTax));
|
2443 |
+
$item->setBasePriceInclTax($priceInclTax);
|
2444 |
+
|
2445 |
+
// row totals are unit price * quantity
|
2446 |
+
$item->setBaseRowTotal($rev);
|
2447 |
+
$item->setRowTotal($store->convertPrice($rev));
|
2448 |
+
|
2449 |
+
$item->setRowTotalInclTax($store->convertPrice($rowTotal));
|
2450 |
+
$item->setBaseRowTotalInclTax($rowTotal);
|
2451 |
+
}
|
2452 |
+
|
2453 |
+
/**
|
2454 |
+
* @param Mage_Sales_Model_Order $order
|
2455 |
+
* @param array $itemArray
|
2456 |
+
* @return mixed
|
2457 |
+
*/
|
2458 |
+
public function saveShippingTaxesForOrder($order, $itemArray)
|
2459 |
+
{
|
2460 |
+
$store = $order->getStore();
|
2461 |
+
$shippingTax = $itemArray['LineItemTax'];
|
2462 |
+
$order->setShippingTaxAmount($store->convertPrice($shippingTax));
|
2463 |
+
$order->setBaseShippingTaxAmount($shippingTax);
|
2464 |
+
//needs to be calculated by magento. Not set.
|
2465 |
+
return $shippingTax;
|
2466 |
+
}
|
2467 |
+
|
2468 |
+
public function saveShippingTaxesForInvoice($invoice, $itemArray)
|
2469 |
+
{
|
2470 |
+
$store = $invoice->getStore();
|
2471 |
+
$shippingAmount = $itemArray['RevenueBase'];
|
2472 |
+
$shippingTax = $itemArray['LineItemTax'];
|
2473 |
+
$shippingInclTax = $shippingAmount + $shippingTax;
|
2474 |
+
$invoice->setShippingTaxAmount($store->convertPrice($shippingTax));
|
2475 |
+
$invoice->setBaseShippingTaxAmount($shippingTax);
|
2476 |
+
$invoice->setShippingInclTax($store->convertPrice($shippingInclTax));
|
2477 |
+
$invoice->setBaseShippingInclTax($shippingInclTax);
|
2478 |
+
return $shippingTax;
|
2479 |
+
}
|
2480 |
+
|
2481 |
+
/**
|
2482 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
2483 |
+
* @param array $itemArray
|
2484 |
+
* @return mixed
|
2485 |
+
*/
|
2486 |
+
public function saveShippingTaxesForCreditMemo($creditMemo, $itemArray)
|
2487 |
+
{
|
2488 |
+
$store = $creditMemo->getStore();
|
2489 |
+
$rev = $itemArray['Revenue'] * -1;
|
2490 |
+
$taxT = $itemArray['LineItemTax'] * -1;
|
2491 |
+
$total = $rev + $taxT;
|
2492 |
+
$creditMemo->setShippingInclTax($store->convertPrice($total));
|
2493 |
+
$creditMemo->setBaseShippingInclTax($total);
|
2494 |
+
$creditMemo->setShippingTaxAmount($store->convertPrice($taxT));
|
2495 |
+
$creditMemo->setBaseShippingTaxAmount($taxT);
|
2496 |
+
|
2497 |
+
return $taxT;
|
2498 |
+
}
|
2499 |
+
|
2500 |
+
/**
|
2501 |
+
* @param WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress $billingAddress
|
2502 |
+
* @param WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress $shipToAddress
|
2503 |
+
* @param WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress $shipFromAddress
|
2504 |
+
* @param string $trxDate
|
2505 |
+
* @param string $providerType
|
2506 |
+
* @param WoltersKluwer_CchSureTax_Helper_Config $config
|
2507 |
+
* @param string $salesTypeCode
|
2508 |
+
* @param string $exemptionCode
|
2509 |
+
* @param string $exemptionReason
|
2510 |
+
* @param float $taxForAdjustment
|
2511 |
+
*
|
2512 |
+
* @return WoltersKluwer_CchSureTax_Model_Ws_TaxAdjustmentItem
|
2513 |
+
*/
|
2514 |
+
public function getTaxAdjustmentItem($billingAddress, $shipToAddress,
|
2515 |
+
$shipFromAddress, $trxDate, $providerType, $config, $salesTypeCode,
|
2516 |
+
$exemptionCode, $exemptionReason, $taxForAdjustment
|
2517 |
+
) {
|
2518 |
+
|
2519 |
+
$lineNumber = 0;
|
2520 |
+
$transTypeCode = Constants::DEFAULT_TRANS_TYPE_CODE;
|
2521 |
+
$sku = '';
|
2522 |
+
$qty = 0;
|
2523 |
+
|
2524 |
+
/* @var $taxAdjustmentItem WoltersKluwer_CchSureTax_Model_Ws_TaxAdjustmentItem*/
|
2525 |
+
$taxAdjustmentItem = Mage::getModel(
|
2526 |
+
'wolterskluwer_cchsuretax/ws_taxAdjustmentItem',
|
2527 |
+
array (
|
2528 |
+
'LineNumber' => $lineNumber,
|
2529 |
+
'InvoiceNumber' => '',
|
2530 |
+
'CustomerNumber' => '',
|
2531 |
+
'OrigNumber' => '',
|
2532 |
+
'TermNumber' => '',
|
2533 |
+
'BillToNumber' => '',
|
2534 |
+
'TransDate' => $trxDate,
|
2535 |
+
'Revenue' => 0.00,
|
2536 |
+
'Units' => $qty,
|
2537 |
+
'UnitType' => $config->getUnitType(),
|
2538 |
+
'Seconds' => '0',
|
2539 |
+
'ShipFromPOB' => '1',
|
2540 |
+
'MailOrder' => '1',
|
2541 |
+
'CommonCarrier' => '1',
|
2542 |
+
'BillingDaysInPeriod' => '',
|
2543 |
+
'TaxIncludedCode' => '0',
|
2544 |
+
'TaxSitusRule' => $config->getTaxSitusRule(),
|
2545 |
+
'TransTypeCode' => $transTypeCode,
|
2546 |
+
'SalesTypeCode' => $salesTypeCode,
|
2547 |
+
'RegulatoryCode' => $providerType,
|
2548 |
+
'BillingAddress' => ((isset($billingAddress) && $billingAddress != null)
|
2549 |
+
? $this->copySureTaxAddress($billingAddress) : ''),
|
2550 |
+
'ShipToAddress' => ((isset($shipToAddress) && $shipToAddress != null)
|
2551 |
+
? $this->copySureTaxAddress($shipToAddress) : ''),
|
2552 |
+
'ShipFromAddress' => ((isset($shipFromAddress) && $shipFromAddress != null)
|
2553 |
+
? $this->copySureTaxAddress($shipFromAddress) : ''),
|
2554 |
+
'LocationCode' => '',
|
2555 |
+
'ExemptReasonCode' => $exemptionReason,
|
2556 |
+
'TaxExemptionCodeList' => array($exemptionCode),
|
2557 |
+
'CostCenter' => '',
|
2558 |
+
'GLAccount' => '',
|
2559 |
+
'UDF' => $sku,
|
2560 |
+
'UDF2' => '',
|
2561 |
+
'Tax' => $taxForAdjustment
|
2562 |
+
)
|
2563 |
+
);
|
2564 |
+
return $taxAdjustmentItem;
|
2565 |
+
}
|
2566 |
+
|
2567 |
+
/**
|
2568 |
+
* @param WoltersKluwer_CchSureTax_Model_Ws_TaxAdjustmentRequest $requestData
|
2569 |
+
*
|
2570 |
+
* @return type
|
2571 |
+
*
|
2572 |
+
* @throws Exception
|
2573 |
+
*/
|
2574 |
+
public function makeTaxAdjustmentRequest($requestData)
|
2575 |
+
{
|
2576 |
+
try {
|
2577 |
+
$config = Config::get();
|
2578 |
+
/* @var $client WoltersKluwer_CchSureTax_Model_Ws_SureTaxClient*/
|
2579 |
+
$client = Mage::getModel(
|
2580 |
+
'wolterskluwer_cchsuretax/ws_sureTaxClient',
|
2581 |
+
array('Config' => $config)
|
2582 |
+
);
|
2583 |
+
$soapCalcRequestResult = $client->callTaxAdjustmentRequest($requestData);
|
2584 |
+
return $soapCalcRequestResult;
|
2585 |
+
} catch (Exception $exe) {
|
2586 |
+
Utility::logCatch($exe, 'Exception with makeTaxAdjustmentRequest : ');
|
2587 |
+
throw $exe;
|
2588 |
+
}
|
2589 |
+
}
|
2590 |
+
|
2591 |
+
public function createSureTaxAdjustRequestFromInvoice($invoice, $shipToAddressArray, $taxForAdjustment)
|
2592 |
+
{
|
2593 |
+
try {
|
2594 |
+
$config = Config::get();
|
2595 |
+
$order = $invoice->getOrder();
|
2596 |
+
$ordCreationDate = $order->getCreatedAt();
|
2597 |
+
$invCreationDate = $invoice->getCreatedAt();
|
2598 |
+
$store = $order->getStore();
|
2599 |
+
$customerFields = $this->getCustomerFields(
|
2600 |
+
$order->getCustomerId(),
|
2601 |
+
$order->getCustomerGroupId()
|
2602 |
+
);
|
2603 |
+
|
2604 |
+
$uniqueId = $this->generateUniqueId($invoice->getIncrementId());
|
2605 |
+
$STAN = 'ADJ-' . $uniqueId;
|
2606 |
+
|
2607 |
+
$currentClientTracking = 'ADJ-' . $uniqueId;
|
2608 |
+
|
2609 |
+
$businessUnit = $this->getBusinessUnit(
|
2610 |
+
$config,
|
2611 |
+
$store->getWebsiteId(),
|
2612 |
+
$store->getGroupId()
|
2613 |
+
);
|
2614 |
+
|
2615 |
+
$shipToAddress = $this->convertToSureTaxAddress($shipToAddressArray);
|
2616 |
+
|
2617 |
+
$billingAddress = null;
|
2618 |
+
|
2619 |
+
$shipFromAddress = $this->convertToSureTaxAddress(
|
2620 |
+
Utility::getShipFromAddress(
|
2621 |
+
$store->getWebsiteId(),
|
2622 |
+
$store->getGroupId()
|
2623 |
+
)
|
2624 |
+
);
|
2625 |
+
|
2626 |
+
$lineItemArray[] = $this->getTaxAdjustmentItem(
|
2627 |
+
$billingAddress, $shipToAddress,
|
2628 |
+
$shipFromAddress, $ordCreationDate,
|
2629 |
+
$config->getProviderType(), $config,
|
2630 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
2631 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
2632 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
2633 |
+
$taxForAdjustment
|
2634 |
+
);
|
2635 |
+
|
2636 |
+
// create TaxAdjustmentRequest
|
2637 |
+
|
2638 |
+
$requestData = Mage::getModel(
|
2639 |
+
'wolterskluwer_cchsuretax/ws_taxAdjustmentRequest',
|
2640 |
+
array (
|
2641 |
+
'ClientNumber' => $config->getClientNumber(),
|
2642 |
+
'BusinessUnit' => $businessUnit,
|
2643 |
+
'ValidationKey' => $config->getValidationKey(),
|
2644 |
+
'DataYear' => date_parse($ordCreationDate)['year'],
|
2645 |
+
'DataMonth' => date_parse($ordCreationDate)['month'],
|
2646 |
+
'CmplDataYear' => date_parse($invCreationDate)['year'],
|
2647 |
+
'CmplDataMonth' => date_parse($invCreationDate)['month'],
|
2648 |
+
'ClientTracking' => $currentClientTracking,
|
2649 |
+
'ResponseType' => $config->getResponseType(),
|
2650 |
+
'ResponseGroup' => $config->getResponseGroup(),
|
2651 |
+
'STAN' => $STAN,
|
2652 |
+
'MasterTransId' => '0',
|
2653 |
+
'ShipToAddress' => $shipToAddress,
|
2654 |
+
'ShipFromAddress' => $shipFromAddress,
|
2655 |
+
'TaxAdjustmentItemList' => $lineItemArray
|
2656 |
+
)
|
2657 |
+
);
|
2658 |
+
|
2659 |
+
return $requestData;
|
2660 |
+
} catch (Exception $exe) {
|
2661 |
+
Utility::logCatch(
|
2662 |
+
$exe,
|
2663 |
+
'Invoice: Exception with createSureTaxAdjustRequestFromInvoice'
|
2664 |
+
);
|
2665 |
+
throw $exe;
|
2666 |
+
}
|
2667 |
+
}
|
2668 |
+
|
2669 |
+
public function sendTaxAdjustmentToSureTax($invoice, $shipToAddressArray, $taxAdjustment)
|
2670 |
+
{
|
2671 |
+
try {
|
2672 |
+
$requestData = $this->createSureTaxAdjustRequestFromInvoice(
|
2673 |
+
$invoice,
|
2674 |
+
$shipToAddressArray,
|
2675 |
+
$taxAdjustment
|
2676 |
+
);
|
2677 |
+
|
2678 |
+
$soapTaxAdjustmentRequestResult = $this
|
2679 |
+
->makeTaxAdjustmentRequest($requestData);
|
2680 |
+
$isSuccessful = $soapTaxAdjustmentRequestResult
|
2681 |
+
->SoapTaxAdjustmentRequestResult->Successful;
|
2682 |
+
$responseCode = $soapTaxAdjustmentRequestResult
|
2683 |
+
->SoapTaxAdjustmentRequestResult->ResponseCode;
|
2684 |
+
|
2685 |
+
if ($isSuccessful == 'Y' && (strcmp(
|
2686 |
+
$responseCode,
|
2687 |
+
Constants::API_RESPONSE_CODE_SUCCESS
|
2688 |
+
) == 0)) {
|
2689 |
+
Utility::logMessage(
|
2690 |
+
'Invoice ' . $invoice->getIncrementId() .
|
2691 |
+
' was successfully adjusted at SureTax', Zend_Log::DEBUG
|
2692 |
+
);
|
2693 |
+
$success = true;
|
2694 |
+
$status = Constants::FINALIZE_ADJUSTED;
|
2695 |
+
} else {
|
2696 |
+
$success = false;
|
2697 |
+
$status = Constants::ADJUSTMENT_FAIL;
|
2698 |
+
}
|
2699 |
+
} catch (Exception $ere) {
|
2700 |
+
$status = Constants::ADJUSTMENT_FAIL;
|
2701 |
+
$success = false;
|
2702 |
+
Utility::logCatch(
|
2703 |
+
$ere,
|
2704 |
+
'Issue calling SureTax Adjustment API for Invoice ' .
|
2705 |
+
$invoice->getIncrementId()
|
2706 |
+
);
|
2707 |
+
}
|
2708 |
+
|
2709 |
+
$data = array(
|
2710 |
+
'status' => $status,
|
2711 |
+
'success' => $success
|
2712 |
+
);
|
2713 |
+
|
2714 |
+
return $data;
|
2715 |
+
}
|
2716 |
+
|
2717 |
+
public function createSureTaxAdjustRequestFromCreditMemo(
|
2718 |
+
$creditMemo,
|
2719 |
+
$shipToAddressArray,
|
2720 |
+
$taxForAdjustment
|
2721 |
+
) {
|
2722 |
+
|
2723 |
+
try {
|
2724 |
+
$config = Config::get();
|
2725 |
+
$order = $creditMemo->getOrder();
|
2726 |
+
$store = $creditMemo->getStore();
|
2727 |
+
$ordCreationDate = $order->getCreatedAt();
|
2728 |
+
$creditmemoCreationDate = $creditMemo->getCreatedAt();
|
2729 |
+
|
2730 |
+
$customerFields = $this->getCustomerFields(
|
2731 |
+
$order->getCustomerId(),
|
2732 |
+
$order->getCustomerGroupId()
|
2733 |
+
);
|
2734 |
+
|
2735 |
+
$uniqueId = $this->generateUniqueId($creditMemo->getIncrementId());
|
2736 |
+
$STAN = 'CM-ADJ-' . $uniqueId;
|
2737 |
+
|
2738 |
+
$currentClientTracking = 'CM-ADJ-' . $uniqueId;
|
2739 |
+
|
2740 |
+
$businessUnit = $this->getBusinessUnit(
|
2741 |
+
$config,
|
2742 |
+
$store->getWebsiteId(),
|
2743 |
+
$store->getGroupId()
|
2744 |
+
);
|
2745 |
+
|
2746 |
+
$shipToAddress = $this->convertToSureTaxAddress($shipToAddressArray);
|
2747 |
+
|
2748 |
+
$billingAddress = $this->convertToSureTaxAddress(
|
2749 |
+
Utility::getShipToAddress(
|
2750 |
+
Mage::getModel('sales/order_address')
|
2751 |
+
->load($creditMemo->getOrder()->getBillingAddress()->getId())
|
2752 |
+
)
|
2753 |
+
);
|
2754 |
+
|
2755 |
+
$shipFromAddress = $this->convertToSureTaxAddress(
|
2756 |
+
Utility::getShipFromAddress(
|
2757 |
+
$store->getWebsiteId(),
|
2758 |
+
$store->getGroupId()
|
2759 |
+
)
|
2760 |
+
);
|
2761 |
+
|
2762 |
+
$lineItemArray[] = $this->getTaxAdjustmentItem(
|
2763 |
+
$billingAddress,
|
2764 |
+
$shipToAddress,
|
2765 |
+
$shipFromAddress,
|
2766 |
+
$ordCreationDate,
|
2767 |
+
$config->getProviderType(),
|
2768 |
+
$config,
|
2769 |
+
$customerFields[Constants::SALES_TYPE_CODE_KEY],
|
2770 |
+
$customerFields[Constants::EXEMPTION_TYPE_CODE_KEY],
|
2771 |
+
$customerFields[Constants::EXEMPTION_REASON_CODE_KEY],
|
2772 |
+
$taxForAdjustment
|
2773 |
+
);
|
2774 |
+
|
2775 |
+
// create TaxAdjustmentRequest
|
2776 |
+
|
2777 |
+
$requestData = Mage::getModel(
|
2778 |
+
'wolterskluwer_cchsuretax/ws_taxAdjustmentRequest',
|
2779 |
+
array (
|
2780 |
+
'ClientNumber' => $config->getClientNumber(),
|
2781 |
+
'BusinessUnit' => $businessUnit,
|
2782 |
+
'ValidationKey' => $config->getValidationKey(),
|
2783 |
+
'DataYear' => date_parse($ordCreationDate)['year'],
|
2784 |
+
'DataMonth' => date_parse($ordCreationDate)['month'],
|
2785 |
+
'CmplDataYear' => date_parse($creditmemoCreationDate)['year'],
|
2786 |
+
'CmplDataMonth' => date_parse($creditmemoCreationDate)['month'],
|
2787 |
+
'ClientTracking' => $currentClientTracking,
|
2788 |
+
'ResponseType' => $config->getResponseType(),
|
2789 |
+
'ResponseGroup' => $config->getResponseGroup(),
|
2790 |
+
'STAN' => $STAN,
|
2791 |
+
'MasterTransId' => '0',
|
2792 |
+
'ShipToAddress' => $shipToAddress,
|
2793 |
+
'ShipFromAddress' => $shipFromAddress,
|
2794 |
+
'TaxAdjustmentItemList' => $lineItemArray
|
2795 |
+
)
|
2796 |
+
);
|
2797 |
+
return $requestData;
|
2798 |
+
} catch (Exception $exe) {
|
2799 |
+
Utility::logCatch(
|
2800 |
+
$exe,
|
2801 |
+
'CreditMemo: createTaxAdjustmentRequestFromCreditMemo'
|
2802 |
+
);
|
2803 |
+
throw $exe;
|
2804 |
+
}
|
2805 |
+
}
|
2806 |
+
|
2807 |
+
public function sendCreditMemoTaxAdjustmentToSureTax($creditMemo,
|
2808 |
+
$shipToAddressArray, $taxAdjustment
|
2809 |
+
) {
|
2810 |
+
try {
|
2811 |
+
$requestData = $this->createSureTaxAdjustRequestFromCreditMemo(
|
2812 |
+
$creditMemo,
|
2813 |
+
$shipToAddressArray,
|
2814 |
+
$taxAdjustment
|
2815 |
+
);
|
2816 |
+
|
2817 |
+
$soapTaxAdjustmentRequestResult = $this
|
2818 |
+
->makeTaxAdjustmentRequest($requestData);
|
2819 |
+
$isSuccessful = $soapTaxAdjustmentRequestResult
|
2820 |
+
->SoapTaxAdjustmentRequestResult->Successful;
|
2821 |
+
$responseCode = $soapTaxAdjustmentRequestResult
|
2822 |
+
->SoapTaxAdjustmentRequestResult->ResponseCode;
|
2823 |
+
|
2824 |
+
if ($isSuccessful == 'Y' && (strcmp(
|
2825 |
+
$responseCode,
|
2826 |
+
Constants::API_RESPONSE_CODE_SUCCESS
|
2827 |
+
) == 0)) {
|
2828 |
+
Utility::logMessage(
|
2829 |
+
'Credit Memo ' . $creditMemo->getIncrementId() .
|
2830 |
+
' was successfully adjusted at SureTax', Zend_Log::DEBUG
|
2831 |
+
);
|
2832 |
+
$success = true;
|
2833 |
+
$status = Constants::FINALIZE_ADJUSTED;
|
2834 |
+
} else {
|
2835 |
+
$success = false;
|
2836 |
+
$status = Constants::ADJUSTMENT_FAIL;
|
2837 |
+
}
|
2838 |
+
} catch (Exception $ere) {
|
2839 |
+
$success = false;
|
2840 |
+
$status = Constants::ADJUSTMENT_FAIL;
|
2841 |
+
|
2842 |
+
Utility::logCatch(
|
2843 |
+
$ere,
|
2844 |
+
'Adjustment Fail for CreditMemo ' .
|
2845 |
+
$creditMemo->getIncrementId()
|
2846 |
+
);
|
2847 |
+
}
|
2848 |
+
|
2849 |
+
$data = array(
|
2850 |
+
'status' => $status,
|
2851 |
+
'success' => $success
|
2852 |
+
);
|
2853 |
+
|
2854 |
+
return $data;
|
2855 |
+
}
|
2856 |
+
|
2857 |
+
/**
|
2858 |
+
* @param Mage_Sales_Model_Order $order
|
2859 |
+
*/
|
2860 |
+
protected function saveZeroTaxesForOrder($order)
|
2861 |
+
{
|
2862 |
+
$order->setSubtotalInclTax($order->getSubtotal());
|
2863 |
+
$order->setBaseSubtotalInclTax($order->getBaseSubtotal());
|
2864 |
+
$order->setBaseTaxAmount(0);
|
2865 |
+
$order->setTaxAmount(0);
|
2866 |
+
}
|
2867 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Helper/WebServiceInterface.php
ADDED
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Interface detailing all Webservice method for calling SureTax API with
|
4 |
+
* Magento.
|
5 |
+
*
|
6 |
+
* @category WoltersKluwer
|
7 |
+
* @package WoltersKluwer_CchSureTax
|
8 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
9 |
+
*/
|
10 |
+
|
11 |
+
interface WoltersKluwer_CchSureTax_Helper_WebServiceInterface
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Creates a SureTaxRequest from a quote's address
|
16 |
+
*
|
17 |
+
* @param Mage_Sales_Model_Quote_Address $address magento's quote address
|
18 |
+
*
|
19 |
+
* @param $estimatedAddress
|
20 |
+
* @return WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest
|
21 |
+
*/
|
22 |
+
public function createSureTaxRequestFromQuoteAddress(
|
23 |
+
Mage_Sales_Model_Quote_Address $address,
|
24 |
+
$estimatedAddress
|
25 |
+
);
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Make the API call for a SureTax quote from the Magento's quote address.
|
29 |
+
*
|
30 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest $requestData
|
31 |
+
*
|
32 |
+
* @return type
|
33 |
+
* @throws Exception
|
34 |
+
*/
|
35 |
+
public function makeSureTaxRequestFromQuoteAddress($requestData);
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Creates SureTaxRequest from an invoice
|
39 |
+
*
|
40 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
41 |
+
* @param array $shipToAddressArray
|
42 |
+
*
|
43 |
+
* @return WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest
|
44 |
+
* @throws Exception
|
45 |
+
*/
|
46 |
+
public function createSureTaxRequestFromInvoice($invoice, $shipToAddressArray);
|
47 |
+
|
48 |
+
public function makeSureTaxRequest($requestData);
|
49 |
+
/**
|
50 |
+
* Called from Observer.
|
51 |
+
* Creates a Finalized transaction from a magento invoice.
|
52 |
+
*
|
53 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
54 |
+
* @param array $shipToAddressArray
|
55 |
+
*
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
public function sendFinalizeInvoiceToSureTax($invoice, $shipToAddressArray);
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Creates the SureTax request to finalize the order
|
62 |
+
*
|
63 |
+
* @param Mage_Sales_Model_Order $order
|
64 |
+
* @param boolean $isFinalize
|
65 |
+
* @param array $shipToAddressArray
|
66 |
+
*
|
67 |
+
* @return WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest
|
68 |
+
* @throws Exception
|
69 |
+
*/
|
70 |
+
public function createSureTaxRequestFromOrder(Mage_Sales_Model_Order $order,
|
71 |
+
$isFinalize, $shipToAddressArray
|
72 |
+
);
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Make the API call to finalize in SureTax
|
76 |
+
*
|
77 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest $requestData
|
78 |
+
*
|
79 |
+
* @return type
|
80 |
+
* @throws Exception
|
81 |
+
*/
|
82 |
+
public function makeSureTaxRequestFromOrder($requestData);
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Called from Observer.
|
86 |
+
* Creates a transaction from a magento order. Can be a finalized order transaction.
|
87 |
+
*
|
88 |
+
* @param Mage_Sales_Model_Order $order
|
89 |
+
* @param array $shipToAddressArray
|
90 |
+
*
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
public function sendOrderToSureTax($order, $shipToAddressArray);
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Make the API call to cancel in SureTax
|
97 |
+
*
|
98 |
+
* @param Mage_Sales_Model_Order $order
|
99 |
+
*
|
100 |
+
* @return type
|
101 |
+
* @throws Exception
|
102 |
+
*/
|
103 |
+
public function makeCancelRequest($order);
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Called from Observer.
|
107 |
+
* Cancel the SureTax transaction associated with the given magento order.
|
108 |
+
*
|
109 |
+
* @param Mage_Sales_Model_Order $order
|
110 |
+
*
|
111 |
+
* @return array
|
112 |
+
*/
|
113 |
+
public function sendCancelToSureTax($order);
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Creates the SureTax request for the given credit memo.
|
117 |
+
*
|
118 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
119 |
+
* @param array $shipToAddressArray
|
120 |
+
*
|
121 |
+
* @return WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest
|
122 |
+
* @throws Exception
|
123 |
+
*/
|
124 |
+
public function createSureTaxRequestFromCreditmemo(
|
125 |
+
Mage_Sales_Model_Order_Creditmemo $creditMemo,
|
126 |
+
$shipToAddressArray
|
127 |
+
);
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Make the API call for a finalized credit memo in SureTax.
|
131 |
+
*
|
132 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest $requestData
|
133 |
+
*
|
134 |
+
* @return type
|
135 |
+
*/
|
136 |
+
public function makeCreditRequest($requestData);
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Called from Observer.
|
140 |
+
* Creates the SureTax transaction associated with the given magento credit
|
141 |
+
* memo.
|
142 |
+
*
|
143 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
144 |
+
* @param array $shipToAddressArray
|
145 |
+
*
|
146 |
+
* @return array
|
147 |
+
*/
|
148 |
+
public function sendCreditMemoToSureTax($creditmemo, $shipToAddressArray);
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Create Line item array that needs to be attached to the request
|
152 |
+
*
|
153 |
+
* @param int $i
|
154 |
+
* @param Mage_Sales_Model_Quote_Item|
|
155 |
+
* Mage_Sales_Model_Order_Item $item
|
156 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $billingAddress
|
157 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $shipToAddress
|
158 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $shipFromAddress
|
159 |
+
* @param string $trxDate
|
160 |
+
* @param float $shippingCharges
|
161 |
+
* @param boolean $isOrderObject
|
162 |
+
* @param string $providerType
|
163 |
+
* @param boolean $isCredit
|
164 |
+
* @param WoltersKluwer_CchSureTax_Helper_Config $config
|
165 |
+
* @param string $salesTypeCode
|
166 |
+
* @param string $exemptionCode
|
167 |
+
* @param string $exemptionReason
|
168 |
+
* @param int $customerId
|
169 |
+
* @return null|WoltersKluwer_CchSureTax_Helper_Ws_SureTaxItem
|
170 |
+
* SureTaxItem or null if no line item created (e.g. gift wrap
|
171 |
+
* not supported)
|
172 |
+
*/
|
173 |
+
public function getLineItem($i, $item, $billingAddress, $shipToAddress,
|
174 |
+
$shipFromAddress, $trxDate, $shippingCharges, $isOrderObject,
|
175 |
+
$providerType, $isCredit, $config, $salesTypeCode, $exemptionCode,
|
176 |
+
$exemptionReason, $customerId
|
177 |
+
);
|
178 |
+
|
179 |
+
/**
|
180 |
+
*
|
181 |
+
*
|
182 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
183 |
+
* @param array $shipToAddressArray
|
184 |
+
* @param float $taxForAdjustment
|
185 |
+
*
|
186 |
+
* @return WoltersKluwer_CchSureTax_Helper_Ws_TaxAdjustmentRequest
|
187 |
+
*/
|
188 |
+
public function createSureTaxAdjustRequestFromInvoice($invoice, $shipToAddressArray, $taxForAdjustment);
|
189 |
+
|
190 |
+
/**
|
191 |
+
*
|
192 |
+
*
|
193 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
194 |
+
* @param array $shipToAddressArray
|
195 |
+
* @param float $taxAdjustment
|
196 |
+
*
|
197 |
+
* @return array
|
198 |
+
*/
|
199 |
+
public function sendTaxAdjustmentToSureTax($invoice, $shipToAddressArray, $taxAdjustment);
|
200 |
+
|
201 |
+
/**
|
202 |
+
*
|
203 |
+
*
|
204 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
205 |
+
* @param array $shipToAddressArray
|
206 |
+
* @param float $taxForAdjustment
|
207 |
+
*
|
208 |
+
* @return WoltersKluwer_CchSureTax_Helper_Ws_TaxAdjustmentRequest
|
209 |
+
*/
|
210 |
+
public function createSureTaxAdjustRequestFromCreditMemo($creditMemo, $shipToAddressArray, $taxForAdjustment);
|
211 |
+
|
212 |
+
/**
|
213 |
+
*
|
214 |
+
*
|
215 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
216 |
+
* @param array $shipToAddressArray
|
217 |
+
* @param float $taxAdjustment
|
218 |
+
*
|
219 |
+
* @return array
|
220 |
+
*/
|
221 |
+
public function sendCreditMemoTaxAdjustmentToSureTax($creditMemo, $shipToAddressArray, $taxAdjustment);
|
222 |
+
|
223 |
+
/**
|
224 |
+
* always get totals by what we get in the soapresult
|
225 |
+
*
|
226 |
+
* @param Mage_Sales_Model_Order $order
|
227 |
+
* @param type $soapResult
|
228 |
+
* @param type $soapRequest
|
229 |
+
*/
|
230 |
+
public function saveOrderTaxesToMagento($order, $soapResult, $soapRequest);
|
231 |
+
|
232 |
+
/**
|
233 |
+
* always get totals by what we get in the soapresult
|
234 |
+
*
|
235 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
236 |
+
* @param type $soapresult
|
237 |
+
* @param array $soapRequest
|
238 |
+
*/
|
239 |
+
public function saveInvoiceTaxesToMagento($invoice, $soapResult, $soapRequest);
|
240 |
+
|
241 |
+
|
242 |
+
/**
|
243 |
+
*
|
244 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
245 |
+
* @param type $soapResult
|
246 |
+
* @param array $soapRequest
|
247 |
+
*/
|
248 |
+
public function saveCreditMemoTaxesToMagento($creditMemo, $soapResult, $soapRequest);
|
249 |
+
|
250 |
+
/**
|
251 |
+
*
|
252 |
+
* @param Mage_Sales_Model_Order_Item $item
|
253 |
+
* @param array $itemArray
|
254 |
+
*/
|
255 |
+
public function saveTaxesForOrderItem($item, $itemArray);
|
256 |
+
|
257 |
+
/**
|
258 |
+
*
|
259 |
+
* @param Mage_Sales_Model_Order_Invoice_Item $item
|
260 |
+
* @param array $itemArray
|
261 |
+
*/
|
262 |
+
public function saveTaxesForInvoiceItem($item, $itemArray);
|
263 |
+
|
264 |
+
/**
|
265 |
+
*
|
266 |
+
* @param Mage_Sales_Model_Order_Creditmemo_Item $item
|
267 |
+
* @param array $itemArray
|
268 |
+
*/
|
269 |
+
public function saveTaxesForCreditMemoItem($item, $itemArray);
|
270 |
+
|
271 |
+
/**
|
272 |
+
*
|
273 |
+
* @param Mage_Sales_Model_Order $order
|
274 |
+
* @param array $itemArray
|
275 |
+
* @return float shipping tax amount
|
276 |
+
*/
|
277 |
+
public function saveShippingTaxesForOrder($order, $itemArray);
|
278 |
+
|
279 |
+
/**
|
280 |
+
*
|
281 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
282 |
+
* @param array $itemArray
|
283 |
+
* @return float shipping tax amount
|
284 |
+
*/
|
285 |
+
public function saveShippingTaxesForInvoice($invoice, $itemArray);
|
286 |
+
|
287 |
+
/**
|
288 |
+
*
|
289 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditMemo
|
290 |
+
* @param array $itemArray
|
291 |
+
* @return float
|
292 |
+
*/
|
293 |
+
public function saveShippingTaxesForCreditMemo($creditMemo, $itemArray);
|
294 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Creditmemo.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Credit Memo model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Creditmemo extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _construct()
|
14 |
+
{
|
15 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::CREDIT_TBL);
|
16 |
+
}
|
17 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Customer.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Customer extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::CUST_TBL);
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Customergroup.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Customergroup extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::CUST_GRP_TBL);
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Info.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Global configuration model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Info extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::GEN_CONFIG_TBL);
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Invoice.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Invoice model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Invoice extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::INVOICE_TBL);
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Observer.php
ADDED
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Observer for all event catching.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
11 |
+
use WoltersKluwer_CchSureTax_Helper_Config as Config;
|
12 |
+
|
13 |
+
class WoltersKluwer_CchSureTax_Model_Observer
|
14 |
+
{
|
15 |
+
const FLAG_SHOW_CONFIG = 'showConfig';
|
16 |
+
const FLAG_SHOW_CONFIG_FORMAT = 'showConfigFormat';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Event that converts the address obj to order setting the applied taxes
|
20 |
+
* to null so it's not duplicated in our dbs
|
21 |
+
*
|
22 |
+
* @param Varien_Event_Observer $observer
|
23 |
+
*/
|
24 |
+
public function salesEventConvertQuoteAddressToOrder($observer)
|
25 |
+
{
|
26 |
+
//This method is kept empty so that Suretax can save taxes that they got
|
27 |
+
//back from tax engine. This way magento does not override our tax saving logic
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* This method is fired for the event sales_order_save_after - config.xml
|
32 |
+
*
|
33 |
+
* @param Varien_Event_Observer $observer
|
34 |
+
*
|
35 |
+
* @return self
|
36 |
+
*/
|
37 |
+
public function afterOrderSaved($observer)
|
38 |
+
{
|
39 |
+
/* @var $order Mage_Sales_Model_Order*/
|
40 |
+
$order = $observer->getEvent()->getOrder();
|
41 |
+
|
42 |
+
Utility::logMessage(
|
43 |
+
'|--After Order ' . $order->getIncrementId() . ' Saved--|',
|
44 |
+
Zend_Log::INFO
|
45 |
+
);
|
46 |
+
|
47 |
+
Utility::logMessage(
|
48 |
+
'Order StatusLabel : ' . $order->getStatusLabel(),
|
49 |
+
Zend_Log::INFO
|
50 |
+
);
|
51 |
+
|
52 |
+
// if not supported country, then do default magento tax calc
|
53 |
+
$shipToAddressArray = Utility::
|
54 |
+
getShipToAddress(
|
55 |
+
Mage::getModel('sales/order_address')
|
56 |
+
->load($order->getShippingAddress()->getId())
|
57 |
+
);
|
58 |
+
|
59 |
+
if (!Utility::isSureTaxSupportedCountry($shipToAddressArray['Country'])) {
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
$store = $order->getStore();
|
63 |
+
$sureTaxConfig = Config::get();
|
64 |
+
$isDebug = $sureTaxConfig->isDebug();
|
65 |
+
$enableCalc = Config::isSureTaxEnabledForWebsiteStore(
|
66 |
+
$store->getWebsiteId(),
|
67 |
+
$store->getGroupId()
|
68 |
+
);
|
69 |
+
if (!$enableCalc) {
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
//following if condition is to make sure that it gets called only once
|
74 |
+
if ((!$order->getStatusLabel() || $order->getStatusLabel() == 'Pending')
|
75 |
+
&& !Mage::registry('prevent_observer_final'.$order->getIncrementId())
|
76 |
+
) {
|
77 |
+
Utility::log(
|
78 |
+
'Posting Order ' . $order->getIncrementId() . ' to SureTax',
|
79 |
+
Zend_Log::INFO,
|
80 |
+
$isDebug
|
81 |
+
);
|
82 |
+
|
83 |
+
/* @var $client WoltersKluwer_CchSureTax_Helper_WebService */
|
84 |
+
$client = Mage::helper('suretax/webService');
|
85 |
+
$client->sendOrderToSureTax($order, $shipToAddressArray);
|
86 |
+
|
87 |
+
/**
|
88 |
+
* This following block saves the order and tax info in the
|
89 |
+
* sales_order_tax table and sales_order_tax_item which gets the
|
90 |
+
* item ids from sales_flat_order_item for tax display purposes which can be
|
91 |
+
* configured under Sales->Configuration->Tax
|
92 |
+
*/
|
93 |
+
|
94 |
+
if (Utility::isEnabledTaxDisplay()) {
|
95 |
+
$jurisdictionArray = $client->getJurisdictionArray();
|
96 |
+
$i = 0;
|
97 |
+
foreach ($jurisdictionArray as $jRate) {
|
98 |
+
$taxAmount = $jRate['TaxAmount'];
|
99 |
+
$taxAmountStore = $store->convertPrice($taxAmount);
|
100 |
+
$taxRate = round(
|
101 |
+
$jRate['TaxRate'],
|
102 |
+
Constants::PRECISION_DIGITS_FOR_DISPLAY,
|
103 |
+
PHP_ROUND_HALF_UP
|
104 |
+
);
|
105 |
+
$title = Utility::generateJurisdictionTitle(
|
106 |
+
$jRate['TaxTypeDesc'],
|
107 |
+
$jRate['TaxAuthorityName']
|
108 |
+
);
|
109 |
+
|
110 |
+
$data = array(
|
111 |
+
'order_id' => $order->getId(),
|
112 |
+
'code' => $title,
|
113 |
+
'title' => $title,
|
114 |
+
'percent' => $taxRate,
|
115 |
+
'amount' => $taxAmountStore,
|
116 |
+
'priority' => 0,
|
117 |
+
'position' => $i,
|
118 |
+
'base_amount' => $taxAmount,
|
119 |
+
'process' => $i,
|
120 |
+
'base_real_amount' => $taxAmount,
|
121 |
+
'hidden' => 0,
|
122 |
+
);
|
123 |
+
$i++;
|
124 |
+
|
125 |
+
$salesOrderTax = Mage::getModel('tax/sales_order_tax')->setData($data)->save();
|
126 |
+
//each jurisdiction tax should be saved for each line
|
127 |
+
//item in the order
|
128 |
+
foreach ($order->getAllItems() as $item) {
|
129 |
+
$data = array(
|
130 |
+
'tax_id' => $salesOrderTax->getTaxId(),
|
131 |
+
'item_id' => $item->getId(),
|
132 |
+
'tax_percent' => $taxRate,
|
133 |
+
);
|
134 |
+
Mage::getModel('tax/sales_order_tax_item')->setData($data)->save();
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
Mage::register('prevent_observer_final' . $order->getIncrementId(), true);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Event driven : called after Invoice creation and save.
|
145 |
+
*
|
146 |
+
* @param Varien_Event_Observer $observer
|
147 |
+
*
|
148 |
+
* @return self
|
149 |
+
*/
|
150 |
+
public function afterInvoiceSaved($observer)
|
151 |
+
{
|
152 |
+
/* @var $invoice Mage_Sales_Model_Order_Invoice*/
|
153 |
+
$invoice = $observer->getEvent()->getInvoice();
|
154 |
+
$order = $invoice->getOrder();
|
155 |
+
$store = $order->getStore();
|
156 |
+
Utility::logMessage(
|
157 |
+
'|--After Invoice ' . $invoice->getIncrementId() . ' Saved--|',
|
158 |
+
Zend_Log::INFO
|
159 |
+
);
|
160 |
+
|
161 |
+
$shipToAddressArray = Utility::
|
162 |
+
getShipToAddress(
|
163 |
+
Mage::getModel('sales/order_address')
|
164 |
+
->load($order->getShippingAddress()->getId())
|
165 |
+
);
|
166 |
+
|
167 |
+
if (!Utility::isSureTaxSupportedCountry($shipToAddressArray['Country'])) {
|
168 |
+
return $this;
|
169 |
+
}
|
170 |
+
|
171 |
+
$sureTaxConfig = Config::get();
|
172 |
+
$isDebug = $sureTaxConfig->isDebug();
|
173 |
+
|
174 |
+
$enableCalc = Config::isSureTaxEnabledForWebsiteStore(
|
175 |
+
$store->getWebsiteId(),
|
176 |
+
$store->getGroupId()
|
177 |
+
);
|
178 |
+
if (!$enableCalc) {
|
179 |
+
return $this;
|
180 |
+
}
|
181 |
+
|
182 |
+
$suretaxInvoiceModel = Mage::getModel(Constants::INVOICE_TBL);
|
183 |
+
$suretaxInvoice = $suretaxInvoiceModel->load($invoice->getIncrementId(), 'increment_id');
|
184 |
+
|
185 |
+
if (($suretaxInvoice->getStatus() === null)) {
|
186 |
+
Utility::log(
|
187 |
+
'Finalizing Invoice '.$invoice->getIncrementId().' to SureTax',
|
188 |
+
Zend_Log::INFO,
|
189 |
+
$isDebug
|
190 |
+
);
|
191 |
+
|
192 |
+
/* @var $client WoltersKluwer_CchSureTax_Helper_WebService*/
|
193 |
+
$client = Mage::helper('suretax/webService');
|
194 |
+
$dataReturned = $client->sendFinalizeInvoiceToSureTax($invoice, $shipToAddressArray);
|
195 |
+
|
196 |
+
$taxDifference = round($invoice->getBaseTaxAmount() - round($dataReturned['total_tax'], 4), 2);
|
197 |
+
|
198 |
+
$status = $dataReturned['status'];
|
199 |
+
if ($status == Constants::FINALIZED_STATUS) {
|
200 |
+
if ($taxDifference > 0) {
|
201 |
+
//that means tax been over collected from customer,
|
202 |
+
//so we need to send for adjustment with over collected amount.
|
203 |
+
$adjustmentResponse = $client->sendTaxAdjustmentToSureTax(
|
204 |
+
$invoice,
|
205 |
+
$shipToAddressArray,
|
206 |
+
$taxDifference
|
207 |
+
);
|
208 |
+
$status = $adjustmentResponse['status'];
|
209 |
+
} elseif ($taxDifference < 0) {
|
210 |
+
//this means you under collected from customer, so you need to pay this much amount more.
|
211 |
+
//Sure tax already has this amount, so no need send an adjustment
|
212 |
+
$status = Constants::FINALIZE_PAYMENT_REQUIRED;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
$data = array(
|
217 |
+
'increment_id' => $invoice->getIncrementId(),
|
218 |
+
'trans_id' => $dataReturned['trans_id'],
|
219 |
+
'client_tracking' => $dataReturned['client_tracking'],
|
220 |
+
'status' => $status,
|
221 |
+
'notes' => $dataReturned['notes'],
|
222 |
+
'tax' => $dataReturned['total_tax']
|
223 |
+
);
|
224 |
+
$suretaxInvoiceModel->setData($data);
|
225 |
+
$suretaxInvoiceModel->save();
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Event driven : called after a Credit memo creation.
|
231 |
+
*
|
232 |
+
* @param Varien_Event_Observer $observer
|
233 |
+
*
|
234 |
+
* @return self
|
235 |
+
*/
|
236 |
+
public function afterCreditMemoRefund($observer)
|
237 |
+
{
|
238 |
+
/* @var $creditmemo Mage_Sales_Model_Order_Creditmemo*/
|
239 |
+
$creditmemo = $observer->getEvent()->getCreditmemo();
|
240 |
+
$order = $creditmemo->getOrder();
|
241 |
+
|
242 |
+
Utility::logMessage(
|
243 |
+
'|--After Credit Memo ' . $creditmemo->getIncrementId() . ' Refund--|',
|
244 |
+
Zend_Log::INFO
|
245 |
+
);
|
246 |
+
|
247 |
+
$shipToAddressArray = Utility::
|
248 |
+
getShipToAddress(
|
249 |
+
Mage::getModel('sales/order_address')
|
250 |
+
->load($order->getShippingAddress()->getId())
|
251 |
+
);
|
252 |
+
|
253 |
+
if (!Utility::isSureTaxSupportedCountry($shipToAddressArray['Country'])) {
|
254 |
+
return $this;
|
255 |
+
}
|
256 |
+
|
257 |
+
$enableCalc = Config::isSureTaxEnabledForWebsiteStore(
|
258 |
+
$order->getStore()->getWebsiteId(),
|
259 |
+
$order->getStore()->getGroupId()
|
260 |
+
);
|
261 |
+
if (!$enableCalc) {
|
262 |
+
return $this;
|
263 |
+
}
|
264 |
+
|
265 |
+
$suretaxCreditmemoModel = Mage::getModel(Constants::CREDIT_TBL)
|
266 |
+
->load($creditmemo->getIncrementId(), 'increment_id');
|
267 |
+
|
268 |
+
if (!Mage::registry('prevent_observer')) {
|
269 |
+
Utility::logMessage(
|
270 |
+
'Order ID to be credited : ' . $order->getIncrementId() .
|
271 |
+
' | Order Status Label : ' . $order->getStatusLabel(),
|
272 |
+
Zend_Log::NOTICE
|
273 |
+
);
|
274 |
+
|
275 |
+
if (!$suretaxCreditmemoModel->getTransId()) {
|
276 |
+
/* @var $client WoltersKluwer_CchSureTax_Helper_WebService*/
|
277 |
+
$client = Mage::helper('suretax/webService');
|
278 |
+
$dataReturned = $client->sendCreditMemoToSureTax($creditmemo, $shipToAddressArray);
|
279 |
+
$suretaxReturnedTax = $dataReturned['total_tax'];
|
280 |
+
$suretaxReturnedTaxAmount = -1 * round($suretaxReturnedTax, 4);
|
281 |
+
$creditMemoTax = $creditmemo->getBaseTaxAmount();
|
282 |
+
|
283 |
+
$taxDifference = round(($creditMemoTax - $suretaxReturnedTaxAmount), 2);
|
284 |
+
$status = $dataReturned['status'];
|
285 |
+
Utility::logMessage(
|
286 |
+
'Total Tax = ' . $dataReturned['total_tax'] .
|
287 |
+
' Tax Difference = ' . $taxDifference .
|
288 |
+
' Status = ' . $status,
|
289 |
+
Zend_Log::DEBUG
|
290 |
+
);
|
291 |
+
|
292 |
+
if ($status == Constants::FINALIZED_STATUS) {
|
293 |
+
if ($taxDifference > 0) {
|
294 |
+
//this means vendor paid more money to customer as tax in refund than actual refund tax.
|
295 |
+
//so it is just to know for vendor
|
296 |
+
$status = Constants::FINALIZE_PAYMENT_REQUIRED;
|
297 |
+
} elseif ($taxDifference < 0) {
|
298 |
+
//this means vendor has been paid less money as tax, so we need to submit adjustment
|
299 |
+
$adjustDataReturned = $client->sendCreditMemoTaxAdjustmentToSureTax(
|
300 |
+
$creditmemo,
|
301 |
+
$shipToAddressArray,
|
302 |
+
$taxDifference * -1
|
303 |
+
);
|
304 |
+
$status = $adjustDataReturned['status'];
|
305 |
+
}
|
306 |
+
}
|
307 |
+
Utility::logMessage('STAN : ' . $dataReturned['stan'], Zend_Log::DEBUG);
|
308 |
+
$data = array(
|
309 |
+
'increment_id' => $creditmemo->getIncrementId(),
|
310 |
+
'trans_id' => $dataReturned['trans_id'],
|
311 |
+
'stan' => $dataReturned['stan'],
|
312 |
+
'client_tracking' => $dataReturned['client_tracking'],
|
313 |
+
'status' => $status,
|
314 |
+
'tax' => $dataReturned['total_tax'] * -1,
|
315 |
+
'notes' => $dataReturned['notes']
|
316 |
+
);
|
317 |
+
$suretaxCreditmemoModel->setData($data);
|
318 |
+
$suretaxCreditmemoModel->save();
|
319 |
+
}
|
320 |
+
Mage::register('prevent_observer', true);
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Corecustomer/Collection.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* To change this license header, choose License Headers in Project Properties.
|
5 |
+
* To change this template file, choose Tools | Templates
|
6 |
+
* and open the template in the editor.
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Corecustomer_Collection extends
|
10 |
+
Mage_Customer_Model_Resource_Customer_Collection
|
11 |
+
{
|
12 |
+
public function filterBasedOnExemptionFields($fieldName,$condition)
|
13 |
+
{
|
14 |
+
$conditionWithNewFields = $this->getConnection()
|
15 |
+
->prepareSqlCondition($fieldName, $condition);
|
16 |
+
$this->getSelect()->where($conditionWithNewFields);
|
17 |
+
}
|
18 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Creditmemo.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Credit Memo resource model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Creditmemo extends Mage_Core_Model_Resource_Db_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::CREDIT_TBL, 'id');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Creditmemo/Collection.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Credit Memo resource collection.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
|
11 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Creditmemo_Collection
|
12 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
$this->_init(Constants::CREDIT_TBL);
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function joinWithCreditmemo()
|
20 |
+
{
|
21 |
+
$resource = Mage::getSingleton('core/resource');
|
22 |
+
//Join it the Magento's Credit Memo table.
|
23 |
+
$collection = Mage::getModel('sales/order_creditmemo')->getCollection();
|
24 |
+
|
25 |
+
$collection->getSelect()->join(
|
26 |
+
array(
|
27 |
+
'order' => $resource->getTableName('sales/order')),
|
28 |
+
'main_table.order_id = order.entity_id',
|
29 |
+
array('order.increment_id as order_number')
|
30 |
+
)->joinLeft(
|
31 |
+
array(
|
32 |
+
'sure' => $resource->getTableName(Constants::CREDIT_TBL)),
|
33 |
+
'main_table.increment_id = sure.increment_id',
|
34 |
+
array('if(isnull(sure.stan), "N/A", sure.stan) as stan',
|
35 |
+
'if(isnull(sure.trans_id), "N/A", sure.trans_id) as trans_id',
|
36 |
+
'if(isnull(sure.client_tracking), "N/A", sure.client_tracking) as client_tracking',
|
37 |
+
'if(isnull(sure.tax), "0", sure.tax) as tax',
|
38 |
+
'if(isnull(sure.status), "N/A", sure.status) as status',
|
39 |
+
'if(isnull(sure.notes), "N/A", sure.notes) as notes',
|
40 |
+
'(main_table.tax_amount - sure.tax) as tax_difference')
|
41 |
+
);
|
42 |
+
|
43 |
+
return $collection;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function joinCreditMemoWithSelfForCreditmemoIds($creditmemoIds)
|
47 |
+
{
|
48 |
+
$creditMemoCollection = Mage::getModel('sales/order_creditmemo')
|
49 |
+
->getCollection()
|
50 |
+
->addFieldToFilter('main_table.entity_id', array('in' => $creditmemoIds));
|
51 |
+
|
52 |
+
$creditMemoCollection->getSelect()
|
53 |
+
->joinLeft(
|
54 |
+
array('address' => $this->getTable('sales/order_address')),
|
55 |
+
'main_table.shipping_address_id = address.entity_id',
|
56 |
+
array('address_entity_id'=>'entity_id', 'postcode', 'street', 'city', 'country_id')
|
57 |
+
)->joinLeft(
|
58 |
+
array('wk_credit_memo' => $this->getTable(Constants::CREDIT_TBL)),
|
59 |
+
'main_table.increment_id = wk_credit_memo.increment_id',
|
60 |
+
array('suretax_id'=>'wk_credit_memo.id',
|
61 |
+
'wk_increment_id'=>'wk_credit_memo.increment_id', 'stan',
|
62 |
+
'trans_id', 'tax', 'client_tracking', 'status', 'notes')
|
63 |
+
)->joinLeft(
|
64 |
+
array('region' => $this->getTable('directory/country_region')),
|
65 |
+
'region.region_id = address.region_id',
|
66 |
+
array('region'=>'code')
|
67 |
+
)->joinLeft(
|
68 |
+
array('store' => $this->getTable('core/store')),
|
69 |
+
'main_table.store_id = store.store_id',
|
70 |
+
array('website_id', 'group_id')
|
71 |
+
)->joinLeft(
|
72 |
+
array('order' => $this->getTable('sales/order')),
|
73 |
+
'main_table.order_id = order.entity_id',
|
74 |
+
array('order_created_at'=>'created_at', 'customer_id', 'customer_group_id',
|
75 |
+
'base_shipping_discount_amount', 'order_increment_id'=>'increment_id')
|
76 |
+
)->joinLeft(
|
77 |
+
array('customer' => $this->getTable(Constants::CUST_TBL)),
|
78 |
+
'order.customer_id = customer.suretax_customer_id',
|
79 |
+
array('customer_exemption_code'=>'exemption_code',
|
80 |
+
'customer_exemption_reason_code'=>'exemption_reason_code',
|
81 |
+
'customer_sales_type_code'=>'sales_type_code')
|
82 |
+
)->joinLeft(
|
83 |
+
array('customer_group' => $this->getTable(Constants::CUST_GRP_TBL)),
|
84 |
+
'order.customer_group_id = customer_group.suretax_customer_group_id',
|
85 |
+
array('customer_group_exemption_code'=>'exemption_code',
|
86 |
+
'customer_group_exemption_reason_code'=>'exemption_reason_code',
|
87 |
+
'customer_group_sales_type_code'=>'sales_type_code')
|
88 |
+
);
|
89 |
+
// Mage::log((string)$creditMemoCollection->getSelect());
|
90 |
+
return $creditMemoCollection;
|
91 |
+
}
|
92 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Customer.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer resource model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Customer extends Mage_Core_Model_Resource_Db_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::CUST_TBL, 'id');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Customer/Collection.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer resource collection.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
|
11 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Customer_Collection
|
12 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
$this->_init(Constants::CUST_TBL);
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function joinWithCustomer()
|
20 |
+
{
|
21 |
+
$resource = Mage::getSingleton('core/resource');
|
22 |
+
/* @var $collection WoltersKluwer_CchSureTax_Model_Resource_Corecustomer_Collection */
|
23 |
+
$collection = Mage::getResourceModel('wolterskluwer_cchsuretax/corecustomer_collection')
|
24 |
+
->addNameToSelect()
|
25 |
+
->addAttributeToSelect('email')
|
26 |
+
->addAttributeToSelect('created_at')
|
27 |
+
->addAttributeToSelect('group_id');
|
28 |
+
|
29 |
+
$collection->getSelect()->join(
|
30 |
+
array(
|
31 |
+
'sure' => $resource->getTableName(Constants::CUST_TBL)
|
32 |
+
), 'e.entity_id = sure.suretax_customer_id'
|
33 |
+
);
|
34 |
+
|
35 |
+
return $collection;
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Magento invoice join with Magento order and SureTax invoice table.
|
41 |
+
*
|
42 |
+
* @param int $customerId
|
43 |
+
*
|
44 |
+
* @return WoltersKluwer_CchSureTax_Model_Customer
|
45 |
+
*/
|
46 |
+
public function loadCustomerForExemption($customerId)
|
47 |
+
{
|
48 |
+
/* @var $collection WoltersKluwer_CchSureTax_Model_Resource_Corecustomer_Collection */
|
49 |
+
$collection = Mage::getResourceModel('wolterskluwer_cchsuretax/corecustomer_collection')
|
50 |
+
->addFieldToFilter('entity_id', $customerId)
|
51 |
+
->addNameToSelect()
|
52 |
+
->addAttributeToSelect('email')
|
53 |
+
->addAttributeToSelect('group_id');
|
54 |
+
|
55 |
+
$collection->getSelect()->join(
|
56 |
+
array('group' => $this->getTable('customer/customer_group')),
|
57 |
+
'e.group_id = group.customer_group_id',
|
58 |
+
array('customer_group_code')
|
59 |
+
);
|
60 |
+
$collection->getSelect()->limit(1);
|
61 |
+
|
62 |
+
return $collection->getFirstItem();
|
63 |
+
}
|
64 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Customergroup.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group resource model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Customergroup extends Mage_Core_Model_Resource_Db_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::CUST_GRP_TBL, 'id');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Customergroup/Collection.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax Customer Group resource collection.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Customergroup_Collection
|
11 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::CUST_GRP_TBL);
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function joinWithCustomerGroup()
|
20 |
+
{
|
21 |
+
$resource = Mage::getSingleton('core/resource');
|
22 |
+
|
23 |
+
$collection = Mage::getResourceModel('customer/group_collection')
|
24 |
+
->addTaxClass();
|
25 |
+
|
26 |
+
$collection->getSelect()->join(
|
27 |
+
array(
|
28 |
+
'suretax_group_info' => $resource->getTableName(WoltersKluwer_CchSureTax_Helper_Constants::CUST_GRP_TBL)),
|
29 |
+
'main_table.customer_group_id = suretax_group_info.suretax_customer_group_id'
|
30 |
+
);
|
31 |
+
|
32 |
+
return $collection;
|
33 |
+
}
|
34 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Info.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Global configuration resource model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Info extends Mage_Core_Model_Resource_Db_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::GEN_CONFIG_TBL, 'info_id');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Info/Collection.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Global Configuration resource collection.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Info_Collection
|
11 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
12 |
+
{
|
13 |
+
public function _construct()
|
14 |
+
{
|
15 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::GEN_CONFIG_TBL);
|
16 |
+
}
|
17 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Invoice.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Invoice resource model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Invoice extends Mage_Core_Model_Resource_Db_Abstract
|
10 |
+
{
|
11 |
+
public function _construct()
|
12 |
+
{
|
13 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::INVOICE_TBL, 'id');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Invoice/Collection.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Invoice resource collection.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
|
11 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Invoice_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
12 |
+
{
|
13 |
+
public function _construct()
|
14 |
+
{
|
15 |
+
$this->_init(Constants::INVOICE_TBL);
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Magento invoice join with Magento order and SureTax invoice table.
|
20 |
+
*
|
21 |
+
* @return Mage_Core_Model_Resource_Db_Collection_Abstract
|
22 |
+
*/
|
23 |
+
public static function joinInvoiceWithSelf()
|
24 |
+
{
|
25 |
+
$resource = Mage::getSingleton('core/resource');
|
26 |
+
$collection = Mage::getModel('sales/order_invoice')->getCollection();
|
27 |
+
|
28 |
+
$collection->getSelect()->joinLeft(
|
29 |
+
array('order' => $resource->getTableName('sales/order')),
|
30 |
+
'main_table.order_id = order.entity_id',
|
31 |
+
array('order.increment_id as order_increment_id')
|
32 |
+
)->joinLeft(
|
33 |
+
array('sure' => $resource->getTableName(Constants::INVOICE_TBL)),
|
34 |
+
'main_table.increment_id = sure.increment_id',
|
35 |
+
array('if(isnull(sure.trans_id), "N/A", sure.trans_id) as trans_id',
|
36 |
+
'if(isnull(sure.tax), "0", sure.tax) as tax',
|
37 |
+
'if(isnull(sure.client_tracking), "N/A", sure.client_tracking) as client_tracking',
|
38 |
+
'if(isnull(sure.status), "N/A", sure.status) as status',
|
39 |
+
'if(isnull(sure.notes), "N/A", sure.notes) as notes',
|
40 |
+
'(main_table.tax_amount - sure.tax) as tax_difference')
|
41 |
+
);
|
42 |
+
|
43 |
+
return $collection;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Magento invoice join with Magento order and SureTax invoice table.
|
48 |
+
*
|
49 |
+
* @param array $invoiceIds
|
50 |
+
*
|
51 |
+
* @return Mage_Core_Model_Resource_Db_Collection_Abstract
|
52 |
+
*/
|
53 |
+
public function joinInvoiceWithSelfForInvoiceIds($invoiceIds)
|
54 |
+
{
|
55 |
+
$invCollection = Mage::getModel('sales/order_invoice')->getCollection()
|
56 |
+
->addFieldToFilter('main_table.entity_id', array('in' => $invoiceIds));
|
57 |
+
|
58 |
+
$invCollection->getSelect()->joinLeft(
|
59 |
+
array('address' => $this->getTable('sales/order_address')),
|
60 |
+
'main_table.shipping_address_id = address.entity_id',
|
61 |
+
array('address_entity_id'=>'entity_id', 'postcode', 'street', 'city', 'country_id')
|
62 |
+
)->joinLeft(
|
63 |
+
array('wk_invoice' => $this->getTable(Constants::INVOICE_TBL)),
|
64 |
+
'main_table.increment_id = wk_invoice.increment_id',
|
65 |
+
array('suretax_id'=>'wk_invoice.id',
|
66 |
+
'wk_increment_id'=>'wk_invoice.increment_id',
|
67 |
+
'trans_id', 'tax', 'client_tracking', 'status', 'notes')
|
68 |
+
)->joinLeft(
|
69 |
+
array('region' => $this->getTable('directory/country_region')),
|
70 |
+
'region.region_id = address.region_id',
|
71 |
+
array('region'=>'code')
|
72 |
+
)->joinLeft(
|
73 |
+
array('store' => $this->getTable('core/store')),
|
74 |
+
'main_table.store_id = store.store_id',
|
75 |
+
array('website_id', 'group_id')
|
76 |
+
)->joinLeft(
|
77 |
+
array('order' => $this->getTable('sales/order')),
|
78 |
+
'main_table.order_id = order.entity_id',
|
79 |
+
array('order_created_at'=>'created_at', 'customer_id', 'customer_group_id',
|
80 |
+
'base_shipping_discount_amount')
|
81 |
+
)->joinLeft(
|
82 |
+
array('customer' => $this->getTable(Constants::CUST_TBL)),
|
83 |
+
'order.customer_id = customer.suretax_customer_id',
|
84 |
+
array('customer_exemption_code'=>'exemption_code',
|
85 |
+
'customer_exemption_reason_code'=>'exemption_reason_code',
|
86 |
+
'customer_sales_type_code'=>'sales_type_code')
|
87 |
+
)->joinLeft(
|
88 |
+
array('customer_group' => $this->getTable(Constants::CUST_GRP_TBL)),
|
89 |
+
'order.customer_group_id = customer_group.suretax_customer_group_id',
|
90 |
+
array('customer_group_exemption_code'=>'exemption_code',
|
91 |
+
'customer_group_exemption_reason_code'=>'exemption_reason_code',
|
92 |
+
'customer_group_sales_type_code'=>'sales_type_code')
|
93 |
+
);
|
94 |
+
|
95 |
+
//Mage::log((string)$invCollection->getSelect());
|
96 |
+
return $invCollection;
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax setup class.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
10 |
+
{
|
11 |
+
|
12 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Websitestore/Config.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Website/Store Configuration resource model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Websitestore_Config extends Mage_Core_Model_Resource_Db_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::WS_CONFIG_TBL, 'id');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Resource/Websitestore/Config/Collection.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Website/Store Configuration resource collection.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Resource_Websitestore_Config_Collection
|
11 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
12 |
+
{
|
13 |
+
public function _construct()
|
14 |
+
{
|
15 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::WS_CONFIG_TBL);
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Join website to get the name
|
20 |
+
*
|
21 |
+
* @return self
|
22 |
+
*/
|
23 |
+
public function joinWebsite()
|
24 |
+
{
|
25 |
+
$this->getSelect()->join(
|
26 |
+
array('wb' => Mage::getSingleton('core/resource')
|
27 |
+
->getTableName('core/website')),
|
28 |
+
'main_table.website_id = wb.website_id',
|
29 |
+
array('wb.name as website')
|
30 |
+
);
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Join store to get the name
|
36 |
+
*
|
37 |
+
* @return self
|
38 |
+
*/
|
39 |
+
public function joinStore()
|
40 |
+
{
|
41 |
+
$this->getSelect()->join(
|
42 |
+
array('grp' => Mage::getSingleton('core/resource')
|
43 |
+
->getTableName('core/store_group')),
|
44 |
+
'main_table.store_id = grp.group_id',
|
45 |
+
array('grp.name as store')
|
46 |
+
);
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Load Website config from the website ID
|
52 |
+
*
|
53 |
+
* @param int $websiteId
|
54 |
+
* @return WoltersKluwer_CchSureTax_Model_Websitestore_Config
|
55 |
+
*/
|
56 |
+
public function loadWebsiteConfig($websiteId)
|
57 |
+
{
|
58 |
+
$this->addFieldToFilter('website_id', $websiteId)
|
59 |
+
->addFieldToFilter('store_id', 0);
|
60 |
+
|
61 |
+
$this->getSelect()->limit(1);
|
62 |
+
|
63 |
+
return $this->getFirstItem();
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Load all Website config.
|
68 |
+
*
|
69 |
+
* @return array WoltersKluwer_CchSureTax_Model_Websitestore_Config
|
70 |
+
*/
|
71 |
+
public function loadAllWebsiteConfig()
|
72 |
+
{
|
73 |
+
$this->addFieldToFilter('store_id', 0);
|
74 |
+
|
75 |
+
return $this->getItems();
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Load Store config from the Website and Store ID
|
80 |
+
*
|
81 |
+
* @param int $websiteId
|
82 |
+
* @param int $storedId
|
83 |
+
* @return WoltersKluwer_CchSureTax_Model_Websitestore_Config
|
84 |
+
*/
|
85 |
+
public function loadStoreConfig($websiteId, $storedId)
|
86 |
+
{
|
87 |
+
$this->addFieldToFilter('website_id', array('eq' =>$websiteId))
|
88 |
+
->addFieldToFilter('store_id', array('eq' =>$storedId));
|
89 |
+
|
90 |
+
$this->getSelect()->limit(1);
|
91 |
+
|
92 |
+
return $this->getFirstItem();
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Load all store config.
|
97 |
+
*
|
98 |
+
* @return array WoltersKluwer_CchSureTax_Model_Websitestore_Config
|
99 |
+
*/
|
100 |
+
public function loadAllStoreConfig()
|
101 |
+
{
|
102 |
+
$this->addFieldToFilter('store_id', array('neq' => 0));
|
103 |
+
|
104 |
+
return $this->getItems();
|
105 |
+
}
|
106 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Tax/Sales/Total/Quote/Giftwrap.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Rewrite collect for Gift wrapping.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Config as Config;
|
11 |
+
|
12 |
+
class WoltersKluwer_CchSureTax_Model_Tax_Sales_Total_Quote_Giftwrap
|
13 |
+
extends Enterprise_GiftWrapping_Model_Total_Quote_Tax_Giftwrapping
|
14 |
+
{
|
15 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
16 |
+
{
|
17 |
+
$quote = $address->getQuote();
|
18 |
+
$isSureTaxEnabled = Config::isSureTaxEnabledForWebsiteStore(
|
19 |
+
$quote->getStore()->getWebsiteId(),
|
20 |
+
$quote->getStore()->getGroupId()
|
21 |
+
);
|
22 |
+
|
23 |
+
if ($isSureTaxEnabled == 0) {
|
24 |
+
return parent::collect($address);
|
25 |
+
}
|
26 |
+
|
27 |
+
$estimatedAddress = Utility::getShipToAddress($address);
|
28 |
+
$theCountry = $estimatedAddress['Country'];
|
29 |
+
$isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
|
30 |
+
$customer = null;
|
31 |
+
if ($isLoggedIn) {
|
32 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
33 |
+
}
|
34 |
+
if (!isset($theCountry) && $customer) {
|
35 |
+
// might have a logged in customer
|
36 |
+
// if logged in, we can try to use their shipping address (if avail)
|
37 |
+
$customerAddressId = $customer->getDefaultShipping();
|
38 |
+
if ($customerAddressId) {
|
39 |
+
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);
|
40 |
+
$estimatedAddress = Utility::getShipToAddress($customerAddress);
|
41 |
+
$theCountry = $estimatedAddress['Country'];
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
// if country isn't set, we return 0 tax
|
46 |
+
if (!isset($theCountry) || $theCountry == null) {
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
// if not supported country, then do default magento tax calc
|
51 |
+
if (!Utility::isSureTaxSupportedCountry($theCountry)) {
|
52 |
+
return parent::collect($address);
|
53 |
+
}
|
54 |
+
|
55 |
+
// set gw taxes for quote from address/s
|
56 |
+
$addys = $quote->getAllAddresses();
|
57 |
+
$gwTax = 0;
|
58 |
+
$gwBaseTax = 0;
|
59 |
+
$gwCardTax = 0;
|
60 |
+
$gwCardBaseTax = 0;
|
61 |
+
$gwItemsTax = 0;
|
62 |
+
$gwItemsBaseTax = 0;
|
63 |
+
if (!empty($addys)) {
|
64 |
+
foreach ($addys as $addy) {
|
65 |
+
$gwTax += $addy->getGwTaxAmount();
|
66 |
+
$gwBaseTax += $addy->getGwBaseTaxAmount();
|
67 |
+
$gwCardTax += $addy->getGwCardTaxAmount();
|
68 |
+
$gwCardBaseTax += $addy->getGwCardBaseTaxAmount();
|
69 |
+
$gwItemsTax += $addy->getGwItemsTaxAmount();
|
70 |
+
$gwItemsBaseTax += $addy->getGwItemsTaxAmount();
|
71 |
+
}
|
72 |
+
}
|
73 |
+
$quote->setGwTaxAmount($gwTax);
|
74 |
+
$quote->setGwBaseTaxAmount($gwBaseTax);
|
75 |
+
$quote->setGwCardTaxAmount($gwCardTax);
|
76 |
+
$quote->setGwCardBaseTaxAmount($gwCardBaseTax);
|
77 |
+
$quote->setGwItemsTaxAmount($gwItemsTax);
|
78 |
+
$quote->setGwItemsBaseTaxAmount($gwItemsBaseTax);
|
79 |
+
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Tax/Sales/Total/Quote/Tax.php
ADDED
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Rewrite collect for quotes.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
11 |
+
use WoltersKluwer_CchSureTax_Helper_Config as Config;
|
12 |
+
|
13 |
+
class WoltersKluwer_CchSureTax_Model_Tax_Sales_Total_Quote_Tax extends Mage_Tax_Model_Sales_Total_Quote_Tax
|
14 |
+
{
|
15 |
+
protected $_totalDiscountWithTax = array();
|
16 |
+
|
17 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
18 |
+
{
|
19 |
+
$quote = $address->getQuote();
|
20 |
+
$store = $quote->getStore();
|
21 |
+
$isSureTaxEnabled = Config::isSureTaxEnabledForWebsiteStore(
|
22 |
+
$store->getWebsiteId(),
|
23 |
+
$store->getGroupId()
|
24 |
+
);
|
25 |
+
|
26 |
+
if ($isSureTaxEnabled == 0) {
|
27 |
+
return parent::collect($address);
|
28 |
+
}
|
29 |
+
|
30 |
+
$estimatedAddress = Utility::getShipToAddress($address);
|
31 |
+
$theCountry = $estimatedAddress['Country'];
|
32 |
+
$isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
|
33 |
+
$customer = null;
|
34 |
+
if ($isLoggedIn) {
|
35 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
36 |
+
}
|
37 |
+
|
38 |
+
if (!isset($theCountry) && $customer) {
|
39 |
+
// might have a logged in customer
|
40 |
+
// if logged in, we can try to use their shipping address (if avail)
|
41 |
+
$customerAddressId = $customer->getDefaultShipping();
|
42 |
+
if ($customerAddressId) {
|
43 |
+
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);
|
44 |
+
$estimatedAddress = Utility::getShipToAddress($customerAddress);
|
45 |
+
$theCountry = $estimatedAddress['Country'];
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
// if country isn't set, we return 0 tax
|
50 |
+
if (!isset($theCountry) || $theCountry == null) {
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
// if not supported country, then do default magento tax calc
|
55 |
+
if (!Utility::isSureTaxSupportedCountry($theCountry)) {
|
56 |
+
return parent::collect($address);
|
57 |
+
}
|
58 |
+
|
59 |
+
// init
|
60 |
+
$this->_setAddress($address);
|
61 |
+
$this->_setAmount(0);
|
62 |
+
$this->_setBaseAmount(0);
|
63 |
+
|
64 |
+
// This logic makes the call only once not twice
|
65 |
+
$items = $this->_getAddressItems($address);
|
66 |
+
if (!count($items)) {
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
|
70 |
+
$subtotal = $address->getBaseSubtotal();
|
71 |
+
|
72 |
+
// check if the address is entered
|
73 |
+
if ($subtotal != 0 && array_filter($estimatedAddress)) {
|
74 |
+
try {
|
75 |
+
/* @var $client WoltersKluwer_CchSureTax_Helper_WebService*/
|
76 |
+
$client = Mage::helper('suretax/webService');
|
77 |
+
$soapRequest = $client->createSureTaxRequestFromQuoteAddress($address, $estimatedAddress);
|
78 |
+
$soapResult = null;
|
79 |
+
try {
|
80 |
+
$soapResult = $client->makeSureTaxRequestFromQuoteAddress($soapRequest);
|
81 |
+
} catch (Exception $exe) {
|
82 |
+
Utility::log(
|
83 |
+
'CALC ERROR: Quote Exception with sendQuoteAddressToSureTax : '
|
84 |
+
. $exe->getTraceAsString(),
|
85 |
+
Zend_Log::ERR,
|
86 |
+
true
|
87 |
+
);
|
88 |
+
return parent::collect($address);
|
89 |
+
}
|
90 |
+
|
91 |
+
if ($soapResult == null) {
|
92 |
+
return parent::collect($address);
|
93 |
+
}
|
94 |
+
|
95 |
+
$isSuccessful = $soapResult->SoapRequestResult->Successful;
|
96 |
+
$responseCode = $soapResult->SoapRequestResult->ResponseCode;
|
97 |
+
|
98 |
+
if ($isSuccessful == 'Y'
|
99 |
+
&& (strcmp($responseCode, Constants::API_RESPONSE_CODE_SUCCESS) == 0)
|
100 |
+
) {
|
101 |
+
$totalTax = $soapResult->SoapRequestResult->TotalTax;
|
102 |
+
$totalGwTax = 0;
|
103 |
+
|
104 |
+
$lineItemTaxArray = Utility::getLineItemLevelTaxByResponseWithRequest(
|
105 |
+
$soapRequest,
|
106 |
+
$soapResult
|
107 |
+
);
|
108 |
+
|
109 |
+
if (!isset($lineItemTaxArray) || $lineItemTaxArray == null) {
|
110 |
+
// we have no taxes
|
111 |
+
$this->saveZeroTaxes($address);
|
112 |
+
return $this;
|
113 |
+
}
|
114 |
+
|
115 |
+
$totalLineTax = 0;
|
116 |
+
$i = Constants::LINE_NUMBER_START_INDEX;
|
117 |
+
foreach ($items as $itemId => $item) {
|
118 |
+
$lineTax = $lineItemTaxArray[$i]['LineItemTax'];
|
119 |
+
$totalLineTax += isset($lineTax) ? $lineTax : 0;
|
120 |
+
|
121 |
+
// save line item level taxes at item level in db
|
122 |
+
$gwIndex = Constants::generateGiftWrapLineNumber($i);
|
123 |
+
if (array_key_exists($gwIndex, $lineItemTaxArray)) {
|
124 |
+
$gwLineItemArray = $lineItemTaxArray[$gwIndex];
|
125 |
+
$tempTax = $gwLineItemArray['LineItemTax'];
|
126 |
+
if (isset($tempTax)) {
|
127 |
+
$totalGwTax += $tempTax;
|
128 |
+
}
|
129 |
+
$this->saveGiftWrapTaxesForQuoteItem($address, $item, $tempTax, $store);
|
130 |
+
}
|
131 |
+
if ($totalGwTax) {
|
132 |
+
$address->setGwItemsTaxAmount($store->convertPrice($totalGwTax));
|
133 |
+
$address->setGwItemsBaseTaxAmount($totalGwTax);
|
134 |
+
}
|
135 |
+
$this->saveTaxesForQuoteItem($item, $lineItemTaxArray[$i], $store);
|
136 |
+
$i++;
|
137 |
+
}
|
138 |
+
|
139 |
+
//processing discount
|
140 |
+
$totalDiscountTax = array_sum($this->_totalDiscountWithTax);
|
141 |
+
$subtotalInclTax = $subtotal + $totalLineTax + $totalDiscountTax;
|
142 |
+
$address->setSubtotalInclTax($store->convertPrice($subtotalInclTax));
|
143 |
+
$address->setBaseSubtotalTotalInclTax($subtotalInclTax);
|
144 |
+
$totalTaxSt = $store->convertPrice($totalTax);
|
145 |
+
$address->setTaxAmount($totalTaxSt);
|
146 |
+
$address->setBaseTaxAmount($totalTax);
|
147 |
+
$this->_addAmount($totalTaxSt);
|
148 |
+
$this->_addBaseAmount($totalTax);
|
149 |
+
|
150 |
+
$shipA = $address->getBaseShippingAmount();
|
151 |
+
// check for shipping
|
152 |
+
$hasShippingLine = array_key_exists(
|
153 |
+
Constants::DEFAULT_SHIPPING_LINE_NUMBER,
|
154 |
+
$lineItemTaxArray
|
155 |
+
);
|
156 |
+
|
157 |
+
if ($hasShippingLine && isset($shipA) && $shipA != 0) {
|
158 |
+
$shipTax =
|
159 |
+
$lineItemTaxArray
|
160 |
+
[Constants::DEFAULT_SHIPPING_LINE_NUMBER]
|
161 |
+
['LineItemTax'];
|
162 |
+
if (isset($shipTax) && $shipTax != 0) {
|
163 |
+
// e.g. ShipA = 100, discount = 20
|
164 |
+
// shipUsedCalc = 80, ShipTax is for this amount
|
165 |
+
// shipping_including_tax = full tax ignores discount
|
166 |
+
// $shipInclTaxAdjusted hold shipping + tax and may be adjusted for discounts to match Mage
|
167 |
+
$shipInclTaxAdjusted = $shipA + $shipTax;
|
168 |
+
$shipDis = $address->getBaseShippingDiscountAmount();
|
169 |
+
if ($shipDis) {
|
170 |
+
$shipUsedCalc = $shipA - $shipDis;
|
171 |
+
$shipApparentRate = $shipTax / $shipUsedCalc;
|
172 |
+
$shipInclTaxAdjusted = $shipA + ($shipApparentRate * $shipA);
|
173 |
+
}
|
174 |
+
$address->setShippingInclTax($store->convertPrice($shipInclTaxAdjusted));
|
175 |
+
$address->setBaseShippingInclTax($shipInclTaxAdjusted);
|
176 |
+
// holds actual tax
|
177 |
+
$address->setShippingTaxAmount($store->convertPrice($shipTax));
|
178 |
+
$address->setBaseShippingTaxAmount($shipTax);
|
179 |
+
}
|
180 |
+
}
|
181 |
+
// check gift wrap
|
182 |
+
if (array_key_exists(
|
183 |
+
Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL,
|
184 |
+
$lineItemTaxArray
|
185 |
+
)) {
|
186 |
+
$tempTax = $lineItemTaxArray
|
187 |
+
[Constants::DEFAULT_GW_LINE_NUMBER_ORDER_LEVEL]
|
188 |
+
['LineItemTax'];
|
189 |
+
$this->saveGiftWrapTaxForQuote($address, $tempTax, $store);
|
190 |
+
}
|
191 |
+
if (array_key_exists(
|
192 |
+
Constants::DEFAULT_GW_CARD_LINE_NUMBER,
|
193 |
+
$lineItemTaxArray
|
194 |
+
)) {
|
195 |
+
$tempTaxCard = $lineItemTaxArray
|
196 |
+
[Constants::DEFAULT_GW_CARD_LINE_NUMBER]
|
197 |
+
['LineItemTax'];
|
198 |
+
$this->saveGiftWrapCardTaxForQuote($address, $tempTaxCard, $store);
|
199 |
+
}
|
200 |
+
|
201 |
+
$jurisdictionArray =
|
202 |
+
Utility::getJurisdictionLevelTaxesTotaledFromResponse($soapResult);
|
203 |
+
|
204 |
+
$appliedTaxes = Utility::generateAppliedTaxesArray(
|
205 |
+
$jurisdictionArray,
|
206 |
+
$store
|
207 |
+
);
|
208 |
+
if ($appliedTaxes != null) {
|
209 |
+
$address->setAppliedTaxes($appliedTaxes);
|
210 |
+
}
|
211 |
+
return $this;
|
212 |
+
} else {
|
213 |
+
$headerMessage = $soapResult->SoapRequestResult->HeaderMessage;
|
214 |
+
|
215 |
+
Utility::log(
|
216 |
+
'CALC ERROR: Failure Response for Quote '
|
217 |
+
. $address->getQuoteId()
|
218 |
+
. ' Header : ' . $headerMessage,
|
219 |
+
Zend_Log::ERR,
|
220 |
+
true
|
221 |
+
);
|
222 |
+
return parent::collect($address);
|
223 |
+
}
|
224 |
+
} catch (Exception $ere) {
|
225 |
+
// ERROR HANDLING - CUSTOMER FACING.
|
226 |
+
Utility::log(
|
227 |
+
'CALC ERROR: Exception calling Suretax API for Quote ' . $ere->getMessage()
|
228 |
+
. ' Quote ID = ' . $address->getQuoteId(),
|
229 |
+
Zend_Log::ERR,
|
230 |
+
true
|
231 |
+
);
|
232 |
+
return parent::collect($address);
|
233 |
+
}
|
234 |
+
}
|
235 |
+
return $this;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
*
|
240 |
+
* @param Mage_Sales_Model_Quote_Item $item
|
241 |
+
* @param type $suretaxLineItem
|
242 |
+
* array holding suretax lineitem tax info
|
243 |
+
* e.g. 'StateCode'=>$stateCode,
|
244 |
+
* 'Revenue'=>$rev
|
245 |
+
* 'RevenueBase'=>$revBase,
|
246 |
+
* 'LineItemNumber'=>$linteItemNumber,
|
247 |
+
* 'LineItemTax'=>$taxAmount
|
248 |
+
* @param Mage_Core_Model_Store $store
|
249 |
+
*/
|
250 |
+
public function saveTaxesForQuoteItem($item, $suretaxLineItem, $store)
|
251 |
+
{
|
252 |
+
$rev = $suretaxLineItem['Revenue'];
|
253 |
+
$taxT = $suretaxLineItem['LineItemTax'];
|
254 |
+
$taxStore = $store->convertPrice($taxT);
|
255 |
+
$item->setTaxAmount($taxStore);
|
256 |
+
$item->setBaseTaxAmount($taxT);
|
257 |
+
$quantity = $item->getQty();
|
258 |
+
// sales_flat_quote_item
|
259 |
+
// set: tax_percent, price_incl_tax, base_price_incl_tax,
|
260 |
+
// row_total_incl_tax, base_row_total_incl_tax
|
261 |
+
$taxPercent = (($rev == 0) ? 0 : (($taxT / $rev) * 100.0));
|
262 |
+
|
263 |
+
$taxRate = (($rev == 0) ? 0 : ($taxT / $rev));
|
264 |
+
$item->setTaxPercent($taxPercent);
|
265 |
+
|
266 |
+
$rowTotal = $rev + $taxT;
|
267 |
+
$priceInclTax = ($quantity == 0) ? 0 : $rowTotal / $quantity;
|
268 |
+
|
269 |
+
//Take discount into consideration.
|
270 |
+
$discAmount = $item->getBaseDiscountAmount();
|
271 |
+
|
272 |
+
//Since calculation is done AFTER discount, we need to add the discount (and its taxes)
|
273 |
+
//back to the price and row totals to see what the result would be before discount.
|
274 |
+
$priceInclTaxBeforeDiscount = $priceInclTax + (($discAmount + ($discAmount * $taxRate)) / $quantity);
|
275 |
+
$rowTotalBeforeDiscount = $rowTotal + $discAmount + ($discAmount * $taxRate);
|
276 |
+
$this->_totalDiscountWithTax[$item->getId()] = $discAmount * $taxRate;
|
277 |
+
|
278 |
+
// base -> default store currency
|
279 |
+
// grand -> currency store currency
|
280 |
+
// price is for single unit
|
281 |
+
$item->setPriceInclTax($store->convertPrice($priceInclTaxBeforeDiscount));
|
282 |
+
$item->setBasePriceInclTax($priceInclTaxBeforeDiscount);
|
283 |
+
|
284 |
+
// row totals are unit price * quantity
|
285 |
+
$item->setRowTotalInclTax($store->convertPrice($rowTotalBeforeDiscount));
|
286 |
+
$item->setBaseRowTotalInclTax($rowTotalBeforeDiscount);
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
*
|
291 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
292 |
+
* @param Mage_Sales_Model_Quote_Address_Item $item
|
293 |
+
* @param array $tax holds taxes
|
294 |
+
* @param Mage_Core_Model_Store $store used for currency conversion
|
295 |
+
*/
|
296 |
+
protected function saveGiftWrapTaxesForQuoteItem(&$address, &$item, $tax, $store)
|
297 |
+
{
|
298 |
+
$qTax = 0;
|
299 |
+
if (isset($tax) && $tax) {
|
300 |
+
$qTax += $tax;
|
301 |
+
$qty = $item->getQty();
|
302 |
+
$gwTaxOnBasePrice = $tax / $qty;
|
303 |
+
$item->setGwTaxAmount($store->convertPrice($gwTaxOnBasePrice));
|
304 |
+
$item->setGwBaseTaxAmount($gwTaxOnBasePrice);
|
305 |
+
}
|
306 |
+
|
307 |
+
$qTax += $address->getGwItemsBaseTaxAmount();
|
308 |
+
$address->setGwItemsTaxAmount($store->convertPrice($qTax));
|
309 |
+
$address->setGwItemsBaseTaxAmount($qTax);
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
*
|
314 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
315 |
+
* @param type $tax
|
316 |
+
* @param Mage_Core_Model_Store $store
|
317 |
+
*/
|
318 |
+
protected function saveGiftWrapTaxForQuote(&$address, $tax, $store)
|
319 |
+
{
|
320 |
+
if (isset($tax) && $tax) {
|
321 |
+
$address->setGwTaxAmount($store->convertPrice($tax));
|
322 |
+
$address->setGwBaseTaxAmount($tax);
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
*
|
328 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
329 |
+
* @param type $tax
|
330 |
+
* @param Mage_Core_Model_Store $store
|
331 |
+
*/
|
332 |
+
protected function saveGiftWrapCardTaxForQuote(&$address, $tax, &$store)
|
333 |
+
{
|
334 |
+
if (isset($tax) && $tax) {
|
335 |
+
$taxStore = $store->convertPrice($tax);
|
336 |
+
$address->setGwCardTaxAmount($taxStore);
|
337 |
+
$address->setGwCardBaseTaxAmount($tax);
|
338 |
+
$quote = $address->getQuote();
|
339 |
+
$quote->setGwCardTaxAmount($taxStore);
|
340 |
+
$quote->setGwCardBaseTaxAmount($tax);
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
346 |
+
*/
|
347 |
+
protected function saveZeroTaxes(&$address)
|
348 |
+
{
|
349 |
+
$address->setSubtotalInclTax($address->getSubtotal());
|
350 |
+
$address->setBaseSubtotalTotalInclTax($address->getBaseSubtotal());
|
351 |
+
$address->setTaxAmount(0);
|
352 |
+
$address->setBaseTaxAmount(0);
|
353 |
+
$address->setShippingTaxAmount(0);
|
354 |
+
$address->setBaseShippingTaxAmount(0);
|
355 |
+
$address->setShippingInclTax($address->getShippingAmount());
|
356 |
+
$address->setBaseShippingInclTax($address->getBaseShippingAmount());
|
357 |
+
// should be Mage_Sales_Model_Quote_Item
|
358 |
+
|
359 |
+
$isMultiShipping = $address->getQuote()->getIsMultiShipping();
|
360 |
+
if ($isMultiShipping) {
|
361 |
+
$itemArray = $address->getItemsCollection();
|
362 |
+
} else {
|
363 |
+
$itemArray = $address->getQuote()->getItemsCollection();
|
364 |
+
}
|
365 |
+
$store = $address->getQuote()->getStore();
|
366 |
+
foreach ($itemArray as $item) {
|
367 |
+
$item->setTaxAmount(0);
|
368 |
+
$item->setBaseTaxAmount(0);
|
369 |
+
// THIS isn't set correctly by magento, so convert from base
|
370 |
+
// for some reason item price appears to hold the base value
|
371 |
+
// setting price to the store currency results in Magento performing
|
372 |
+
// an extra currency conversion when viewing price excluding tax on OnePage
|
373 |
+
$item->setPriceInclTax($store->convertPrice($item->getBasePrice()));
|
374 |
+
$item->setBasePriceInclTax($item->getBasePrice());
|
375 |
+
$item->setRowTotalInclTax($item->getRowTotal());
|
376 |
+
$item->setBaseRowTotalInclTax($item->getBaseRowTotal());
|
377 |
+
$item->setTaxPercent(0.00);
|
378 |
+
}
|
379 |
+
}
|
380 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Websitestore/Config.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Website/Store configuration model.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Websitestore_Config extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->_init(WoltersKluwer_CchSureTax_Helper_Constants::WS_CONFIG_TBL);
|
15 |
+
}
|
16 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Ws/SureTaxAddress.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Represents Address XML element for SureTax web service requests.
|
4 |
+
*
|
5 |
+
* @category SureTax
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Model_Ws_SureTaxAddress
|
11 |
+
extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @var string $PrimaryAddressLine
|
17 |
+
* @access public
|
18 |
+
*/
|
19 |
+
public $PrimaryAddressLine = '';
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
* @var string $SecondaryAddressLine
|
24 |
+
* @access public
|
25 |
+
*/
|
26 |
+
public $SecondaryAddressLine = '';
|
27 |
+
|
28 |
+
/**
|
29 |
+
*
|
30 |
+
* @var string $County
|
31 |
+
* @access public
|
32 |
+
*/
|
33 |
+
public $County = null;
|
34 |
+
|
35 |
+
/**
|
36 |
+
*
|
37 |
+
* @var string $City
|
38 |
+
* @access public
|
39 |
+
*/
|
40 |
+
public $City = '';
|
41 |
+
|
42 |
+
/**
|
43 |
+
*
|
44 |
+
* @var string $State
|
45 |
+
* @access public
|
46 |
+
*/
|
47 |
+
public $State = '';
|
48 |
+
|
49 |
+
/**
|
50 |
+
*
|
51 |
+
* @var string $PostalCode
|
52 |
+
* @access public
|
53 |
+
*/
|
54 |
+
public $PostalCode = '';
|
55 |
+
|
56 |
+
/**
|
57 |
+
*
|
58 |
+
* @var string $Plus4
|
59 |
+
* @access public
|
60 |
+
*/
|
61 |
+
public $Plus4 = '';
|
62 |
+
|
63 |
+
/**
|
64 |
+
*
|
65 |
+
* @var string $Country
|
66 |
+
* @access public
|
67 |
+
*/
|
68 |
+
public $Country = '';
|
69 |
+
|
70 |
+
/**
|
71 |
+
*
|
72 |
+
* @var string $Geocode
|
73 |
+
* @access public
|
74 |
+
*/
|
75 |
+
public $Geocode = null;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* default is true
|
79 |
+
*
|
80 |
+
* @var boolean true/false
|
81 |
+
*/
|
82 |
+
public $VerifyAddress = true;
|
83 |
+
|
84 |
+
/**
|
85 |
+
*
|
86 |
+
* @param string $primaryAddressLine
|
87 |
+
* @param string $secondaryAddressLine
|
88 |
+
* @param string $county
|
89 |
+
* @param string $city
|
90 |
+
* @param string $state
|
91 |
+
* @param string $postalCode
|
92 |
+
* @param string $plus4
|
93 |
+
* @param string $country
|
94 |
+
* @param string $geocode
|
95 |
+
* @param string $verifyAddress
|
96 |
+
* @access public
|
97 |
+
*/
|
98 |
+
public function __construct(array $data)
|
99 |
+
{
|
100 |
+
$this->PrimaryAddressLine = $this->getValue($data['PrimaryAddressLine']);
|
101 |
+
$this->SecondaryAddressLine = $this->getValue($data['SecondaryAddressLine']);
|
102 |
+
$this->County = ''; //Not set
|
103 |
+
$this->City = $this->getValue($data['City']);
|
104 |
+
$this->State = $this->getValue($data['State']);
|
105 |
+
$this->PostalCode = $this->getValue($data['PostalCode']);
|
106 |
+
$this->Plus4 = $this->getValue($data['Plus4']);
|
107 |
+
$this->Country = $this->getValue($data['Country']);
|
108 |
+
$this->Geocode = ''; //Not set
|
109 |
+
$this->VerifyAddress = (empty($data['VerifyAddress'])) ? true : $data['VerifyAddress'];
|
110 |
+
}
|
111 |
+
|
112 |
+
public function _construct()
|
113 |
+
{
|
114 |
+
$this->_init('wolterskluwer_cchsuretax/ws_sureTaxAddress');
|
115 |
+
}
|
116 |
+
|
117 |
+
protected function getValue($arg)
|
118 |
+
{
|
119 |
+
// works since empty returns true if the variable is an empty string,
|
120 |
+
// false, array(), NULL, “0?, 0, and an unset variable. we are good
|
121 |
+
// with setting '' strings
|
122 |
+
return (empty($arg) ? '' : $arg);
|
123 |
+
}
|
124 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Ws/SureTaxClient.php
ADDED
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Use to call 'soap' methods, not the 'post' methods for SureTax web service
|
4 |
+
* calls
|
5 |
+
*
|
6 |
+
* uses PHP SoapClient
|
7 |
+
*
|
8 |
+
* @category SureTax
|
9 |
+
* @package WoltersKluwer_CchSureTax
|
10 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
11 |
+
*/
|
12 |
+
class WoltersKluwer_CchSureTax_Model_Ws_SureTaxClient
|
13 |
+
extends Mage_Core_Model_Abstract
|
14 |
+
{
|
15 |
+
protected $_conf; // SureTaxConfigInterface
|
16 |
+
protected $_client; // SoapClient object
|
17 |
+
|
18 |
+
public function _construct()
|
19 |
+
{
|
20 |
+
$this->_init('wolterskluwer_cchsuretax/ws_sureTaxClient');
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param WoltersKluwer_CchSureTax_Helper_Config $config
|
25 |
+
*/
|
26 |
+
public function __construct(array $data)
|
27 |
+
{
|
28 |
+
$this->_conf = $data['Config'];
|
29 |
+
$timeStart = microtime(true);
|
30 |
+
/**
|
31 |
+
* There is a known bug with some versions of Xdebug which can cause
|
32 |
+
* SoapClient to not throw an exception but instead cause a fatal error.
|
33 |
+
* Surround the SoapClient call with xdebug_disable(); and
|
34 |
+
* xdebug_enable(); to work around this problem.
|
35 |
+
*/
|
36 |
+
$this->_client = new SoapClient(
|
37 |
+
$this->_conf->getWsdlUrl(),
|
38 |
+
array(
|
39 |
+
'trace' => 1,
|
40 |
+
'exceptions' => true ,
|
41 |
+
'cache_wsdl' => $this->_conf->getWsdlCaching(),
|
42 |
+
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
if ($this->_conf->isProfiling()) {
|
47 |
+
WoltersKluwer_CchSureTax_Helper_Utility::doProfile(
|
48 |
+
$timeStart,
|
49 |
+
'SureTaxClient Construct'
|
50 |
+
);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
*
|
56 |
+
* @throws Exception
|
57 |
+
*/
|
58 |
+
public function callHealthMonitor()
|
59 |
+
{
|
60 |
+
try {
|
61 |
+
$timeStart = microtime(true);
|
62 |
+
$result = $this->_client->HealthMonitor('');
|
63 |
+
if ($this->_conf->isProfiling()) {
|
64 |
+
WoltersKluwer_CchSureTax_Helper_Utility::doProfile(
|
65 |
+
$timeStart,
|
66 |
+
'SureTax CallHealthMonitor'
|
67 |
+
);
|
68 |
+
}
|
69 |
+
$this->doLog();
|
70 |
+
return $result;
|
71 |
+
} catch(Exception $ere){
|
72 |
+
$this->logCatch($ere);
|
73 |
+
throw $ere;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
*
|
79 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxRequest $requestData
|
80 |
+
*
|
81 |
+
* @return type
|
82 |
+
* @throws Exception
|
83 |
+
*/
|
84 |
+
public function callSoapRequest($requestData)
|
85 |
+
{
|
86 |
+
try {
|
87 |
+
$timeStart = microtime(true);
|
88 |
+
$result = $this->_client->SoapRequest(
|
89 |
+
array('request' => $requestData)
|
90 |
+
);
|
91 |
+
if ($this->_conf->isProfiling()) {
|
92 |
+
WoltersKluwer_CchSureTax_Helper_Utility::doProfile(
|
93 |
+
$timeStart,
|
94 |
+
'SureTax CallSoapRequest'
|
95 |
+
);
|
96 |
+
}
|
97 |
+
$this->doLog();
|
98 |
+
return $result;
|
99 |
+
} catch (Exception $ere) {
|
100 |
+
$this->logCatch($ere);
|
101 |
+
throw $ere;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
*
|
107 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_TaxAdjustmentRequest $requestData
|
108 |
+
* @return type
|
109 |
+
* @throws Exception
|
110 |
+
*/
|
111 |
+
public function callTaxAdjustmentRequest($requestData)
|
112 |
+
{
|
113 |
+
try {
|
114 |
+
$timeStart = microtime(true);
|
115 |
+
|
116 |
+
$this->logRequest();
|
117 |
+
$result = $this->_client->SoapTaxAdjustmentRequest(
|
118 |
+
array('request' => $requestData)
|
119 |
+
);
|
120 |
+
if ($this->_conf->isProfiling()) {
|
121 |
+
WoltersKluwer_CchSureTax_Helper_Utility::doProfile(
|
122 |
+
$timeStart,
|
123 |
+
'SureTax CallSoapTaxAdjustmentRequest'
|
124 |
+
);
|
125 |
+
}
|
126 |
+
$this->doLog();
|
127 |
+
return $result;
|
128 |
+
} catch (Exception $ere) {
|
129 |
+
$this->logRequest();
|
130 |
+
$this->logCatch($ere);
|
131 |
+
throw $ere;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @param array $requestDataArray array of SureTaxRequest
|
137 |
+
*
|
138 |
+
* @return type
|
139 |
+
* @throws Exception
|
140 |
+
*/
|
141 |
+
public function callSoapRequestBatch($requestDataArray)
|
142 |
+
{
|
143 |
+
try {
|
144 |
+
$timeStart = microtime(true);
|
145 |
+
$result = $this->_client->SoapRequestBatch(
|
146 |
+
array('requests' => $requestDataArray)
|
147 |
+
);
|
148 |
+
if ($this->_conf->isProfiling()) {
|
149 |
+
WoltersKluwer_CchSureTax_Helper_Utility::doProfile(
|
150 |
+
$timeStart,
|
151 |
+
'SureTax callSoapRequestBatch'
|
152 |
+
);
|
153 |
+
}
|
154 |
+
$this->doLog();
|
155 |
+
return $result;
|
156 |
+
} catch (Exception $ere) {
|
157 |
+
$this->logCatch($ere);
|
158 |
+
throw $ere;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @param int $theId
|
164 |
+
* @param string $clientTracking
|
165 |
+
*
|
166 |
+
* @return type
|
167 |
+
* @throws Exception
|
168 |
+
*/
|
169 |
+
public function callCancelSoapRequest($theId, $clientTracking)
|
170 |
+
{
|
171 |
+
$theR=
|
172 |
+
array('requestCancel'
|
173 |
+
=>array(
|
174 |
+
'ClientNumber'=>$this->_conf->getClientNumber(),
|
175 |
+
'ValidationKey'=>$this->_conf->getValidationKey(),
|
176 |
+
'ClientTracking'=>$clientTracking,
|
177 |
+
'TransId'=>$theId
|
178 |
+
)
|
179 |
+
);
|
180 |
+
try {
|
181 |
+
$timeStart = microtime(true);
|
182 |
+
$result = $this->_client->CancelSoapRequest($theR);
|
183 |
+
if ($this->_conf->isProfiling()) {
|
184 |
+
WoltersKluwer_CchSureTax_Helper_Utility::doProfile(
|
185 |
+
$timeStart,
|
186 |
+
'SureTax callCancelSoapRequest'
|
187 |
+
);
|
188 |
+
}
|
189 |
+
$this->doLog();
|
190 |
+
return $result;
|
191 |
+
} catch (Exception $ere){
|
192 |
+
$this->logCatch($ere);
|
193 |
+
throw $ere;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* @param string $masterTransId
|
199 |
+
* @param string $clientTracking
|
200 |
+
*
|
201 |
+
* @return type
|
202 |
+
* @throws Exception
|
203 |
+
*/
|
204 |
+
public function callCancelSoapRequestWithMasterTransId($masterTransId,
|
205 |
+
$clientTracking)
|
206 |
+
{
|
207 |
+
$theR=
|
208 |
+
array('requestCancelWithMasterTransId'
|
209 |
+
=>array(
|
210 |
+
'ClientNumber'=>$this->_conf->getClientNumber(),
|
211 |
+
'ValidationKey'=>$this->_conf->getValidationKey(),
|
212 |
+
'ClientTracking'=>$clientTracking,
|
213 |
+
'MasterTransId'=>$masterTransId
|
214 |
+
)
|
215 |
+
);
|
216 |
+
try {
|
217 |
+
$timeStart = microtime(true);
|
218 |
+
$result = $this->_client->CancelSoapRequestWithMasterTransId($theR);
|
219 |
+
if ($this->_conf->isProfiling()) {
|
220 |
+
WoltersKluwer_CchSureTax_Helper_Utility::doProfile(
|
221 |
+
$timeStart,
|
222 |
+
'SureTax callCancelSoapRequestWithMasterTransId'
|
223 |
+
);
|
224 |
+
}
|
225 |
+
$this->doLog();
|
226 |
+
return $result;
|
227 |
+
}catch(Exception $ere){
|
228 |
+
$this->logCatch($ere);
|
229 |
+
throw $ere;
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* @param string $stan
|
235 |
+
* @param string $clientTracking
|
236 |
+
*
|
237 |
+
* @return type
|
238 |
+
* @throws Exception
|
239 |
+
*/
|
240 |
+
public function callCancelSoapRequestWithSTAN($stan, $clientTracking)
|
241 |
+
{
|
242 |
+
$theR=
|
243 |
+
array('requestCancelWithSTAN'
|
244 |
+
=>array(
|
245 |
+
'ClientNumber'=>$this->_conf->getClientNumber(),
|
246 |
+
'ValidationKey'=>$this->_conf->getValidationKey(),
|
247 |
+
'ClientTracking'=>$clientTracking,
|
248 |
+
'STAN'=>$stan
|
249 |
+
)
|
250 |
+
);
|
251 |
+
try {
|
252 |
+
$timeStart = microtime(true);
|
253 |
+
$result = $this->_client->CancelSoapRequestWithSTAN($theR);
|
254 |
+
if ($this->_conf->isProfiling()) {
|
255 |
+
WoltersKluwer_CchSureTax_Helper_Utility::doProfile(
|
256 |
+
$timeStart,
|
257 |
+
'SureTax callCancelSoapRequestWithSTAN'
|
258 |
+
);
|
259 |
+
}
|
260 |
+
$this->doLog();
|
261 |
+
return $result;
|
262 |
+
}catch(Exception $ere){
|
263 |
+
$this->logCatch($ere);
|
264 |
+
throw $ere;
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* @param Exception $ex
|
270 |
+
*/
|
271 |
+
protected function logCatch($ex)
|
272 |
+
{
|
273 |
+
WoltersKluwer_CchSureTax_Helper_Utility::log(
|
274 |
+
'SureTaxClient LogCatch: ' .
|
275 |
+
$ex->getMessage() . '::TRACE::' . $ex->getTraceAsString(),
|
276 |
+
Zend_Log::ERR, true
|
277 |
+
);
|
278 |
+
}
|
279 |
+
|
280 |
+
protected function doLog()
|
281 |
+
{
|
282 |
+
$this->logRequest();
|
283 |
+
$this->logResponse();
|
284 |
+
}
|
285 |
+
|
286 |
+
protected function logRequest()
|
287 |
+
{
|
288 |
+
if ($this->_conf->isDebug() == true) {
|
289 |
+
WoltersKluwer_CchSureTax_Helper_Utility::log(
|
290 |
+
"SureTax SOAP Request: " . $this->_client->__getLastRequest(),
|
291 |
+
Zend_Log::DEBUG, $this->_conf->isDebug()
|
292 |
+
);
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
protected function logResponse()
|
297 |
+
{
|
298 |
+
if ($this->_conf->isDebug() == true) {
|
299 |
+
WoltersKluwer_CchSureTax_Helper_Utility::log(
|
300 |
+
"SureTax SOAP Response: " . $this->_client->__getLastResponse(),
|
301 |
+
Zend_Log::DEBUG, $this->_conf->isDebug()
|
302 |
+
);
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Ws/SureTaxItem.php
ADDED
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Represents item XML for SureTax web service requests.
|
4 |
+
*
|
5 |
+
* @category SureTax
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
class WoltersKluwer_CchSureTax_Model_Ws_SureTaxItem
|
10 |
+
extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
* @var string $LineNumber
|
15 |
+
* @access public
|
16 |
+
*/
|
17 |
+
public $LineNumber = null;
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @var string $InvoiceNumber
|
22 |
+
* @access public
|
23 |
+
*/
|
24 |
+
public $InvoiceNumber = null;
|
25 |
+
|
26 |
+
/**
|
27 |
+
*
|
28 |
+
* @var string $CustomerNumber
|
29 |
+
* @access public
|
30 |
+
*/
|
31 |
+
public $CustomerNumber = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @var string $LocationCode
|
36 |
+
* @access public
|
37 |
+
*/
|
38 |
+
public $LocationCode = null;
|
39 |
+
|
40 |
+
/**
|
41 |
+
*
|
42 |
+
* @var string $BillToNumber
|
43 |
+
* @access public
|
44 |
+
*/
|
45 |
+
public $BillToNumber = null;
|
46 |
+
|
47 |
+
/**
|
48 |
+
*
|
49 |
+
* @var string $OrigNumber
|
50 |
+
* @access public
|
51 |
+
*/
|
52 |
+
public $OrigNumber = null;
|
53 |
+
|
54 |
+
/**
|
55 |
+
*
|
56 |
+
* @var string $TermNumber
|
57 |
+
* @access public
|
58 |
+
*/
|
59 |
+
public $TermNumber = null;
|
60 |
+
|
61 |
+
/**
|
62 |
+
*
|
63 |
+
* @var string $TransDate
|
64 |
+
* @access public
|
65 |
+
*/
|
66 |
+
public $TransDate = null;
|
67 |
+
|
68 |
+
/**
|
69 |
+
*
|
70 |
+
* @var float $Revenue
|
71 |
+
* @access public
|
72 |
+
*/
|
73 |
+
public $Revenue = null;
|
74 |
+
|
75 |
+
/**
|
76 |
+
*
|
77 |
+
* @var string $TaxIncludedCode
|
78 |
+
* @access public
|
79 |
+
*/
|
80 |
+
public $TaxIncludedCode = null;
|
81 |
+
|
82 |
+
/**
|
83 |
+
*
|
84 |
+
* @var float $Units
|
85 |
+
* @access public
|
86 |
+
*/
|
87 |
+
public $Units = null;
|
88 |
+
|
89 |
+
/**
|
90 |
+
*
|
91 |
+
* @var string $UnitType
|
92 |
+
* @access public
|
93 |
+
*/
|
94 |
+
public $UnitType = null;
|
95 |
+
|
96 |
+
/**
|
97 |
+
*
|
98 |
+
* @var int $Seconds
|
99 |
+
* @access public
|
100 |
+
*/
|
101 |
+
public $Seconds = null;
|
102 |
+
|
103 |
+
/**
|
104 |
+
*
|
105 |
+
* @var string $TaxSitusRule
|
106 |
+
* @access public
|
107 |
+
*/
|
108 |
+
public $TaxSitusRule = null;
|
109 |
+
|
110 |
+
/**
|
111 |
+
* for current version, all API calls expected to be in USD due to use of
|
112 |
+
* base currency
|
113 |
+
*
|
114 |
+
* @var string $CurrencyCode
|
115 |
+
* @access public
|
116 |
+
*/
|
117 |
+
public $CurrencyCode = 'USD';
|
118 |
+
|
119 |
+
/**
|
120 |
+
* not used
|
121 |
+
*
|
122 |
+
* @var string $TaxSitusOverrideCode
|
123 |
+
* @access public
|
124 |
+
*/
|
125 |
+
// public $TaxSitusOverrideCode = null;
|
126 |
+
|
127 |
+
/**
|
128 |
+
* SureTax TransTypeCode OR Magento Product Tax Class
|
129 |
+
*
|
130 |
+
* @var string $TransTypeCode
|
131 |
+
* @access public
|
132 |
+
*/
|
133 |
+
public $TransTypeCode = null;
|
134 |
+
|
135 |
+
/**
|
136 |
+
*
|
137 |
+
* @var string $SalesTypeCode
|
138 |
+
* @access public
|
139 |
+
*/
|
140 |
+
public $SalesTypeCode = null;
|
141 |
+
|
142 |
+
/**
|
143 |
+
*
|
144 |
+
* @var string $RegulatoryCode
|
145 |
+
* @access public
|
146 |
+
*/
|
147 |
+
public $RegulatoryCode = null;
|
148 |
+
|
149 |
+
/**
|
150 |
+
*
|
151 |
+
* @var String[] $TaxExemptionCodeList
|
152 |
+
* @access public
|
153 |
+
*/
|
154 |
+
public $TaxExemptionCodeList = null;
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Hold's magento 'SKU' info for products
|
158 |
+
*
|
159 |
+
* @var string $UDF
|
160 |
+
* @access public
|
161 |
+
*/
|
162 |
+
public $UDF = '';
|
163 |
+
|
164 |
+
/**
|
165 |
+
* set system info for system support
|
166 |
+
*
|
167 |
+
* @var string $UDF2
|
168 |
+
* @access public
|
169 |
+
*/
|
170 |
+
public $UDF2 = '';
|
171 |
+
|
172 |
+
/**
|
173 |
+
* not used
|
174 |
+
*
|
175 |
+
* @var string $FreightOnBoard
|
176 |
+
* @access public
|
177 |
+
*/
|
178 |
+
// public $FreightOnBoard = null;
|
179 |
+
|
180 |
+
/**
|
181 |
+
* do not change.
|
182 |
+
*
|
183 |
+
* @var boolean Always true (1 = default/yes)
|
184 |
+
* @access public
|
185 |
+
*/
|
186 |
+
public $ShipFromPOB = 1;
|
187 |
+
|
188 |
+
/**
|
189 |
+
* do not change
|
190 |
+
*
|
191 |
+
* @var boolean $MailOrder Always 1.
|
192 |
+
* @access public
|
193 |
+
*/
|
194 |
+
public $MailOrder = 1;
|
195 |
+
|
196 |
+
/**
|
197 |
+
*
|
198 |
+
* @var boolean $CommonCarrier Always 1
|
199 |
+
* @access public
|
200 |
+
*/
|
201 |
+
public $CommonCarrier = 1;
|
202 |
+
|
203 |
+
/**
|
204 |
+
* don't use for gen sales
|
205 |
+
*
|
206 |
+
* @var string $OriginCountryCode
|
207 |
+
* @access public
|
208 |
+
*/
|
209 |
+
// public $OriginCountryCode = null;
|
210 |
+
|
211 |
+
/**
|
212 |
+
*
|
213 |
+
* @var string $DestCountryCode
|
214 |
+
* @access public
|
215 |
+
*/
|
216 |
+
// public $DestCountryCode = null;
|
217 |
+
|
218 |
+
/**
|
219 |
+
*
|
220 |
+
* @var float $AuxRevenue Always 0
|
221 |
+
* @access public
|
222 |
+
*/
|
223 |
+
public $AuxRevenue = 0;
|
224 |
+
|
225 |
+
/**
|
226 |
+
*
|
227 |
+
* @var string $AuxRevenueType Always 01.
|
228 |
+
* @access public
|
229 |
+
*/
|
230 |
+
public $AuxRevenueType = '01';
|
231 |
+
|
232 |
+
/**
|
233 |
+
*
|
234 |
+
* @var int $BillingDaysInPeriod
|
235 |
+
* @access public
|
236 |
+
*/
|
237 |
+
public $BillingDaysInPeriod = '';
|
238 |
+
|
239 |
+
/**
|
240 |
+
*
|
241 |
+
* @var string $CostCenter
|
242 |
+
* @access public
|
243 |
+
*/
|
244 |
+
public $CostCenter = null;
|
245 |
+
|
246 |
+
/**
|
247 |
+
*
|
248 |
+
* @var string $GLAccount
|
249 |
+
* @access public
|
250 |
+
*/
|
251 |
+
public $GLAccount = null;
|
252 |
+
|
253 |
+
/**
|
254 |
+
*
|
255 |
+
* @var string $MaterialGroup
|
256 |
+
* @access public
|
257 |
+
*/
|
258 |
+
// public $MaterialGroup = null;
|
259 |
+
|
260 |
+
// /**
|
261 |
+
// *
|
262 |
+
// * @var string $Parameter1
|
263 |
+
// * @access public
|
264 |
+
// */
|
265 |
+
// public $Parameter1 = null;
|
266 |
+
//
|
267 |
+
|
268 |
+
/**
|
269 |
+
*
|
270 |
+
* @var string $ExemptReasonCode
|
271 |
+
* @access public
|
272 |
+
*/
|
273 |
+
public $ExemptReasonCode = null;
|
274 |
+
|
275 |
+
/**
|
276 |
+
*
|
277 |
+
* @var WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $BillingAddress
|
278 |
+
* @access public
|
279 |
+
*/
|
280 |
+
public $BillingAddress = null;
|
281 |
+
|
282 |
+
// /**
|
283 |
+
// *
|
284 |
+
// * @var SureTaxAddress $P2PAddress
|
285 |
+
// * @access public
|
286 |
+
// */
|
287 |
+
// public $P2PAddress = null;
|
288 |
+
|
289 |
+
/**
|
290 |
+
*
|
291 |
+
* @var WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $ShipToAddress
|
292 |
+
* @access public
|
293 |
+
*/
|
294 |
+
public $ShipToAddress = null;
|
295 |
+
|
296 |
+
/**
|
297 |
+
*
|
298 |
+
* @var WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $ShipFromAddress
|
299 |
+
* @access public
|
300 |
+
*/
|
301 |
+
public $ShipFromAddress = null;
|
302 |
+
|
303 |
+
/**
|
304 |
+
* @param array $data
|
305 |
+
* @param string $data['LineNumber']
|
306 |
+
* @param string $data['InvoiceNumber']
|
307 |
+
* @param string $data['CustomerNumber']
|
308 |
+
* @param string $data['LocationCode']
|
309 |
+
* @param string $data['BillToNumber']
|
310 |
+
* @param string $data['OrigNumber']
|
311 |
+
* @param string $data['TermNumber']
|
312 |
+
* @param string $data['TransDate']
|
313 |
+
* @param float $data['Revenue']
|
314 |
+
* @param string $data['TaxIncludedCode']
|
315 |
+
* @param float $data['Units']
|
316 |
+
* @param string $data['UnitType']
|
317 |
+
* @param string $data['TaxSitusRule']
|
318 |
+
* @param string $data['TransTypeCode']
|
319 |
+
* @param string $data['SalesTypeCode']
|
320 |
+
* @param string $data['RegulatoryCode']
|
321 |
+
* @param String[] $data['TaxExemptionCodeList']
|
322 |
+
* @param string $data['CostCenter']
|
323 |
+
* @param string $data['GLAccount']
|
324 |
+
* @param string $data['ExemptReasonCode']
|
325 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $data['BillingAddress']
|
326 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $data['ShipToAddress']
|
327 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $data['ShipFromAddress']
|
328 |
+
* @param string $data['UDF']
|
329 |
+
* @access public
|
330 |
+
*/
|
331 |
+
public function __construct(array $data)
|
332 |
+
{
|
333 |
+
$this->LineNumber = $data['LineNumber'];
|
334 |
+
$this->InvoiceNumber = $data['InvoiceNumber'];
|
335 |
+
$this->CustomerNumber = $data['CustomerNumber'];
|
336 |
+
$this->LocationCode = $data['LocationCode'];
|
337 |
+
$this->BillToNumber = $data['BillToNumber'];
|
338 |
+
$this->OrigNumber = $data['OrigNumber'];
|
339 |
+
$this->TermNumber = $data['TermNumber'];
|
340 |
+
$this->TransDate = $data['TransDate'];
|
341 |
+
$this->Revenue = $data['Revenue'];
|
342 |
+
$this->TaxIncludedCode = $data['TaxIncludedCode'];
|
343 |
+
$this->Units = $data['Units'];
|
344 |
+
$this->UnitType = $data['UnitType'];
|
345 |
+
$this->Seconds = 0;
|
346 |
+
$this->TaxSitusRule = $data['TaxSitusRule'];
|
347 |
+
$this->TransTypeCode = $data['TransTypeCode'];
|
348 |
+
$this->SalesTypeCode = $data['SalesTypeCode'];
|
349 |
+
$this->RegulatoryCode = $data['RegulatoryCode'];
|
350 |
+
$this->TaxExemptionCodeList = $data['TaxExemptionCodeList'];
|
351 |
+
$this->CostCenter = $data['CostCenter'];
|
352 |
+
$this->GLAccount = $data['GLAccount'];
|
353 |
+
$this->ExemptReasonCode = $data['ExemptReasonCode'];
|
354 |
+
//$this->BillingAddress = $data['BillingAddress'];
|
355 |
+
//$this->ShipToAddress = $data['ShipToAddress'];
|
356 |
+
//$this->ShipFromAddress = $data['ShipFromAddress'];
|
357 |
+
$this->UDF = $data['UDF']; // holds 'SKU'
|
358 |
+
$this->UDF2 = WoltersKluwer_CchSureTax_Helper_Utility::getVersionString();
|
359 |
+
}
|
360 |
+
|
361 |
+
public function _construct()
|
362 |
+
{
|
363 |
+
$this->_init('wolterskluwer_cchsuretax/ws_sureTaxItem');
|
364 |
+
}
|
365 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Ws/SureTaxRequest.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Represents Request XML for SureTax web service requests.
|
4 |
+
*
|
5 |
+
* @category SureTax
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
class WoltersKluwer_CchSureTax_Model_Ws_SureTaxRequest
|
10 |
+
extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @var string $ClientNumber
|
16 |
+
* @access public
|
17 |
+
*/
|
18 |
+
public $ClientNumber = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* @var string $BusinessUnit
|
23 |
+
* @access public
|
24 |
+
*/
|
25 |
+
public $BusinessUnit = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* @var string $ValidationKey
|
30 |
+
* @access public
|
31 |
+
*/
|
32 |
+
public $ValidationKey = null;
|
33 |
+
|
34 |
+
/**
|
35 |
+
*
|
36 |
+
* @var string $DataYear
|
37 |
+
* @access public
|
38 |
+
*/
|
39 |
+
public $DataYear = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @var string $DataMonth
|
44 |
+
* @access public
|
45 |
+
*/
|
46 |
+
public $DataMonth = null;
|
47 |
+
|
48 |
+
/**
|
49 |
+
*
|
50 |
+
* @var string $CmplDataYear
|
51 |
+
* @access public
|
52 |
+
*/
|
53 |
+
public $CmplDataYear = null;
|
54 |
+
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
* @var string $CmplDataMonth
|
58 |
+
* @access public
|
59 |
+
*/
|
60 |
+
public $CmplDataMonth = null;
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @var float $TotalRevenue
|
65 |
+
* @access public
|
66 |
+
*/
|
67 |
+
public $TotalRevenue = null;
|
68 |
+
|
69 |
+
/**
|
70 |
+
*
|
71 |
+
* @var string $ClientTracking
|
72 |
+
* @access public
|
73 |
+
*/
|
74 |
+
public $ClientTracking = null;
|
75 |
+
|
76 |
+
/**
|
77 |
+
*
|
78 |
+
* @var string $ResponseType
|
79 |
+
* @access public
|
80 |
+
*/
|
81 |
+
public $ResponseType = null;
|
82 |
+
|
83 |
+
/**
|
84 |
+
*
|
85 |
+
* @var string $ResponseGroup
|
86 |
+
* @access public
|
87 |
+
*/
|
88 |
+
public $ResponseGroup = null;
|
89 |
+
|
90 |
+
/**
|
91 |
+
*
|
92 |
+
* @var string $ReturnFileCode
|
93 |
+
* @access public
|
94 |
+
*/
|
95 |
+
public $ReturnFileCode = null;
|
96 |
+
|
97 |
+
/**
|
98 |
+
*
|
99 |
+
* @var string $STAN
|
100 |
+
* @access public
|
101 |
+
*/
|
102 |
+
public $STAN = null;
|
103 |
+
|
104 |
+
/**
|
105 |
+
*
|
106 |
+
* @var int $MasterTransId
|
107 |
+
* @access public
|
108 |
+
*/
|
109 |
+
public $MasterTransId = null;
|
110 |
+
|
111 |
+
/**
|
112 |
+
*
|
113 |
+
* @var WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $BillingAddress
|
114 |
+
* @access public
|
115 |
+
*/
|
116 |
+
// public $BillingAddress = null;
|
117 |
+
|
118 |
+
/**
|
119 |
+
*
|
120 |
+
* @var WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $ShipToAddress
|
121 |
+
* @access public
|
122 |
+
*/
|
123 |
+
public $ShipToAddress = null;
|
124 |
+
|
125 |
+
/**
|
126 |
+
*
|
127 |
+
* @var WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $ShipFromAddress
|
128 |
+
* @access public
|
129 |
+
*/
|
130 |
+
public $ShipFromAddress = null;
|
131 |
+
|
132 |
+
/**
|
133 |
+
*
|
134 |
+
* @var WoltersKluwer_CchSureTax_Helper_Ws_SureTaxItem[] $ItemList
|
135 |
+
* @access public
|
136 |
+
*/
|
137 |
+
public $ItemList = null;
|
138 |
+
|
139 |
+
/**
|
140 |
+
*
|
141 |
+
* @param string $clientNumber
|
142 |
+
* @param string $businessUnit
|
143 |
+
* @param string $validationKey
|
144 |
+
* @param string $dataYear
|
145 |
+
* @param string $dataMonth
|
146 |
+
* @param string $cmplDataYear
|
147 |
+
* @param string $cmplDataMonth
|
148 |
+
* @param float $totalRevenue
|
149 |
+
* @param string $clientTracking
|
150 |
+
* @param string $responseType
|
151 |
+
* @param string $responseGroup
|
152 |
+
* @param string $returnFileCode
|
153 |
+
* @param string $stan
|
154 |
+
* @param int $masterTransId
|
155 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $billingAddress
|
156 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $shipToAddress
|
157 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxAddress $shipFromAddress
|
158 |
+
* @param WoltersKluwer_CchSureTax_Helper_Ws_SureTaxItem[] $itemList
|
159 |
+
* @access public
|
160 |
+
*/
|
161 |
+
public function __construct(array $data)
|
162 |
+
{
|
163 |
+
$this->ClientNumber = $data['ClientNumber'];
|
164 |
+
$this->BusinessUnit =
|
165 |
+
(!isset($data['BusinessUnit']) || $data['BusinessUnit'] === null)
|
166 |
+
? '' : $data['BusinessUnit'];
|
167 |
+
$this->ValidationKey = $data['ValidationKey'];
|
168 |
+
$this->DataYear = $data['DataYear'];
|
169 |
+
$this->DataMonth = $data['DataMonth'];
|
170 |
+
$this->CmplDataYear = $data['CmplDataYear'];
|
171 |
+
$this->CmplDataMonth = $data['CmplDataMonth'];
|
172 |
+
$this->TotalRevenue = $data['TotalRevenue'];
|
173 |
+
$this->ClientTracking = $data['ClientTracking'];
|
174 |
+
$this->ResponseType = $data['ResponseType'];
|
175 |
+
$this->ResponseGroup = $data['ResponseGroup'];
|
176 |
+
$this->ReturnFileCode = $data['ReturnFileCode'];
|
177 |
+
$this->STAN = $data['STAN'];
|
178 |
+
$this->MasterTransId = $data['MasterTransId'];
|
179 |
+
$this->ShipToAddress = $data['ShipToAddress'];
|
180 |
+
$this->ShipFromAddress = $data['ShipFromAddress'];
|
181 |
+
$this->ItemList = $data['ItemList'];
|
182 |
+
}
|
183 |
+
|
184 |
+
public function _construct()
|
185 |
+
{
|
186 |
+
$this->_init('wolterskluwer_cchsuretax/ws_sureTaxRequest');
|
187 |
+
}
|
188 |
+
|
189 |
+
public function getItemList()
|
190 |
+
{
|
191 |
+
return $this->ItemList;
|
192 |
+
}
|
193 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Ws/TaxAdjustmentItem.php
ADDED
@@ -0,0 +1,467 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Represents tax adjustment item XML for SureTax web service requests.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
class WoltersKluwer_CchSureTax_Model_Ws_TaxAdjustmentItem
|
10 |
+
extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @var string $LineNumber
|
16 |
+
* @access public
|
17 |
+
*/
|
18 |
+
public $LineNumber = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* @var string $InvoiceNumber
|
23 |
+
* @access public
|
24 |
+
*/
|
25 |
+
public $InvoiceNumber = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* @var string $CustomerNumber
|
30 |
+
* @access public
|
31 |
+
*/
|
32 |
+
public $CustomerNumber = null;
|
33 |
+
|
34 |
+
/**
|
35 |
+
*
|
36 |
+
* @var string $LocationCode
|
37 |
+
* @access public
|
38 |
+
*/
|
39 |
+
public $LocationCode = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @var string $BillToNumber
|
44 |
+
* @access public
|
45 |
+
*/
|
46 |
+
public $BillToNumber = null;
|
47 |
+
|
48 |
+
/**
|
49 |
+
*
|
50 |
+
* @var string $OrigNumber
|
51 |
+
* @access public
|
52 |
+
*/
|
53 |
+
public $OrigNumber = null;
|
54 |
+
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
* @var string $TermNumber
|
58 |
+
* @access public
|
59 |
+
*/
|
60 |
+
public $TermNumber = null;
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @var string $TransDate
|
65 |
+
* @access public
|
66 |
+
*/
|
67 |
+
public $TransDate = null;
|
68 |
+
|
69 |
+
/**
|
70 |
+
*
|
71 |
+
* @var string $BillingPeriodStartDate
|
72 |
+
* @access public
|
73 |
+
*/
|
74 |
+
public $BillingPeriodStartDate = null;
|
75 |
+
|
76 |
+
/**
|
77 |
+
*
|
78 |
+
* @var string $BillingPeriodEndDate
|
79 |
+
* @access public
|
80 |
+
*/
|
81 |
+
public $BillingPeriodEndDate = null;
|
82 |
+
|
83 |
+
/**
|
84 |
+
*
|
85 |
+
* @var float $Revenue
|
86 |
+
* @access public
|
87 |
+
*/
|
88 |
+
public $Revenue = null;
|
89 |
+
|
90 |
+
/**
|
91 |
+
*
|
92 |
+
* @var float $Tax
|
93 |
+
* @access public
|
94 |
+
*/
|
95 |
+
public $Tax = null;
|
96 |
+
|
97 |
+
/**
|
98 |
+
*
|
99 |
+
* @var float $Units
|
100 |
+
* @access public
|
101 |
+
*/
|
102 |
+
public $Units = null;
|
103 |
+
|
104 |
+
/**
|
105 |
+
*
|
106 |
+
* @var string $UnitType
|
107 |
+
* @access public
|
108 |
+
*/
|
109 |
+
public $UnitType = null;
|
110 |
+
|
111 |
+
/**
|
112 |
+
*
|
113 |
+
* @var string $TaxSitusRule
|
114 |
+
* @access public
|
115 |
+
*/
|
116 |
+
public $TaxSitusRule = null;
|
117 |
+
|
118 |
+
/**
|
119 |
+
*
|
120 |
+
* @var string $TaxSitusOverrideCode
|
121 |
+
* @access public
|
122 |
+
*/
|
123 |
+
public $TaxSitusOverrideCode = null;
|
124 |
+
|
125 |
+
/**
|
126 |
+
*
|
127 |
+
* @var string $TransTypeCode
|
128 |
+
* @access public
|
129 |
+
*/
|
130 |
+
public $TransTypeCode = null;
|
131 |
+
|
132 |
+
/**
|
133 |
+
*
|
134 |
+
* @var string $SalesTypeCode
|
135 |
+
* @access public
|
136 |
+
*/
|
137 |
+
public $SalesTypeCode = null;
|
138 |
+
|
139 |
+
/**
|
140 |
+
*
|
141 |
+
* @var string $RegulatoryCode
|
142 |
+
* @access public
|
143 |
+
*/
|
144 |
+
public $RegulatoryCode = null;
|
145 |
+
|
146 |
+
/**
|
147 |
+
*
|
148 |
+
* @var String[] $TaxExemptionCodeList
|
149 |
+
* @access public
|
150 |
+
*/
|
151 |
+
public $TaxExemptionCodeList = null;
|
152 |
+
|
153 |
+
/**
|
154 |
+
*
|
155 |
+
* @var string $UDF
|
156 |
+
* @access public
|
157 |
+
*/
|
158 |
+
public $UDF = null;
|
159 |
+
|
160 |
+
/**
|
161 |
+
*
|
162 |
+
* @var string $UDF2
|
163 |
+
* @access public
|
164 |
+
*/
|
165 |
+
public $UDF2 = null;
|
166 |
+
|
167 |
+
/**
|
168 |
+
*
|
169 |
+
* @var string $FreightOnBoard
|
170 |
+
* @access public
|
171 |
+
*/
|
172 |
+
public $FreightOnBoard = null;
|
173 |
+
|
174 |
+
/**
|
175 |
+
*
|
176 |
+
* @var boolean $ShipFromPOB
|
177 |
+
* @access public
|
178 |
+
*/
|
179 |
+
public $ShipFromPOB = null;
|
180 |
+
|
181 |
+
/**
|
182 |
+
*
|
183 |
+
* @var boolean $MailOrder
|
184 |
+
* @access public
|
185 |
+
*/
|
186 |
+
public $MailOrder = null;
|
187 |
+
|
188 |
+
/**
|
189 |
+
*
|
190 |
+
* @var boolean $CommonCarrier
|
191 |
+
* @access public
|
192 |
+
*/
|
193 |
+
public $CommonCarrier = null;
|
194 |
+
|
195 |
+
/**
|
196 |
+
*
|
197 |
+
* @var string $OriginCountryCode
|
198 |
+
* @access public
|
199 |
+
*/
|
200 |
+
public $OriginCountryCode = null;
|
201 |
+
|
202 |
+
/**
|
203 |
+
*
|
204 |
+
* @var string $DestCountryCode
|
205 |
+
* @access public
|
206 |
+
*/
|
207 |
+
public $DestCountryCode = null;
|
208 |
+
|
209 |
+
/**
|
210 |
+
*
|
211 |
+
* @var int $BillingDaysInPeriod
|
212 |
+
* @access public
|
213 |
+
*/
|
214 |
+
public $BillingDaysInPeriod = null;
|
215 |
+
|
216 |
+
/**
|
217 |
+
*
|
218 |
+
* @var string $CostCenter
|
219 |
+
* @access public
|
220 |
+
*/
|
221 |
+
public $CostCenter = null;
|
222 |
+
|
223 |
+
/**
|
224 |
+
*
|
225 |
+
* @var string $GLAccount
|
226 |
+
* @access public
|
227 |
+
*/
|
228 |
+
public $GLAccount = null;
|
229 |
+
|
230 |
+
/**
|
231 |
+
*
|
232 |
+
* @var string $MaterialGroup
|
233 |
+
* @access public
|
234 |
+
*/
|
235 |
+
public $MaterialGroup = null;
|
236 |
+
|
237 |
+
/**
|
238 |
+
*
|
239 |
+
* @var string $Parameter1
|
240 |
+
* @access public
|
241 |
+
*/
|
242 |
+
public $Parameter1 = null;
|
243 |
+
|
244 |
+
/**
|
245 |
+
*
|
246 |
+
* @var string $Parameter2
|
247 |
+
* @access public
|
248 |
+
*/
|
249 |
+
public $Parameter2 = null;
|
250 |
+
|
251 |
+
/**
|
252 |
+
*
|
253 |
+
* @var string $Parameter3
|
254 |
+
* @access public
|
255 |
+
*/
|
256 |
+
public $Parameter3 = null;
|
257 |
+
|
258 |
+
/**
|
259 |
+
*
|
260 |
+
* @var string $Parameter4
|
261 |
+
* @access public
|
262 |
+
*/
|
263 |
+
public $Parameter4 = null;
|
264 |
+
|
265 |
+
/**
|
266 |
+
*
|
267 |
+
* @var string $Parameter5
|
268 |
+
* @access public
|
269 |
+
*/
|
270 |
+
public $Parameter5 = null;
|
271 |
+
|
272 |
+
/**
|
273 |
+
*
|
274 |
+
* @var string $Parameter6
|
275 |
+
* @access public
|
276 |
+
*/
|
277 |
+
public $Parameter6 = null;
|
278 |
+
|
279 |
+
/**
|
280 |
+
*
|
281 |
+
* @var string $Parameter7
|
282 |
+
* @access public
|
283 |
+
*/
|
284 |
+
public $Parameter7 = null;
|
285 |
+
|
286 |
+
/**
|
287 |
+
*
|
288 |
+
* @var string $Parameter8
|
289 |
+
* @access public
|
290 |
+
*/
|
291 |
+
public $Parameter8 = null;
|
292 |
+
|
293 |
+
/**
|
294 |
+
*
|
295 |
+
* @var string $Parameter9
|
296 |
+
* @access public
|
297 |
+
*/
|
298 |
+
public $Parameter9 = null;
|
299 |
+
|
300 |
+
/**
|
301 |
+
*
|
302 |
+
* @var string $Parameter10
|
303 |
+
* @access public
|
304 |
+
*/
|
305 |
+
public $Parameter10 = null;
|
306 |
+
|
307 |
+
/**
|
308 |
+
*
|
309 |
+
* @var string $RuleOverride
|
310 |
+
* @access public
|
311 |
+
*/
|
312 |
+
public $RuleOverride = null;
|
313 |
+
|
314 |
+
/**
|
315 |
+
*
|
316 |
+
* @var string $CurrencyCode
|
317 |
+
* @access public
|
318 |
+
*/
|
319 |
+
public $CurrencyCode = 'USD';
|
320 |
+
|
321 |
+
/**
|
322 |
+
*
|
323 |
+
* @var string $ExemptReasonCode
|
324 |
+
* @access public
|
325 |
+
*/
|
326 |
+
public $ExemptReasonCode = null;
|
327 |
+
|
328 |
+
/**
|
329 |
+
*
|
330 |
+
* @var Address $BillingAddress
|
331 |
+
* @access public
|
332 |
+
*/
|
333 |
+
public $BillingAddress = null;
|
334 |
+
|
335 |
+
/**
|
336 |
+
*
|
337 |
+
* @var Address $P2PAddress
|
338 |
+
* @access public
|
339 |
+
*/
|
340 |
+
public $P2PAddress = null;
|
341 |
+
|
342 |
+
/**
|
343 |
+
*
|
344 |
+
* @var Address $ShipToAddress
|
345 |
+
* @access public
|
346 |
+
*/
|
347 |
+
public $ShipToAddress = null;
|
348 |
+
|
349 |
+
/**
|
350 |
+
*
|
351 |
+
* @var Address $ShipFromAddress
|
352 |
+
* @access public
|
353 |
+
*/
|
354 |
+
public $ShipFromAddress = null;
|
355 |
+
|
356 |
+
/**
|
357 |
+
*
|
358 |
+
* @var Address $OrderPlacementAddress
|
359 |
+
* @access public
|
360 |
+
*/
|
361 |
+
public $OrderPlacementAddress = null;
|
362 |
+
|
363 |
+
/**
|
364 |
+
*
|
365 |
+
* @var Address $OrderApprovalAddress
|
366 |
+
* @access public
|
367 |
+
*/
|
368 |
+
public $OrderApprovalAddress = null;
|
369 |
+
|
370 |
+
/**
|
371 |
+
*
|
372 |
+
* @var TaxAdjustmentTax[] $TaxAdjustmentTaxList
|
373 |
+
* @access public
|
374 |
+
*/
|
375 |
+
public $TaxAdjustmentTaxList = null;
|
376 |
+
|
377 |
+
/**
|
378 |
+
*
|
379 |
+
* @param string $lineNumber
|
380 |
+
* @param string $invoiceNumber
|
381 |
+
* @param string $customerNumber
|
382 |
+
* @param string $locationCode
|
383 |
+
* @param string $billToNumber
|
384 |
+
* @param string $origNumber
|
385 |
+
* @param string $termNumber
|
386 |
+
* @param string $transDate
|
387 |
+
* @param string $BillingPeriodStartDate
|
388 |
+
* @param string $BillingPeriodEndDate
|
389 |
+
* @param float $Revenue
|
390 |
+
* @param float $tax
|
391 |
+
* @param float $units
|
392 |
+
* @param string $unitType
|
393 |
+
* @param string $taxSitusRule
|
394 |
+
* @param string $TaxSitusOverrideCode
|
395 |
+
* @param string $transTypeCode
|
396 |
+
* @param string $salesTypeCode
|
397 |
+
* @param string $regulatoryCode
|
398 |
+
* @param String[] $taxExemptionCodeList
|
399 |
+
* @param string $uDF
|
400 |
+
* @param string $uDF2
|
401 |
+
* @param string $FreightOnBoard
|
402 |
+
* @param boolean $ShipFromPOB
|
403 |
+
* @param boolean $MailOrder
|
404 |
+
* @param boolean $CommonCarrier
|
405 |
+
* @param string $OriginCountryCode
|
406 |
+
* @param string $DestCountryCode
|
407 |
+
* @param int $BillingDaysInPeriod
|
408 |
+
* @param string $costCenter
|
409 |
+
* @param string $gLAccount
|
410 |
+
* @param string $MaterialGroup
|
411 |
+
* @param string $Parameter1
|
412 |
+
* @param string $Parameter2
|
413 |
+
* @param string $Parameter3
|
414 |
+
* @param string $Parameter4
|
415 |
+
* @param string $Parameter5
|
416 |
+
* @param string $Parameter6
|
417 |
+
* @param string $Parameter7
|
418 |
+
* @param string $Parameter8
|
419 |
+
* @param string $Parameter9
|
420 |
+
* @param string $Parameter10
|
421 |
+
* @param string $RuleOverride
|
422 |
+
* @param string $currencyCode
|
423 |
+
* @param string $exemptReasonCode
|
424 |
+
* @param Address $BillingAddress
|
425 |
+
* @param Address $P2PAddress
|
426 |
+
* @param Address $ShipToAddress
|
427 |
+
* @param Address $ShipFromAddress
|
428 |
+
* @param Address $OrderPlacementAddress
|
429 |
+
* @param Address $OrderApprovalAddress
|
430 |
+
* @param TaxAdjustmentTax[] $TaxAdjustmentTaxList
|
431 |
+
* @access public
|
432 |
+
*/
|
433 |
+
public function __construct(array $data)
|
434 |
+
{
|
435 |
+
$this->LineNumber = $data['LineNumber'];
|
436 |
+
$this->InvoiceNumber = $data['InvoiceNumber'];
|
437 |
+
$this->CustomerNumber = $data['CustomerNumber'];
|
438 |
+
$this->LocationCode = $data['LocationCode'];
|
439 |
+
$this->BillToNumber = $data['BillToNumber'];
|
440 |
+
$this->OrigNumber = $data['OrigNumber'];
|
441 |
+
$this->TermNumber = $data['TermNumber'];
|
442 |
+
$this->TransDate = $data['TransDate'];
|
443 |
+
$this->Tax = $data['Tax'];
|
444 |
+
$this->Units = $data['Units'];
|
445 |
+
$this->UnitType = $data['UnitType'];
|
446 |
+
$this->TaxSitusRule = $data['TaxSitusRule'];
|
447 |
+
$this->TransTypeCode = $data['TransTypeCode'];
|
448 |
+
$this->SalesTypeCode = $data['SalesTypeCode'];
|
449 |
+
$this->RegulatoryCode = $data['RegulatoryCode'];
|
450 |
+
$this->TaxExemptionCodeList = $data['TaxExemptionCodeList'];
|
451 |
+
$this->CostCenter = $data['CostCenter'];
|
452 |
+
$this->UDF = $data['UDF'];
|
453 |
+
$this->UDF2 = $data['UDF2'];
|
454 |
+
$this->ExemptReasonCode = $data['ExemptReasonCode'];
|
455 |
+
$this->GLAccount = $data['GLAccount'];
|
456 |
+
$this->Revenue = 0;
|
457 |
+
$this->ShipFromPOB = false;
|
458 |
+
$this->MailOrder = false;
|
459 |
+
$this->CommonCarrier = false;
|
460 |
+
$this->BillingDaysInPeriod = 0;
|
461 |
+
}
|
462 |
+
|
463 |
+
public function _construct()
|
464 |
+
{
|
465 |
+
$this->_init('wolterskluwer_cchsuretax/ws_taxAdjustmentItem');
|
466 |
+
}
|
467 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/Model/Ws/TaxAdjustmentRequest.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Represents Tax Adjustment request XML for SureTax web service requests.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
class WoltersKluwer_CchSureTax_Model_Ws_TaxAdjustmentRequest
|
10 |
+
extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @var string $ClientNumber
|
16 |
+
* @access public
|
17 |
+
*/
|
18 |
+
public $ClientNumber = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* @var string $BusinessUnit
|
23 |
+
* @access public
|
24 |
+
*/
|
25 |
+
public $BusinessUnit = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* @var string $ValidationKey
|
30 |
+
* @access public
|
31 |
+
*/
|
32 |
+
public $ValidationKey = null;
|
33 |
+
|
34 |
+
/**
|
35 |
+
*
|
36 |
+
* @var string $DataYear
|
37 |
+
* @access public
|
38 |
+
*/
|
39 |
+
public $DataYear = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @var string $DataMonth
|
44 |
+
* @access public
|
45 |
+
*/
|
46 |
+
public $DataMonth = null;
|
47 |
+
|
48 |
+
/**
|
49 |
+
*
|
50 |
+
* @var string $CmplDataYear
|
51 |
+
* @access public
|
52 |
+
*/
|
53 |
+
public $CmplDataYear = null;
|
54 |
+
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
* @var string $CmplDataMonth
|
58 |
+
* @access public
|
59 |
+
*/
|
60 |
+
public $CmplDataMonth = null;
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @var string $ClientTracking
|
65 |
+
* @access public
|
66 |
+
*/
|
67 |
+
public $ClientTracking = null;
|
68 |
+
|
69 |
+
/**
|
70 |
+
*
|
71 |
+
* @var string $ResponseType
|
72 |
+
* @access public
|
73 |
+
*/
|
74 |
+
public $ResponseType = null;
|
75 |
+
|
76 |
+
/**
|
77 |
+
*
|
78 |
+
* @var string $ResponseGroup
|
79 |
+
* @access public
|
80 |
+
*/
|
81 |
+
public $ResponseGroup = null;
|
82 |
+
|
83 |
+
/**
|
84 |
+
*
|
85 |
+
* @var string $STAN
|
86 |
+
* @access public
|
87 |
+
*/
|
88 |
+
public $STAN = null;
|
89 |
+
|
90 |
+
/**
|
91 |
+
*
|
92 |
+
* @var int $MasterTransId
|
93 |
+
* @access public
|
94 |
+
*/
|
95 |
+
public $MasterTransId = null;
|
96 |
+
|
97 |
+
/**
|
98 |
+
*
|
99 |
+
* @var Address $BillingAddress
|
100 |
+
* @access public
|
101 |
+
*/
|
102 |
+
public $BillingAddress = null;
|
103 |
+
|
104 |
+
/**
|
105 |
+
*
|
106 |
+
* @var Address $P2PAddress
|
107 |
+
* @access public
|
108 |
+
*/
|
109 |
+
public $P2PAddress = null;
|
110 |
+
|
111 |
+
/**
|
112 |
+
*
|
113 |
+
* @var Address $ShipToAddress
|
114 |
+
* @access public
|
115 |
+
*/
|
116 |
+
public $ShipToAddress = null;
|
117 |
+
|
118 |
+
/**
|
119 |
+
*
|
120 |
+
* @var Address $ShipFromAddress
|
121 |
+
* @access public
|
122 |
+
*/
|
123 |
+
public $ShipFromAddress = null;
|
124 |
+
|
125 |
+
/**
|
126 |
+
*
|
127 |
+
* @var Address $OrderPlacementAddress
|
128 |
+
* @access public
|
129 |
+
*/
|
130 |
+
public $OrderPlacementAddress = null;
|
131 |
+
|
132 |
+
/**
|
133 |
+
*
|
134 |
+
* @var Address $OrderApprovalAddress
|
135 |
+
* @access public
|
136 |
+
*/
|
137 |
+
public $OrderApprovalAddress = null;
|
138 |
+
|
139 |
+
/**
|
140 |
+
*
|
141 |
+
* @var TaxAdjustmentItem[] $TaxAdjustmentItemList
|
142 |
+
* @access public
|
143 |
+
*/
|
144 |
+
public $TaxAdjustmentItemList = null;
|
145 |
+
|
146 |
+
/**
|
147 |
+
*
|
148 |
+
* @param string $ClientNumber
|
149 |
+
* @param string $BusinessUnit
|
150 |
+
* @param string $ValidationKey
|
151 |
+
* @param string $DataYear
|
152 |
+
* @param string $DataMonth
|
153 |
+
* @param string $CmplDataYear
|
154 |
+
* @param string $CmplDataMonth
|
155 |
+
* @param string $ClientTracking
|
156 |
+
* @param string $ResponseType
|
157 |
+
* @param string $ResponseGroup
|
158 |
+
* @param string $STAN
|
159 |
+
* @param int $MasterTransId
|
160 |
+
* @param Address $BillingAddress
|
161 |
+
* @param Address $P2PAddress
|
162 |
+
* @param Address $ShipToAddress
|
163 |
+
* @param Address $ShipFromAddress
|
164 |
+
* @param Address $OrderPlacementAddress
|
165 |
+
* @param Address $OrderApprovalAddress
|
166 |
+
* @param TaxAdjustmentItem[] $TaxAdjustmentItemList
|
167 |
+
* @access public
|
168 |
+
*/
|
169 |
+
public function __construct(array $data)
|
170 |
+
{
|
171 |
+
$this->ClientNumber = $data['ClientNumber'];
|
172 |
+
$this->BusinessUnit =
|
173 |
+
(!isset($data['BusinessUnit']) || $data['BusinessUnit'] === null)
|
174 |
+
? '' : $data['BusinessUnit'];
|
175 |
+
$this->ValidationKey = $data['ValidationKey'];
|
176 |
+
$this->DataYear = $data['DataYear'];
|
177 |
+
$this->DataMonth = $data['DataMonth'];
|
178 |
+
$this->CmplDataYear = $data['CmplDataYear'];
|
179 |
+
$this->CmplDataMonth = $data['CmplDataMonth'];
|
180 |
+
$this->ClientTracking = $data['ClientTracking'];
|
181 |
+
$this->ResponseType = $data['ResponseType'];
|
182 |
+
$this->ResponseGroup = $data['ResponseGroup'];
|
183 |
+
$this->STAN = $data['STAN'];
|
184 |
+
$this->MasterTransId = $data['MasterTransId'];
|
185 |
+
$this->ShipToAddress = $data['ShipToAddress'];
|
186 |
+
$this->ShipFromAddress = $data['ShipFromAddress'];
|
187 |
+
$this->TaxAdjustmentItemList = $data['TaxAdjustmentItemList'];
|
188 |
+
}
|
189 |
+
|
190 |
+
public function _construct()
|
191 |
+
{
|
192 |
+
$this->_init('wolterskluwer_cchsuretax/ws_taxAdjustmentRequest');
|
193 |
+
}
|
194 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/ConfigController.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Global Configuration controller.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
10 |
+
|
11 |
+
class WoltersKluwer_CchSureTax_Adminhtml_Suretax_ConfigController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
+
|
14 |
+
public function indexAction()
|
15 |
+
{
|
16 |
+
$this->loadLayout()->_setActiveMenu('suretax/suretaxconfig');
|
17 |
+
return $this->renderLayout();
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _isAllowed()
|
21 |
+
{
|
22 |
+
return Mage::getSingleton('admin/session')->isAllowed('suretax/suretax_config');
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Saving the configuration that is entered in admin
|
27 |
+
*/
|
28 |
+
public function saveAction()
|
29 |
+
{
|
30 |
+
if ($formData = $this->getRequest()->getPost()) {
|
31 |
+
try {
|
32 |
+
unset($formData['key']);
|
33 |
+
unset($formData['form_key']);
|
34 |
+
$suretaxPath = WoltersKluwer_CchSureTax_Helper_Constants::SURETAX_CONFIG_PATH;
|
35 |
+
$this->validate($formData);
|
36 |
+
foreach ($formData as $key => $value) {
|
37 |
+
$valueData = trim($value);
|
38 |
+
if ($key === 'validationkey') {
|
39 |
+
$valueData = Mage::helper('core')->encrypt(trim($value));
|
40 |
+
}
|
41 |
+
Mage::getModel('core/config')->saveConfig($suretaxPath . '/' . $key, $valueData);
|
42 |
+
}
|
43 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
44 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
45 |
+
$this->__("Your SureTax Global configuration has been saved.")
|
46 |
+
);
|
47 |
+
} catch (Exception $ex) {
|
48 |
+
Utility::logMessage(
|
49 |
+
'Exception when saving global configuration: ' .
|
50 |
+
$ex->getMessage(), Zend_Log::ERR
|
51 |
+
);
|
52 |
+
Mage::getSingleton('adminhtml/session')->addErrors(
|
53 |
+
$this->__(
|
54 |
+
'Your SureTax Global configuration did not save successfully. ' .
|
55 |
+
'Please check the logs.'
|
56 |
+
)
|
57 |
+
);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
$this->_redirect('*/*/index');
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* For validating the Global configuration form data.
|
66 |
+
*
|
67 |
+
* @param array $formData the global config form data array.
|
68 |
+
*/
|
69 |
+
protected function validate($formData)
|
70 |
+
{
|
71 |
+
$validateResult = Utility::validateConfiguration($formData);
|
72 |
+
if (isset($validateResult)) {
|
73 |
+
Mage::getSingleton('adminhtml/session')->addWarning(
|
74 |
+
$this->__($validateResult)
|
75 |
+
);
|
76 |
+
} else {
|
77 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
78 |
+
$this->__("Your SureTax Configuration validated successfully.")
|
79 |
+
);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/CreditmemosController.php
ADDED
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Credit Memo grid controller.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
11 |
+
use WoltersKluwer_CchSureTax_Helper_Config as Config;
|
12 |
+
|
13 |
+
class WoltersKluwer_CchSureTax_Adminhtml_Suretax_CreditmemosController extends Mage_Adminhtml_Controller_Action
|
14 |
+
{
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$this->loadLayout()->_setActiveMenu('suretax/creditmemos');
|
19 |
+
return $this->renderLayout();
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _isAllowed()
|
23 |
+
{
|
24 |
+
return Mage::getSingleton('admin/session')->isAllowed('suretax/suretax_transactions/suretax_creditmemos');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Export SureTax Credit Memos grid to CSV format
|
29 |
+
*/
|
30 |
+
public function exportCsvAction()
|
31 |
+
{
|
32 |
+
$fileName = 'SureTax_Creditmemos.csv';
|
33 |
+
$content = $this->getLayout()->createBlock('suretax/adminhtml_creditmemos_container_grid')
|
34 |
+
->getCsvFile();
|
35 |
+
|
36 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
37 |
+
Utility::logMessage('Exported Credit Memos CSV', Zend_Log::INFO);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Export SureTax Credit Memos grid to XML format
|
42 |
+
*/
|
43 |
+
public function exportXmlAction()
|
44 |
+
{
|
45 |
+
$fileName = 'SureTax_Creditmemos.xml';
|
46 |
+
$content = $this->getLayout()->createBlock('suretax/adminhtml_creditmemos_container_grid')
|
47 |
+
->getExcelFile();
|
48 |
+
|
49 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
50 |
+
Utility::logMessage('Exported Credit Memos XML', Zend_Log::INFO);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Batch Finalize all applicable credit memos.
|
55 |
+
*/
|
56 |
+
public function batchFinalizeAction()
|
57 |
+
{
|
58 |
+
|
59 |
+
Utility::logMessage('|---Batch Finalize Credit Memos Start---|', Zend_Log::NOTICE);
|
60 |
+
|
61 |
+
$creditmemoIds = $this->getRequest()->getPost('creditmemo_ids', array());
|
62 |
+
$timeStart = microtime(true);
|
63 |
+
|
64 |
+
$successIds = array();
|
65 |
+
$noticeIds = array();
|
66 |
+
$suretaxConfigDisabledForIds = array();
|
67 |
+
$errorIds = array();
|
68 |
+
$outOfUSAAndCAN = array();
|
69 |
+
$storeIsDeletedInvoiceIds = array();
|
70 |
+
|
71 |
+
$creditMemoCollection = Mage::getModel(Constants::CREDIT_TBL)
|
72 |
+
->getCollection()
|
73 |
+
->joinCreditMemoWithSelfForCreditmemoIds($creditmemoIds);
|
74 |
+
|
75 |
+
if (count($creditmemoIds) > Constants::MAXIMUM_NUMBER_OF_ORDERS_TO_PROCESS) {
|
76 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
77 |
+
"Please select only ".Constants::MAXIMUM_NUMBER_OF_ORDERS_TO_PROCESS.
|
78 |
+
" credit memos or fewer to Batch Finalize."
|
79 |
+
);
|
80 |
+
} else {
|
81 |
+
/* @var $client WoltersKluwer_CchSureTax_Helper_WebService*/
|
82 |
+
$client = Mage::helper('suretax/webService');
|
83 |
+
$requestArray = array();
|
84 |
+
$wsConfigArray = Config::getWebsiteStoreConfig();
|
85 |
+
foreach ($creditMemoCollection as $creditMemo) {
|
86 |
+
$creditmemoId = $creditMemo->getEntityId();
|
87 |
+
Utility::logMessage('Credit Memo Id : '. $creditmemoId, Zend_Log::NOTICE);
|
88 |
+
|
89 |
+
$incrementId = $creditMemo->getIncrementId();
|
90 |
+
|
91 |
+
Utility::logMessage('IncrementId : '.$incrementId, Zend_Log::NOTICE);
|
92 |
+
|
93 |
+
$shipToAddressArray = Utility::getAddress(
|
94 |
+
$creditMemo->getStreet(),
|
95 |
+
$creditMemo->getCity(),
|
96 |
+
$creditMemo->getPostcode(),
|
97 |
+
$creditMemo->getRegion(),
|
98 |
+
$creditMemo->getCountryId()
|
99 |
+
);
|
100 |
+
|
101 |
+
if (!Utility::isSureTaxSupportedCountry(
|
102 |
+
$shipToAddressArray['Country']
|
103 |
+
)) {
|
104 |
+
Utility::logMessage(
|
105 |
+
'Skipping. SureTax does not support Country '. $shipToAddressArray['Country'] .
|
106 |
+
' for credit memo '. $creditmemoId,
|
107 |
+
Zend_Log::WARN
|
108 |
+
);
|
109 |
+
|
110 |
+
array_push($outOfUSAAndCAN, $incrementId);
|
111 |
+
continue;
|
112 |
+
}
|
113 |
+
$suretaxCreditmemoId = $creditMemo->getSuretaxId();
|
114 |
+
Utility::logMessage(
|
115 |
+
'Suretax order ID : ' . $suretaxCreditmemoId,
|
116 |
+
Zend_Log::NOTICE
|
117 |
+
);
|
118 |
+
Utility::logMessage(
|
119 |
+
'Status : ' . $creditMemo->getStatus(),
|
120 |
+
Zend_Log::NOTICE
|
121 |
+
);
|
122 |
+
if (null !== $creditMemo->getStatus()
|
123 |
+
&& !in_array(
|
124 |
+
$creditMemo->getStatus(),
|
125 |
+
Constants::$BATCH_STATUS_ALLOW
|
126 |
+
)
|
127 |
+
) {
|
128 |
+
array_push($noticeIds, $incrementId);
|
129 |
+
continue;
|
130 |
+
}
|
131 |
+
$websiteId = $creditMemo->getWebsiteId();
|
132 |
+
$storeId = $creditMemo->getGroupId();
|
133 |
+
|
134 |
+
if ($websiteId === null || $storeId === null) {
|
135 |
+
array_push($storeIsDeletedInvoiceIds, $incrementId);
|
136 |
+
continue;
|
137 |
+
}
|
138 |
+
// This new method called form batch will not call db everytime.
|
139 |
+
$enableCalc = Config::isSureTaxEnabledForWebsiteStoreConfig(
|
140 |
+
$websiteId,
|
141 |
+
$storeId,
|
142 |
+
$wsConfigArray
|
143 |
+
);
|
144 |
+
if (!$enableCalc) {
|
145 |
+
array_push($suretaxConfigDisabledForIds, $incrementId);
|
146 |
+
continue;
|
147 |
+
}
|
148 |
+
$wsConfigFilteredArray = Utility::filterWebsiteStoreArray($wsConfigArray, $websiteId, $storeId);
|
149 |
+
array_push(
|
150 |
+
$requestArray,
|
151 |
+
$client->createSureTaxRequestFromBatchCreditmemo(
|
152 |
+
$creditMemo,
|
153 |
+
$shipToAddressArray,
|
154 |
+
$wsConfigFilteredArray
|
155 |
+
)
|
156 |
+
);
|
157 |
+
unset($creditMemo);
|
158 |
+
}
|
159 |
+
if (!empty($requestArray)) {
|
160 |
+
$dataReturned = $client->sendBatchFinalizeToSureTax($requestArray, "Credit Memo");
|
161 |
+
foreach ($creditMemoCollection as $creditMemo) {
|
162 |
+
$incrementId = $creditMemo->getIncrementId();
|
163 |
+
$orderId = $creditMemo->getOrderIncrementId();
|
164 |
+
$suretaxCreditmemoId = $creditMemo->getSuretaxId();
|
165 |
+
|
166 |
+
//This if condition checks if the array key contains credit memo number
|
167 |
+
//as the array index set is clientTraking which contains credit memo number
|
168 |
+
//but not always just credit memo number. It may contain other strings.
|
169 |
+
if (!isset($dataReturned[$incrementId])) {
|
170 |
+
$arrayKeys = array_keys($dataReturned);
|
171 |
+
$matchedKey = Utility::checkIfIdExistsInArray($arrayKeys, $incrementId);
|
172 |
+
if ($matchedKey !== 'false') {
|
173 |
+
$dataReturnForCreditMemo = $dataReturned[$matchedKey];
|
174 |
+
} else {
|
175 |
+
continue;
|
176 |
+
}
|
177 |
+
} else {
|
178 |
+
$dataReturnForCreditMemo = $dataReturned[$orderId];
|
179 |
+
}
|
180 |
+
$transId = $dataReturnForCreditMemo['trans_id'];
|
181 |
+
$clientTracking = $dataReturnForCreditMemo['client_tracking'];
|
182 |
+
$status = $dataReturnForCreditMemo['status'];
|
183 |
+
$notes = $dataReturnForCreditMemo['notes'];
|
184 |
+
$creditMemoTax = $creditMemo->getBaseTaxAmount();
|
185 |
+
$sureTaxCalculatedTax = $dataReturnForCreditMemo['total_tax'];
|
186 |
+
$sureTaxCalculated = -1 * round($sureTaxCalculatedTax, 4);
|
187 |
+
$taxDifference = round(($creditMemoTax - $sureTaxCalculated), 2);
|
188 |
+
|
189 |
+
if ($status == Constants::FINALIZED_STATUS) {
|
190 |
+
if ($taxDifference > 0) {
|
191 |
+
//customer is paid more in taxes.
|
192 |
+
//so make a note
|
193 |
+
$status = Constants::FINALIZE_PAYMENT_REQUIRED;
|
194 |
+
} elseif ($taxDifference < 0) {
|
195 |
+
//customer is paid less, so adjust at suretax for the remaining
|
196 |
+
$adjustmentData = $client->sendCreditMemoTaxAdjustmentToSureTax(
|
197 |
+
$creditMemo,
|
198 |
+
$shipToAddressArray,
|
199 |
+
-1*$taxDifference
|
200 |
+
);
|
201 |
+
$status = $adjustmentData['status'];
|
202 |
+
}
|
203 |
+
}
|
204 |
+
$suretaxCreditmemo = Mage::getModel(Constants::CREDIT_TBL);
|
205 |
+
$data = array(
|
206 |
+
'id'=>$suretaxCreditmemoId,
|
207 |
+
'increment_id' => $creditMemo->getIncrementId(),
|
208 |
+
'stan' => $dataReturnForCreditMemo['stan'],
|
209 |
+
'trans_id' => $transId,
|
210 |
+
'client_tracking' => $clientTracking,
|
211 |
+
'status' => $status,
|
212 |
+
'notes' => $notes,
|
213 |
+
'tax'=> -1 * $dataReturnForCreditMemo['total_tax']
|
214 |
+
);
|
215 |
+
|
216 |
+
$suretaxCreditmemo->setData($data);
|
217 |
+
$suretaxCreditmemo->save();
|
218 |
+
if ($dataReturnForCreditMemo['success'] === true) {
|
219 |
+
array_push($successIds, $incrementId);
|
220 |
+
$totalTax = $dataReturnForCreditMemo['total_tax'];
|
221 |
+
$creditMemo->setTaxAmount($creditMemo->getStore()->convertPrice($totalTax));
|
222 |
+
$creditMemo->setBaseTaxAmount($totalTax);
|
223 |
+
$creditMemo->setId($creditmemoId);
|
224 |
+
} else {
|
225 |
+
array_push($errorIds, $incrementId);
|
226 |
+
}
|
227 |
+
unset($suretaxCreditmemo);
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
if (count($successIds)) {
|
233 |
+
Utility::addSuccessAdmin(
|
234 |
+
$successIds,
|
235 |
+
" credit memo(s) have been successfully finalized : "
|
236 |
+
);
|
237 |
+
}
|
238 |
+
if (count($suretaxConfigDisabledForIds)) {
|
239 |
+
Utility::addNoticeAdmin(
|
240 |
+
$suretaxConfigDisabledForIds,
|
241 |
+
" credit memo(s) cannot be finalized because SureTax calculation is disabled : "
|
242 |
+
);
|
243 |
+
}
|
244 |
+
if (count($noticeIds)) {
|
245 |
+
Utility::addNoticeAdmin(
|
246 |
+
$noticeIds,
|
247 |
+
" credit memo(s) cannot be finalized because they have already been processed in SureTax : "
|
248 |
+
);
|
249 |
+
}
|
250 |
+
if (count($errorIds)) {
|
251 |
+
Utility::addErrorAdmin(
|
252 |
+
$errorIds,
|
253 |
+
" credit memo(s) cannot be finalized due to an error from SureTax : "
|
254 |
+
);
|
255 |
+
}
|
256 |
+
|
257 |
+
if (count($outOfUSAAndCAN)) {
|
258 |
+
Utility::addErrorAdmin(
|
259 |
+
$outOfUSAAndCAN,
|
260 |
+
" credit memos(s) cannot be finalized because SureTax does not support its ship-to-address country : "
|
261 |
+
);
|
262 |
+
}
|
263 |
+
if (count($storeIsDeletedInvoiceIds)) {
|
264 |
+
Utility::addErrorAdmin(
|
265 |
+
$storeIsDeletedInvoiceIds,
|
266 |
+
" invoice(s) cannot be finalized because the underlying store or website was deleted : "
|
267 |
+
);
|
268 |
+
}
|
269 |
+
|
270 |
+
Utility::doProfile($timeStart, 'Credit Memos Batch Finalize ');
|
271 |
+
Utility::logMessage('|---Batch Finalize Credit Memos End---|', Zend_Log::NOTICE);
|
272 |
+
$this->_redirect('*/*/');
|
273 |
+
}
|
274 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/CustomerController.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Customer Configuration controller.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
|
11 |
+
class WoltersKluwer_CchSureTax_Adminhtml_Suretax_CustomerController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
+
|
14 |
+
public function indexAction()
|
15 |
+
{
|
16 |
+
$this->loadLayout()->_setActiveMenu('suretax/customer');
|
17 |
+
return $this->renderLayout();
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _isAllowed()
|
21 |
+
{
|
22 |
+
return Mage::getSingleton('admin/session')->isAllowed('suretax/suretax_customer');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function editAction()
|
26 |
+
{
|
27 |
+
$this->_title($this->__('SureTax'))
|
28 |
+
->_title($this->__('Customer'))
|
29 |
+
->_title($this->__('Manage Customer'));
|
30 |
+
|
31 |
+
$customerId = $this->getRequest()->getParam('id');
|
32 |
+
$suretaxcustomerId = $this->getRequest()->getParam('suretaxId');
|
33 |
+
|
34 |
+
// pull up customer exemption info
|
35 |
+
$customerExemptionArray = WoltersKluwer_CchSureTax_Helper_Data::
|
36 |
+
getCustomerExemptionInfo($customerId, $suretaxcustomerId);
|
37 |
+
$salesTypeCode = $customerExemptionArray['salesTypeCode'];
|
38 |
+
$exemptionCode = $customerExemptionArray['exemptionCode'];
|
39 |
+
$exemptionReason = $customerExemptionArray['exemptionReason'];
|
40 |
+
$name = $customerExemptionArray['name'];
|
41 |
+
$email = $customerExemptionArray['email'];
|
42 |
+
$group = $customerExemptionArray['group'];
|
43 |
+
$groupName = $customerExemptionArray['groupName'];
|
44 |
+
|
45 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
46 |
+
'id='.$customerId.' name= '.
|
47 |
+
$name. ' group= '.$group. 'sales type code = '.$salesTypeCode.' exemption code '.
|
48 |
+
$exemptionCode. ' exemption reason'. $exemptionReason, Zend_Log::ERR
|
49 |
+
);
|
50 |
+
|
51 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
52 |
+
'id='.$customerId.' name= '.
|
53 |
+
$name. ' group= '.$group. 'sales type code = '.$salesTypeCode.' exemption code '.
|
54 |
+
$exemptionCode. ' exemption reason'. $exemptionReason, Zend_Log::DEBUG
|
55 |
+
);
|
56 |
+
|
57 |
+
$config = array(
|
58 |
+
'customerId'=>$customerId,
|
59 |
+
'name'=>$name,
|
60 |
+
'sales_type_code'=>$salesTypeCode,
|
61 |
+
'exemption_code'=>$exemptionCode,
|
62 |
+
'exemption_reason'=>$exemptionReason,
|
63 |
+
'email'=>$email,
|
64 |
+
'groupName'=>$groupName,
|
65 |
+
'suretaxCustId'=>$suretaxcustomerId,
|
66 |
+
'customerGroupId'=>$group,
|
67 |
+
);
|
68 |
+
Mage::register('customerConfig', $config);
|
69 |
+
|
70 |
+
$this->loadLayout()
|
71 |
+
->_setActiveMenu('suretax/customer');
|
72 |
+
|
73 |
+
return $this->renderLayout();
|
74 |
+
}
|
75 |
+
|
76 |
+
protected function _initAction()
|
77 |
+
{
|
78 |
+
$this->loadLayout()
|
79 |
+
->_setActiveMenu('suretax/customer');
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Saving the Website or Store configuration.
|
85 |
+
*/
|
86 |
+
public function saveAction()
|
87 |
+
{
|
88 |
+
|
89 |
+
$customerId = $this->getRequest()->getParam('id');
|
90 |
+
|
91 |
+
$suretaxCustomerId = $this->getRequest()->getParam('suretaxCustomerId');
|
92 |
+
$salesTypeCode = $this->getRequest()->getParam('sales_type_code');
|
93 |
+
$exemptionCode = $this->getRequest()->getParam('exemption_code');
|
94 |
+
$exemptionReason = $this->getRequest()->getParam('exemption_reason');
|
95 |
+
|
96 |
+
if ($exemptionCode !== null && $exemptionReason === null) {
|
97 |
+
$exemptionReason = Constants::DEFAULT_EXEMPTION_REASON_CODE;
|
98 |
+
}
|
99 |
+
try {
|
100 |
+
if ($customerId !== null) {
|
101 |
+
if ($suretaxCustomerId !== null) {
|
102 |
+
$suretaxCustomer = Mage::getModel(Constants::CUST_TBL)
|
103 |
+
->load($customerId, 'suretax_customer_id');
|
104 |
+
} else {
|
105 |
+
$suretaxCustomer = Mage::getModel(Constants::CUST_TBL);
|
106 |
+
$suretaxCustomer->setSuretaxCustomerId($customerId);
|
107 |
+
}
|
108 |
+
$suretaxCustomer->setSalesTypeCode($salesTypeCode);
|
109 |
+
$suretaxCustomer->setExemptionCode($exemptionCode);
|
110 |
+
$suretaxCustomer->setExemptionReasonCode($exemptionReason);
|
111 |
+
$suretaxCustomer->save();
|
112 |
+
|
113 |
+
Mage::getSingleton('adminhtml/session')
|
114 |
+
->addSuccess($this->__('Your SureTax Customer configuration has been saved!'));
|
115 |
+
}
|
116 |
+
} catch (Exception $e) {
|
117 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
118 |
+
'Exception when saving customer configuration: ' .
|
119 |
+
$e->getMessage(), Zend_Log::ERR
|
120 |
+
);
|
121 |
+
Mage::getSingleton('adminhtml/session')->addErrors(
|
122 |
+
$this->__(
|
123 |
+
'Your SureTax Customer configuration did not save successfully. ' .
|
124 |
+
'Please check the logs.'
|
125 |
+
)
|
126 |
+
);
|
127 |
+
}
|
128 |
+
$this->_redirect('*/*/');
|
129 |
+
}
|
130 |
+
|
131 |
+
public function deleteAction()
|
132 |
+
{
|
133 |
+
try {
|
134 |
+
if (!($this->getRequest()->getParam('suretaxId') === null)) {
|
135 |
+
$suretaxCustomer = Mage::getModel(Constants::CUST_TBL);
|
136 |
+
$suretaxCustomer->setId($this->getRequest()->getParam('suretaxId'));
|
137 |
+
$suretaxCustomer->delete();
|
138 |
+
Mage::getSingleton('adminhtml/session')
|
139 |
+
->addSuccess($this->__('Your SureTax Customer configuration was successfully deleted.'));
|
140 |
+
}
|
141 |
+
} catch (Exception $e) {
|
142 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
143 |
+
'Exception when deleting customer configuration: ' .
|
144 |
+
$e->getMessage(), Zend_Log::ERR
|
145 |
+
);
|
146 |
+
Mage::getSingleton('adminthml/session')->addErrors(
|
147 |
+
$this->__(
|
148 |
+
'Your SureTax Customer configuration did not delete successfully. ' .
|
149 |
+
'Please check the logs.'
|
150 |
+
)
|
151 |
+
);
|
152 |
+
}
|
153 |
+
$this->_redirect('*/*/');
|
154 |
+
}
|
155 |
+
|
156 |
+
public function selectCustomerAction()
|
157 |
+
{
|
158 |
+
$this->loadLayout()->_setActiveMenu('suretax/customer');
|
159 |
+
return $this->renderLayout();
|
160 |
+
}
|
161 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/CustomergroupController.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Customer Group Configuration controller.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
11 |
+
|
12 |
+
class WoltersKluwer_CchSureTax_Adminhtml_Suretax_CustomergroupController extends Mage_Adminhtml_Controller_Action
|
13 |
+
{
|
14 |
+
public function indexAction()
|
15 |
+
{
|
16 |
+
$this->loadLayout()->_setActiveMenu('suretax/customergroup');
|
17 |
+
return $this->renderLayout();
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _isAllowed()
|
21 |
+
{
|
22 |
+
return Mage::getSingleton('admin/session')
|
23 |
+
->isAllowed('suretax/suretax_customergroup');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function editAction()
|
27 |
+
{
|
28 |
+
Utility::logMessage('edit ', Zend_Log::NOTICE);
|
29 |
+
$this->_title($this->__('SureTax'))
|
30 |
+
->_title($this->__('Customer'))
|
31 |
+
->_title($this->__('Manage Customer'));
|
32 |
+
|
33 |
+
$grpId = $this->getRequest()->getParam('id');
|
34 |
+
$suretaxCustomerGroupId = $this->getRequest()->getParam('suretaxId');
|
35 |
+
$salesTypeCode = Constants::DEFAULT_SALES_TYPE_CODE;
|
36 |
+
$exemptionCode = Constants::DEFAULT_EXEMPTION_CODE;
|
37 |
+
$exemptionReason = Constants::DEFAULT_EXEMPTION_REASON_CODE;
|
38 |
+
|
39 |
+
$customerGroup = Mage::getModel('customer/group')->load($grpId);
|
40 |
+
$groupName = $customerGroup->getData('customer_group_code');
|
41 |
+
|
42 |
+
if ($suretaxCustomerGroupId !== null) {
|
43 |
+
$suretaxCustomerGrp = Mage::getModel(Constants::CUST_GRP_TBL)
|
44 |
+
->load($suretaxCustomerGroupId);
|
45 |
+
$salesTypeCode = $suretaxCustomerGrp->getSalesTypeCode();
|
46 |
+
$exemptionCode = $suretaxCustomerGrp->getExemptionCode();
|
47 |
+
$exemptionReason = $suretaxCustomerGrp->getExemptionReasonCode();
|
48 |
+
}
|
49 |
+
|
50 |
+
$config = array(
|
51 |
+
'groupId'=>$grpId,
|
52 |
+
'suretaxGrpId' => $suretaxCustomerGroupId,
|
53 |
+
'grpName' => $groupName,
|
54 |
+
'sales_type_code' => $salesTypeCode,
|
55 |
+
'exemption_code' => $exemptionCode,
|
56 |
+
'exemption_reason' => $exemptionReason
|
57 |
+
);
|
58 |
+
|
59 |
+
Mage::register('custGrpConfig', $config);
|
60 |
+
$this->loadLayout()->_setActiveMenu('suretax/customergroup');
|
61 |
+
|
62 |
+
return $this->renderLayout();
|
63 |
+
}
|
64 |
+
|
65 |
+
public function saveAction()
|
66 |
+
{
|
67 |
+
try {
|
68 |
+
$suretaxGroupId = $this->getRequest()->getParam('suretaxGrpId');
|
69 |
+
$customerGroupId = $this->getRequest()->getParam('customerGroupId');
|
70 |
+
|
71 |
+
if ($suretaxGroupId !== null) {
|
72 |
+
$suretaxCustomerGroup = Mage::getModel(Constants::CUST_GRP_TBL)
|
73 |
+
->load((int)$suretaxGroupId);
|
74 |
+
} else {
|
75 |
+
$suretaxCustomerGroup = Mage::getModel(Constants::CUST_GRP_TBL);
|
76 |
+
}
|
77 |
+
|
78 |
+
$salesTypeCode = Constants::DEFAULT_SALES_TYPE_CODE;
|
79 |
+
$exemptionCode = Constants::DEFAULT_EXEMPTION_CODE;
|
80 |
+
$exemptionReason = Constants::DEFAULT_EXEMPTION_REASON_CODE;
|
81 |
+
|
82 |
+
if (!($this->getRequest()->getParam('sales_type_code') === null)) {
|
83 |
+
$salesTypeCode = $this->getRequest()->getParam('sales_type_code');
|
84 |
+
}
|
85 |
+
if (!($this->getRequest()->getParam('exemption_code') === null)) {
|
86 |
+
$exemptionCode = $this->getRequest()->getParam('exemption_code');
|
87 |
+
}
|
88 |
+
if ($this->getRequest()->getParam('exemption_reason')) {
|
89 |
+
$exemptionReason = $this->getRequest()->getParam('exemption_reason');
|
90 |
+
}
|
91 |
+
Utility::logMessage($salesTypeCode, Zend_Log::NOTICE);
|
92 |
+
Utility::logMessage($exemptionCode, Zend_Log::NOTICE);
|
93 |
+
Utility::logMessage($exemptionReason, Zend_Log::NOTICE);
|
94 |
+
|
95 |
+
$suretaxCustomerGroup->setSalesTypeCode($salesTypeCode);
|
96 |
+
$suretaxCustomerGroup->setExemptionCode($exemptionCode);
|
97 |
+
$suretaxCustomerGroup->setExemptionReasonCode($exemptionReason);
|
98 |
+
|
99 |
+
if (!($customerGroupId === null)) {
|
100 |
+
$suretaxCustomerGroup->setSuretaxCustomerGroupId($customerGroupId);
|
101 |
+
}
|
102 |
+
$suretaxCustomerGroup->save();
|
103 |
+
Mage::getSingleton('adminhtml/session')
|
104 |
+
->addSuccess($this->__('Your SureTax Customer Group configuration has been saved!'));
|
105 |
+
} catch (Exception $t) {
|
106 |
+
Utility::logMessage(
|
107 |
+
'Exception when saving customer group configuration: ' .
|
108 |
+
$t->getMessage(), Zend_Log::ERR
|
109 |
+
);
|
110 |
+
Mage::getSingleton('adminhtml/session')->addErrors(
|
111 |
+
$this->__(
|
112 |
+
'Your SureTax Customer Group configuration did not save successfully. ' .
|
113 |
+
'Please check the logs.'
|
114 |
+
)
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
$this->_redirect('*/*/index');
|
119 |
+
}
|
120 |
+
|
121 |
+
public function deleteAction()
|
122 |
+
{
|
123 |
+
try {
|
124 |
+
if (!($this->getRequest()->getParam('suretaxId') === null)) {
|
125 |
+
$suretaxGroup = Mage::getModel(Constants::CUST_GRP_TBL);
|
126 |
+
$suretaxGroup->setId($this->getRequest()->getParam('suretaxId'));
|
127 |
+
$suretaxGroup->delete();
|
128 |
+
}
|
129 |
+
Mage::getSingleton('adminhtml/session')
|
130 |
+
->addSuccess('Your SureTax Customer Group configuration was successfully deleted.');
|
131 |
+
} catch (Exception $e) {
|
132 |
+
Utility::logMessage(
|
133 |
+
'Exception when deleting customer group configuration: ' .
|
134 |
+
$e->getMessage(), Zend_Log::ERR
|
135 |
+
);
|
136 |
+
Mage::getSingleton('adminhtml/session')->addErrors(
|
137 |
+
$this->__(
|
138 |
+
'Your SureTax Customer Group configuration did not delete successfully. ' .
|
139 |
+
'Please check the logs.'
|
140 |
+
)
|
141 |
+
);
|
142 |
+
}
|
143 |
+
|
144 |
+
$this->_redirect('*/*/index');
|
145 |
+
}
|
146 |
+
|
147 |
+
public function selectAction()
|
148 |
+
{
|
149 |
+
$this->loadLayout()->_setActiveMenu('suretax/group');
|
150 |
+
return $this->renderLayout();
|
151 |
+
}
|
152 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/HelpController.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Help Screen controller.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WoltersKluwer_CchSureTax_Adminhtml_Suretax_HelpController extends Mage_Adminhtml_Controller_Action
|
11 |
+
{
|
12 |
+
|
13 |
+
public function indexAction()
|
14 |
+
{
|
15 |
+
$this->loadLayout()->_setActiveMenu('suretax/help');
|
16 |
+
return $this->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _isAllowed()
|
20 |
+
{
|
21 |
+
return Mage::getSingleton('admin/session')->isAllowed('suretax/suretax_help');
|
22 |
+
}
|
23 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/InvoicesController.php
ADDED
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Invoices grid controller.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Utility as Utility;
|
11 |
+
use WoltersKluwer_CchSureTax_Helper_Config as Config;
|
12 |
+
|
13 |
+
class WoltersKluwer_CchSureTax_Adminhtml_Suretax_InvoicesController extends Mage_Adminhtml_Controller_Action
|
14 |
+
{
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$this->loadLayout()->_setActiveMenu('suretax/invoices');
|
19 |
+
return $this->renderLayout();
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _isAllowed()
|
23 |
+
{
|
24 |
+
return Mage::getSingleton('admin/session')->isAllowed('suretax/suretax_transactions/suretax_invoices');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Export SureTax Invoice grid to CSV format
|
29 |
+
*/
|
30 |
+
public function exportCsvAction()
|
31 |
+
{
|
32 |
+
$fileName = 'SureTax_Invoices.csv';
|
33 |
+
$content = $this->getLayout()->createBlock('suretax/adminhtml_invoices_container_grid')
|
34 |
+
->getCsvFile();
|
35 |
+
|
36 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
37 |
+
Utility::logMessage('Exported Invoices CSV', Zend_Log::INFO);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Export SureTax Invoice grid to XML format
|
42 |
+
*/
|
43 |
+
public function exportXmlAction()
|
44 |
+
{
|
45 |
+
$fileName = 'SureTax_Invoices.xml';
|
46 |
+
$content = $this->getLayout()->createBlock('suretax/adminhtml_invoices_container_grid')
|
47 |
+
->getExcelFile();
|
48 |
+
|
49 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
50 |
+
Utility::logMessage('Exported Invoices XML', Zend_Log::INFO);
|
51 |
+
}
|
52 |
+
|
53 |
+
public function batchFinalizeAction()
|
54 |
+
{
|
55 |
+
|
56 |
+
Utility::logMessage('|---Batch Finalize Invoices Start---|', Zend_Log::DEBUG);
|
57 |
+
$timeStart = microtime(true);
|
58 |
+
$invoiceIds = $this->getRequest()->getPost('invoice_Ids', array());
|
59 |
+
|
60 |
+
$successSureTaxInvoiceIds = array();
|
61 |
+
$noticeSureTaxInvoiceIds = array();
|
62 |
+
$sureTaxConfigDisabledForIds = array();
|
63 |
+
$errorSureTaxInvoiceIds = array();
|
64 |
+
$outOfUSAndCANInvoiceIds = array();
|
65 |
+
$storeIsDeletedInvoiceIds = array();
|
66 |
+
|
67 |
+
$invCollection = Mage::getModel(Constants::INVOICE_TBL)->getCollection()
|
68 |
+
->joinInvoiceWithSelfForInvoiceIds($invoiceIds);
|
69 |
+
|
70 |
+
if ($invoiceIds !== null) {
|
71 |
+
if (count($invoiceIds) > Constants::MAXIMUM_NUMBER_OF_INVOICES_TO_PROCESS) {
|
72 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
73 |
+
"Please select only " .
|
74 |
+
Constants::MAXIMUM_NUMBER_OF_INVOICES_TO_PROCESS .
|
75 |
+
" invoices or fewer to Batch Finalize."
|
76 |
+
);
|
77 |
+
} else {
|
78 |
+
/* @var $client WoltersKluwer_CchSureTax_Helper_WebService*/
|
79 |
+
$client = Mage::helper('suretax/webService');
|
80 |
+
$requestArray = array();
|
81 |
+
$wsConfigArray = Config::getWebsiteStoreConfig();
|
82 |
+
foreach ($invCollection as $invoice) {
|
83 |
+
Utility::logMessage('Invoice Id : '. $invoice->getEntityId(), Zend_Log::DEBUG);
|
84 |
+
|
85 |
+
$incrementId = $invoice->getIncrementId();
|
86 |
+
|
87 |
+
Utility::logMessage('IncrementId : '.$incrementId, Zend_Log::DEBUG);
|
88 |
+
|
89 |
+
// if not supported country, then do default magento tax calc
|
90 |
+
$shipToAddressArray = Utility::getAddress(
|
91 |
+
$invoice->getStreet(),
|
92 |
+
$invoice->getCity(),
|
93 |
+
$invoice->getPostcode(),
|
94 |
+
$invoice->getRegion(),
|
95 |
+
$invoice->getCountryId()
|
96 |
+
);
|
97 |
+
//check street2
|
98 |
+
|
99 |
+
if (Utility::isSureTaxSupportedCountry($shipToAddressArray['Country']) === false) {
|
100 |
+
Utility::logMessage(
|
101 |
+
'Skipping. SureTax does not support this country ' .
|
102 |
+
$shipToAddressArray['Country'] . '. For Invoice Id : ' .
|
103 |
+
$invoice->getEntityId(), Zend_Log::WARN
|
104 |
+
);
|
105 |
+
|
106 |
+
array_push($outOfUSAndCANInvoiceIds, $incrementId);
|
107 |
+
continue;
|
108 |
+
}
|
109 |
+
|
110 |
+
$suretaxInvoiceId = $invoice->getSuretaxId();
|
111 |
+
|
112 |
+
Utility::logMessage(
|
113 |
+
'SureTax invoice ID : ' .
|
114 |
+
$suretaxInvoiceId, Zend_Log::DEBUG
|
115 |
+
);
|
116 |
+
|
117 |
+
Utility::logMessage(
|
118 |
+
'Status : ' .
|
119 |
+
$invoice->getStatus(), Zend_Log::DEBUG
|
120 |
+
);
|
121 |
+
// If status is not null (No suretax_order associated with this order)
|
122 |
+
// and is not Finalize_Fail then we do not process them.
|
123 |
+
|
124 |
+
if (null !== $invoice->getStatus()
|
125 |
+
&& ($invoice->getStatus() == Constants::FINALIZED_STATUS
|
126 |
+
|| $invoice->getStatus() == Constants::FINALIZE_ADJUSTED
|
127 |
+
|| $invoice->getStatus() == Constants::ADJUSTMENT_FAIL
|
128 |
+
|| $invoice->getStatus() == Constants::FINALIZE_PAYMENT_REQUIRED)
|
129 |
+
) {
|
130 |
+
array_push($noticeSureTaxInvoiceIds, $incrementId);
|
131 |
+
continue;
|
132 |
+
}
|
133 |
+
$websiteId = $invoice->getWebsiteId();
|
134 |
+
$storeId = $invoice->getGroupId();
|
135 |
+
|
136 |
+
if ($websiteId === null || $storeId === null) {
|
137 |
+
array_push($storeIsDeletedInvoiceIds, $incrementId);
|
138 |
+
continue;
|
139 |
+
}
|
140 |
+
// If based on website and store sure tax calc is turned off then do not send to sure tax.
|
141 |
+
// This new method called form batch will not call db everytime.
|
142 |
+
|
143 |
+
$enableCalc = Config::isSureTaxEnabledForWebsiteStoreConfig(
|
144 |
+
$websiteId,
|
145 |
+
$storeId,
|
146 |
+
$wsConfigArray
|
147 |
+
);
|
148 |
+
|
149 |
+
if (!$enableCalc) {
|
150 |
+
array_push($sureTaxConfigDisabledForIds, $incrementId);
|
151 |
+
continue;
|
152 |
+
}
|
153 |
+
$wsConfigFilteredArray = Utility::filterWebsiteStoreArray($wsConfigArray, $websiteId, $storeId);
|
154 |
+
array_push(
|
155 |
+
$requestArray,
|
156 |
+
$client->createSureTaxRequestFromBatchInvoice(
|
157 |
+
$invoice,
|
158 |
+
$shipToAddressArray,
|
159 |
+
$wsConfigFilteredArray
|
160 |
+
)
|
161 |
+
);
|
162 |
+
|
163 |
+
unset($invoice);
|
164 |
+
}
|
165 |
+
if (!empty($requestArray)) {
|
166 |
+
$dataReturned = $client->sendBatchFinalizeToSureTax($requestArray, "Invoice");
|
167 |
+
foreach ($invCollection as $invoice) {
|
168 |
+
$incrementId = $invoice->getIncrementId();
|
169 |
+
$suretaxInvoiceId = $invoice->getSuretaxId();
|
170 |
+
|
171 |
+
//This if condition checks if the array key contains invoice number
|
172 |
+
//as the array index set is clientTraking which contains invoice number
|
173 |
+
//but not always just invoice number. It may contain other strings.
|
174 |
+
if (!isset($dataReturned[$incrementId])) {
|
175 |
+
$arrayKeys = array_keys($dataReturned);
|
176 |
+
$matchedKey = Utility::checkIfIdExistsInArray($arrayKeys, $incrementId);
|
177 |
+
if ($matchedKey !== 'false') {
|
178 |
+
$dataReturnForInvoice = $dataReturned[$matchedKey];
|
179 |
+
} else {
|
180 |
+
continue;
|
181 |
+
}
|
182 |
+
} else {
|
183 |
+
$dataReturnForInvoice = $dataReturned[$incrementId];
|
184 |
+
}
|
185 |
+
$taxDifference = round(
|
186 |
+
$invoice->getBaseTaxAmount() -
|
187 |
+
round($dataReturnForInvoice['total_tax'], 4), 2
|
188 |
+
);
|
189 |
+
|
190 |
+
$status = $dataReturnForInvoice['status'];
|
191 |
+
|
192 |
+
if ($status === Constants::FINALIZED_STATUS) {
|
193 |
+
if ($taxDifference > 0) {
|
194 |
+
// that means tax been over collected from customer,
|
195 |
+
// so we need to send for adjustment with over collected amount.
|
196 |
+
$adjustmentResponse = $client->sendTaxAdjustmentToSureTax(
|
197 |
+
$invoice,
|
198 |
+
$shipToAddressArray,
|
199 |
+
$taxDifference
|
200 |
+
);
|
201 |
+
$status = $adjustmentResponse['status'];
|
202 |
+
} elseif ($taxDifference < 0) {
|
203 |
+
// this means you under collected from customer,
|
204 |
+
// so you need to pay this much amount more.
|
205 |
+
// Sure tax already has this amount, so no need send an adjustment
|
206 |
+
$status = Constants::FINALIZE_PAYMENT_REQUIRED;
|
207 |
+
}
|
208 |
+
}
|
209 |
+
$suretaxInvoice = Mage::getModel(Constants::INVOICE_TBL);
|
210 |
+
$data = array(
|
211 |
+
'increment_id' => $incrementId,
|
212 |
+
'id'=>$suretaxInvoiceId,
|
213 |
+
'trans_id' => $dataReturnForInvoice['trans_id'],
|
214 |
+
'tax' => $dataReturnForInvoice['total_tax'],
|
215 |
+
'client_tracking' => $dataReturnForInvoice['client_tracking'],
|
216 |
+
'status' => $status,
|
217 |
+
'notes' => $dataReturnForInvoice['notes'],
|
218 |
+
);
|
219 |
+
$suretaxInvoice->setData($data);
|
220 |
+
$suretaxInvoice->save();
|
221 |
+
if ($dataReturnForInvoice['success'] === true) {
|
222 |
+
array_push($successSureTaxInvoiceIds, $incrementId);
|
223 |
+
} else {
|
224 |
+
array_push($errorSureTaxInvoiceIds, $incrementId);
|
225 |
+
|
226 |
+
}
|
227 |
+
unset($suretaxInvoice);
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
if (count($successSureTaxInvoiceIds)) {
|
233 |
+
Utility::addSuccessAdmin(
|
234 |
+
$successSureTaxInvoiceIds,
|
235 |
+
" invoice(s) have been successfully finalized : "
|
236 |
+
);
|
237 |
+
}
|
238 |
+
if (count($sureTaxConfigDisabledForIds)) {
|
239 |
+
Utility::addNoticeAdmin(
|
240 |
+
$sureTaxConfigDisabledForIds,
|
241 |
+
" invoice(s) cannot be finalized because SureTax calculation is disabled : "
|
242 |
+
);
|
243 |
+
}
|
244 |
+
if (count($noticeSureTaxInvoiceIds)) {
|
245 |
+
Utility::addNoticeAdmin(
|
246 |
+
$noticeSureTaxInvoiceIds,
|
247 |
+
" invoice(s) cannot be finalized because they have already been processed in SureTax : "
|
248 |
+
);
|
249 |
+
}
|
250 |
+
if (count($errorSureTaxInvoiceIds)) {
|
251 |
+
Utility::addErrorAdmin(
|
252 |
+
$errorSureTaxInvoiceIds,
|
253 |
+
" invoice(s) cannot be finalized due to an error from SureTax : "
|
254 |
+
);
|
255 |
+
}
|
256 |
+
if (count($outOfUSAndCANInvoiceIds)) {
|
257 |
+
Utility::addErrorAdmin(
|
258 |
+
$outOfUSAndCANInvoiceIds,
|
259 |
+
" invoice(s) cannot be finalized because SureTax does not support its ship-to-address country : "
|
260 |
+
);
|
261 |
+
}
|
262 |
+
if (count($storeIsDeletedInvoiceIds)) {
|
263 |
+
Utility::addErrorAdmin(
|
264 |
+
$storeIsDeletedInvoiceIds,
|
265 |
+
" invoice(s) cannot be finalized because the underlying store or website was deleted : "
|
266 |
+
);
|
267 |
+
}
|
268 |
+
|
269 |
+
Utility::doProfile($timeStart, 'Invoice Batch Finalize ');
|
270 |
+
Utility::logMessage(
|
271 |
+
'|---Batch Finalize Invoices End---|',
|
272 |
+
Zend_Log::NOTICE
|
273 |
+
);
|
274 |
+
|
275 |
+
$this->_redirect('*/*/');
|
276 |
+
}
|
277 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/controllers/Adminhtml/Suretax/WebsitestoreController.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SureTax Website/Store Configuration controller.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
use WoltersKluwer_CchSureTax_Helper_Constants as Constants;
|
11 |
+
|
12 |
+
class WoltersKluwer_CchSureTax_Adminhtml_Suretax_WebsitestoreController extends Mage_Adminhtml_Controller_Action
|
13 |
+
{
|
14 |
+
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
+
$this->loadLayout()->_setActiveMenu('suretax/websitestore');
|
18 |
+
return $this->renderLayout();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _isAllowed()
|
22 |
+
{
|
23 |
+
return Mage::getSingleton('admin/session')->isAllowed('suretax/suretax_websitestore');
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _initAction()
|
27 |
+
{
|
28 |
+
$this->loadLayout()
|
29 |
+
->_setActiveMenu('suretax/websitestore');
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Edit action
|
35 |
+
*/
|
36 |
+
public function editAction()
|
37 |
+
{
|
38 |
+
$this->_title($this->__('SureTax'))
|
39 |
+
->_title($this->__('Website/Store'))
|
40 |
+
->_title($this->__('Manage Website and Store'));
|
41 |
+
|
42 |
+
$websiteId = $this->getRequest()->getParam('websiteId');
|
43 |
+
$storeId = $this->getRequest()->getParam('storeId');
|
44 |
+
$name = $this->getRequest()->getParam('name');
|
45 |
+
$config = array ('storeId' => $storeId,
|
46 |
+
'websiteId' => $websiteId,
|
47 |
+
'name' => $name);
|
48 |
+
|
49 |
+
Mage::register('config', $config);
|
50 |
+
|
51 |
+
$this->loadLayout()
|
52 |
+
->_setActiveMenu('suretax/websitestore');
|
53 |
+
|
54 |
+
return $this->renderLayout();
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* saving the Website or Store configuration.
|
59 |
+
*/
|
60 |
+
public function saveAction()
|
61 |
+
{
|
62 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
63 |
+
'Saving website or store',
|
64 |
+
Zend_Log::NOTICE
|
65 |
+
);
|
66 |
+
|
67 |
+
try {
|
68 |
+
$request = $this->getRequest();
|
69 |
+
$formData = $request->getPost();
|
70 |
+
|
71 |
+
$websiteId = $formData['website_id'];
|
72 |
+
$storeId = $formData['store_id'];
|
73 |
+
$isEnableCalc = $formData['is_enable_calc'];
|
74 |
+
$useBusinessUnit = $formData['use_business_unit'];
|
75 |
+
$businessUnit = isset($formData['business_unit']) ?
|
76 |
+
$formData['business_unit'] : '';
|
77 |
+
$useDefaultAddress = $formData['use_default_address'];
|
78 |
+
$streetAddress1 = isset($formData['ship_from_address1']) ?
|
79 |
+
$formData['ship_from_address1'] : '';
|
80 |
+
$streetAddress2 = isset($formData['ship_from_address2']) ?
|
81 |
+
$formData['ship_from_address2'] : '';
|
82 |
+
$city = isset($formData['ship_from_city']) ?
|
83 |
+
$formData['ship_from_city'] : '';
|
84 |
+
$country = isset($formData['ship_from_country']) ?
|
85 |
+
$formData['ship_from_country'] : '';
|
86 |
+
$stateProvince = isset($formData['ship_from_state']) ?
|
87 |
+
$formData['ship_from_state'] : '';
|
88 |
+
$zipPostal = isset($formData['ship_from_zip']) ?
|
89 |
+
$formData['ship_from_zip'] : '';
|
90 |
+
|
91 |
+
if ($storeId == 0) {
|
92 |
+
$row = Mage::getModel(Constants::WS_CONFIG_TBL)
|
93 |
+
->getCollection()
|
94 |
+
->loadWebsiteConfig($websiteId);
|
95 |
+
} else {
|
96 |
+
$row = Mage::getModel(Constants::WS_CONFIG_TBL)
|
97 |
+
->getCollection()
|
98 |
+
->loadStoreConfig($websiteId, $storeId);
|
99 |
+
}
|
100 |
+
|
101 |
+
$row->setData(
|
102 |
+
array(
|
103 |
+
'id' => $row->getId(),
|
104 |
+
'website_id'=>$websiteId,
|
105 |
+
'store_id'=>$storeId,
|
106 |
+
'is_enable_calc'=>$isEnableCalc,
|
107 |
+
'use_business_unit'=>$useBusinessUnit,
|
108 |
+
'business_unit'=>$businessUnit,
|
109 |
+
'use_default_address'=>$useDefaultAddress,
|
110 |
+
'street_address1'=>$streetAddress1,
|
111 |
+
'street_address2'=>$streetAddress2,
|
112 |
+
'city'=>$city,
|
113 |
+
'country'=>$country,
|
114 |
+
'state_province'=>$stateProvince,
|
115 |
+
'zip_postal'=>$zipPostal
|
116 |
+
)
|
117 |
+
)->save();
|
118 |
+
|
119 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
120 |
+
$this->__("Your SureTax Website/Store configuration has been saved.")
|
121 |
+
);
|
122 |
+
} catch (Exception $ex) {
|
123 |
+
WoltersKluwer_CchSureTax_Helper_Utility::logMessage(
|
124 |
+
'Exception when saving Website/Store configuration: ' .
|
125 |
+
$ex->getMessage(), Zend_Log::ERR
|
126 |
+
);
|
127 |
+
Mage::getSingleton('adminhtml/session')->addErrors(
|
128 |
+
$this->__(
|
129 |
+
'Your SureTax Website/Store configuration did not save! ' .
|
130 |
+
'Please check the logs.'
|
131 |
+
)
|
132 |
+
);
|
133 |
+
}
|
134 |
+
$this->_redirect('*/*/index');
|
135 |
+
}
|
136 |
+
}
|
app/code/community/WoltersKluwer/CchSureTax/etc/adminhtml.xml
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<menu>
|
12 |
+
<suretax translate="title" module="suretax">
|
13 |
+
<title>SureTax</title>
|
14 |
+
<sort_order>1000</sort_order>
|
15 |
+
<children>
|
16 |
+
<suretax_config translate="title" module="suretax">
|
17 |
+
<title>Global</title>
|
18 |
+
<!-- This 'suretaxconfig should match admin tag in config and Controller class under controllers/adminhtml' -->
|
19 |
+
<action>adminhtml/suretax_config</action>
|
20 |
+
<sort_order>10</sort_order>
|
21 |
+
</suretax_config>
|
22 |
+
<suretax_websitestore translate="title" module="suretax">
|
23 |
+
<title>Website/Store</title>
|
24 |
+
<action>adminhtml/suretax_websitestore</action>
|
25 |
+
<sort_order>20</sort_order>
|
26 |
+
</suretax_websitestore>
|
27 |
+
<suretax_customer translate="title" module="suretax">
|
28 |
+
<title>Customers</title>
|
29 |
+
<sort_order>40</sort_order>
|
30 |
+
<action>adminhtml/suretax_customer</action>
|
31 |
+
</suretax_customer>
|
32 |
+
<suretax_customergroup translate="title" module="suretax">
|
33 |
+
<title>Customer Groups</title>
|
34 |
+
<sort_order>30</sort_order>
|
35 |
+
<action>adminhtml/suretax_customergroup</action>
|
36 |
+
</suretax_customergroup>
|
37 |
+
<suretax_transactions translate="title" module="suretax">
|
38 |
+
<title>Transactions</title>
|
39 |
+
<sort_order>50</sort_order>
|
40 |
+
<children>
|
41 |
+
<suretax_invoices translate="title" module="suretax">
|
42 |
+
<title>Invoices</title>
|
43 |
+
<action>adminhtml/suretax_invoices</action>
|
44 |
+
</suretax_invoices>
|
45 |
+
<suretax_creditmemos translate="title" module="suretax">
|
46 |
+
<title>Credit Memos</title>
|
47 |
+
<action>adminhtml/suretax_creditmemos</action>
|
48 |
+
</suretax_creditmemos>
|
49 |
+
</children>
|
50 |
+
</suretax_transactions>
|
51 |
+
<suretax_help translate="title" module="suretax">
|
52 |
+
<title>Help</title>
|
53 |
+
<action>adminhtml/suretax_help</action>
|
54 |
+
<sort_order>60</sort_order>
|
55 |
+
</suretax_help>
|
56 |
+
</children>
|
57 |
+
</suretax>
|
58 |
+
</menu>
|
59 |
+
<acl>
|
60 |
+
<resources>
|
61 |
+
<admin>
|
62 |
+
<children>
|
63 |
+
<suretax translate="title" module="suretax">
|
64 |
+
<title>SureTax</title>
|
65 |
+
<sort_order>1000</sort_order>
|
66 |
+
<children>
|
67 |
+
<suretax_config translate="title">
|
68 |
+
<title>Global</title>
|
69 |
+
<sort_order>10</sort_order>
|
70 |
+
</suretax_config>
|
71 |
+
<suretax_websitestore translate="title">
|
72 |
+
<title>Website/Store</title>
|
73 |
+
<sort_order>20</sort_order>
|
74 |
+
</suretax_websitestore>
|
75 |
+
<suretax_customer translate='title'>
|
76 |
+
<title>Customers</title>
|
77 |
+
<sort_order>40</sort_order>
|
78 |
+
</suretax_customer>
|
79 |
+
<suretax_customergroup translate='title'>
|
80 |
+
<title>Customer Groups</title>
|
81 |
+
<sort_order>30</sort_order>
|
82 |
+
</suretax_customergroup>
|
83 |
+
|
84 |
+
<suretax_transactions translate="title">
|
85 |
+
<title>Transactions</title>
|
86 |
+
<sort_order>50</sort_order>
|
87 |
+
<children>
|
88 |
+
<suretax_invoices translate="title">
|
89 |
+
<title>Invoices</title>
|
90 |
+
<sort_order>10</sort_order>
|
91 |
+
</suretax_invoices>
|
92 |
+
<suretax_creditmemos translate="title">
|
93 |
+
<title>Credit Memos</title>
|
94 |
+
<sort_order>20</sort_order>
|
95 |
+
</suretax_creditmemos>
|
96 |
+
</children>
|
97 |
+
</suretax_transactions>
|
98 |
+
<suretax_help translate="title">
|
99 |
+
<title>Help</title>
|
100 |
+
<sort_order>60</sort_order>
|
101 |
+
</suretax_help>
|
102 |
+
</children>
|
103 |
+
</suretax>
|
104 |
+
</children>
|
105 |
+
</admin>
|
106 |
+
</resources>
|
107 |
+
</acl>
|
108 |
+
</config>
|
app/code/community/WoltersKluwer/CchSureTax/etc/config.xml
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category WoltersKluwer
|
5 |
+
* @package WoltersKluwer_CchSureTax
|
6 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<config>
|
10 |
+
<modules>
|
11 |
+
<WoltersKluwer_CchSureTax>
|
12 |
+
<version>1.0.3</version>
|
13 |
+
</WoltersKluwer_CchSureTax>
|
14 |
+
</modules>
|
15 |
+
<global>
|
16 |
+
<events>
|
17 |
+
<sales_order_save_after>
|
18 |
+
<observers>
|
19 |
+
<wolterskluwer_cchsuretax_save_after>
|
20 |
+
<type>singleton</type>
|
21 |
+
<class>WoltersKluwer_CchSureTax_Model_Observer</class>
|
22 |
+
<method>afterOrderSaved</method>
|
23 |
+
</wolterskluwer_cchsuretax_save_after>
|
24 |
+
</observers>
|
25 |
+
</sales_order_save_after>
|
26 |
+
<sales_order_invoice_save_after>
|
27 |
+
<observers>
|
28 |
+
<wolterskluwer_cchsuretax_invoice_after>
|
29 |
+
<type>singleton</type>
|
30 |
+
<class>WoltersKluwer_CchSureTax_Model_Observer</class>
|
31 |
+
<method>afterInvoiceSaved</method>
|
32 |
+
</wolterskluwer_cchsuretax_invoice_after>
|
33 |
+
</observers>
|
34 |
+
</sales_order_invoice_save_after>
|
35 |
+
<sales_convert_quote_address_to_order>
|
36 |
+
<observers>
|
37 |
+
<tax>
|
38 |
+
<class>WoltersKluwer_CchSureTax_Model_Observer</class>
|
39 |
+
<method>salesEventConvertQuoteAddressToOrder</method>
|
40 |
+
</tax>
|
41 |
+
</observers>
|
42 |
+
</sales_convert_quote_address_to_order>
|
43 |
+
<sales_order_creditmemo_save_after>
|
44 |
+
<observers>
|
45 |
+
<wolterskluwer_cchsuretax_creditmemo_refund>
|
46 |
+
<type>singleton</type>
|
47 |
+
<class>WoltersKluwer_CchSureTax_Model_Observer</class>
|
48 |
+
<method>afterCreditMemoRefund</method>
|
49 |
+
</wolterskluwer_cchsuretax_creditmemo_refund>
|
50 |
+
</observers>
|
51 |
+
</sales_order_creditmemo_save_after>
|
52 |
+
</events>
|
53 |
+
<models>
|
54 |
+
<wolterskluwer_cchsuretax>
|
55 |
+
<class>WoltersKluwer_CchSureTax_Model</class>
|
56 |
+
<resourceModel>wolterskluwer_cchsuretax_resource</resourceModel>
|
57 |
+
</wolterskluwer_cchsuretax>
|
58 |
+
<wolterskluwer_cchsuretax_resource>
|
59 |
+
<class>WoltersKluwer_CchSureTax_Model_Resource</class>
|
60 |
+
<entities>
|
61 |
+
|
62 |
+
<suretaxaddress>
|
63 |
+
<class>WoltersKluwer_CchSureTax_Ws_SureTaxAddress</class>
|
64 |
+
</suretaxaddress>
|
65 |
+
<suretaxclient>
|
66 |
+
<class>WoltersKluwer_CchSureTax_Ws_SureTaxClient</class>
|
67 |
+
</suretaxclient>
|
68 |
+
<suretaxitem>
|
69 |
+
<class>WoltersKluwer_CchSureTax_Ws_SureTaxItem</class>
|
70 |
+
</suretaxitem>
|
71 |
+
<suretaxrequest>
|
72 |
+
<class>WoltersKluwer_CchSureTax_Ws_SureTaxRequest</class>
|
73 |
+
</suretaxrequest>
|
74 |
+
<taxadjustmentitem>
|
75 |
+
<class>WoltersKluwer_CchSureTax_Ws_TaxAdjustmentItem</class>
|
76 |
+
</taxadjustmentitem>
|
77 |
+
<taxadjustmentrequest>
|
78 |
+
<class>WoltersKluwer_CchSureTax_Ws_TaxAdjustmentRequest</class>
|
79 |
+
</taxadjustmentrequest>
|
80 |
+
|
81 |
+
|
82 |
+
<info>
|
83 |
+
<table>wolterskluwer_cchsuretax_info</table>
|
84 |
+
</info>
|
85 |
+
<info_registrant>
|
86 |
+
<table>wolterskluwer_cchsuretax_info_registrant</table>
|
87 |
+
</info_registrant>
|
88 |
+
<websitestore_config>
|
89 |
+
<table>wolterskluwer_cchsuretax_websitestore_config</table>
|
90 |
+
</websitestore_config>
|
91 |
+
<order>
|
92 |
+
<table>wolterskluwer_cchsuretax_order</table>
|
93 |
+
</order>
|
94 |
+
<order_registrant>
|
95 |
+
<table>wolterskluwer_cchsuretax_order_registrant</table>
|
96 |
+
</order_registrant>
|
97 |
+
<invoice>
|
98 |
+
<table>wolterskluwer_cchsuretax_invoice</table>
|
99 |
+
</invoice>
|
100 |
+
<creditmemo>
|
101 |
+
<table>wolterskluwer_cchsuretax_creditmemo</table>
|
102 |
+
</creditmemo>
|
103 |
+
<customergroup>
|
104 |
+
<table>wolterskluwer_cchsuretax_customergroup</table>
|
105 |
+
</customergroup>
|
106 |
+
<customergroup_registrant>
|
107 |
+
<table>wolterskluwer_cchsuretax_customergroup_registrant</table>
|
108 |
+
</customergroup_registrant>
|
109 |
+
<customer>
|
110 |
+
<table>wolterskluwer_cchsuretax_customer</table>
|
111 |
+
</customer>
|
112 |
+
<customer_registrant>
|
113 |
+
<table>wolterskluwer_cchsuretax_customer_registrant</table>
|
114 |
+
</customer_registrant>
|
115 |
+
</entities>
|
116 |
+
</wolterskluwer_cchsuretax_resource>
|
117 |
+
|
118 |
+
<tax>
|
119 |
+
<rewrite>
|
120 |
+
<sales_total_quote_tax>WoltersKluwer_CchSureTax_Model_Tax_Sales_Total_Quote_Tax</sales_total_quote_tax>
|
121 |
+
</rewrite>
|
122 |
+
</tax>
|
123 |
+
<enterprise_giftwrapping>
|
124 |
+
<rewrite>
|
125 |
+
<total_quote_tax_giftwrapping>WoltersKluwer_CchSureTax_Model_Tax_Sales_Total_Quote_Giftwrap</total_quote_tax_giftwrapping>
|
126 |
+
</rewrite>
|
127 |
+
</enterprise_giftwrapping>
|
128 |
+
<core_customer_collection>
|
129 |
+
<rewrite>
|
130 |
+
<resource_customer_collection>WoltersKluwer_CchSureTax_Model_Resource_Corecustomer_Collection</resource_customer_collection>
|
131 |
+
</rewrite>
|
132 |
+
</core_customer_collection>
|
133 |
+
</models>
|
134 |
+
<resources>
|
135 |
+
<suretax_setup>
|
136 |
+
<setup>
|
137 |
+
<module>WoltersKluwer_CchSureTax</module>
|
138 |
+
<class>WoltersKluwer_CchSureTax_Model_Resource_Setup</class>
|
139 |
+
</setup>
|
140 |
+
</suretax_setup>
|
141 |
+
</resources>
|
142 |
+
<blocks>
|
143 |
+
<suretax>
|
144 |
+
<class>WoltersKluwer_CchSureTax_Block</class>
|
145 |
+
</suretax>
|
146 |
+
|
147 |
+
</blocks>
|
148 |
+
<helpers>
|
149 |
+
<suretax>
|
150 |
+
<class>WoltersKluwer_CchSureTax_Helper</class>
|
151 |
+
</suretax>
|
152 |
+
</helpers>
|
153 |
+
</global>
|
154 |
+
<admin>
|
155 |
+
<routers>
|
156 |
+
<adminhtml>
|
157 |
+
<use>admin</use>
|
158 |
+
<args>
|
159 |
+
<modules>
|
160 |
+
|
161 |
+
<suretax before="Mage_Adminhtml">WoltersKluwer_CchSureTax_Adminhtml</suretax>
|
162 |
+
<!-- This 'suretaxconfig' tag should match action tag in adminhtml.xml and Controller class under controllers/adminhtml' -->
|
163 |
+
<WoltersKluwer_CchSureTax_Adminhtml before="Mage_Adminhtml">WoltersKluwer_CchSureTax_Adminhtml</WoltersKluwer_CchSureTax_Adminhtml>
|
164 |
+
</modules>
|
165 |
+
</args>
|
166 |
+
</adminhtml>
|
167 |
+
</routers>
|
168 |
+
</admin>
|
169 |
+
<adminhtml>
|
170 |
+
<layout>
|
171 |
+
<updates>
|
172 |
+
<suretax>
|
173 |
+
<file>cchsuretax.xml</file>
|
174 |
+
</suretax>
|
175 |
+
</updates>
|
176 |
+
</layout>
|
177 |
+
</adminhtml>
|
178 |
+
<frontend>
|
179 |
+
<routers>
|
180 |
+
<suretax>
|
181 |
+
<use>standard</use>
|
182 |
+
<args>
|
183 |
+
<module>WoltersKluwer_CchSureTax</module>
|
184 |
+
<frontName>suretax</frontName>
|
185 |
+
</args>
|
186 |
+
</suretax>
|
187 |
+
</routers>
|
188 |
+
</frontend>
|
189 |
+
</config>
|
app/code/community/WoltersKluwer/CchSureTax/sql/suretax_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* SureTax installation script.
|
4 |
+
*
|
5 |
+
* @category WoltersKluwer
|
6 |
+
* @package WoltersKluwer_CchSureTax
|
7 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
8 |
+
*/
|
9 |
+
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
$tableName = $installer->getTable('wolterskluwer_cchsuretax/websitestore_config');
|
13 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
14 |
+
$websiteStoreTable = $installer->getConnection()->newTable($installer->getTable('wolterskluwer_cchsuretax/websitestore_config'))
|
15 |
+
->addColumn(
|
16 |
+
'id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
17 |
+
'unsigned' => true,
|
18 |
+
'nullable' => false,
|
19 |
+
'primary' => true,
|
20 |
+
'identity' => true,
|
21 |
+
), 'ID'
|
22 |
+
)
|
23 |
+
->addColumn(
|
24 |
+
'website_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
25 |
+
'nullable'=>true,
|
26 |
+
), 'Website ID'
|
27 |
+
)
|
28 |
+
->addColumn(
|
29 |
+
'store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
30 |
+
'nullable'=>true,
|
31 |
+
), 'Store ID'
|
32 |
+
)
|
33 |
+
->addColumn(
|
34 |
+
'is_enable_calc', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
35 |
+
'nullable'=>true,
|
36 |
+
), 'Is enabled flag'
|
37 |
+
)
|
38 |
+
->addColumn(
|
39 |
+
'use_business_unit', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
40 |
+
'nullable'=>true,
|
41 |
+
), 'Flag to use this Business Unit'
|
42 |
+
)
|
43 |
+
->addColumn(
|
44 |
+
'business_unit', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
45 |
+
'nullable'=>true,
|
46 |
+
), 'Business Unit for this config'
|
47 |
+
)
|
48 |
+
->addColumn(
|
49 |
+
'use_default_address', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
50 |
+
'nullable'=>true,
|
51 |
+
), 'Flag to use Default Address'
|
52 |
+
)
|
53 |
+
->addColumn(
|
54 |
+
'street_address1', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
55 |
+
'nullable'=>true,
|
56 |
+
), 'Ship From Street Address 1'
|
57 |
+
)
|
58 |
+
->addColumn(
|
59 |
+
'street_address2', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
60 |
+
'nullable'=>true,
|
61 |
+
), 'Ship From Street Address 2'
|
62 |
+
)
|
63 |
+
->addColumn(
|
64 |
+
'city', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
65 |
+
'nullable'=>true,
|
66 |
+
), 'Ship From City'
|
67 |
+
)
|
68 |
+
->addColumn(
|
69 |
+
'country', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
70 |
+
'nullable'=>true,
|
71 |
+
), 'Ship From Country'
|
72 |
+
)
|
73 |
+
->addColumn(
|
74 |
+
'state_province', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
75 |
+
'nullable'=>true,
|
76 |
+
), 'Ship From State'
|
77 |
+
)
|
78 |
+
->addColumn(
|
79 |
+
'zip_postal', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
80 |
+
'nullable'=>true,
|
81 |
+
), 'Ship From Zip'
|
82 |
+
)
|
83 |
+
->addIndex('IDX_SURETAX_WEBSITESTORE_CONF_WEBSITE', array('website_id'))
|
84 |
+
->addIndex('IDX_SURETAX_WEBSITESTORE_CONF_STORE', array('store_id'))
|
85 |
+
->addIndex('IDX_SURETAX_WEBSITESTORE_BUSINESSUNIT', array('business_unit'))
|
86 |
+
->setComment('Magento Suretax Website/Store Config Settings');
|
87 |
+
|
88 |
+
$installer->getConnection()->createTable($websiteStoreTable);
|
89 |
+
}
|
90 |
+
if ($installer->getConnection()->isTableExists($tableName) == true) {
|
91 |
+
$installer->getConnection()->addForeignKey(
|
92 |
+
'FK_SURETAX_WEBSITESTORE_CONF_WEBSITE',
|
93 |
+
'wolterskluwer_cchsuretax_websitestore_config',
|
94 |
+
'website_id',
|
95 |
+
'core_website',
|
96 |
+
'website_id',
|
97 |
+
Varien_Db_Adapter_Interface::FK_ACTION_CASCADE,
|
98 |
+
Varien_Db_Adapter_Interface::FK_ACTION_CASCADE
|
99 |
+
);
|
100 |
+
$installer->getConnection()->addForeignKey(
|
101 |
+
'FK_SURETAX_WEBSITESTORE_CONF_STORE',
|
102 |
+
'wolterskluwer_cchsuretax_websitestore_config',
|
103 |
+
'store_id',
|
104 |
+
'core_store_group',
|
105 |
+
'group_id',
|
106 |
+
Varien_Db_Adapter_Interface::FK_ACTION_CASCADE,
|
107 |
+
Varien_Db_Adapter_Interface::FK_ACTION_CASCADE
|
108 |
+
);
|
109 |
+
}
|
110 |
+
|
111 |
+
$tableName = $installer->getTable('wolterskluwer_cchsuretax/invoice');
|
112 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
113 |
+
$suretaxInvoiceTable = $installer->getConnection()->newTable($installer->getTable('wolterskluwer_cchsuretax/invoice'))
|
114 |
+
->addColumn(
|
115 |
+
'id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
116 |
+
'unsigned' => true,
|
117 |
+
'nullable' => false,
|
118 |
+
'primary' => true,
|
119 |
+
'identity' => true,
|
120 |
+
), 'ID'
|
121 |
+
)
|
122 |
+
->addColumn(
|
123 |
+
'increment_id', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
124 |
+
'nullable' => true,
|
125 |
+
), 'Invoice Increment Id'
|
126 |
+
)
|
127 |
+
->addColumn(
|
128 |
+
'trans_id', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
129 |
+
'nullable' => true,
|
130 |
+
)
|
131 |
+
)
|
132 |
+
->addColumn(
|
133 |
+
'tax', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
|
134 |
+
'nullable' => true,
|
135 |
+
)
|
136 |
+
)
|
137 |
+
->addColumn(
|
138 |
+
'client_tracking', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
139 |
+
'nullable' => true,
|
140 |
+
)
|
141 |
+
)
|
142 |
+
->addColumn(
|
143 |
+
'status', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
144 |
+
'nullable' => true,
|
145 |
+
)
|
146 |
+
)
|
147 |
+
->addColumn(
|
148 |
+
'notes', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
149 |
+
'nullable' => true,
|
150 |
+
)
|
151 |
+
)
|
152 |
+
->addIndex('IDX_SURETAX_INVOICE_INCREMENT_ID', array('increment_id'))
|
153 |
+
->addIndex('IDX_SURETAX_INVOICE_TRANS_ID', array('trans_id'))
|
154 |
+
->addIndex('IDX_SURETAX_INVOICE_CLIENT_TRACKING', array('client_tracking'))
|
155 |
+
->setComment('Magento Suretax Invoice Table');
|
156 |
+
|
157 |
+
$installer->getConnection()->createTable($suretaxInvoiceTable);
|
158 |
+
}
|
159 |
+
|
160 |
+
$tableName = $installer->getTable('wolterskluwer_cchsuretax/creditmemo');
|
161 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
162 |
+
$suretaxCreditmemoTable = $installer->getConnection()->newTable($installer->getTable('wolterskluwer_cchsuretax/creditmemo'))
|
163 |
+
->addColumn(
|
164 |
+
'id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
165 |
+
'unsigned' => true,
|
166 |
+
'nullable' => false,
|
167 |
+
'primary' => true,
|
168 |
+
'identity' => true,
|
169 |
+
), 'ID'
|
170 |
+
)
|
171 |
+
->addColumn(
|
172 |
+
'increment_id', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
173 |
+
'nullable' => true,
|
174 |
+
), 'Credit Memo Increment Id'
|
175 |
+
)
|
176 |
+
->addColumn(
|
177 |
+
'stan', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
178 |
+
'nullable' => true,
|
179 |
+
), 'Credit Memo STAN we send to SureTax'
|
180 |
+
)
|
181 |
+
->addColumn(
|
182 |
+
'trans_id', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
183 |
+
'nullable' => true,
|
184 |
+
)
|
185 |
+
)
|
186 |
+
->addColumn(
|
187 |
+
'tax', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
|
188 |
+
'nullable' => true,
|
189 |
+
)
|
190 |
+
)
|
191 |
+
->addColumn(
|
192 |
+
'client_tracking', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
193 |
+
'nullable' => true,
|
194 |
+
)
|
195 |
+
)
|
196 |
+
->addColumn(
|
197 |
+
'status', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
198 |
+
'nullable' => true,
|
199 |
+
)
|
200 |
+
)
|
201 |
+
->addColumn(
|
202 |
+
'notes', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
203 |
+
'nullable' => true,
|
204 |
+
)
|
205 |
+
)
|
206 |
+
->addIndex('IDX_SURETAX_CREDITMEMO_INCREMENT_ID', array('increment_id'))
|
207 |
+
->addIndex('IDX_SURETAX_CREDITMEMO_TRANS_ID', array('trans_id'))
|
208 |
+
->addIndex('IDX_SURETAX_CREDITMEMO_CLIENT_TRACKING', array('client_tracking'))
|
209 |
+
->setComment('Magento Suretax Credit Memo Table');
|
210 |
+
|
211 |
+
$installer->getConnection()->createTable($suretaxCreditmemoTable);
|
212 |
+
}
|
213 |
+
|
214 |
+
$tableName = $installer->getTable('wolterskluwer_cchsuretax/customergroup');
|
215 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
216 |
+
$customergroupinfoTable = $installer->getConnection()->newTable($installer->getTable('wolterskluwer_cchsuretax/customergroup'))
|
217 |
+
->addColumn(
|
218 |
+
'id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
219 |
+
'unsigned' => true,
|
220 |
+
'nullable' => false,
|
221 |
+
'primary' => true,
|
222 |
+
'identity' => true,
|
223 |
+
), 'SURE TAX CUSTOMER GROUP ID'
|
224 |
+
)
|
225 |
+
->addColumn(
|
226 |
+
'exemption_code', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
227 |
+
'length' => 255,
|
228 |
+
'nullable' => true,
|
229 |
+
), 'Exemption Code'
|
230 |
+
)
|
231 |
+
->addColumn(
|
232 |
+
'exemption_reason_code', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
233 |
+
'nullable' => true,
|
234 |
+
'length' => 255,
|
235 |
+
), 'Exemption Reason Code'
|
236 |
+
)
|
237 |
+
->addColumn(
|
238 |
+
'sales_type_code', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
239 |
+
'nullable' => true,
|
240 |
+
'length' => 255,
|
241 |
+
), 'Sales Type Code'
|
242 |
+
)
|
243 |
+
->addColumn(
|
244 |
+
'suretax_customer_group_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
245 |
+
'nullable' => false,
|
246 |
+
'unsigned' => true,
|
247 |
+
), 'Customer group ID'
|
248 |
+
)
|
249 |
+
->addIndex('IDX_SURETAX_CUSTOMER_GRP', array('suretax_customer_group_id'))
|
250 |
+
->setComment('Sure tax customer group');
|
251 |
+
|
252 |
+
$installer->getConnection()->createTable($customergroupinfoTable);
|
253 |
+
|
254 |
+
$installer->getConnection()->addForeignKey(
|
255 |
+
'FK_SURETAX_CUSTOMER_GRP',
|
256 |
+
'wolterskluwer_cchsuretax_customergroup',
|
257 |
+
'suretax_customer_group_id',
|
258 |
+
'customer_group',
|
259 |
+
'customer_group_id',
|
260 |
+
Varien_Db_Adapter_Interface::FK_ACTION_CASCADE,
|
261 |
+
Varien_Db_Adapter_Interface::FK_ACTION_CASCADE
|
262 |
+
);
|
263 |
+
}
|
264 |
+
|
265 |
+
$tableName = $installer->getTable('wolterskluwer_cchsuretax/customer');
|
266 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
267 |
+
$customerinfoTable = $installer->getConnection()->newTable($installer->getTable('wolterskluwer_cchsuretax/customer'))
|
268 |
+
->addColumn(
|
269 |
+
'id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
270 |
+
'unsigned' => true,
|
271 |
+
'nullable' => false,
|
272 |
+
'primary' => true,
|
273 |
+
'identity' => true,
|
274 |
+
), 'SURE TAX CUSTOMER ID'
|
275 |
+
)
|
276 |
+
->addColumn(
|
277 |
+
'exemption_code', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
278 |
+
'length' => 255,
|
279 |
+
'nullable' => true,
|
280 |
+
), 'Exemption Code'
|
281 |
+
)
|
282 |
+
->addColumn(
|
283 |
+
'exemption_reason_code', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
284 |
+
'nullable' => true,
|
285 |
+
'length' => 255,
|
286 |
+
), 'Exemption Reason Code'
|
287 |
+
)
|
288 |
+
->addColumn(
|
289 |
+
'sales_type_code', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
290 |
+
'nullable' => true,
|
291 |
+
'length' => 255,
|
292 |
+
), 'Sales Type Code'
|
293 |
+
)
|
294 |
+
->addColumn(
|
295 |
+
'suretax_customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
296 |
+
'nullable' => false,
|
297 |
+
'unsigned' => true,
|
298 |
+
), 'Customer ID'
|
299 |
+
)
|
300 |
+
->addIndex('IDX_SURETAX_CUSTOMER', array('suretax_customer_id'))
|
301 |
+
->setComment('Sure tax customer');
|
302 |
+
|
303 |
+
$installer->getConnection()->createTable($customerinfoTable);
|
304 |
+
|
305 |
+
$installer->getConnection()->addForeignKey(
|
306 |
+
'FK_SURETAX_CUSTOMER',
|
307 |
+
'wolterskluwer_cchsuretax_customer',
|
308 |
+
'suretax_customer_id',
|
309 |
+
'customer_entity',
|
310 |
+
'entity_id',
|
311 |
+
Varien_Db_Adapter_Interface::FK_ACTION_CASCADE,
|
312 |
+
Varien_Db_Adapter_Interface::FK_ACTION_CASCADE
|
313 |
+
);
|
314 |
+
}
|
315 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/cchsuretax.xml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* WoltersKluwer_CchSureTax
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE:
|
7 |
+
* http://www.suretax.com/resources/ecommerce/extension/license
|
8 |
+
*
|
9 |
+
* @category WoltersKluwer
|
10 |
+
* @package WoltersKluwer_CchSureTax
|
11 |
+
* @copyright Copyright (c) 2016, CCH Incorporated. All rights reserved
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
<layout>
|
15 |
+
<!--<default>
|
16 |
+
<reference name="content">
|
17 |
+
<block type="suretax/adminhtml_suretaxconfig_edit" name="suretax.config" />
|
18 |
+
</reference>
|
19 |
+
<reference name="left">
|
20 |
+
<block type="suretax/adminhtml_suretaxconfig_edit_tabs" name="suretax.config.tabs" />
|
21 |
+
</reference>
|
22 |
+
</default>-->
|
23 |
+
<adminhtml_suretax_config_index>
|
24 |
+
<reference name="content">
|
25 |
+
<block type="suretax/adminhtml_suretaxconfig_edit" name="suretax.config" />
|
26 |
+
</reference>
|
27 |
+
<reference name="left">
|
28 |
+
<block type="suretax/adminhtml_suretaxconfig_edit_tabs" name="suretax.config.tabs" />
|
29 |
+
</reference>
|
30 |
+
</adminhtml_suretax_config_index>
|
31 |
+
|
32 |
+
<adminhtml_suretax_websitestore_index>
|
33 |
+
<reference name="content">
|
34 |
+
<block type="suretax/adminhtml_websitestore_container" name="suretax.websitestore" />
|
35 |
+
</reference>
|
36 |
+
</adminhtml_suretax_websitestore_index>
|
37 |
+
|
38 |
+
<adminhtml_suretax_websitestore_edit>
|
39 |
+
<reference name="content">
|
40 |
+
<block type="suretax/adminhtml_websitestore_container_edit" name="suretax.websitestore.edit" />
|
41 |
+
</reference>
|
42 |
+
</adminhtml_suretax_websitestore_edit>
|
43 |
+
|
44 |
+
<adminhtml_suretax_invoices_index>
|
45 |
+
<reference name="content">
|
46 |
+
<block type="suretax/adminhtml_invoices_container" name="suretax.invoices" />
|
47 |
+
</reference>
|
48 |
+
</adminhtml_suretax_invoices_index>
|
49 |
+
|
50 |
+
<adminhtml_suretax_creditmemos_index>
|
51 |
+
<reference name="content">
|
52 |
+
<block type="suretax/adminhtml_creditmemos_container" name="suretax.creditmemos" />
|
53 |
+
</reference>
|
54 |
+
</adminhtml_suretax_creditmemos_index>
|
55 |
+
|
56 |
+
<adminhtml_suretax_customer_index>
|
57 |
+
<reference name="content">
|
58 |
+
<block type="suretax/adminhtml_customer_container" name="suretax.customer" />
|
59 |
+
</reference>
|
60 |
+
</adminhtml_suretax_customer_index>
|
61 |
+
|
62 |
+
<adminhtml_suretax_customer_edit>
|
63 |
+
<reference name="content">
|
64 |
+
<block type="suretax/adminhtml_customer_container_edit" name="suretax.customer.edit" />
|
65 |
+
</reference>
|
66 |
+
</adminhtml_suretax_customer_edit>
|
67 |
+
|
68 |
+
<adminhtml_suretax_customer_selectcustomer>
|
69 |
+
<reference name="content">
|
70 |
+
<block type="suretax/adminhtml_customer_container_select_container" name="suretax.customer.selectcustomer" />
|
71 |
+
</reference>
|
72 |
+
</adminhtml_suretax_customer_selectcustomer>
|
73 |
+
|
74 |
+
<adminhtml_suretax_customergroup_index>
|
75 |
+
<reference name="content">
|
76 |
+
<block type="suretax/adminhtml_customergroup_container" name="suretax.customergroup" />
|
77 |
+
</reference>
|
78 |
+
</adminhtml_suretax_customergroup_index>
|
79 |
+
|
80 |
+
<adminhtml_suretax_customergroup_edit>
|
81 |
+
<reference name="content">
|
82 |
+
<block type="suretax/adminhtml_customergroup_container_edit" name="suretax.customergroup.edit" />
|
83 |
+
</reference>
|
84 |
+
</adminhtml_suretax_customergroup_edit>
|
85 |
+
|
86 |
+
<adminhtml_suretax_customergroup_select>
|
87 |
+
<reference name="content">
|
88 |
+
<block type="suretax/adminhtml_customergroup_container_select_container" name="suretax.customergroup.select" />
|
89 |
+
</reference>
|
90 |
+
</adminhtml_suretax_customergroup_select>
|
91 |
+
|
92 |
+
<adminhtml_suretax_help_index>
|
93 |
+
<reference name="content">
|
94 |
+
<block type="suretax/adminhtml_help_container" name="suretax.help" />
|
95 |
+
</reference>
|
96 |
+
</adminhtml_suretax_help_index>
|
97 |
+
|
98 |
+
</layout>
|
app/etc/modules/WoltersKluwer_CchSureTax.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<WoltersKluwer_CchSureTax>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</WoltersKluwer_CchSureTax>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>WoltersKluwer_CchSureTax</name>
|
4 |
+
<version>1.0.3</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>NA</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>The CCH SureTax connector for Magento allows users to accurately calculate real-time sales tax.</summary>
|
10 |
+
<description>Accurately calculate real-time sales tax in shopping cart and on sale orders using CCH SureTax. Record taxes in CCH SureTax when invoices and credit memos are processed.</description>
|
11 |
+
<notes>Initial Release.</notes>
|
12 |
+
<authors><author><name>Wolters Kluwer</name><user>WoltersKluwer</user><email>Nicole.Tilton@wolterskluwer.com</email></author></authors>
|
13 |
+
<date>2016-08-16</date>
|
14 |
+
<time>23:27:04</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="WoltersKluwer_CchSureTax.xml" hash="6006c36411809123d51f29858d9bade3"/></dir></target><target name="magecommunity"><dir name="WoltersKluwer"><dir name="CchSureTax"><dir name="Block"><dir name="Adminhtml"><dir name="Creditmemos"><dir name="Container"><file name="Grid.php" hash="a8828aa2477f668956719a0e0a7f05bf"/></dir><file name="Container.php" hash="55de12709ca6ae04ccdec6e34bba3339"/></dir><dir name="Customer"><dir name="Container"><dir name="Edit"><file name="Form.php" hash="4a4b0febc6e74ed04dce4641dc898232"/></dir><file name="Edit.php" hash="513cafe4edc54e9630e2d68f7b83f7e1"/><file name="Grid.php" hash="4b6cb3573966f691e72224763ab3b40e"/><dir name="Select"><dir name="Container"><file name="Grid.php" hash="6ce41e53b41781424dc3ca9a7335bb85"/></dir><file name="Container.php" hash="6a6e834d67d23799c9c83ffafd216d64"/></dir></dir><file name="Container.php" hash="a9b759ff7a17ea131c139f1b7f0ade6e"/></dir><dir name="Customergroup"><dir name="Container"><dir name="Edit"><file name="Form.php" hash="468e97974a553b499b174cc3acc13377"/></dir><file name="Edit.php" hash="0307c5cd52a8edff78007b5ca9face69"/><file name="Grid.php" hash="820c809382674731b18cfede83a17d14"/><dir name="Select"><dir name="Container"><file name="Grid.php" hash="a3bae1a384811887c026fcce04a7846a"/></dir><file name="Container.php" hash="cc35d4929dfddfa278376e620b4aceed"/></dir></dir><file name="Container.php" hash="f127a4350fe0dad2b98e945b08a92cb7"/></dir><file name="Grid.php" hash="61458224cbda20b7262bfab154f230cf"/><dir name="Help"><file name="Container.php" hash="9936284b9a9fe724d89c9e8008baa29a"/></dir><dir name="Invoices"><dir name="Container"><file name="Grid.php" hash="ed73bd95179ebd242a5f74ff54988608"/></dir><file name="Container.php" hash="51bd1b5e7330c7c4b12e25668ee6ebdd"/></dir><dir name="Suretaxconfig"><dir name="Edit"><file name="Form.php" hash="a01a75364aeeeb7b1f4dc3d1f113a746"/><dir name="Tab"><file name="Advanced.php" hash="f326c3584e543dc11d214df01bc34eff"/><file name="Basic.php" hash="79feaf12a4dde6884f7eb51adec19ad0"/></dir><file name="Tabs.php" hash="cec5b2b6718f5728b2be8e104b807c6c"/></dir><file name="Edit.php" hash="c80bf38d71e7911c24b88a708548594a"/></dir><file name="Suretaxconfig.php" hash="d93152bf4ecbfe8b91bf44a359c9e9a2"/><dir name="Websitestore"><dir name="Container"><dir name="Edit"><file name="Form.php" hash="3a9ff2de5f537d2160999a7a3eeb7f04"/></dir><file name="Edit.php" hash="95dd5df99727de7d9605ff5c7c5804c6"/><file name="Grid.php" hash="bea2a04aaaaa7f7770480e170de5672b"/></dir><file name="Container.php" hash="eae470252ed5041d1bf38affab014ebb"/></dir></dir></dir><dir name="Helper"><file name="Config.php" hash="4a00ccbde32a5883bbb223778f222e13"/><file name="Constants.php" hash="cf823c259e5dfc7c271b4235b29ea2a7"/><file name="Data.php" hash="88dcf138a7ba0e1d65098e4560c16494"/><file name="Env.php" hash="e333ba465be559b2d5632f9e51711c62"/><file name="Utility.php" hash="fb739e86ce96e70d453ac343d8b0c54a"/><file name="WebService.php" hash="b170a90ea36883f036a0c0e5daf9f778"/><file name="WebServiceInterface.php" hash="7a8aa4fa60e6ed08acec1df9fb578597"/></dir><dir name="Model"><file name="Creditmemo.php" hash="826c929bcba2ab3fab9d155d17f5f1d6"/><file name="Customer.php" hash="13d702a1740b089f1af20fdf2ad43633"/><file name="Customergroup.php" hash="c642a7bc32a93c0b052e506c4adc08f0"/><file name="Info.php" hash="373c381f70ce1e37a5bea03020897a89"/><file name="Invoice.php" hash="c212ca8e079b2b3d8478de6566d92435"/><file name="Observer.php" hash="0aa92f0f13f8fd4494c0c6865dfde861"/><dir name="Resource"><dir name="Corecustomer"><file name="Collection.php" hash="4748f8b380462a1aa8dd50fd2429c5d8"/></dir><dir name="Creditmemo"><file name="Collection.php" hash="ca4b6146d4e51a781e621f31aa51113f"/></dir><file name="Creditmemo.php" hash="42606ce410771511b6a42f3f8b8f594b"/><dir name="Customer"><file name="Collection.php" hash="196b8c2f3139ae16f0beb387b628eebe"/></dir><file name="Customer.php" hash="03c8b6f822d60fc403abb3277a87191a"/><dir name="Customergroup"><file name="Collection.php" hash="715be78167273a8fd1467d80839d3fc4"/></dir><file name="Customergroup.php" hash="482a44ba89ec705b4c6d4d85a0757c7b"/><dir name="Info"><file name="Collection.php" hash="fc77730f91b91b071dc96aacb973ca44"/></dir><file name="Info.php" hash="90d73ba0df6ac8ebbb2e09616830009a"/><dir name="Invoice"><file name="Collection.php" hash="1d8f2fc21ef5964dd6bbae42bfaa649f"/></dir><file name="Invoice.php" hash="d89e2d668b8ccb3b797387de6df2f01a"/><file name="Setup.php" hash="a3fdc7ce36bc41f80940739f4572308e"/><dir name="Websitestore"><dir name="Config"><file name="Collection.php" hash="24c4ef3a59ed737991fa73e82846c363"/></dir><file name="Config.php" hash="ff039ec741082579a574d14f769d335e"/></dir></dir><dir name="Tax"><dir name="Sales"><dir name="Total"><dir name="Quote"><file name="Giftwrap.php" hash="71cf26bcc4e232eca88b2537a3455021"/><file name="Tax.php" hash="8093ecba70cae0ee96681f12d61d6cbe"/></dir></dir></dir></dir><dir name="Websitestore"><file name="Config.php" hash="81f80cfb8073bcaf90f61270035bcda5"/></dir><dir name="Ws"><file name="SureTaxAddress.php" hash="6d8a0820095e3fbb3cac64c3829b54bc"/><file name="SureTaxClient.php" hash="539d0bab37f0ec1daddd7f791ed866a1"/><file name="SureTaxItem.php" hash="b6ca3782dc523d0b72220d4659f32f30"/><file name="SureTaxRequest.php" hash="5f074318b30ad034057667a4f2ab83e7"/><file name="TaxAdjustmentItem.php" hash="b5eb7d0b564276d687be6fd0b9c429b3"/><file name="TaxAdjustmentRequest.php" hash="dad672a0c6a2d1d4c1d5d07b8d3b1a8a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Suretax"><file name="ConfigController.php" hash="17ebb51ba1c3d1d4baad91a301f13e69"/><file name="CreditmemosController.php" hash="9602aff2697fcafbd63f120ce9af2ff4"/><file name="CustomerController.php" hash="a75470e463267d3adf8fb36e1bfdf575"/><file name="CustomergroupController.php" hash="4dcdf31ade58d640af5340bc0c586550"/><file name="HelpController.php" hash="4194278b7bcb237eb6683a3fc1867a44"/><file name="InvoicesController.php" hash="d3a79804f05e597af6b99932435572a0"/><file name="WebsitestoreController.php" hash="a9b6f6336918670609628967953c82b9"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="abd601936506e0eea3e398f0c9348fbd"/><file name="config.xml" hash="8c65d21145713548c387dd2cefbe9772"/></dir><dir name="sql"><dir name="suretax_setup"><file name="install-1.0.0.php" hash="8832db548a0d3f5ffbe9d2c95e8134b6"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="cchsuretax.xml" hash="5b64d8541e42b9fda775de29e4524b51"/></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.4.0</min><max>5.6.0</max></php></required></dependencies>
|
18 |
+
</package>
|