OnePica_AvaTax - Version 2.5.0

Version Notes

Improved performance

Improved logging

Fixed tax calculation for configurable products

Fixed tax calculation when coupon is applied

Fixed tax calculation with gift wrapping

Fixed filter tax calculation option

Fixed queue clean up process

Download this release

Release Info

Developer Astound Commerce
Extension OnePica_AvaTax
Version 2.5.0
Comparing to
See all releases


Code changes from version 2.4.3.3 to 2.5.0

Files changed (180) hide show
  1. app/code/community/OnePica/AvaTax/.DS_Store +0 -0
  2. app/code/community/OnePica/AvaTax/Block/Adminhtml/Export/Abstract/Grid.php +68 -113
  3. app/code/community/OnePica/AvaTax/Block/Adminhtml/Export/Log/Grid.php +79 -71
  4. app/code/community/OnePica/AvaTax/Block/Adminhtml/Export/Log/View.php +21 -14
  5. app/code/community/OnePica/AvaTax/Block/Adminhtml/Export/Queue/Grid.php +94 -79
  6. app/code/community/OnePica/AvaTax/Block/Adminhtml/Notification/Toolbar.php +48 -26
  7. app/code/community/OnePica/AvaTax/Block/Adminhtml/System/Config/Form/Field/Export.php +25 -6
  8. app/code/community/OnePica/AvaTax/Block/Adminhtml/Tax/Class/Edit/Form.php +33 -24
  9. app/code/community/OnePica/AvaTax/Block/Adminhtml/Tax/Class/Grid.php +56 -46
  10. app/code/community/OnePica/AvaTax/Block/Checkout/Onepage/Shipping/Method/Available.php +106 -78
  11. app/code/community/OnePica/AvaTax/Helper/Data.php +495 -416
  12. app/code/community/OnePica/AvaTax/Helper/Tax/Data.php +126 -124
  13. app/code/community/OnePica/AvaTax/Model/.DS_Store +0 -0
  14. app/code/community/OnePica/AvaTax/Model/Abstract.php +107 -114
  15. app/code/community/OnePica/AvaTax/Model/Admin/Session.php +35 -30
  16. app/code/community/OnePica/AvaTax/Model/Adminhtml/Config.php +54 -42
  17. app/code/community/OnePica/AvaTax/Model/Adminhtml/Sales/Order/Create.php +68 -64
  18. app/code/community/OnePica/AvaTax/Model/Avatax/Abstract.php +420 -234
  19. app/code/community/OnePica/AvaTax/Model/Avatax/Address.php +284 -256
  20. app/code/community/OnePica/AvaTax/Model/Avatax/Estimate.php +447 -425
  21. app/code/community/OnePica/AvaTax/Model/Avatax/Exception/Address.php +25 -21
  22. app/code/community/OnePica/AvaTax/Model/Avatax/Exception/Commitfailure.php +25 -21
  23. app/code/community/OnePica/AvaTax/Model/Avatax/Exception/Unbalanced.php +25 -21
  24. app/code/community/OnePica/AvaTax/Model/Avatax/Invoice.php +459 -438
  25. app/code/community/OnePica/AvaTax/Model/Avatax/Ping.php +65 -49
  26. app/code/community/OnePica/AvaTax/Model/Config.php +233 -240
  27. app/code/community/OnePica/AvaTax/{sql/avatax_records_setup/mysql4-upgrade-2.2.0-2.2.1.php → Model/Exception.php} +25 -29
  28. app/code/community/OnePica/AvaTax/Model/Export.php +105 -0
  29. app/code/community/OnePica/AvaTax/Model/Export/Adapter/Abstract.php +62 -0
  30. app/code/community/OnePica/AvaTax/Model/Export/Adapter/Sql.php +117 -0
  31. app/code/community/OnePica/AvaTax/Model/Export/Entity/Abstract.php +113 -0
  32. app/code/community/OnePica/AvaTax/Model/Export/Entity/Log.php +52 -0
  33. app/code/community/OnePica/AvaTax/Model/Export/Entity/Queue.php +57 -0
  34. app/code/community/OnePica/AvaTax/Model/Observer.php +345 -212
  35. app/code/community/OnePica/AvaTax/Model/Records/.DS_Store +0 -0
  36. app/code/community/OnePica/AvaTax/Model/Records/Log.php +103 -55
  37. app/code/community/OnePica/AvaTax/Model/Records/Mysql4/Log.php +63 -38
  38. app/code/community/OnePica/AvaTax/Model/Records/Mysql4/Log/Collection.php +35 -25
  39. app/code/community/OnePica/AvaTax/Model/Records/Mysql4/Queue.php +130 -105
  40. app/code/community/OnePica/AvaTax/Model/Records/Mysql4/Queue/Collection.php +35 -25
  41. app/code/community/OnePica/AvaTax/Model/Records/Queue.php +130 -70
  42. app/code/community/OnePica/AvaTax/Model/Records/Queue/Process.php +210 -143
  43. app/code/community/OnePica/AvaTax/Model/Sales/Quote/Address.php +221 -203
  44. app/code/community/OnePica/AvaTax/Model/Sales/Quote/Address/Total/Grand.php +29 -13
  45. app/code/community/OnePica/AvaTax/Model/Sales/Quote/Address/Total/Tax.php +168 -140
  46. app/code/community/OnePica/AvaTax/Model/Session.php +36 -27
  47. app/code/community/OnePica/AvaTax/Model/Source/Actions.php +40 -30
  48. app/code/community/OnePica/AvaTax/Model/Source/Addressvalidation.php +37 -17
  49. app/code/community/OnePica/AvaTax/Model/Source/Customercodeformat.php +64 -44
  50. app/code/community/OnePica/AvaTax/Model/Source/Error.php +45 -37
  51. app/code/community/OnePica/AvaTax/Model/Source/Fieldlist.php +25 -21
  52. app/code/community/OnePica/AvaTax/Model/Source/Logmode.php +64 -44
  53. app/code/community/OnePica/AvaTax/Model/Source/Logtype.php +55 -27
  54. app/code/community/OnePica/AvaTax/Model/Source/Onerrorfrontend.php +39 -24
  55. app/code/community/OnePica/AvaTax/Model/Source/Regionfilter/List.php +39 -23
  56. app/code/community/OnePica/AvaTax/Model/Source/Regionfilter/Mode.php +49 -40
  57. app/code/community/OnePica/AvaTax/Model/Tax/Config.php +42 -0
  58. app/code/community/OnePica/AvaTax/controllers/.DS_Store +0 -0
  59. app/code/community/OnePica/AvaTax/controllers/Adminhtml/ExportController.php +90 -52
  60. app/code/community/OnePica/AvaTax/controllers/Adminhtml/GridController.php +137 -93
  61. app/code/community/OnePica/AvaTax/controllers/CartController.php +0 -35
  62. app/code/community/OnePica/AvaTax/{controllers/OnepageController.php → data/avatax_records_setup/data-upgrade-2.2.0-2.2.1.php} +15 -16
  63. app/code/community/OnePica/AvaTax/etc/adminhtml.xml +68 -69
  64. app/code/community/OnePica/AvaTax/etc/config.xml +336 -324
  65. app/code/community/OnePica/AvaTax/etc/system-disabled.xml +90 -91
  66. app/code/community/OnePica/AvaTax/etc/system.xml +522 -523
  67. app/code/community/OnePica/AvaTax/lib/AvaTax.php +1 -6
  68. app/code/community/OnePica/AvaTax/lib/classes/ATConfig.class.php +0 -4
  69. app/code/community/OnePica/AvaTax/lib/classes/ATObject.class.php +1 -3
  70. app/code/community/OnePica/AvaTax/lib/classes/AVObject.class.php +0 -0
  71. app/code/community/OnePica/AvaTax/lib/classes/Address.class.php +1 -3
  72. app/code/community/OnePica/AvaTax/lib/classes/AddressServiceSoap.class.php +0 -4
  73. app/code/community/OnePica/AvaTax/lib/classes/AddressType.class.php +0 -2
  74. app/code/community/OnePica/AvaTax/lib/classes/AdjustTaxRequest.class.php +1 -3
  75. app/code/community/OnePica/AvaTax/lib/classes/AdjustTaxResult.class.php +1 -3
  76. app/code/community/OnePica/AvaTax/lib/classes/ApplyPaymentRequest.class.php +1 -3
  77. app/code/community/OnePica/AvaTax/lib/classes/ApplyPaymentResult.class.php +1 -3
  78. app/code/community/OnePica/AvaTax/lib/classes/AvalaraSoapClient.class.php +0 -4
  79. app/code/community/OnePica/AvaTax/lib/classes/BaseResult.class.php +1 -3
  80. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/AuditMessage.class.php +0 -2
  81. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/AvaTaxBatchSvc.php +1 -4
  82. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BaseResult.class.php +1 -3
  83. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/Batch.class.php +0 -2
  84. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchDelete.class.php +1 -3
  85. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchDeleteResponse.class.php +0 -2
  86. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFetch.class.php +0 -2
  87. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFetchResponse.class.php +0 -2
  88. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFetchResult.class.php +0 -2
  89. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFile.class.php +0 -2
  90. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileDelete.class.php +0 -2
  91. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileDeleteResponse.class.php +1 -3
  92. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileFetch.class.php +0 -2
  93. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileFetchResponse.class.php +0 -2
  94. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileFetchResult.class.php +0 -2
  95. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileSave.class.php +1 -3
  96. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileSaveResponse.class.php +1 -3
  97. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileSaveResult.class.php +0 -2
  98. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchProcess.class.php +0 -2
  99. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchProcessRequest.class.php +0 -2
  100. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchProcessResponse.class.php +0 -2
  101. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchProcessResult.class.php +0 -2
  102. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchSave.class.php +0 -2
  103. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchSaveResponse.class.php +0 -2
  104. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchSaveResult.class.php +0 -2
  105. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchSvc.class.php +0 -2
  106. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/DeleteRequest.class.php +0 -2
  107. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/DeleteResult.class.php +1 -3
  108. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/FetchRequest.class.php +0 -2
  109. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/FilterRequest.class.php +1 -3
  110. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/FilterResult.class.php +1 -3
  111. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/IsAuthorized.class.php +0 -2
  112. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/IsAuthorizedResponse.class.php +1 -3
  113. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/IsAuthorizedResult.class.php +0 -2
  114. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/Message.class.php +0 -2
  115. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/Ping.class.php +0 -2
  116. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/PingResponse.class.php +0 -2
  117. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/PingResult.class.php +0 -2
  118. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/Profile.class.php +1 -3
  119. app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/SeverityLevel.class.php +1 -3
  120. app/code/community/OnePica/AvaTax/lib/classes/BoundaryLevel.class.php +1 -4
  121. app/code/community/OnePica/AvaTax/lib/classes/CancelCode.class.php +1 -3
  122. app/code/community/OnePica/AvaTax/lib/classes/CancelTaxRequest.class.php +1 -7
  123. app/code/community/OnePica/AvaTax/lib/classes/CancelTaxResult.class.php +1 -3
  124. app/code/community/OnePica/AvaTax/lib/classes/CommitTaxRequest.class.php +1 -4
  125. app/code/community/OnePica/AvaTax/lib/classes/CommitTaxResult.class.php +1 -3
  126. app/code/community/OnePica/AvaTax/lib/classes/DetailLevel.class.php +1 -3
  127. app/code/community/OnePica/AvaTax/lib/classes/DocStatus.class.php +1 -3
  128. app/code/community/OnePica/AvaTax/lib/classes/DocumentType.class.php +1 -3
  129. app/code/community/OnePica/AvaTax/lib/classes/DynamicSoapClient.class.php +0 -2
  130. app/code/community/OnePica/AvaTax/lib/classes/Enum.class.php +1 -3
  131. app/code/community/OnePica/AvaTax/lib/classes/GetTaxHistoryRequest.class.php +1 -3
  132. app/code/community/OnePica/AvaTax/lib/classes/GetTaxHistoryResult.class.php +1 -3
  133. app/code/community/OnePica/AvaTax/lib/classes/GetTaxRequest.class.php +12 -14
  134. app/code/community/OnePica/AvaTax/lib/classes/GetTaxResult.class.php +1 -3
  135. app/code/community/OnePica/AvaTax/lib/classes/IsAuthorizedResult.class.php +1 -3
  136. app/code/community/OnePica/AvaTax/lib/classes/JurisdictionType.class.php +1 -3
  137. app/code/community/OnePica/AvaTax/lib/classes/Line.class.php +12 -15
  138. app/code/community/OnePica/AvaTax/lib/classes/Message.class.php +1 -3
  139. app/code/community/OnePica/AvaTax/lib/classes/PingResult.class.php +1 -3
  140. app/code/community/OnePica/AvaTax/lib/classes/PostTaxRequest.class.php +1 -6
  141. app/code/community/OnePica/AvaTax/lib/classes/PostTaxResult.class.php +1 -3
  142. app/code/community/OnePica/AvaTax/lib/classes/ReconcileTaxHistoryRequest.class.php +1 -3
  143. app/code/community/OnePica/AvaTax/lib/classes/ReconcileTaxHistoryResult.class.php +1 -3
  144. app/code/community/OnePica/AvaTax/lib/classes/SearchTaxHistoryResult.class.php +1 -3
  145. app/code/community/OnePica/AvaTax/lib/classes/ServiceMode.class.php +1 -2
  146. app/code/community/OnePica/AvaTax/lib/classes/SeverityLevel.class.php +1 -3
  147. app/code/community/OnePica/AvaTax/lib/classes/TaxDetail.class.php +1 -7
  148. app/code/community/OnePica/AvaTax/lib/classes/TaxLine.class.php +1 -2
  149. app/code/community/OnePica/AvaTax/lib/classes/TaxOverride.class.php +1 -3
  150. app/code/community/OnePica/AvaTax/lib/classes/TaxOverrideType.class.php +1 -3
  151. app/code/community/OnePica/AvaTax/lib/classes/TaxRequest.class.php +1 -3
  152. app/code/community/OnePica/AvaTax/lib/classes/TaxServiceSoap.class.php +0 -2
  153. app/code/community/OnePica/AvaTax/lib/classes/TaxType.class.php +1 -5
  154. app/code/community/OnePica/AvaTax/lib/classes/TextCase.class.php +1 -3
  155. app/code/community/OnePica/AvaTax/lib/classes/ValidAddress.class.php +1 -3
  156. app/code/community/OnePica/AvaTax/lib/classes/ValidateRequest.class.php +0 -2
  157. app/code/community/OnePica/AvaTax/lib/classes/ValidateResult.class.php +1 -3
  158. app/code/community/OnePica/AvaTax/lib/classes/wsdl/Address.wsdl +0 -0
  159. app/code/community/OnePica/AvaTax/lib/classes/wsdl/BatchSvc.wsdl +0 -0
  160. app/code/community/OnePica/AvaTax/lib/classes/wsdl/Tax.wsdl +0 -0
  161. app/code/community/OnePica/AvaTax/lib/functions.php +0 -0
  162. app/code/community/OnePica/AvaTax/sql/avatax_records_setup/mysql4-install-0.1.0.php +37 -33
  163. app/code/community/OnePica/AvaTax/sql/avatax_records_setup/mysql4-upgrade-0.1.4-0.1.5.php +81 -34
  164. app/code/community/OnePica/AvaTax/sql/avatax_records_setup/mysql4-upgrade-1.0.1-2.0.0.php +122 -37
  165. app/code/community/OnePica/AvaTax/sql/avatax_records_setup/mysql4-upgrade-2.5.0.0-2.5.0.1.php +306 -0
  166. app/design/adminhtml/default/default/layout/avatax.xml +0 -14
  167. app/design/adminhtml/default/default/layout/onepica/avatax.xml +43 -0
  168. app/design/adminhtml/default/default/template/{avatax → onepica/avatax}/log/view.phtml +6 -8
  169. app/design/adminhtml/default/default/template/onepica/avatax/notification/toolbar.phtml +34 -0
  170. app/design/frontend/base/default/layout/avatax.xml +0 -12
  171. app/design/frontend/base/default/layout/onepica/avatax.xml +29 -0
  172. app/etc/modules/OnePica_AvaTax.xml +23 -6
  173. app/locale/de_DE/OnePica_AvaTax.csv +13 -0
  174. app/locale/en_US/OnePica_AvaTax.csv +13 -0
  175. app/locale/es_ES/OnePica_AvaTax.csv +13 -0
  176. app/locale/fr_FR/OnePica_AvaTax.csv +13 -0
  177. app/locale/nl_NL/OnePica_AvaTax.csv +13 -0
  178. app/locale/pt_BR/OnePica_AvaTax.csv +13 -0
  179. app/locale/zh_CN/OnePica_AvaTax.csv +13 -0
  180. package.xml +18 -11
app/code/community/OnePica/AvaTax/.DS_Store DELETED
Binary file
app/code/community/OnePica/AvaTax/Block/Adminhtml/Export/Abstract/Grid.php CHANGED
@@ -1,113 +1,68 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- abstract class OnePica_AvaTax_Block_Adminhtml_Export_Abstract_Grid extends Mage_Adminhtml_Block_Widget_Grid
19
- {
20
-
21
- /**
22
- * Constructor: sets grid id and sort order
23
- *
24
- */
25
- public function __construct() {
26
- parent::__construct();
27
- $this->setId('export_grid');
28
- $this->setDefaultDir('DESC');
29
- $this->setSaveParametersInSession(false);
30
-
31
- $url = Mage::helper('avatax')->getDocumentationUrl();
32
- Mage::helper('adminhtml')->setPageHelpUrl($url);
33
- }
34
-
35
- /**
36
- * Mass adds columns based on passed in array
37
- *
38
- * @param array $columns array(columnName => dataType)
39
- * @return self
40
- */
41
- protected function _addColumnsForExport($columns) {
42
- foreach ($columns as $name=>$type) {
43
- if(is_array($type)) {
44
- $this->addColumn($name, array(
45
- 'header' => Mage::helper('avatax')->__(ucwords(str_replace('_', ' ', $name))),
46
- 'index' => $name,
47
- 'type' => 'options',
48
- 'options' => $type
49
- ));
50
- } else {
51
- $this->addColumn($name, array(
52
- 'header' => Mage::helper('avatax')->__(ucwords(str_replace('_', ' ', $name))),
53
- 'index' => $name,
54
- 'type' => $type
55
- ));
56
- }
57
- }
58
- return $this;
59
- }
60
-
61
- /**
62
- * Creates SQL code from collection
63
- *
64
- * @return string
65
- */
66
- public function getSql() {
67
- $this->_isExport = true;
68
- $this->_prepareGrid();
69
- $this->getCollection()->getSelect()->limit();
70
- $this->getCollection()->setPageSize(0);
71
- $this->getCollection()->load();
72
- $this->_afterLoadCollection();
73
-
74
- $columns = array();
75
- foreach ($this->_columns as $column) {
76
- if (!$column->getIsSystem()) {
77
- $columns[] = $column->getIndex();
78
- }
79
- }
80
-
81
- $resourceModel = $this->getCollection()->getResource();
82
- $adapter = $resourceModel->getReadConnection();
83
- $version = Mage::getResourceModel('core/resource')->getDbVersion('avatax_records_setup');
84
- $stores = count(Mage::app()->getStores());
85
-
86
- $sql = '-- ' . strtoupper($resourceModel->getMainTable()) . " EXPORT\n";
87
- $sql .= '-- Created at: ' . gmdate(DATE_W3C) . "\n";
88
- $sql .= '-- Created by: ' . Mage::getUrl('/') . "\n";
89
- $sql .= '-- Magento v' . Mage::getVersion() . ' // OP_AvaTax v' . $version . ' // Stores: ' . $stores . "\n";
90
- $sql .= '-- Total rows: ' . $this->getCollection()->count() . "\n\n";
91
-
92
- $rows = array();
93
- foreach ($this->getCollection() as $item) {
94
- $values = array();
95
- foreach($columns as $column) {
96
- $values[] = $adapter->quote($item->getData($column));
97
- }
98
- $rows[] = "(" . implode(", ", $values) . ")";
99
- }
100
-
101
- $chunks = array_chunk($rows, 50);
102
- unset($rows);
103
-
104
- foreach($chunks as $chunk) {
105
- $sql .= 'INSERT INTO `' . $resourceModel->getMainTable() . '` (`' . implode('`, `', $columns) . '`) VALUES ';
106
- $sql .= "\n" . implode(",\n", $chunk);
107
- $sql .= ";\n\n";
108
- }
109
-
110
- return $sql;
111
- }
112
-
113
- }
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Avatax admin abstract grid
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ abstract class OnePica_AvaTax_Block_Adminhtml_Export_Abstract_Grid extends Mage_Adminhtml_Block_Widget_Grid
26
+ {
27
+ /**
28
+ * Constructor: sets grid id and sort order
29
+ */
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setId('export_grid');
34
+ $this->setDefaultDir('DESC');
35
+ $this->setSaveParametersInSession(false);
36
+
37
+ $url = Mage::helper('avatax')->getDocumentationUrl();
38
+ Mage::helper('adminhtml')->setPageHelpUrl($url);
39
+ }
40
+
41
+ /**
42
+ * Mass adds columns based on passed in array
43
+ *
44
+ * @param array $columns array(columnName => dataType)
45
+ * @return $this
46
+ * @throws Exception
47
+ */
48
+ protected function _addColumns($columns)
49
+ {
50
+ foreach ($columns as $name => $type) {
51
+ if (is_array($type)) {
52
+ $this->addColumn($name, array(
53
+ 'header' => Mage::helper('avatax')->__(ucwords(str_replace('_', ' ', $name))),
54
+ 'index' => $name,
55
+ 'type' => 'options',
56
+ 'options' => $type
57
+ ));
58
+ } else {
59
+ $this->addColumn($name, array(
60
+ 'header' => Mage::helper('avatax')->__(ucwords(str_replace('_', ' ', $name))),
61
+ 'index' => $name,
62
+ 'type' => $type
63
+ ));
64
+ }
65
+ }
66
+ return $this;
67
+ }
68
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/OnePica/AvaTax/Block/Adminhtml/Export/Log/Grid.php CHANGED
@@ -1,71 +1,79 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- class OnePica_AvaTax_Block_Adminhtml_Export_Log_Grid extends OnePica_AvaTax_Block_Adminhtml_Export_Abstract_Grid
19
- {
20
-
21
- /**
22
- * Sets default sort to id field
23
- *
24
- */
25
- public function __construct() {
26
- parent::__construct();
27
- $this->setDefaultSort('log_id');
28
- $this->setGridHeader(
29
- '<h3 class="icon-head" style="background-image:url(' . $this->getSkinUrl('images/fam_application_view_tile.gif') . ');">' .
30
- $this->__('AvaTax Action Log') .
31
- '</h3>'
32
- );
33
- }
34
-
35
- /**
36
- * Adds columns to grid
37
- *
38
- * @return self
39
- */
40
- protected function _prepareColumns() {
41
- return $this->_addColumnsForExport(array(
42
- 'log_id' => 'number',
43
- 'store_id' => 'number',
44
- 'level' => Mage::getModel('avatax_records/log')->getLevelOptions(),
45
- 'type' => Mage::getModel('avatax_records/log')->getTypeOptions(),
46
- // 'request' => 'text',
47
- // 'result' => 'text',
48
- // 'additional' => 'text',
49
- 'created_at' => 'datetime',
50
- ));
51
- return $this;
52
- }
53
-
54
- /**
55
- * Adds collection
56
- *
57
- * @return unknown
58
- */
59
- protected function _prepareCollection() {
60
- $collection = Mage::getModel('avatax_records/log')->getCollection();
61
- $this->setCollection($collection);
62
- return parent::_prepareCollection();
63
- }
64
-
65
- public function getRowUrl($row)
66
- {
67
- return $this->getUrl('*/*/logView', array('id' => $row->getId()));
68
- }
69
-
70
-
71
- }
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Admin log grid block
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Block_Adminhtml_Export_Log_Grid extends OnePica_AvaTax_Block_Adminhtml_Export_Abstract_Grid
26
+ {
27
+ /**
28
+ * Construct: Sets default sort to id field
29
+ */
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setDefaultSort('log_id');
34
+ $this->setGridHeader(
35
+ '<h3 class="icon-head" style="background-image:url('
36
+ . $this->getSkinUrl('images/fam_application_view_tile.gif') . ');">'
37
+ . $this->__('AvaTax Action Log') . '</h3>'
38
+ );
39
+ }
40
+
41
+ /**
42
+ * Adds columns to grid
43
+ *
44
+ * @return $this
45
+ */
46
+ protected function _prepareColumns()
47
+ {
48
+ return $this->_addColumns(array(
49
+ 'log_id' => 'number',
50
+ 'store_id' => 'number',
51
+ 'level' => Mage::getModel('avatax_records/log')->getLevelOptions(),
52
+ 'type' => Mage::getModel('avatax_records/log')->getTypeOptions(),
53
+ 'created_at' => 'datetime',
54
+ ));
55
+ }
56
+
57
+ /**
58
+ * Adds collection
59
+ *
60
+ * @return unknown
61
+ */
62
+ protected function _prepareCollection()
63
+ {
64
+ $collection = Mage::getModel('avatax_records/log')->getCollection();
65
+ $this->setCollection($collection);
66
+ return parent::_prepareCollection();
67
+ }
68
+
69
+ /**
70
+ * Get row url
71
+ *
72
+ * @param OnePica_AvaTax_Model_Records_Log $row
73
+ * @return string
74
+ */
75
+ public function getRowUrl($row)
76
+ {
77
+ return $this->getUrl('*/*/logView', array('id' => $row->getId()));
78
+ }
79
+ }
app/code/community/OnePica/AvaTax/Block/Adminhtml/Export/Log/View.php CHANGED
@@ -15,6 +15,13 @@
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
 
 
 
 
 
 
 
18
  class OnePica_AvaTax_Block_Adminhtml_Export_Log_View extends Mage_Adminhtml_Block_Widget_Container
19
  {
20
  /**
@@ -25,14 +32,13 @@ class OnePica_AvaTax_Block_Adminhtml_Export_Log_View extends Mage_Adminhtml_Bloc
25
  protected $_currentEevent = null;
26
 
27
  /**
28
- * Add back button
29
- *
30
  */
31
  public function __construct()
32
  {
33
  parent::__construct();
34
-
35
- $this->_addButton('back', array(
36
  'label' => Mage::helper('avatax')->__('Back'),
37
  'onclick' => "setLocation('" . Mage::getSingleton('adminhtml/url')->getUrl('*/*/log'). "')",
38
  'class' => 'back'
@@ -45,20 +51,22 @@ class OnePica_AvaTax_Block_Adminhtml_Export_Log_View extends Mage_Adminhtml_Bloc
45
  * @return string
46
  */
47
  public function getHeaderText()
48
- {
49
  if ($this->getCurrentEvent()) {
50
- return '<h3 class="icon-head" style="background-image:url(' . $this->getSkinUrl('images/fam_application_view_tile.gif') . ');">' .
51
- $this->__('AvaTax Action Log Entry #%d', $this->getCurrentEvent()->getId()) .
52
- '</h3>';
 
53
  }
54
- return '<h3 class="icon-head" style="background-image:url(' . $this->getSkinUrl('images/fam_application_view_tile.gif') . ');">' .
55
- $this->__('AvaTax Action Log Entry Details') .
56
- '</h3>';
 
57
  }
58
 
59
  /**
60
  * Get current event
61
- *
62
  * @return OnePica_AvaTax_Model_Event|null
63
  */
64
  public function getCurrentEvent()
@@ -68,5 +76,4 @@ class OnePica_AvaTax_Block_Adminhtml_Export_Log_View extends Mage_Adminhtml_Bloc
68
  }
69
  return $this->_currentEevent;
70
  }
71
-
72
- }
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
+ /**
19
+ * Admin html export detail view block
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Block_Adminhtml_Export_Log_View extends Mage_Adminhtml_Block_Widget_Container
26
  {
27
  /**
32
  protected $_currentEevent = null;
33
 
34
  /**
35
+ * Construct: Add back button
 
36
  */
37
  public function __construct()
38
  {
39
  parent::__construct();
40
+
41
+ $this->_addButton('back', array(
42
  'label' => Mage::helper('avatax')->__('Back'),
43
  'onclick' => "setLocation('" . Mage::getSingleton('adminhtml/url')->getUrl('*/*/log'). "')",
44
  'class' => 'back'
51
  * @return string
52
  */
53
  public function getHeaderText()
54
+ {
55
  if ($this->getCurrentEvent()) {
56
+ return '<h3 class="icon-head" style="background-image:url('
57
+ . $this->getSkinUrl('images/fam_application_view_tile.gif') . ');">'
58
+ . $this->__('AvaTax Action Log Entry #%d', $this->getCurrentEvent()->getId())
59
+ . '</h3>';
60
  }
61
+ return '<h3 class="icon-head" style="background-image:url('
62
+ . $this->getSkinUrl('images/fam_application_view_tile.gif') . ');">'
63
+ . $this->__('AvaTax Action Log Entry Details')
64
+ . '</h3>';
65
  }
66
 
67
  /**
68
  * Get current event
69
+ *
70
  * @return OnePica_AvaTax_Model_Event|null
71
  */
72
  public function getCurrentEvent()
76
  }
77
  return $this->_currentEevent;
78
  }
79
+ }
 
app/code/community/OnePica/AvaTax/Block/Adminhtml/Export/Queue/Grid.php CHANGED
@@ -1,79 +1,94 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- class OnePica_AvaTax_Block_Adminhtml_Export_Queue_Grid extends OnePica_AvaTax_Block_Adminhtml_Export_Abstract_Grid
19
- {
20
-
21
- /**
22
- * Sets default sort to id field
23
- *
24
- */
25
- public function __construct() {
26
- parent::__construct();
27
- $this->setDefaultSort('id');
28
- $this->setGridHeader(
29
- '<h3 class="icon-head" style="background-image:url(' . $this->getSkinUrl('images/fam_application_view_tile.gif') . ');">' .
30
- $this->__('AvaTax Order Sync Queue') .
31
- '</h3>'
32
- );
33
- }
34
-
35
- /**
36
- * Adds custom buttons
37
- *
38
- */
39
- public function getMainButtonsHtml()
40
- {
41
- $html = $this->getButtonHtml($this->__('Clear Queue Now'), 'setLocation(\'' . $this->getUrl('*/*/clearQueue') . '\')');
42
- $html .= $this->getButtonHtml($this->__('Process Queue Now'), 'setLocation(\'' . $this->getUrl('*/*/processQueue') . '\')');
43
- $html .= parent::getMainButtonsHtml();
44
- return $html;
45
- }
46
-
47
- /**
48
- * Adds columns to grid
49
- *
50
- * @return self
51
- */
52
- protected function _prepareColumns() {
53
- return $this->_addColumnsForExport(array(
54
- 'id' => 'number',
55
- 'store_id' => 'number',
56
- 'entity_id' => 'number',
57
- 'entity_increment_id' => 'number',
58
- 'type' => Mage::getModel('avatax/records_queue')->getTypeOptions(),
59
- 'status' => Mage::getModel('avatax/records_queue')->getStatusOptions(),
60
- 'attempt' => 'number',
61
- 'message' => 'default',
62
- 'created_at' => 'datetime',
63
- 'updated_at' => 'datetime'
64
- ));
65
- return $this;
66
- }
67
-
68
- /**
69
- * Adds collection
70
- *
71
- * @return unknown
72
- */
73
- protected function _prepareCollection() {
74
- $collection = Mage::getModel('avatax_records/queue')->getCollection();
75
- $this->setCollection($collection);
76
- return parent::_prepareCollection();
77
- }
78
-
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Admin queue grid block
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Block_Adminhtml_Export_Queue_Grid extends OnePica_AvaTax_Block_Adminhtml_Export_Abstract_Grid
26
+ {
27
+ /**
28
+ * Construct: Sets default sort to id field
29
+ */
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setDefaultSort('id');
34
+ $this->setGridHeader(
35
+ '<h3 class="icon-head" style="background-image:url('
36
+ . $this->getSkinUrl('images/fam_application_view_tile.gif') . ');">'
37
+ . $this->__('AvaTax Order Sync Queue')
38
+ . '</h3>'
39
+ );
40
+ }
41
+
42
+ /**
43
+ * Adds custom buttons
44
+ *
45
+ * @return string
46
+ */
47
+ public function getMainButtonsHtml()
48
+ {
49
+ $html = $this->getButtonHtml(
50
+ $this->__('Clear Queue Now'),
51
+ 'setLocation(\'' . $this->getUrl('*/*/clearQueue') . '\')'
52
+ );
53
+ $html .= $this->getButtonHtml(
54
+ $this->__('Process Queue Now'),
55
+ 'setLocation(\'' . $this->getUrl('*/*/processQueue') . '\')'
56
+ );
57
+ $html .= parent::getMainButtonsHtml();
58
+ return $html;
59
+ }
60
+
61
+ /**
62
+ * Adds columns to grid
63
+ *
64
+ * @return $this
65
+ */
66
+ protected function _prepareColumns()
67
+ {
68
+ return $this->_addColumns(array(
69
+ 'queue_id' => 'number',
70
+ 'store_id' => 'number',
71
+ 'entity_id' => 'number',
72
+ 'entity_increment_id' => 'number',
73
+ 'type' => Mage::getModel('avatax/records_queue')->getTypeOptions(),
74
+ 'status' => Mage::getModel('avatax/records_queue')->getStatusOptions(),
75
+ 'attempt' => 'number',
76
+ 'message' => 'default',
77
+ 'created_at' => 'datetime',
78
+ 'updated_at' => 'datetime'
79
+ ));
80
+ }
81
+
82
+ /**
83
+ * Adds collection
84
+ *
85
+ * @return $this
86
+ */
87
+ protected function _prepareCollection()
88
+ {
89
+ /** @var OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection $collection */
90
+ $collection = Mage::getModel('avatax_records/queue')->getCollection();
91
+ $this->setCollection($collection);
92
+ return parent::_prepareCollection();
93
+ }
94
+ }
app/code/community/OnePica/AvaTax/Block/Adminhtml/Notification/Toolbar.php CHANGED
@@ -15,43 +15,65 @@
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
 
 
 
 
 
 
 
18
  class OnePica_AvaTax_Block_Adminhtml_Notification_Toolbar extends Mage_Adminhtml_Block_Notification_Toolbar
19
  {
20
-
21
  /**
22
  * Count the number of pending_retry items in queue
23
  *
24
  * @return int
25
  */
26
- protected function _getQueuePendingRetryCount() {
27
- return Mage::getModel('avatax_records/queue')->getCollection()
28
- ->addFieldToFilter('status', OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_RETRY)
29
- ->load()
30
- ->count();
31
- }
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  /**
34
- * Piggyback the admin notification messages block to show AvaTax warnings as needed
35
  *
36
  * @return string
37
  */
38
- protected function _toHtml() {
39
- $html = '';
40
-
41
- if(Mage::getStoreConfig('tax/avatax/error_notification_toolbar')) {
42
- $count = $this->_getQueuePendingRetryCount();
43
- if ($count) {
44
- if($count==1) $text = 'There is <strong>' . $count . '</strong> entry in the AvaTax Order Sync Queue that has errored. Syncing is attemped ' . OnePica_AvaTax_Model_Config::QUEUE_ATTEMPT_MAX . ' times before permanently failing.';
45
- else $text = 'There are <strong>' . $count . '</strong> entries in the AvaTax Order Sync Queue that have errored. Syncing is attemped ' . OnePica_AvaTax_Model_Config::QUEUE_ATTEMPT_MAX . ' times before permanently failing.';
46
-
47
- $html = '<div class="notification-global">';
48
- if (Mage::getSingleton('admin/session')->isAllowed('avatax')) {
49
- $html .= '<span class="f-right">Go to the <a href="' . $this->getUrl('avatax/adminhtml_grid/queue') . '">AvaTax Order Sync Queue</a></span>';
50
- }
51
- $html .= '<strong class="label">AvaTax:</strong> ' . $text . '</div>';
52
- }
53
- }
54
-
55
- return parent::_toHtml() . $html;
 
 
 
 
 
56
  }
57
  }
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
+ /**
19
+ * Admin notification toolbar block
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Block_Adminhtml_Notification_Toolbar extends Mage_Adminhtml_Block_Notification_Toolbar
26
  {
 
27
  /**
28
  * Count the number of pending_retry items in queue
29
  *
30
  * @return int
31
  */
32
+ public function getQueuePendingRetryCount()
33
+ {
34
+ return Mage::getModel('avatax_records/queue')->getCollection()
35
+ ->addFieldToFilter('status', OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_RETRY)
36
+ ->load()
37
+ ->count();
38
+ }
39
+
40
+ /**
41
+ * Check if avatax is allowed
42
+ *
43
+ * @return bool
44
+ */
45
+ public function isAllowed()
46
+ {
47
+ return Mage::getSingleton('admin/session')->isAllowed('avatax');
48
+ }
49
 
50
  /**
51
+ * Get queue grid url
52
  *
53
  * @return string
54
  */
55
+ public function getQueueGridUrl()
56
+ {
57
+ return $this->getUrl('avatax/adminhtml_grid/queue');
58
+ }
59
+
60
+ /**
61
+ * Check if avatax toolbar is enabled
62
+ *
63
+ * @return boolean
64
+ */
65
+ public function isEnabled()
66
+ {
67
+ return Mage::getStoreConfigFlag('tax/avatax/error_notification_toolbar');
68
+ }
69
+
70
+ /**
71
+ * Get Queue attempt max value
72
+ *
73
+ * @return int
74
+ */
75
+ public function getQueueAttemptMaxValue()
76
+ {
77
+ return OnePica_AvaTax_Model_Config::QUEUE_ATTEMPT_MAX;
78
  }
79
  }
app/code/community/OnePica/AvaTax/Block/Adminhtml/System/Config/Form/Field/Export.php CHANGED
@@ -15,22 +15,41 @@
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
- class OnePica_AvaTax_Block_Adminhtml_System_Config_Form_Field_Export extends Mage_Adminhtml_Block_System_Config_Form_Field
 
 
 
 
 
 
 
 
19
  {
20
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
21
- $buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button');
 
 
 
 
 
 
 
 
22
  $params = array(
23
  'website' => $buttonBlock->getRequest()->getParam('website')
24
  );
25
 
26
  $data1 = array(
27
  'label' => Mage::helper('avatax')->__('Export Logs'),
28
- 'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl("avatax/adminhtml_export/log", $params) . '\')',
 
29
  'class' => '',
30
  );
31
  $data2 = array(
32
  'label' => Mage::helper('avatax')->__('Export Queue'),
33
- 'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl("avatax/adminhtml_export/queue", $params) . '\')',
 
 
34
  'class' => '',
35
  );
36
 
@@ -38,5 +57,5 @@ class OnePica_AvaTax_Block_Adminhtml_System_Config_Form_Field_Export extends Mag
38
  $html .= $buttonBlock->setData($data2)->toHtml();
39
 
40
  return $html;
41
- }
42
  }
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
+ /**
19
+ * Config form field export block
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Block_Adminhtml_System_Config_Form_Field_Export
26
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
27
  {
28
+ /**
29
+ * Get element html
30
+ *
31
+ * @param Varien_Data_Form_Element_Abstract $element
32
+ * @return string
33
+ * @throws Exception
34
+ */
35
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
36
+ {
37
+ $buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button');
38
  $params = array(
39
  'website' => $buttonBlock->getRequest()->getParam('website')
40
  );
41
 
42
  $data1 = array(
43
  'label' => Mage::helper('avatax')->__('Export Logs'),
44
+ 'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("avatax/adminhtml_export/log", $params)
45
+ . '\')',
46
  'class' => '',
47
  );
48
  $data2 = array(
49
  'label' => Mage::helper('avatax')->__('Export Queue'),
50
+ 'onclick' => 'setLocation(\''
51
+ . Mage::helper('adminhtml')->getUrl("avatax/adminhtml_export/queue", $params)
52
+ . '\')',
53
  'class' => '',
54
  );
55
 
57
  $html .= $buttonBlock->setData($data2)->toHtml();
58
 
59
  return $html;
60
+ }
61
  }
app/code/community/OnePica/AvaTax/Block/Adminhtml/Tax/Class/Edit/Form.php CHANGED
@@ -1,30 +1,39 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
 
 
 
 
 
 
 
 
19
  class OnePica_AvaTax_Block_Adminhtml_Tax_Class_Edit_Form extends Mage_Adminhtml_Block_Tax_Class_Edit_Form
20
  {
21
-
 
 
 
 
22
  protected function _prepareForm()
23
- {
24
- parent::_prepareForm();
25
- $fieldset = $this->getForm()->getElement('base_fieldset');
26
-
27
- $model = Mage::registry('tax_class');
28
  $fieldset->addField('op_avatax_code', 'text',
29
  array(
30
  'name' => 'op_avatax_code',
@@ -35,4 +44,4 @@ class OnePica_AvaTax_Block_Adminhtml_Tax_Class_Edit_Form extends Mage_Adminhtml_
35
 
36
  return $this;
37
  }
38
- }
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
 
17
 
18
+ /**
19
+ * Admin tax edit form block
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Block_Adminhtml_Tax_Class_Edit_Form extends Mage_Adminhtml_Block_Tax_Class_Edit_Form
26
  {
27
+ /**
28
+ * Prepare form
29
+ *
30
+ * @return $this|Mage_Adminhtml_Block_Widget_Form
31
+ */
32
  protected function _prepareForm()
33
+ {
34
+ parent::_prepareForm();
35
+ $fieldset = $this->getForm()->getElement('base_fieldset');
36
+ $model = Mage::registry('tax_class');
 
37
  $fieldset->addField('op_avatax_code', 'text',
38
  array(
39
  'name' => 'op_avatax_code',
44
 
45
  return $this;
46
  }
47
+ }
app/code/community/OnePica/AvaTax/Block/Adminhtml/Tax/Class/Grid.php CHANGED
@@ -1,46 +1,56 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Block_Adminhtml_Tax_Class_Grid extends Mage_Adminhtml_Block_Tax_Class_Grid
20
- {
21
-
22
- /**
23
- * Set the help url
24
- *
25
- */
26
- public function __construct() {
27
- $url = Mage::helper('avatax')->getDocumentationUrl();
28
- Mage::helper('adminhtml')->setPageHelpUrl($url);
29
-
30
- return parent::__construct();
31
- }
32
-
33
- protected function _prepareColumns() {
34
- $this->addColumn('op_avatax_code',
35
- array(
36
- 'header' => Mage::helper('avatax')->__('AvaTax Code'),
37
- 'align' => 'left',
38
- 'index' => 'op_avatax_code',
39
- 'width' => '175px'
40
- )
41
- );
42
-
43
- return parent::_prepareColumns();
44
- }
45
-
46
- }
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Admin tax grid
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Block_Adminhtml_Tax_Class_Grid extends Mage_Adminhtml_Block_Tax_Class_Grid
26
+ {
27
+ /**
28
+ * Construct: Set the help url
29
+ */
30
+ public function __construct()
31
+ {
32
+ $url = Mage::helper('avatax')->getDocumentationUrl();
33
+ Mage::helper('adminhtml')->setPageHelpUrl($url);
34
+ return parent::__construct();
35
+ }
36
+
37
+ /**
38
+ * Prepare columns
39
+ *
40
+ * @return $this
41
+ * @throws Exception
42
+ */
43
+ protected function _prepareColumns()
44
+ {
45
+ $this->addColumn('op_avatax_code',
46
+ array(
47
+ 'header' => Mage::helper('avatax')->__('AvaTax Code'),
48
+ 'align' => 'left',
49
+ 'index' => 'op_avatax_code',
50
+ 'width' => '175px'
51
+ )
52
+ );
53
+
54
+ return parent::_prepareColumns();
55
+ }
56
+ }
app/code/community/OnePica/AvaTax/Block/Checkout/Onepage/Shipping/Method/Available.php CHANGED
@@ -1,78 +1,106 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * The Onepage Shipping Method Available block
20
- */
21
- class OnePica_AvaTax_Block_Checkout_Onepage_Shipping_Method_Available extends Mage_Core_Block_Abstract
22
- {
23
- protected $_address;
24
-
25
- public function getAddress()
26
- {
27
- if (empty($this->_address)) {
28
- $this->_address = $this->getQuote()->getShippingAddress();
29
- }
30
- return $this->_address;
31
- }
32
-
33
- /**
34
- * Retrieve checkout session model
35
- *
36
- * @return Mage_Checkout_Model_Session
37
- */
38
- public function getCheckout()
39
- {
40
- if (empty($this->_checkout)) {
41
- $this->_checkout = Mage::getSingleton('checkout/session');
42
- }
43
- return $this->_checkout;
44
- }
45
-
46
- /**
47
- * Retrieve sales quote model
48
- *
49
- * @return Mage_Sales_Model_Quote
50
- */
51
- public function getQuote()
52
- {
53
- if (empty($this->_quote)) {
54
- $this->_quote = $this->getCheckout()->getQuote();
55
- }
56
- return $this->_quote;
57
- }
58
-
59
- /**
60
- * Overriding parent to insert session message block if an address has been validated.
61
- *
62
- * @return string
63
- */
64
- protected function _toHtml ()
65
- {
66
- $additional = parent::_toHtml();
67
- if ($this->getAddress()->getAddressNormalized()) {
68
- $notice = Mage::getSingleton('avatax/config')->getConfig('onepage_normalize_message');
69
- if ($notice) {
70
- Mage::getSingleton('core/session')->addNotice($notice);
71
- $additional .= $this->getMessagesBlock()->getGroupedHtml();
72
- }
73
- } else if ($this->getAddress()->getAddressNotified()) {
74
- $additional .= $this->getMessagesBlock()->getGroupedHtml();
75
- }
76
- return $additional;
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The Onepage Shipping Method Available block
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Block_Checkout_Onepage_Shipping_Method_Available extends Mage_Core_Block_Abstract
26
+ {
27
+ /**
28
+ * Quote address
29
+ *
30
+ * @var Mage_Sales_Model_Quote_Address
31
+ */
32
+ protected $_address;
33
+
34
+ /**
35
+ * Checkout session
36
+ *
37
+ * @var Mage_Checkout_Model_Session
38
+ */
39
+ protected $_checkout;
40
+
41
+ /**
42
+ * Sales quote
43
+ *
44
+ * @var Mage_Sales_Model_Quote
45
+ */
46
+ protected $_quote;
47
+
48
+ /**
49
+ * Get quote address
50
+ *
51
+ * @return Mage_Sales_Model_Quote_Address
52
+ */
53
+ public function getAddress()
54
+ {
55
+ if (empty($this->_address)) {
56
+ $this->_address = $this->getQuote()->getShippingAddress();
57
+ }
58
+ return $this->_address;
59
+ }
60
+
61
+ /**
62
+ * Retrieve checkout session model
63
+ *
64
+ * @return Mage_Checkout_Model_Session
65
+ */
66
+ public function getCheckout()
67
+ {
68
+ if (empty($this->_checkout)) {
69
+ $this->_checkout = Mage::getSingleton('checkout/session');
70
+ }
71
+ return $this->_checkout;
72
+ }
73
+
74
+ /**
75
+ * Retrieve sales quote model
76
+ *
77
+ * @return Mage_Sales_Model_Quote
78
+ */
79
+ public function getQuote()
80
+ {
81
+ if (empty($this->_quote)) {
82
+ $this->_quote = $this->getCheckout()->getQuote();
83
+ }
84
+ return $this->_quote;
85
+ }
86
+
87
+ /**
88
+ * Overriding parent to insert session message block if an address has been validated.
89
+ *
90
+ * @return string
91
+ */
92
+ protected function _toHtml ()
93
+ {
94
+ $additional = parent::_toHtml();
95
+ if ($this->getAddress()->getAddressNormalized()) {
96
+ $notice = Mage::getSingleton('avatax/config')->getConfig('onepage_normalize_message');
97
+ if ($notice) {
98
+ Mage::getSingleton('core/session')->addNotice($notice);
99
+ $additional .= $this->getMessagesBlock()->getGroupedHtml();
100
+ }
101
+ } elseif ($this->getAddress()->getAddressNotified()) {
102
+ $additional .= $this->getMessagesBlock()->getGroupedHtml();
103
+ }
104
+ return $additional;
105
+ }
106
+ }
app/code/community/OnePica/AvaTax/Helper/Data.php CHANGED
@@ -1,416 +1,495 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * The base AvaTax Helper class.
20
- */
21
- class OnePica_AvaTax_Helper_Data extends Mage_Core_Helper_Abstract
22
- {
23
- public function isAvataxEnabled($store = null)
24
- {
25
- return ($this->_getConfig('action', $store) != OnePica_AvaTax_Model_Config::ACTION_DISABLE);
26
- }
27
-
28
- /**
29
- * Gets the documenation url
30
- *
31
- * @return string
32
- */
33
- public function getDocumentationUrl()
34
- {
35
- return 'http://www.onepica.com/magento-extensions/avatax/';
36
- }
37
-
38
- /**
39
- * Loads a class from the AvaTax library.
40
- *
41
- * @param string $className
42
- * @return OnePica_AvaTax_Helper_Data
43
- */
44
- public function loadClass ($className)
45
- {
46
- require_once $this->getLibPath() . DS . 'classes' . DS . $className . '.class.php';
47
- return $this;
48
- }
49
-
50
- /**
51
- * Loads an array of AvaTax classes.
52
- *
53
- * @param array $classes
54
- * @return OnePica_AvaTax_Helper_Data
55
- */
56
- public function loadClasses (array $classes)
57
- {
58
- foreach ($classes as $class) {
59
- $this->loadClass($class);
60
- }
61
- return $this;
62
- }
63
-
64
- /**
65
- * Returns the path to the etc directory.
66
- *
67
- * @return string
68
- */
69
- public function getEtcPath ()
70
- {
71
- return dirname(dirname(__FILE__)) . DS . 'etc';
72
- }
73
-
74
- /**
75
- * Returns the path to the AvaTax SDK lib directory.
76
- *
77
- * @return string
78
- */
79
- public function getLibPath ()
80
- {
81
- return Mage::getModuleDir('', 'OnePica_AvaTax') . DS . 'lib';
82
- }
83
-
84
- /**
85
- * Returns the path to the AvaTax SDK WSDL directory.
86
- *
87
- * @return string
88
- */
89
- public function getWsdlPath ()
90
- {
91
- return $this->getLibPath() . DS . 'wsdl';
92
- }
93
-
94
- /**
95
- * Returns a config value from the admin.
96
- *
97
- * @param string $path
98
- * @param int $store
99
- * @return string
100
- */
101
- protected function _getConfig ($path, $store = null)
102
- {
103
- return Mage::getSingleton('avatax/config')->getConfig($path, $store);
104
- }
105
-
106
- /**
107
- * Returns the logging level
108
- *
109
- * @return int
110
- */
111
- public function getLogMode($store=null)
112
- {
113
- return $this->_getConfig('log_status', $store);
114
- }
115
-
116
- /**
117
- * Returns the logging type
118
- *
119
- * @return string
120
- */
121
- public function getLogType($store=null)
122
- {
123
- return explode(",", $this->_getConfig('log_type_list', $store));
124
- }
125
-
126
-
127
- /**
128
- * Returns shipping line item faked sku
129
- *
130
- * @return string
131
- */
132
- public function getShippingSku($store=null)
133
- {
134
- return $this->_getConfig('shipping_sku', $store);
135
- }
136
-
137
- /**
138
- * Returns giftwraporder line item faked sku
139
- *
140
- * @return string
141
- */
142
- public function getGwOrderSku($store=null)
143
- {
144
- return $this->_getConfig('gw_order_sku', $store);
145
- }
146
-
147
- /**
148
- * Returns giftwrapitems line item faked sku
149
- *
150
- * @return string
151
- */
152
- public function getGwItemsSku($store=null)
153
- {
154
- return $this->_getConfig('gw_items_sku', $store);
155
- }
156
-
157
- /**
158
- * Returns giftwrapprintedcard line item faked sku
159
- *
160
- * @return string
161
- */
162
- public function getGwPrintedCardSku($store=null)
163
- {
164
- return $this->_getConfig('gw_printed_card_sku', $store);
165
- }
166
-
167
- /**
168
- * Returns shipping line item faked sku
169
- *
170
- * @return string
171
- */
172
- public function getSalesPersonCode($store=null)
173
- {
174
- return $this->_getConfig('sales_person_code', $store);
175
- }
176
-
177
- /**
178
- * Returns attribute code for the location code to send to Avalara
179
- *
180
- * @return string
181
- */
182
- public function getLocationCode($store=null)
183
- {
184
- return $this->_getConfig('location_code', $store);
185
- }
186
-
187
- /**
188
- * Returns attribute code for the reference code 1 to send to Avalara
189
- *
190
- * @return string
191
- */
192
- public function getRef1AttributeCode($store=null)
193
- {
194
- return $this->_getConfig('line_ref1_code', $store);
195
- }
196
-
197
- /**
198
- * Returns attribute code for the reference code 2 to send to Avalara
199
- *
200
- * @return string
201
- */
202
- public function getRef2AttributeCode($store=null)
203
- {
204
- return $this->_getConfig('line_ref2_code', $store);
205
- }
206
-
207
- /**
208
- * Returns the positive adjustment identifier to send to Avalara
209
- *
210
- * @return string
211
- */
212
- public function getPositiveAdjustmentSku($store=null)
213
- {
214
- return $this->_getConfig('adjustment_positive_sku', $store);
215
- }
216
-
217
- /**
218
- * Returns the negative adjustment identifier to send to Avalara
219
- *
220
- * @return string
221
- */
222
- public function getNegativeAdjustmentSku($store=null)
223
- {
224
- return $this->_getConfig('adjustment_negative_sku', $store);
225
- }
226
-
227
- /**
228
- * Returns the required field list
229
- *
230
- * @return string
231
- */
232
- public function getFieldRequiredList($store=null)
233
- {
234
- return $this->_getConfig('field_required_list', $store);
235
- }
236
-
237
- /**
238
- * Returns the rules for field
239
- *
240
- * @return string
241
- */
242
- public function getFieldRule($store=null)
243
- {
244
- return $this->_getConfig('field_rule', $store);
245
- }
246
-
247
-
248
- /**
249
- *
250
- *
251
- * @return string
252
- */
253
- public function fullStopOnError($store=null)
254
- {
255
- return (bool)$this->_getConfig('error_full_stop', $store);
256
- }
257
-
258
- /**
259
- * Adds error message if there is an error
260
- *
261
- * @return string
262
- */
263
- public function addErrorMessage($store=null)
264
- {
265
- static $isMessageSet = false;
266
- $message = $this->getErrorMessage($store);
267
-
268
- if(Mage::app()->getStore()->isAdmin()) {
269
- if(!$isMessageSet) Mage::getSingleton('adminhtml/session_quote')->addError($message);
270
- } else {
271
- if(!$isMessageSet) Mage::getSingleton('checkout/session')->addError($message);
272
- }
273
-
274
- $isMessageSet = true;
275
- return $message;
276
- }
277
-
278
- /**
279
- * Gets error message
280
- *
281
- * @return string
282
- */
283
- public function getErrorMessage($store=null) {
284
- if(Mage::app()->getStore()->isAdmin()) {
285
- return $this->_getConfig('error_backend_message', $store);
286
- } else {
287
- return $this->_getConfig('error_frontend_message', $store);
288
- }
289
- }
290
-
291
- /**
292
- * Does any store have this extension disabled?
293
- *
294
- * @return bool
295
- */
296
- public function isAnyStoreDisabled()
297
- {
298
- $disabled = false;
299
- $storeCollection = Mage::app()->getStores();
300
-
301
- foreach($storeCollection as $store) {
302
- $disabled |= Mage::getStoreConfig('tax/avatax/action', $store->getId()) == OnePica_AvaTax_Model_Config::ACTION_DISABLE;
303
- }
304
-
305
- return $disabled;
306
- }
307
-
308
- /**
309
- * Determines if address validation is enabled
310
- *
311
- * @param Mage_Customer_Model_Address $address
312
- * @param int $storeId
313
- * @return bool
314
- */
315
- public function isAddressValidationOn($address, $storeId) {
316
- if(!$this->isAddressActionable($address, $storeId)) {
317
- return false;
318
- }
319
- return Mage::getStoreConfig('tax/avatax/validate_address', $storeId);
320
- }
321
-
322
- /**
323
- * Determines if address normalization is enabled
324
- *
325
- * @param Mage_Customer_Model_Address $address
326
- * @param int $storeId
327
- * @return bool
328
- */
329
- public function isAddressNormalizationOn($address, $storeId) {
330
- if(!$this->isAddressActionable($address, $storeId)) {
331
- return false;
332
- }
333
- return Mage::getStoreConfig('tax/avatax/normalize_address', $storeId);
334
- }
335
-
336
- /**
337
- * Determines if the address should be filtered
338
- *
339
- * @param Mage_Customer_Model_Address
340
- * @param int $storeId
341
- * @return bool
342
- */
343
- public function isAddressActionable($address, $storeId, $filterMode = OnePica_AvaTax_Model_Config::REGIONFILTER_ALL) {
344
- $filter = false;
345
-
346
- if(Mage::getStoreConfig('tax/avatax/action', $storeId) == OnePica_AvaTax_Model_Config::ACTION_DISABLE) {
347
- return false;
348
- }
349
-
350
- if(Mage::getStoreConfig('tax/avatax/region_filter_mode', $storeId) >= $filterMode) {
351
- $regionFilters = explode(',', Mage::getStoreConfig('tax/avatax/region_filter_list', $storeId));
352
- if(!in_array($address->getRegionId(), $regionFilters)) {
353
- $filter = 'region';
354
- }
355
- }
356
-
357
- $countryFilters = explode(',', Mage::getStoreConfig('tax/avatax/country_filter_list', $storeId));
358
- if(!in_array($address->getCountryId(), $countryFilters)) {
359
- $filter = 'country';
360
- }
361
-
362
- if($filter && $this->getLogMode($storeId)) {
363
- $filterLog = Mage::getSingleton('avatax/session')->getFilterLog();
364
- if(!is_array($filterLog)) $filterLog = array();
365
- $key = $address->getCacheHashKey();
366
-
367
- //did we already log this filtered address?
368
- if(!in_array($key, $filterLog)) {
369
- $filterLog[] = $key;
370
- Mage::getSingleton('avatax/session')->setFilterLog($filterLog);
371
-
372
- $type = ($filterMode == OnePica_AvaTax_Model_Config::REGIONFILTER_TAX) ? 'tax_calc' : 'tax_calc|address_opts';
373
- Mage::getModel('avatax_records/log')
374
- ->setStoreId($storeId)
375
- ->setLevel('Success')
376
- ->setType('Filter')
377
- ->setRequest(print_r($address->debug(), true))
378
- ->setResult('filter: ' . $filter . ', type: ' . $type)
379
- ->save();
380
- }
381
- }
382
-
383
- return $filter ? false : true;
384
- }
385
-
386
- /**
387
- * Determines if the object (quote, invoice, or credit memo) should use AvaTax services
388
- *
389
- * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo
390
- * @param Mage_Sales_Model_Quote_Address
391
- * @return bool
392
- */
393
- public function isObjectActionable($object, $shippingAddress=null) {
394
- $storeId = $object->getStore()->getId();
395
-
396
- //is action enabled?
397
- $action = $object->getOrder() ? OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT : OnePica_AvaTax_Model_Config::ACTION_CALC;
398
- if(Mage::getStoreConfig('tax/avatax/action', $storeId) < $action) {
399
- return false;
400
- }
401
-
402
- if(!$shippingAddress) {
403
- $shippingAddress = $object->getShippingAddress();
404
- }
405
- if(!$shippingAddress) {
406
- $shippingAddress = $object->getBillingAddress();
407
- }
408
-
409
- //is the region filtered?
410
- if(!$this->isAddressActionable($shippingAddress, $storeId, OnePica_AvaTax_Model_Config::REGIONFILTER_TAX)) {
411
- return false;
412
- }
413
-
414
- return true;
415
- }
416
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The base AvaTax Helper class
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Helper_Data extends Mage_Core_Helper_Abstract
26
+ {
27
+ /**
28
+ * Identifier for error message
29
+ */
30
+ const CALCULATE_ERROR_MESSAGE_IDENTIFIER = 'avatax_calculate_error';
31
+
32
+ /**
33
+ * Check if avatax extension is enabled
34
+ *
35
+ * @param null|bool|int|Mage_Core_Model_Store $store $store
36
+ * @return bool
37
+ */
38
+ public function isAvataxEnabled($store = null)
39
+ {
40
+ return ($this->_getConfig('action', $store) != OnePica_AvaTax_Model_Config::ACTION_DISABLE);
41
+ }
42
+
43
+ /**
44
+ * Gets the documenation url
45
+ *
46
+ * @return string
47
+ */
48
+ public function getDocumentationUrl()
49
+ {
50
+ return 'http://www.onepica.com/magento-extensions/avatax/';
51
+ }
52
+
53
+ /**
54
+ * Loads a class from the AvaTax library.
55
+ *
56
+ * @param string $className
57
+ * @return OnePica_AvaTax_Helper_Data
58
+ */
59
+ public function loadClass($className)
60
+ {
61
+ require_once $this->getLibPath() . DS . 'classes' . DS . $className . '.class.php';
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Loads an array of AvaTax classes.
67
+ *
68
+ * @param array $classes
69
+ * @return OnePica_AvaTax_Helper_Data
70
+ */
71
+ public function loadClasses(array $classes)
72
+ {
73
+ foreach ($classes as $class) {
74
+ $this->loadClass($class);
75
+ }
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Load functions required to work with Avalara API
81
+ *
82
+ * @return $this
83
+ */
84
+ public function loadFunctions()
85
+ {
86
+ require_once $this->getLibPath() . DS . 'functions.php';
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Returns the path to the etc directory.
92
+ *
93
+ * @return string
94
+ */
95
+ public function getEtcPath ()
96
+ {
97
+ return dirname(dirname(__FILE__)) . DS . 'etc';
98
+ }
99
+
100
+ /**
101
+ * Returns the path to the AvaTax SDK lib directory.
102
+ *
103
+ * @return string
104
+ */
105
+ public function getLibPath ()
106
+ {
107
+ return Mage::getModuleDir('', 'OnePica_AvaTax') . DS . 'lib';
108
+ }
109
+
110
+ /**
111
+ * Returns the path to the AvaTax SDK WSDL directory.
112
+ *
113
+ * @return string
114
+ */
115
+ public function getWsdlPath ()
116
+ {
117
+ return $this->getLibPath() . DS . 'wsdl';
118
+ }
119
+
120
+ /**
121
+ * Returns a config value from the admin.
122
+ *
123
+ * @param string $path
124
+ * @param null|bool|int|Mage_Core_Model_Store $store
125
+ * @return string
126
+ */
127
+ protected function _getConfig ($path, $store = null)
128
+ {
129
+ return Mage::getSingleton('avatax/config')->getConfig($path, $store);
130
+ }
131
+
132
+ /**
133
+ * Returns the logging level
134
+ *
135
+ * @param null|bool|int|Mage_Core_Model_Store $store
136
+ * @return int
137
+ */
138
+ public function getLogMode($store = null)
139
+ {
140
+ return $this->_getConfig('log_status', $store);
141
+ }
142
+
143
+ /**
144
+ * Returns the logging type
145
+ *
146
+ * @param null|bool|int|Mage_Core_Model_Store $store
147
+ * @return string
148
+ */
149
+ public function getLogType($store = null)
150
+ {
151
+ return explode(",", $this->_getConfig('log_type_list', $store));
152
+ }
153
+
154
+ /**
155
+ * Returns shipping line item faked sku
156
+ *
157
+ * @param null|bool|int|Mage_Core_Model_Store $store
158
+ * @return string
159
+ */
160
+ public function getShippingSku($store = null)
161
+ {
162
+ return $this->_getConfig('shipping_sku', $store);
163
+ }
164
+
165
+ /**
166
+ * Returns giftwraporder line item faked sku
167
+ *
168
+ * @param null|bool|int|Mage_Core_Model_Store $store
169
+ * @return string
170
+ */
171
+ public function getGwOrderSku($store = null)
172
+ {
173
+ return $this->_getConfig('gw_order_sku', $store);
174
+ }
175
+
176
+ /**
177
+ * Returns giftwrapitems line item faked sku
178
+ *
179
+ * @param null|bool|int|Mage_Core_Model_Store $store
180
+ * @return string
181
+ */
182
+ public function getGwItemsSku($store = null)
183
+ {
184
+ return $this->_getConfig('gw_items_sku', $store);
185
+ }
186
+
187
+ /**
188
+ * Returns giftwrapprintedcard line item faked sku
189
+ *
190
+ * @param null|bool|int|Mage_Core_Model_Store $store
191
+ * @return string
192
+ */
193
+ public function getGwPrintedCardSku($store = null)
194
+ {
195
+ return $this->_getConfig('gw_printed_card_sku', $store);
196
+ }
197
+
198
+ /**
199
+ * Returns shipping line item faked sku
200
+ *
201
+ * @param null|bool|int|Mage_Core_Model_Store $store
202
+ * @return string
203
+ */
204
+ public function getSalesPersonCode($store = null)
205
+ {
206
+ return $this->_getConfig('sales_person_code', $store);
207
+ }
208
+
209
+ /**
210
+ * Returns attribute code for the location code to send to Avalara
211
+ *
212
+ * @param null|bool|int|Mage_Core_Model_Store $store
213
+ * @return string
214
+ */
215
+ public function getLocationCode($store = null)
216
+ {
217
+ return $this->_getConfig('location_code', $store);
218
+ }
219
+
220
+ /**
221
+ * Returns attribute code for the reference code 1 to send to Avalara
222
+ *
223
+ * @param null|bool|int|Mage_Core_Model_Store $store
224
+ * @return string
225
+ */
226
+ public function getRef1AttributeCode($store = null)
227
+ {
228
+ return $this->_getConfig('line_ref1_code', $store);
229
+ }
230
+
231
+ /**
232
+ * Returns attribute code for the reference code 2 to send to Avalara
233
+ *
234
+ * @param null|bool|int|Mage_Core_Model_Store $store
235
+ * @return string
236
+ */
237
+ public function getRef2AttributeCode($store = null)
238
+ {
239
+ return $this->_getConfig('line_ref2_code', $store);
240
+ }
241
+
242
+ /**
243
+ * Returns the positive adjustment identifier to send to Avalara
244
+ *
245
+ * @param null|bool|int|Mage_Core_Model_Store $store
246
+ * @return string
247
+ */
248
+ public function getPositiveAdjustmentSku($store = null)
249
+ {
250
+ return $this->_getConfig('adjustment_positive_sku', $store);
251
+ }
252
+
253
+ /**
254
+ * Returns the negative adjustment identifier to send to Avalara
255
+ *
256
+ * @param null|bool|int|Mage_Core_Model_Store $store
257
+ * @return string
258
+ */
259
+ public function getNegativeAdjustmentSku($store = null)
260
+ {
261
+ return $this->_getConfig('adjustment_negative_sku', $store);
262
+ }
263
+
264
+ /**
265
+ * Returns the required field list
266
+ *
267
+ * @param null|bool|int|Mage_Core_Model_Store $store
268
+ * @return string
269
+ */
270
+ public function getFieldRequiredList($store = null)
271
+ {
272
+ return $this->_getConfig('field_required_list', $store);
273
+ }
274
+
275
+ /**
276
+ * Returns the rules for field
277
+ *
278
+ * @param null|bool|int|Mage_Core_Model_Store $store
279
+ * @return string
280
+ */
281
+ public function getFieldRule($store = null)
282
+ {
283
+ return $this->_getConfig('field_rule', $store);
284
+ }
285
+
286
+ /**
287
+ * Returns full stop on error
288
+ *
289
+ * @param null|bool|int|Mage_Core_Model_Store $store
290
+ * @return bool
291
+ */
292
+ public function fullStopOnError($store = null)
293
+ {
294
+ return (bool)$this->_getConfig('error_full_stop', $store);
295
+ }
296
+
297
+ /**
298
+ * Adds error message if there is an error
299
+ *
300
+ * @param null|bool|int|Mage_Core_Model_Store $store
301
+ * @return string
302
+ */
303
+ public function addErrorMessage($store = null)
304
+ {
305
+ $message = $this->getErrorMessage($store);
306
+ if (Mage::app()->getStore()->isAdmin()) {
307
+ /** @var Mage_Adminhtml_Model_Session_Quote $session */
308
+ $session = Mage::getSingleton('adminhtml/session_quote');
309
+ } else {
310
+ /** @var Mage_Checkout_Model_Session $session */
311
+ $session = Mage::getSingleton('checkout/session');
312
+ }
313
+
314
+ $messages = $session->getMessages();
315
+ if (!$messages->getMessageByIdentifier(self::CALCULATE_ERROR_MESSAGE_IDENTIFIER)) {
316
+ /** @var Mage_Core_Model_Message_Error $error */
317
+ $error = Mage::getSingleton('core/message')->error($message);
318
+ $error->setIdentifier(self::CALCULATE_ERROR_MESSAGE_IDENTIFIER);
319
+ $session->addMessage($error);
320
+ }
321
+ return $message;
322
+ }
323
+
324
+ /**
325
+ * Remove error message
326
+ *
327
+ * @return $this
328
+ */
329
+ public function removeErrorMessage()
330
+ {
331
+ if (Mage::app()->getStore()->isAdmin()) {
332
+ /** @var Mage_Adminhtml_Model_Session_Quote $session */
333
+ $session = Mage::getSingleton('adminhtml/session_quote');
334
+ } else {
335
+ /** @var Mage_Checkout_Model_Session $session */
336
+ $session = Mage::getSingleton('checkout/session');
337
+ }
338
+ /** @var Mage_Core_Model_Message_Collection $messages */
339
+ $messages = $session->getMessages();
340
+ $messages->deleteMessageByIdentifier(self::CALCULATE_ERROR_MESSAGE_IDENTIFIER);
341
+ return $this;
342
+ }
343
+
344
+ /**
345
+ * Gets error message
346
+ *
347
+ * @param null|bool|int|Mage_Core_Model_Store $store
348
+ * @return string
349
+ */
350
+ public function getErrorMessage($store = null)
351
+ {
352
+ if (Mage::app()->getStore()->isAdmin()) {
353
+ return $this->_getConfig('error_backend_message', $store);
354
+ } else {
355
+ return $this->_getConfig('error_frontend_message', $store);
356
+ }
357
+ }
358
+
359
+ /**
360
+ * Does any store have this extension disabled?
361
+ *
362
+ * @return bool
363
+ */
364
+ public function isAnyStoreDisabled()
365
+ {
366
+ $disabled = false;
367
+ $storeCollection = Mage::app()->getStores();
368
+
369
+ foreach ($storeCollection as $store) {
370
+ //@startSkipCommitHooks
371
+ $disabled |= Mage::getStoreConfig('tax/avatax/action', $store->getId()) == OnePica_AvaTax_Model_Config::ACTION_DISABLE;
372
+ //@finishSkipCommitHooks
373
+ }
374
+
375
+ return $disabled;
376
+ }
377
+
378
+ /**
379
+ * Determines if address validation is enabled
380
+ *
381
+ * @param Mage_Customer_Model_Address $address
382
+ * @param int $storeId
383
+ * @return bool
384
+ */
385
+ public function isAddressValidationOn($address, $storeId)
386
+ {
387
+ if (!$this->isAddressActionable($address, $storeId)) {
388
+ return false;
389
+ }
390
+ return Mage::getStoreConfig('tax/avatax/validate_address', $storeId);
391
+ }
392
+
393
+ /**
394
+ * Determines if address normalization is enabled
395
+ *
396
+ * @param Mage_Customer_Model_Address $address
397
+ * @param int $storeId
398
+ * @return bool
399
+ */
400
+ public function isAddressNormalizationOn($address, $storeId)
401
+ {
402
+ if (!$this->isAddressActionable($address, $storeId)) {
403
+ return false;
404
+ }
405
+ return Mage::getStoreConfig('tax/avatax/normalize_address', $storeId);
406
+ }
407
+
408
+ /**
409
+ * Determines if the address should be filtered
410
+ *
411
+ * @param Mage_Customer_Model_Address
412
+ * @param int $storeId
413
+ * @param int $filterMode
414
+ * @return bool
415
+ */
416
+ public function isAddressActionable($address, $storeId, $filterMode = OnePica_AvaTax_Model_Config::REGIONFILTER_ALL)
417
+ {
418
+ $filter = false;
419
+
420
+ if (Mage::getStoreConfig('tax/avatax/action', $storeId) == OnePica_AvaTax_Model_Config::ACTION_DISABLE) {
421
+ return false;
422
+ }
423
+
424
+ if (Mage::getStoreConfig('tax/avatax/region_filter_mode', $storeId) >= $filterMode) {
425
+ $regionFilters = explode(',', Mage::getStoreConfig('tax/avatax/region_filter_list', $storeId));
426
+ if (!in_array($address->getRegionId(), $regionFilters)) {
427
+ $filter = 'region';
428
+ }
429
+ }
430
+
431
+ $countryFilters = explode(',', Mage::getStoreConfig('tax/avatax/country_filter_list', $storeId));
432
+ if (!in_array($address->getCountryId(), $countryFilters)) {
433
+ $filter = 'country';
434
+ }
435
+
436
+ if ($filter && $this->getLogMode($storeId)) {
437
+ $filterLog = Mage::getSingleton('avatax/session')->getFilterLog();
438
+ if (!is_array($filterLog)) {
439
+ $filterLog = array();
440
+ }
441
+ $key = $address->getCacheHashKey();
442
+
443
+ //did we already log this filtered address?
444
+ if (!in_array($key, $filterLog)) {
445
+ $filterLog[] = $key;
446
+ Mage::getSingleton('avatax/session')->setFilterLog($filterLog);
447
+
448
+ $type = ($filterMode == OnePica_AvaTax_Model_Config::REGIONFILTER_TAX) ?
449
+ 'tax_calc' : 'tax_calc|address_opts';
450
+ Mage::getModel('avatax_records/log')
451
+ ->setStoreId($storeId)
452
+ ->setLevel('Success')
453
+ ->setType('Filter')
454
+ ->setRequest(print_r($address->debug(), true))
455
+ ->setResult('filter: ' . $filter . ', type: ' . $type)
456
+ ->save();
457
+ }
458
+ }
459
+
460
+ return $filter ? false : true;
461
+ }
462
+
463
+ /**
464
+ * Determines if the object (quote, invoice, or credit memo) should use AvaTax services
465
+ *
466
+ * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
467
+ * @param Mage_Sales_Model_Quote_Address $shippingAddress
468
+ * @return bool
469
+ */
470
+ public function isObjectActionable($object, $shippingAddress = null)
471
+ {
472
+ $storeId = $object->getStore()->getId();
473
+
474
+ //is action enabled?
475
+ $action = $object->getOrder() ?
476
+ OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT : OnePica_AvaTax_Model_Config::ACTION_CALC;
477
+ if (Mage::getStoreConfig('tax/avatax/action', $storeId) < $action) {
478
+ return false;
479
+ }
480
+
481
+ if (!$shippingAddress) {
482
+ $shippingAddress = $object->getShippingAddress();
483
+ }
484
+ if (!$shippingAddress) {
485
+ $shippingAddress = $object->getBillingAddress();
486
+ }
487
+
488
+ //is the region filtered?
489
+ if (!$this->isAddressActionable($shippingAddress, $storeId, OnePica_AvaTax_Model_Config::REGIONFILTER_TAX)) {
490
+ return false;
491
+ }
492
+
493
+ return true;
494
+ }
495
+ }
app/code/community/OnePica/AvaTax/Helper/Tax/Data.php CHANGED
@@ -1,124 +1,126 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- /**
20
- * Catalog data helper
21
- */
22
- class OnePica_AvaTax_Helper_Tax_Data extends Mage_Tax_Helper_Data
23
- {
24
- /**
25
- * Items should not include tax so that AvaTax can calculate it
26
- *
27
- * @return bool
28
- */
29
- public function priceIncludesTax($store = null)
30
- {
31
- if (Mage::helper('avatax')->isAvataxEnabled($store)) {
32
- return false;
33
- }
34
- return parent::priceIncludesTax($store);
35
- }
36
-
37
- /**
38
- * Shipping should not include tax so that AvaTax can calculate it
39
- *
40
- * @return bool
41
- */
42
- public function shippingPriceIncludesTax($store = null)
43
- {
44
- if (Mage::helper('avatax')->isAvataxEnabled($store)) {
45
- return false;
46
- }
47
- return parent::shippingPriceIncludesTax($store);
48
- }
49
-
50
- /**
51
- * Returns AvaTax's hard-coded shipping tax class
52
- *
53
- * @return string
54
- */
55
- public function getShippingTaxClass($store)
56
- {
57
- if (Mage::helper('avatax')->isAvataxEnabled($store)) {
58
- return 'FR020100';
59
- }
60
- return parent::getShippingTaxClass($store);
61
- }
62
-
63
- /**
64
- * AvaTax always computes tax based on ship from and ship to addresses
65
- *
66
- * @return string
67
- */
68
- public function getTaxBasedOn($store = null)
69
- {
70
- if (Mage::helper('avatax')->isAvataxEnabled($store)) {
71
- return 'shipping';
72
- }
73
- return parent::getTaxBasedOn($store);
74
- }
75
-
76
- /**
77
- * Always apply tax on custom price
78
- *
79
- * @return bool
80
- */
81
- public function applyTaxOnCustomPrice($store = null) {
82
- if (Mage::helper('avatax')->isAvataxEnabled($store)) {
83
- return true;
84
- }
85
- return parent::applyTaxOnCustomPrice($store);
86
- }
87
-
88
- /**
89
- * Always apply tax on custom price (not original)
90
- *
91
- * @return bool
92
- */
93
- public function applyTaxOnOriginalPrice($store = null) {
94
- if (Mage::helper('avatax')->isAvataxEnabled($store)) {
95
- return false;
96
- }
97
- return parent::applyTaxOnOriginalPrice($store);
98
- }
99
-
100
- /**
101
- * Always apply discount first since AvaTax doesn't support line-level item discount amounts
102
- *
103
- * @return bool
104
- */
105
- public function applyTaxAfterDiscount($store = null) {
106
- if (Mage::helper('avatax')->isAvataxEnabled($store)) {
107
- return true;
108
- }
109
- return parent::applyTaxAfterDiscount($store);
110
- }
111
-
112
- /**
113
- * Always apply discount first since AvaTax doesn't support line-level item discount amounts
114
- *
115
- * @return bool
116
- */
117
- public function discountTax($store = null) {
118
- if (Mage::helper('avatax')->isAvataxEnabled($store)) {
119
- return false;
120
- }
121
- return parent::discountTax($store);
122
- }
123
-
124
- }
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Catalog data helper
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Helper_Tax_Data extends Mage_Tax_Helper_Data
26
+ {
27
+ /**
28
+ * Avatax shipping tax class
29
+ */
30
+ const AVATAX_SHIPPING_TAX_CLASS = 'FR020100';
31
+
32
+ /**
33
+ * Items should not include tax so that AvaTax can calculate it
34
+ *
35
+ * @param null|bool|int|Mage_Core_Model_Store $store
36
+ * @return bool
37
+ */
38
+ public function priceIncludesTax($store = null)
39
+ {
40
+ if (Mage::helper('avatax')->isAvataxEnabled($store)) {
41
+ return false;
42
+ }
43
+ return parent::priceIncludesTax($store);
44
+ }
45
+
46
+ /**
47
+ * Shipping should not include tax so that AvaTax can calculate it
48
+ *
49
+ * @param null|bool|int|Mage_Core_Model_Store $store
50
+ * @return bool
51
+ */
52
+ public function shippingPriceIncludesTax($store = null)
53
+ {
54
+ if (Mage::helper('avatax')->isAvataxEnabled($store)) {
55
+ return false;
56
+ }
57
+ return parent::shippingPriceIncludesTax($store);
58
+ }
59
+
60
+ /**
61
+ * Returns AvaTax's hard-coded shipping tax class
62
+ *
63
+ * @param null|bool|int|Mage_Core_Model_Store $store
64
+ * @return string
65
+ */
66
+ public function getShippingTaxClass($store)
67
+ {
68
+ if (Mage::helper('avatax')->isAvataxEnabled($store)) {
69
+ return self::AVATAX_SHIPPING_TAX_CLASS;
70
+ }
71
+ return parent::getShippingTaxClass($store);
72
+ }
73
+
74
+ /**
75
+ * AvaTax always computes tax based on ship from and ship to addresses
76
+ *
77
+ * @param null|bool|int|Mage_Core_Model_Store $store
78
+ * @return string
79
+ */
80
+ public function getTaxBasedOn($store = null)
81
+ {
82
+ if (Mage::helper('avatax')->isAvataxEnabled($store)) {
83
+ return 'shipping';
84
+ }
85
+ return parent::getTaxBasedOn($store);
86
+ }
87
+
88
+ /**
89
+ * Always apply tax on custom price
90
+ *
91
+ * @param null|bool|int|Mage_Core_Model_Store $store
92
+ * @return bool
93
+ */
94
+ public function applyTaxOnCustomPrice($store = null) {
95
+ if (Mage::helper('avatax')->isAvataxEnabled($store)) {
96
+ return true;
97
+ }
98
+ return parent::applyTaxOnCustomPrice($store);
99
+ }
100
+
101
+ /**
102
+ * Always apply tax on custom price (not original)
103
+ *
104
+ * @param null|bool|int|Mage_Core_Model_Store $store
105
+ * @return bool
106
+ */
107
+ public function applyTaxOnOriginalPrice($store = null) {
108
+ if (Mage::helper('avatax')->isAvataxEnabled($store)) {
109
+ return false;
110
+ }
111
+ return parent::applyTaxOnOriginalPrice($store);
112
+ }
113
+
114
+ /**
115
+ * Always apply discount first since AvaTax doesn't support line-level item discount amounts
116
+ *
117
+ * @param null|bool|int|Mage_Core_Model_Store $store
118
+ * @return bool
119
+ */
120
+ public function applyTaxAfterDiscount($store = null) {
121
+ if (Mage::helper('avatax')->isAvataxEnabled($store)) {
122
+ return true;
123
+ }
124
+ return parent::applyTaxAfterDiscount($store);
125
+ }
126
+ }
app/code/community/OnePica/AvaTax/Model/.DS_Store DELETED
Binary file
app/code/community/OnePica/AvaTax/Model/Abstract.php CHANGED
@@ -1,114 +1,107 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * The abstract base AvaTax model.
20
- */
21
- abstract class OnePica_AvaTax_Model_Abstract extends Varien_Object
22
- {
23
- /**
24
- * The module helper
25
- *
26
- * @var OnePica_AvaTax_Helper_Data
27
- */
28
- protected $_helper = null;
29
-
30
- /**
31
- * Constructor
32
- *
33
- * @return null
34
- */
35
- protected function _construct ()
36
- {
37
- Mage::getSingleton('avatax/config');
38
- }
39
-
40
- /**
41
- * Logs a debug message
42
- *
43
- * @param string $request the request string
44
- * @param string $result the result string
45
- * @param int $storeId id of the store the call is make for
46
- * @param mixed $additional any other info
47
- */
48
- protected function _log ($request, $result, $storeId=null, $additional=null)
49
- {
50
- if($result->getResultCode() == SeverityLevel::$Success) {
51
- switch(Mage::helper('avatax')->getLogMode($storeId)) {
52
- case OnePica_AvaTax_Model_Source_Logmode::ERRORS:
53
- return;
54
- break;
55
- case OnePica_AvaTax_Model_Source_Logmode::NORMAL:
56
- $additional = null;
57
- break;
58
- }
59
- }
60
-
61
- $requestType = str_replace('Request', '', get_class($request));
62
- $resultType = str_replace('Result', '', get_class($result));
63
- $type = $requestType ? $requestType : $resultType;
64
- if($type == 'Varien_Object') $type = 'Unknown';
65
-
66
- if (in_array($resultType, Mage::helper('avatax')->getLogType($storeId)))
67
- {
68
- Mage::getModel('avatax_records/log')
69
- ->setStoreId($storeId)
70
- ->setLevel($result->getResultCode())
71
- ->setType($type)
72
- ->setRequest(print_r($request, true))
73
- ->setResult(print_r($result, true))
74
- ->setAdditional($additional)
75
- ->save();
76
- }
77
- }
78
-
79
- /**
80
- * Returns the AvaTax session.
81
- *
82
- * @return OnePica_AvaTax_Model_Session
83
- */
84
- public function getSession ()
85
- {
86
- return Mage::getSingleton('avatax/session');
87
- }
88
-
89
- /**
90
- * Returns the AvaTax helper.
91
- *
92
- * @return OnePica_AvaTax_Helper_Data
93
- */
94
- public function getHelper ()
95
- {
96
- if (!$this->_helper) {
97
- $this->_helper = Mage::helper('avatax');
98
- }
99
- return $this->_helper;
100
- }
101
-
102
- /**
103
- * Alias to the helper translate method.
104
- *
105
- * @param string $message
106
- * @param string var number of replacement vars
107
- * @return string
108
- */
109
- public function __ ($message)
110
- {
111
- $args = func_get_args();
112
- return call_user_func_array(array($this->getHelper(), '__'), $args);
113
- }
114
- }
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The abstract base AvaTax model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ abstract class OnePica_AvaTax_Model_Abstract extends Varien_Object
26
+ {
27
+ /**
28
+ * The module helper
29
+ *
30
+ * @var OnePica_AvaTax_Helper_Data
31
+ */
32
+ protected $_helper = null;
33
+
34
+ /**
35
+ * Logs a debug message
36
+ *
37
+ * @param string $type
38
+ * @param string $request the request string
39
+ * @param string $result the result string
40
+ * @param int $storeId id of the store the call is make for
41
+ * @param mixed $additional any other info
42
+ * @return $this
43
+ */
44
+ protected function _log($type, $request, $result, $storeId = null, $additional = null)
45
+ {
46
+ if ($result->getResultCode() == SeverityLevel::$Success) {
47
+ switch (Mage::helper('avatax')->getLogMode($storeId)) {
48
+ case OnePica_AvaTax_Model_Source_Logmode::ERRORS:
49
+ return;
50
+ break;
51
+ case OnePica_AvaTax_Model_Source_Logmode::NORMAL:
52
+ $additional = null;
53
+ break;
54
+ }
55
+ }
56
+
57
+ if (in_array($type, Mage::helper('avatax')->getLogType($storeId))) {
58
+ Mage::getModel('avatax_records/log')
59
+ ->setStoreId($storeId)
60
+ ->setLevel($result->getResultCode())
61
+ ->setType($type)
62
+ ->setRequest(print_r($request, true))
63
+ ->setResult(print_r($result, true))
64
+ ->setAdditional($additional)
65
+ ->save();
66
+ }
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * Returns the AvaTax session.
72
+ *
73
+ * @return OnePica_AvaTax_Model_Session
74
+ */
75
+ public function getSession ()
76
+ {
77
+ return Mage::getSingleton('avatax/session');
78
+ }
79
+
80
+ /**
81
+ * Returns the AvaTax helper.
82
+ *
83
+ * @return OnePica_AvaTax_Helper_Data
84
+ */
85
+ public function getHelper ()
86
+ {
87
+ if (!$this->_helper) {
88
+ $this->_helper = Mage::helper('avatax');
89
+ }
90
+ return $this->_helper;
91
+ }
92
+
93
+ //@startSkipCommitHooks
94
+ /**
95
+ * Alias to the helper translate method.
96
+ *
97
+ * @param string $message
98
+ * @param string var number of replacement vars
99
+ * @return string
100
+ */
101
+ public function __($message)
102
+ {
103
+ $args = func_get_args();
104
+ return call_user_func_array(array($this->getHelper(), '__'), $args);
105
+ }
106
+ //@finishSkipCommitHooks
107
+ }
 
 
 
 
 
 
 
app/code/community/OnePica/AvaTax/Model/Admin/Session.php CHANGED
@@ -1,24 +1,29 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
 
 
 
 
 
 
 
 
19
  class OnePica_AvaTax_Model_Admin_Session extends Mage_Admin_Model_Session
20
  {
21
-
22
  /**
23
  * Check current user permission on resource and privilege
24
  *
@@ -29,18 +34,18 @@ class OnePica_AvaTax_Model_Admin_Session extends Mage_Admin_Model_Session
29
  * @param string $privilege
30
  * @return boolean
31
  */
32
- public function isAllowed($resource, $privilege=null)
33
  {
34
- $block = array(
35
- 'admin/sales/tax/rules',
36
- 'admin/sales/tax/rates',
37
- 'admin/sales/tax/import_export'
38
- );
39
-
40
- if(in_array($resource, $block) && !Mage::helper('avatax')->isAnyStoreDisabled()) {
41
- return false;
42
- } else {
43
- return parent::isAllowed($resource, $privilege);
44
- }
45
  }
46
  }
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
 
17
 
18
+ /**
19
+ * Admin session model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Model_Admin_Session extends Mage_Admin_Model_Session
26
  {
 
27
  /**
28
  * Check current user permission on resource and privilege
29
  *
34
  * @param string $privilege
35
  * @return boolean
36
  */
37
+ public function isAllowed($resource, $privilege = null)
38
  {
39
+ $block = array(
40
+ 'admin/sales/tax/rules',
41
+ 'admin/sales/tax/rates',
42
+ 'admin/sales/tax/import_export'
43
+ );
44
+
45
+ if (in_array($resource, $block) && !Mage::helper('avatax')->isAnyStoreDisabled()) {
46
+ return false;
47
+ } else {
48
+ return parent::isAllowed($resource, $privilege);
49
+ }
50
  }
51
  }
app/code/community/OnePica/AvaTax/Model/Adminhtml/Config.php CHANGED
@@ -1,42 +1,54 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Adminhtml_Config extends Mage_Adminhtml_Model_Config
20
- {
21
-
22
- protected function _initSectionsAndTabs() {
23
- if(Mage::helper('avatax')->isAnyStoreDisabled()) {
24
- $config = Mage::getConfig()->loadModulesConfiguration('system.xml')
25
- ->applyExtends();
26
-
27
- Mage::dispatchEvent('adminhtml_init_system_config', array('config' => $config));
28
-
29
- //these 4 lines are the only added content
30
- $configFile = Mage::helper('avatax')->getEtcPath() . DS . 'system-disabled.xml';
31
- $mergeModel = new Mage_Core_Model_Config_Base();
32
- $mergeModel->loadFile($configFile);
33
- $config = $config->extend($mergeModel, true);
34
-
35
- $this->_sections = $config->getNode('sections');
36
- $this->_tabs = $config->getNode('tabs');
37
- } else {
38
- return parent::_initSectionsAndTabs();
39
- }
40
- }
41
-
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Admin config model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Adminhtml_Config extends Mage_Adminhtml_Model_Config
26
+ {
27
+ /**
28
+ * Init modules configuration
29
+ *
30
+ * @return $this
31
+ */
32
+ protected function _initSectionsAndTabs()
33
+ {
34
+ if (Mage::helper('avatax')->isAnyStoreDisabled()) {
35
+ $config = Mage::getConfig()->loadModulesConfiguration('system.xml')
36
+ ->applyExtends();
37
+
38
+ Mage::dispatchEvent('adminhtml_init_system_config', array('config' => $config));
39
+
40
+ //these 4 lines are the only added content
41
+ $configFile = Mage::helper('avatax')->getEtcPath() . DS . 'system-disabled.xml';
42
+ /** @var Mage_Core_Model_Config_Base $mergeModel */
43
+ $mergeModel = Mage::getModel('core/config_base');
44
+ $mergeModel->loadFile($configFile);
45
+ $config = $config->extend($mergeModel, true);
46
+ $this->_sections = $config->getNode('sections');
47
+ $this->_tabs = $config->getNode('tabs');
48
+ } else {
49
+ parent::_initSectionsAndTabs();
50
+ }
51
+
52
+ return $this;
53
+ }
54
+ }
app/code/community/OnePica/AvaTax/Model/Adminhtml/Sales/Order/Create.php CHANGED
@@ -1,64 +1,68 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * The Admin Sales Order Create model.
20
- */
21
- class OnePica_AvaTax_Model_Adminhtml_Sales_Order_Create extends Mage_Adminhtml_Model_Sales_Order_Create
22
- {
23
- /**
24
- * If a session message has been added.
25
- *
26
- * @var bool
27
- */
28
- protected $_messageAdded = false;
29
-
30
- /**
31
- * Overrides the parent to validate the shipping address.
32
- *
33
- * @param array $address
34
- * @return OnePica_AvaTax_Model_Adminhtml_Sales_Order_Create
35
- */
36
- public function setShippingAddress($address)
37
- {
38
- parent::setShippingAddress($address);
39
-
40
- if ($this->getQuote()->getIsVirtual()) {
41
- return $this;
42
- }
43
-
44
- if (Mage::helper('avatax')->isAvataxEnabled()) {
45
- if (!Mage::app()->getFrontController()->getRequest()->getParam('isAjax')) {
46
- $result = $this->getShippingAddress()->validate();
47
- if ($result !== true) {
48
- $storeId = $this->_session->getStore()->getId();
49
- if(Mage::helper('avatax')->fullStopOnError($storeId)) {
50
- foreach ($result as $error) {
51
- $this->getSession()->addError($error);
52
- }
53
- Mage::throwException('');
54
- }
55
- }
56
- else if ($this->getShippingAddress()->getAddressNormalized() && !$this->_messageAdded) {
57
- Mage::getSingleton('avatax/session')->addNotice(Mage::helper('avatax')->__('The shipping address has been modified during the validation process. Please confirm the address below is accurate.'));
58
- $this->_messageAdded = true; // only add the message once
59
- }
60
- }
61
- }
62
- return $this;
63
- }
64
- }
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The Admin Sales Order Create model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Adminhtml_Sales_Order_Create extends Mage_Adminhtml_Model_Sales_Order_Create
26
+ {
27
+ /**
28
+ * If a session message has been added.
29
+ *
30
+ * @var bool
31
+ */
32
+ protected $_messageAdded = false;
33
+
34
+ /**
35
+ * Overrides the parent to validate the shipping address.
36
+ *
37
+ * @param array $address
38
+ * @return $this
39
+ * @throws Mage_Core_Exception
40
+ */
41
+ public function setShippingAddress($address)
42
+ {
43
+ parent::setShippingAddress($address);
44
+
45
+ if ($this->getQuote()->getIsVirtual()) {
46
+ return $this;
47
+ }
48
+
49
+ if (Mage::helper('avatax')->isAvataxEnabled()) {
50
+ if (!Mage::app()->getFrontController()->getRequest()->getParam('isAjax')) {
51
+ $result = $this->getShippingAddress()->validate();
52
+ if ($result !== true) {
53
+ $storeId = $this->_session->getStore()->getId();
54
+ if (Mage::helper('avatax')->fullStopOnError($storeId)) {
55
+ foreach ($result as $error) {
56
+ $this->getSession()->addError($error);
57
+ }
58
+ throw new Mage_Core_Exception(implode('<br />', $result));
59
+ }
60
+ } elseif ($this->getShippingAddress()->getAddressNormalized() && !$this->_messageAdded) {
61
+ Mage::getSingleton('avatax/session')->addNotice(Mage::helper('avatax')->__('The shipping address has been modified during the validation process. Please confirm the address below is accurate.'));
62
+ $this->_messageAdded = true; // only add the message once
63
+ }
64
+ }
65
+ }
66
+ return $this;
67
+ }
68
+ }
app/code/community/OnePica/AvaTax/Model/Avatax/Abstract.php CHANGED
@@ -1,234 +1,420 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- abstract class OnePica_AvaTax_Model_Avatax_Abstract extends OnePica_AvaTax_Model_Abstract
20
- {
21
-
22
- /**
23
- * Flag that states if there was an error
24
- *
25
- * @var bool
26
- */
27
- protected static $_hasError = false;
28
-
29
- /**
30
- * The request data object
31
- *
32
- * @var mixed
33
- */
34
- protected $_request = null;
35
-
36
- /**
37
- * Sets the company code on the request
38
- *
39
- * @return null
40
- */
41
- protected function _setCompanyCode($storeId=null) {
42
- $config = Mage::getSingleton('avatax/config');
43
- $this->_request->setCompanyCode($config->getCompanyCode($storeId));
44
- }
45
-
46
- /**
47
- * Sends a request to the Avatax server
48
- *
49
- * @param int $storeId
50
- * @return mixed
51
- */
52
- protected function _send($storeId) {
53
- $config = Mage::getSingleton('avatax/config')->init($storeId);
54
- $connection = $config->getTaxConnection();
55
- $result = null;
56
- $message = null;
57
-
58
- try { $result = $connection->getTax($this->_request); }
59
- catch(Exception $exception) { $message = $exception->getMessage(); }
60
-
61
- if(!isset($result) || !is_object($result) || !$result->getResultCode()) {
62
- $result = Mage::getModel('Varien_Object')
63
- ->setResultCode(SeverityLevel::$Exception)
64
- ->setActualResult($result)
65
- ->setMessage($message);
66
- }
67
-
68
- $this->_log($this->_request, $result, $storeId, $connection);
69
-
70
- if($result->getResultCode() != SeverityLevel::$Success) {
71
- self::$_hasError = true;
72
- if(Mage::helper('avatax')->fullStopOnError($storeId)) {
73
- Mage::helper('avatax')->addErrorMessage($storeId);
74
- }
75
- }
76
-
77
- return $result;
78
- }
79
-
80
- /**
81
- * Adds additional transaction based data
82
- *
83
- * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
84
- */
85
- protected function _addGeneralInfo($object) {
86
- $storeId = $object->getStoreId();
87
- $this->_setCompanyCode($storeId);
88
- $this->_request->setDetailLevel(DetailLevel::$Document);
89
- $this->_request->setDocDate(date('Y-m-d'));
90
- $this->_request->setExemptionNo('');
91
- $this->_request->setDiscount(0.00); //cannot be used in Magento
92
- $this->_request->setSalespersonCode(Mage::helper('avatax')->getSalesPersonCode($storeId));
93
- $this->_request->setLocationCode(Mage::helper('avatax')->getLocationCode($storeId));
94
- $this->_request->setCountry(Mage::getStoreConfig('shipping/origin/country_id', $storeId));
95
- $this->_request->setCurrencyCode(Mage::app()->getStore()->getBaseCurrencyCode());
96
- $this->_addCustomer($object);
97
- if($object instanceof Mage_Sales_Model_Order && $object->getIncrementId()) {
98
- $this->_request->setReferenceCode('Magento Order #' . $object->getIncrementId());
99
- }
100
- }
101
-
102
- /**
103
- * Sets the customer info if available
104
- *
105
- * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
106
- */
107
- protected function _addCustomer($object) {
108
- $format = Mage::getStoreConfig('tax/avatax/cust_code_format', $object->getStoreId());
109
- $customer = Mage::getModel('customer/customer');
110
- $customerCode = '';
111
-
112
- if($object->getCustomerId()) {
113
- $customer->load($object->getCustomerId());
114
- $taxClass = Mage::getModel('tax/class')->load($customer->getTaxClassId())->getOpAvataxCode();
115
- $this->_request->setCustomerUsageType($taxClass);
116
- }
117
-
118
- switch($format) {
119
- case OnePica_AvaTax_Model_Source_Customercodeformat::LEGACY:
120
- if($customer->getId()) {
121
- $customerCode = $customer->getName() . ' (' . $customer->getId() . ')';
122
- } else {
123
- $address = $object->getBillingAddress() ? $object->getBillingAddress() : $object;
124
- $customerCode = $address->getFirstname() . ' ' . $address->getLastname() . ' (Guest)';
125
- }
126
- break;
127
-
128
- case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_EMAIL:
129
- $customerCode = $object->getCustomerEmail() ? $object->getCustomerEmail() : $customer->getEmail();
130
- break;
131
-
132
- case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_ID:
133
- default:
134
- $customerCode = $object->getCustomerId() ? $object->getCustomerId() : 'guest-'.$object->getId();
135
- break;
136
- }
137
-
138
- $this->_request->setCustomerCode($customerCode);
139
- }
140
-
141
- /**
142
- * Adds the orgin address to the request
143
- *
144
- * @return Address
145
- */
146
- protected function _setOriginAddress($store=null) {
147
- $country = Mage::getStoreConfig('shipping/origin/country_id', $store);
148
- $zip = Mage::getStoreConfig('shipping/origin/postcode', $store);
149
- $regionId = Mage::getStoreConfig('shipping/origin/region_id', $store);
150
- $state = Mage::getModel('directory/region')->load($regionId)->getCode();
151
- $city = Mage::getStoreConfig('shipping/origin/city', $store);
152
- $street = Mage::getStoreConfig('shipping/origin/street', $store);
153
- $address = $this->_newAddress($street, '', $city, $state, $zip, $country);
154
- return $this->_request->setOriginAddress($address);
155
- }
156
-
157
- /**
158
- * Adds the shipping address to the request
159
- *
160
- * @param Address
161
- * @return bool
162
- */
163
- protected function _setDestinationAddress($address) {
164
- $street1 = $address->getStreet(1);
165
- $street2 = $address->getStreet(2);
166
- $city = $address->getCity();
167
- $zip = preg_replace('/[^0-9\-]*/', '', $address->getPostcode());
168
- $state = Mage::getModel('directory/region')->load($address->getRegionId())->getCode();
169
- $country = $address->getCountry();
170
-
171
- if(($city && $state) || $zip) {
172
- $address = $this->_newAddress($street1, $street2, $city, $state, $zip, $country);
173
- return $this->_request->setDestinationAddress($address);
174
- } else {
175
- return false;
176
- }
177
- }
178
-
179
- /**
180
- * Generic address maker
181
- *
182
- * @param string $line1
183
- * @param string $line2
184
- * @param string $city
185
- * @param string $state
186
- * @param string $zip
187
- * @param string $country
188
- * @return Address
189
- */
190
- protected function _newAddress($line1, $line2, $city, $state, $zip, $country='USA') {
191
- $address = new Address();
192
- $address->setLine1($line1);
193
- $address->setLine2($line2);
194
- $address->setCity($city);
195
- $address->setRegion($state);
196
- $address->setPostalCode($zip);
197
- $address->setCountry($country);
198
- return $address;
199
- }
200
-
201
- /**
202
- * Test to see if the product carries its own numbers or is calculated based on parent or children
203
- *
204
- * @param Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item|mixed $item
205
- * @return bool
206
- */
207
- public function isProductCalculated($item) {
208
- try {
209
- if($item->isChildrenCalculated() && !$item->getParentItem()) {
210
- return true;
211
- }
212
- if(!$item->isChildrenCalculated() && $item->getParentItem()) {
213
- return true;
214
- }
215
- } catch(Exception $e) { }
216
- return false;
217
- }
218
-
219
- /**
220
- * Adds a comment to order history. Method choosen based on Magento version.
221
- *
222
- * @param Mage_Sales_Model_Order
223
- * @param string
224
- * @return self
225
- */
226
- protected function _addStatusHistoryComment($order, $comment) {
227
- if(method_exists($order, 'addStatusHistoryComment')) {
228
- $order->addStatusHistoryComment($comment)->save();;
229
- } elseif(method_exists($order, 'addStatusToHistory')) {
230
- $order->addStatusToHistory($order->getStatus(), $comment, false)->save();;
231
- }
232
- return $this;
233
- }
234
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Avatax abstract model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ abstract class OnePica_AvaTax_Model_Avatax_Abstract extends OnePica_AvaTax_Model_Abstract
26
+ {
27
+ /**
28
+ * Flag that states if there was an error
29
+ *
30
+ * @var bool
31
+ */
32
+ protected static $_hasError = false;
33
+
34
+ /**
35
+ * The request data object
36
+ *
37
+ * @var mixed
38
+ */
39
+ protected $_request = null;
40
+
41
+ /**
42
+ * Product collection for items to be calculated
43
+ *
44
+ * @var Mage_Catalog_Model_Resource_Product_Collection
45
+ */
46
+ protected $_productCollection = null;
47
+
48
+ /**
49
+ * Tax class collection for items to be calculated
50
+ *
51
+ * @var Mage_Tax_Model_Resource_Class_Collection
52
+ */
53
+ protected $_taxClassCollection = null;
54
+
55
+ /**
56
+ * Sets the company code on the request
57
+ *
58
+ * @param int|null $storeId
59
+ * @return $this
60
+ */
61
+ protected function _setCompanyCode($storeId = null)
62
+ {
63
+ $config = Mage::getSingleton('avatax/config');
64
+ $this->_request->setCompanyCode($config->getCompanyCode($storeId));
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Sends a request to the Avatax server
70
+ *
71
+ * @param int $storeId
72
+ * @return mixed
73
+ */
74
+ protected function _send($storeId)
75
+ {
76
+ /** @var OnePica_AvaTax_Model_Config $config */
77
+ $config = Mage::getSingleton('avatax/config')->init($storeId);
78
+ $connection = $config->getTaxConnection();
79
+ $result = null;
80
+ $message = null;
81
+
82
+ try {
83
+ $result = $connection->getTax($this->_request);
84
+ } catch (Exception $exception) {
85
+ $message = new Message();
86
+ $message->setSummary($exception->getMessage());
87
+ }
88
+
89
+ if (!isset($result) || !is_object($result) || !$result->getResultCode()) {
90
+ $actualResult = $result;
91
+ $result = new Varien_Object();
92
+ $result->setResultCode(SeverityLevel::$Exception)
93
+ ->setActualResult($actualResult)
94
+ ->setMessages(array($message));
95
+ }
96
+
97
+ $this->_log(
98
+ OnePica_AvaTax_Model_Source_Logtype::GET_TAX,
99
+ $this->_request,
100
+ $result,
101
+ $storeId,
102
+ $config->getParams()
103
+ );
104
+
105
+ if ($result->getResultCode() != SeverityLevel::$Success) {
106
+ self::$_hasError = true;
107
+ if (Mage::helper('avatax')->fullStopOnError($storeId)) {
108
+ Mage::helper('avatax')->addErrorMessage($storeId);
109
+ }
110
+ } else {
111
+ Mage::helper('avatax')->removeErrorMessage();
112
+ }
113
+
114
+ return $result;
115
+ }
116
+
117
+ /**
118
+ * Adds additional transaction based data
119
+ *
120
+ * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
121
+ * @return $this
122
+ */
123
+ protected function _addGeneralInfo($object)
124
+ {
125
+ $storeId = $object->getStoreId();
126
+ $this->_setCompanyCode($storeId);
127
+ $this->_request->setDetailLevel(DetailLevel::$Document);
128
+ $this->_request->setDocDate(date('Y-m-d'));
129
+ $this->_request->setExemptionNo('');
130
+ $this->_request->setDiscount(0.00); //cannot be used in Magento
131
+ $this->_request->setSalespersonCode(Mage::helper('avatax')->getSalesPersonCode($storeId));
132
+ $this->_request->setLocationCode(Mage::helper('avatax')->getLocationCode($storeId));
133
+ $this->_request->setCountry(Mage::getStoreConfig('shipping/origin/country_id', $storeId));
134
+ $this->_request->setCurrencyCode(Mage::app()->getStore()->getBaseCurrencyCode());
135
+ $this->_addCustomer($object);
136
+ if ($object instanceof Mage_Sales_Model_Order && $object->getIncrementId()) {
137
+ $this->_request->setReferenceCode('Magento Order #' . $object->getIncrementId());
138
+ }
139
+ return $this;
140
+ }
141
+
142
+ /**
143
+ * Sets the customer info if available
144
+ *
145
+ * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
146
+ * @return $this
147
+ */
148
+ protected function _addCustomer($object)
149
+ {
150
+ $format = Mage::getStoreConfig('tax/avatax/cust_code_format', $object->getStoreId());
151
+ $customer = Mage::getModel('customer/customer');
152
+
153
+ if ($object->getCustomerId()) {
154
+ $customer->load($object->getCustomerId());
155
+ $taxClass = Mage::getModel('tax/class')->load($customer->getTaxClassId())->getOpAvataxCode();
156
+ $this->_request->setCustomerUsageType($taxClass);
157
+ }
158
+
159
+ switch ($format) {
160
+ case OnePica_AvaTax_Model_Source_Customercodeformat::LEGACY:
161
+ if ($customer->getId()) {
162
+ $customerCode = $customer->getName() . ' (' . $customer->getId() . ')';
163
+ } else {
164
+ $address = $object->getBillingAddress() ? $object->getBillingAddress() : $object;
165
+ $customerCode = $address->getFirstname() . ' ' . $address->getLastname() . ' (Guest)';
166
+ }
167
+ break;
168
+ case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_EMAIL:
169
+ $customerCode = $object->getCustomerEmail() ? $object->getCustomerEmail() : $customer->getEmail();
170
+ break;
171
+ case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_ID:
172
+ default:
173
+ $customerCode = $object->getCustomerId() ? $object->getCustomerId() : 'guest-'.$object->getId();
174
+ break;
175
+ }
176
+
177
+ $this->_request->setCustomerCode($customerCode);
178
+ return $this;
179
+ }
180
+
181
+ /**
182
+ * Adds the orgin address to the request
183
+ *
184
+ * @param null|bool|int|Mage_Core_Model_Store $store
185
+ * @return Address
186
+ */
187
+ protected function _setOriginAddress($store = null)
188
+ {
189
+ $country = Mage::getStoreConfig('shipping/origin/country_id', $store);
190
+ $zip = Mage::getStoreConfig('shipping/origin/postcode', $store);
191
+ $regionId = Mage::getStoreConfig('shipping/origin/region_id', $store);
192
+ $state = Mage::getModel('directory/region')->load($regionId)->getCode();
193
+ $city = Mage::getStoreConfig('shipping/origin/city', $store);
194
+ $street = Mage::getStoreConfig('shipping/origin/street', $store);
195
+ $address = $this->_newAddress($street, '', $city, $state, $zip, $country);
196
+ return $this->_request->setOriginAddress($address);
197
+ }
198
+
199
+ /**
200
+ * Adds the shipping address to the request
201
+ *
202
+ * @param Address
203
+ * @return bool
204
+ */
205
+ protected function _setDestinationAddress($address)
206
+ {
207
+ $street1 = $address->getStreet(1);
208
+ $street2 = $address->getStreet(2);
209
+ $city = $address->getCity();
210
+ $zip = $address->getPostcode();
211
+ $state = Mage::getModel('directory/region')->load($address->getRegionId())->getCode();
212
+ $country = $address->getCountry();
213
+
214
+ if (($city && $state) || $zip) {
215
+ $address = $this->_newAddress($street1, $street2, $city, $state, $zip, $country);
216
+ return $this->_request->setDestinationAddress($address);
217
+ } else {
218
+ return false;
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Generic address maker
224
+ *
225
+ * @param string $line1
226
+ * @param string $line2
227
+ * @param string $city
228
+ * @param string $state
229
+ * @param string $zip
230
+ * @param string $country
231
+ * @return Address
232
+ */
233
+ protected function _newAddress($line1, $line2, $city, $state, $zip, $country = 'USA')
234
+ {
235
+ $address = new Address();
236
+ $address->setLine1($line1);
237
+ $address->setLine2($line2);
238
+ $address->setCity($city);
239
+ $address->setRegion($state);
240
+ $address->setPostalCode($zip);
241
+ $address->setCountry($country);
242
+ return $address;
243
+ }
244
+
245
+ /**
246
+ * Test to see if the product carries its own numbers or is calculated based on parent or children
247
+ *
248
+ * @param Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item|mixed $item
249
+ * @return bool
250
+ */
251
+ public function isProductCalculated($item)
252
+ {
253
+ // check if item has methods as far as shipping, gift wrapping, printed card item comes as Varien_Object
254
+ // TODO: Refactor OnePica_AvaTax_Model_Sales_Quote_Address_Total_Tax::collect method
255
+ if (method_exists($item, 'isChildrenCalculated') && method_exists($item, 'getParentItem')) {
256
+ if ($item->isChildrenCalculated() && !$item->getParentItem()) {
257
+ return true;
258
+ }
259
+ if (!$item->isChildrenCalculated() && $item->getParentItem()) {
260
+ return true;
261
+ }
262
+ }
263
+ return false;
264
+ }
265
+
266
+ /**
267
+ * Adds a comment to order history. Method choosen based on Magento version.
268
+ *
269
+ * @param Mage_Sales_Model_Order
270
+ * @param string
271
+ * @return self
272
+ */
273
+ protected function _addStatusHistoryComment($order, $comment)
274
+ {
275
+ if (method_exists($order, 'addStatusHistoryComment')) {
276
+ $order->addStatusHistoryComment($comment)->save();
277
+ } elseif (method_exists($order, 'addStatusToHistory')) {
278
+ $order->addStatusToHistory($order->getStatus(), $comment, false)->save();;
279
+ }
280
+ return $this;
281
+ }
282
+
283
+ /**
284
+ * Init product collection for items to be calculated
285
+ *
286
+ * @param Mage_Sales_Model_Mysql4_Order_Invoice_Item_Collection|array $items
287
+ * @return $this
288
+ */
289
+ protected function _initProductCollection($items)
290
+ {
291
+ $productIds = array();
292
+ foreach ($items as $item) {
293
+ if (!$this->isProductCalculated($item)) {
294
+ $productIds[] = $item->getProductId();
295
+ }
296
+ }
297
+ $this->_productCollection = Mage::getModel('catalog/product')->getCollection()
298
+ ->addAttributeToSelect('*')
299
+ ->addAttributeToFilter('entity_id', array('in' => $productIds));
300
+ return $this;
301
+ }
302
+
303
+ /**
304
+ * Init tax class collection for items to be calculated
305
+ *
306
+ * @return $this
307
+ * @throws OnePica_AvaTax_Model_Exception
308
+ */
309
+ protected function _initTaxClassCollection()
310
+ {
311
+ $taxClassIds = array();
312
+ foreach ($this->_getProductCollection() as $product) {
313
+ if (!in_array($product->getTaxClassId(), $taxClassIds)) {
314
+ $taxClassIds[] = $product->getTaxClassId();
315
+ }
316
+ }
317
+ $this->_taxClassCollection = Mage::getModel('tax/class')->getCollection()
318
+ ->addFieldToSelect(array('class_id', 'op_avatax_code'))
319
+ ->addFieldToFilter('class_id', array('in' => $taxClassIds));
320
+ return $this;
321
+ }
322
+
323
+ /**
324
+ * Get product collection for items to be calculated
325
+ *
326
+ * @return Mage_Catalog_Model_Resource_Product_Collection
327
+ * @throws OnePica_AvaTax_Model_Exception
328
+ */
329
+ protected function _getProductCollection()
330
+ {
331
+ if (!$this->_productCollection) {
332
+ throw new OnePica_AvaTax_Model_Exception('Product collection should be set before usage');
333
+ }
334
+
335
+ return $this->_productCollection;
336
+ }
337
+
338
+ /**
339
+ * Get tax class collection for items to be calculated
340
+ *
341
+ * @return Mage_Tax_Model_Resource_Class_Collection
342
+ * @throws OnePica_AvaTax_Model_Exception
343
+ */
344
+ protected function _getTaxClassCollection()
345
+ {
346
+ if (!$this->_taxClassCollection) {
347
+ throw new OnePica_AvaTax_Model_Exception('Tax class collection should be set before usage');
348
+ }
349
+
350
+ return $this->_taxClassCollection;
351
+ }
352
+
353
+ /**
354
+ * Get Avatax class for given product
355
+ *
356
+ * @param Mage_Catalog_Model_Product $product
357
+ * @return string
358
+ */
359
+ protected function _getTaxClassByProduct($product)
360
+ {
361
+ $taxClass = '';
362
+ if ($product->getTaxClassId()) {
363
+ $taxClass = $this->_getTaxClassCollection()
364
+ ->getItemById($product->getTaxClassId())
365
+ ->getOpAvataxCode();
366
+ }
367
+ return $taxClass;
368
+ }
369
+
370
+ /**
371
+ * Get product from collection by given product id
372
+ *
373
+ * @param int $productId
374
+ * @return Mage_Catalog_Model_Product
375
+ * @throws OnePica_AvaTax_Model_Exception
376
+ */
377
+ protected function _getProductByProductId($productId)
378
+ {
379
+ return $this->_getProductCollection()->getItemById($productId);
380
+ }
381
+
382
+ /**
383
+ * Get proper ref value for given product
384
+ *
385
+ * @param Mage_Catalog_Model_Product $product
386
+ * @param int $refNumber
387
+ * @return null|string
388
+ */
389
+ protected function _getRefValueByProductAndNumber($product, $refNumber)
390
+ {
391
+ $value = null;
392
+ $helperMethod = 'getRef' . $refNumber . 'AttributeCode';
393
+ $refCode = Mage::helper('avatax')->{$helperMethod}($product->getStoreId());
394
+ if ($refCode && $product->getResource()->getAttribute($refCode)) {
395
+ try {
396
+ $value = (string)$product->getResource()->getAttribute($refCode)->getFrontend()->getValue($product);
397
+ } catch (Exception $e) {
398
+ Mage::logException($e);
399
+ }
400
+ }
401
+ return $value;
402
+ }
403
+
404
+ /**
405
+ * Init tax override object
406
+ *
407
+ * @param string $taxOverrideType
408
+ * @param string $reason
409
+ * @param float $taxAmount
410
+ * @return TaxOverride
411
+ */
412
+ protected function _getTaxOverrideObject($taxOverrideType, $reason, $taxAmount)
413
+ {
414
+ $taxOverride = new TaxOverride();
415
+ $taxOverride->setTaxOverrideType($taxOverrideType);
416
+ $taxOverride->setReason($reason);
417
+ $taxOverride->setTaxAmount($taxAmount);
418
+ return $taxOverride;
419
+ }
420
+ }
app/code/community/OnePica/AvaTax/Model/Avatax/Address.php CHANGED
@@ -1,256 +1,284 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * The AvaTax Address Validator model.
20
- */
21
- class OnePica_AvaTax_Model_Avatax_Address extends OnePica_AvaTax_Model_Abstract
22
- {
23
- /**
24
- * An array of previously checked addresses
25
- * Example: $_cache[$key] = serialize($resultObjectFromAvalara)
26
- *
27
- * @var array
28
- */
29
- protected $_cache = array();
30
-
31
- /**
32
- * The Mage Address object
33
- *
34
- * @var Mage_Customer_Model_Address_Abstract
35
- */
36
- protected $_mageAddress = null;
37
-
38
- /**
39
- * The AvaTax Request Address object.
40
- * This is a Ava address copy of the Mage address attributes.
41
- *
42
- * @var Address
43
- */
44
- protected $_requestAddress = null;
45
-
46
- /**
47
- * The AvaTax Response (Normalized) Address object.
48
- * This is the normalized Ava address returned by the validation request.
49
- *
50
- * @var ValidAddress
51
- */
52
- protected $_responseAddress = null;
53
-
54
- /**
55
- * Saves the store id
56
- *
57
- * @var int
58
- */
59
- protected $_storeId = null;
60
-
61
- /**
62
- * Loads any saved addresses in session
63
- *
64
- */
65
- public function __construct() {
66
- $addresses = Mage::getSingleton('avatax/session')->getAddresses();
67
- if(is_array($addresses)) {
68
- $this->_cache = $addresses;
69
- }
70
- parent::__construct();
71
- }
72
-
73
- /**
74
- * Saves any current addresses to session
75
- *
76
- */
77
- public function __destruct() {
78
- Mage::getSingleton('avatax/session')->setAddresses($this->_cache);
79
-
80
- if(method_exists(get_parent_class(), '__destruct')) {
81
- parent::__destruct();
82
- }
83
- }
84
-
85
- /**
86
- * Sets the Mage address.
87
- *
88
- * @return OnePica_AvaTax_Model_Validate_Address
89
- */
90
- public function setAddress (Mage_Customer_Model_Address_Abstract $address)
91
- {
92
- $this->_storeId = Mage::app()->getStore()->getId();
93
- $this->_mageAddress = $address;
94
- $this->_convertRequestAddress();
95
- return $this;
96
- }
97
-
98
- /**
99
- * Sets attributes from the Mage address on the AvaTax Request address.
100
- *
101
- * @return OnePica_AvaTax_Model_Validate_Address
102
- */
103
- protected function _convertRequestAddress ()
104
- {
105
- if (!$this->_requestAddress) {
106
- $this->_requestAddress = new Address();
107
- }
108
- $this->_requestAddress->setLine1($this->_mageAddress->getStreet(1));
109
- $this->_requestAddress->setLine2($this->_mageAddress->getStreet(2));
110
- $this->_requestAddress->setCity($this->_mageAddress->getCity());
111
- $this->_requestAddress->setRegion($this->_mageAddress->getRegionCode());
112
- $this->_requestAddress->setCountry($this->_mageAddress->getCountry());
113
- $this->_requestAddress->setPostalCode($this->_mageAddress->getPostcode());
114
-
115
- return $this;
116
- }
117
-
118
- /**
119
- * Sets attributes from the AvaTax Response address on the Mage address.
120
- *
121
- * @return OnePica_AvaTax_Model_Validate_Address
122
- */
123
- protected function _convertResponseAddress ()
124
- {
125
- $street = array($this->_responseAddress->getLine1(), $this->_responseAddress->getLine2());
126
- $region = Mage::getModel('directory/region')->loadByCode($this->_responseAddress->getRegion(), $this->_mageAddress->getCountryId());
127
-
128
- $this->_mageAddress->setStreet($street)
129
- ->setCity($this->_responseAddress->getCity())
130
- ->setRegionId($region->getId())
131
- ->setPostcode($this->_responseAddress->getPostalCode())
132
- ->setCountryId($this->_responseAddress->getCountry())
133
- ->save()
134
- ->setAddressNormalized(true);
135
- return $this;
136
- }
137
-
138
- /**
139
- * Validates the address with the AvaTax validation API.
140
- * Returns true on success and an array with an error on failure.
141
- *
142
- * @return true|array
143
- */
144
- public function validate () {
145
- if (!$this->_mageAddress) {
146
- throw new OnePica_AvaTax_Model_Avatax_Address_Exception($this->__('An address must be set before validation.'));
147
- }
148
-
149
- $config = Mage::getSingleton('avatax/config')->init($this->_storeId);
150
- $isAddressValidationOn = Mage::helper('avatax')->isAddressValidationOn($this->_mageAddress, $this->_storeId);
151
- $isAddressNormalizationOn = Mage::helper('avatax')->isAddressNormalizationOn($this->_mageAddress, $this->_storeId);
152
- $isQuoteActionable = Mage::helper('avatax')->isObjectActionable($this->_mageAddress->getQuote(), $this->_mageAddress);
153
-
154
- //if there is no use cases for AvaTax services, return address as valid without doing a lookup
155
- if(!$isAddressValidationOn && !$isAddressNormalizationOn && !$isQuoteActionable) {
156
- return true;
157
- }
158
-
159
- //lookup in AvaTax (with caching)
160
- $key = $this->_mageAddress->getCacheHashKey();
161
- if (array_key_exists($key, $this->_cache)) {
162
- $result = unserialize($this->_cache[$key]);
163
- } else if ($this->_mageAddress->getPostcode() && $this->_mageAddress->getPostcode() != '-') {
164
- $session = Mage::getSingleton('checkout/session');
165
- if ($session->getPostType() == 'onepage')
166
- {
167
- $requiredFields = explode(",", $this->getHelper()->getFieldRequiredList());
168
- $fieldRules = explode(",", $this->getHelper()->getFieldRule());
169
- foreach ($requiredFields as $field)
170
- {
171
- $requiredFlag = 0;
172
- foreach ($fieldRules as $rule)
173
- {
174
- if (preg_match("/street\d/", $field)) $field = "street";
175
- if ($field == "country") $field = "country_id";
176
- if ($this->_mageAddress->getData($field) == $rule || !$this->_mageAddress->getData($field))
177
- {
178
- $requiredFlag = 1;
179
- }
180
- }
181
- if ($requiredFlag)
182
- {
183
- $errors = array();
184
- $errors[] = $this->__('Invalid ').$this->__($field);
185
- return $errors;
186
- }
187
- }
188
- }
189
-
190
- $client = $config->getAddressConnection();
191
- $request = new ValidateRequest($this->_requestAddress, TextCase::$Mixed, 0);
192
- $request->setTaxability(true);
193
- $result = $client->Validate($request);
194
- $this->_log($request, $result, $this->_storeId, $client);
195
- $this->_cache[$key] = serialize($result);
196
- } else {
197
- $errors = array();
198
- $errors[] = $this->__('Invalid ZIP/Postal Code.');
199
- return $errors;
200
- }
201
-
202
- //normalization
203
- if ($isAddressNormalizationOn && $result->getResultCode() == SeverityLevel::$Success) {
204
- $responseAddress = $result->getValidAddresses();
205
- $responseAddress = array_pop($responseAddress);
206
- if ($responseAddress instanceof ValidAddress) {
207
- $this->_responseAddress = $responseAddress;
208
- $this->_convertResponseAddress();
209
- } else {
210
- throw new OnePica_AvaTax_Model_Avatax_Address_Exception($this->__('Invalid response address type.'));
211
- }
212
- }
213
-
214
- //validation
215
- if($isAddressValidationOn == 1) {
216
- if($result->getResultCode() == SeverityLevel::$Success) {
217
- $this->_mageAddress->setAddressValidated(true);
218
- return true;
219
- } else {
220
- $errors = array();
221
- foreach ($result->getMessages() as $message) {
222
- $errors[] = $this->__($message->getSummary());
223
- }
224
- return $errors;
225
- }
226
-
227
- } else if ($isAddressValidationOn == 2) {
228
- $this->_mageAddress->setAddressValidated(true);
229
- if($result->getResultCode() == SeverityLevel::$Success) {
230
- return true;
231
- } else {
232
- $this->_mageAddress->setAddressNotified(true);
233
- foreach ($result->getMessages() as $message) {
234
- Mage::getSingleton('core/session')->addNotice($this->__($message->getSummary()));
235
- }
236
- return true;
237
- }
238
-
239
- //a valid address isn't required, but Avalara has to say there is
240
- //enough info to drill down to a tax jurisdiction to calc on
241
- } elseif(!$isAddressValidationOn && $isQuoteActionable) {
242
- if($result->isTaxable()) {
243
- $this->_mageAddress->setAddressValidated(true);
244
- return true;
245
- } else {
246
- $errors = array();
247
- foreach ($result->getMessages() as $message) {
248
- $errors[] = $this->__($message->getSummary());
249
- }
250
- return $errors;
251
- }
252
- }
253
-
254
- return true;
255
- }
256
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The AvaTax Address Validator model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Avatax_Address extends OnePica_AvaTax_Model_Abstract
26
+ {
27
+ /**
28
+ * An array of previously checked addresses
29
+ * Example: $_cache[$key] = serialize($resultObjectFromAvalara)
30
+ *
31
+ * @var array
32
+ */
33
+ protected $_cache = array();
34
+
35
+ /**
36
+ * The Mage Address object
37
+ *
38
+ * @var Mage_Customer_Model_Address_Abstract
39
+ */
40
+ protected $_mageAddress = null;
41
+
42
+ /**
43
+ * The AvaTax Request Address object.
44
+ * This is a Ava address copy of the Mage address attributes.
45
+ *
46
+ * @var Address
47
+ */
48
+ protected $_requestAddress = null;
49
+
50
+ /**
51
+ * The AvaTax Response (Normalized) Address object.
52
+ * This is the normalized Ava address returned by the validation request.
53
+ *
54
+ * @var ValidAddress
55
+ */
56
+ protected $_responseAddress = null;
57
+
58
+ /**
59
+ * Saves the store id
60
+ *
61
+ * @var int
62
+ */
63
+ protected $_storeId = null;
64
+
65
+ /**
66
+ * Loads any saved addresses in session
67
+ */
68
+ public function __construct()
69
+ {
70
+ $addresses = Mage::getSingleton('avatax/session')->getAddresses();
71
+ if (is_array($addresses)) {
72
+ $this->_cache = $addresses;
73
+ }
74
+ parent::__construct();
75
+ }
76
+
77
+ /**
78
+ * Saves any current addresses to session
79
+ */
80
+ public function __destruct()
81
+ {
82
+ Mage::getSingleton('avatax/session')->setAddresses($this->_cache);
83
+
84
+ if (method_exists(get_parent_class(), '__destruct')) {
85
+ parent::__destruct();
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Sets the Mage address.
91
+ *
92
+ * @param Mage_Customer_Model_Address_Abstract $address
93
+ * @return $this
94
+ */
95
+ public function setAddress(Mage_Customer_Model_Address_Abstract $address)
96
+ {
97
+ $this->_storeId = Mage::app()->getStore()->getId();
98
+ $this->_mageAddress = $address;
99
+ $this->_convertRequestAddress();
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * Sets attributes from the Mage address on the AvaTax Request address.
105
+ *
106
+ * @return $this
107
+ */
108
+ protected function _convertRequestAddress()
109
+ {
110
+ if (!$this->_requestAddress) {
111
+ $this->_requestAddress = new Address();
112
+ }
113
+ $this->_requestAddress->setLine1($this->_mageAddress->getStreet(1));
114
+ $this->_requestAddress->setLine2($this->_mageAddress->getStreet(2));
115
+ $this->_requestAddress->setCity($this->_mageAddress->getCity());
116
+ $this->_requestAddress->setRegion($this->_mageAddress->getRegionCode());
117
+ $this->_requestAddress->setCountry($this->_mageAddress->getCountry());
118
+ $this->_requestAddress->setPostalCode($this->_mageAddress->getPostcode());
119
+
120
+ return $this;
121
+ }
122
+
123
+ /**
124
+ * Sets attributes from the AvaTax Response address on the Mage address.
125
+ *
126
+ * @return $this
127
+ */
128
+ protected function _convertResponseAddress()
129
+ {
130
+ $street = array($this->_responseAddress->getLine1(), $this->_responseAddress->getLine2());
131
+ $region = Mage::getModel('directory/region')
132
+ ->loadByCode($this->_responseAddress->getRegion(), $this->_mageAddress->getCountryId());
133
+
134
+ $this->_mageAddress->setStreet($street)
135
+ ->setCity($this->_responseAddress->getCity())
136
+ ->setRegionId($region->getId())
137
+ ->setPostcode($this->_responseAddress->getPostalCode())
138
+ ->setCountryId($this->_responseAddress->getCountry())
139
+ ->save()
140
+ ->setAddressNormalized(true);
141
+ return $this;
142
+ }
143
+
144
+ /**
145
+ * Validates the address with the AvaTax validation API.
146
+ * Returns true on success and an array with an error on failure.
147
+ *
148
+ * @return array|bool
149
+ * @throws OnePica_AvaTax_Model_Avatax_Address_Exception
150
+ */
151
+ public function validate()
152
+ {
153
+ if (!$this->_mageAddress) {
154
+ throw new OnePica_AvaTax_Model_Avatax_Address_Exception(
155
+ $this->__('An address must be set before validation.')
156
+ );
157
+ }
158
+
159
+ /** @var OnePica_AvaTax_Model_Config $config */
160
+ $config = Mage::getSingleton('avatax/config')->init($this->_storeId);
161
+ /** @var Mage_Sales_Model_Quote $quote */
162
+ $quote = $this->_mageAddress->getQuote();
163
+ $isAddressValidationOn = $this->_getDataHelper()->isAddressValidationOn($this->_mageAddress, $this->_storeId);
164
+ $isAddressNormalizationOn = $this->_getDataHelper()
165
+ ->isAddressNormalizationOn($this->_mageAddress, $this->_storeId);
166
+ $isAddressActionable = $this->_getDataHelper()->isAddressActionable($this->_mageAddress, $quote->getStoreId());
167
+ //if there is no use cases for AvaTax services, return address as valid without doing a lookup
168
+ if (!$isAddressValidationOn && !$isAddressNormalizationOn && !$isAddressActionable) {
169
+ return true;
170
+ }
171
+
172
+ //lookup in AvaTax (with caching)
173
+ $key = $this->_mageAddress->getCacheHashKey();
174
+ if (array_key_exists($key, $this->_cache)) {
175
+ $result = unserialize($this->_cache[$key]);
176
+ } elseif ($this->_mageAddress->getPostcode() && $this->_mageAddress->getPostcode() != '-') {
177
+ $session = Mage::getSingleton('checkout/session');
178
+ if ($session->getPostType() == 'onepage') {
179
+ $requiredFields = explode(",", $this->getHelper()->getFieldRequiredList());
180
+ $fieldRules = explode(",", $this->getHelper()->getFieldRule());
181
+ foreach ($requiredFields as $field) {
182
+ $requiredFlag = 0;
183
+ foreach ($fieldRules as $rule) {
184
+ if (preg_match("/street\d/", $field)) {
185
+ $field = "street";
186
+ }
187
+ if ($field == "country") {
188
+ $field = "country_id";
189
+ }
190
+ if ($this->_mageAddress->getData($field) == $rule || !$this->_mageAddress->getData($field)) {
191
+ $requiredFlag = 1;
192
+ }
193
+ }
194
+ if ($requiredFlag) {
195
+ $errors = array();
196
+ $errors[] = $this->__('Invalid ') . $this->__($field);
197
+ return $errors;
198
+ }
199
+ }
200
+ }
201
+
202
+ $client = $config->getAddressConnection();
203
+ $request = new ValidateRequest($this->_requestAddress, TextCase::$Mixed, 0);
204
+ $request->setTaxability(true);
205
+ $result = $client->Validate($request);
206
+ $this->_log(
207
+ OnePica_AvaTax_Model_Source_Logtype::VALIDATE,
208
+ $request,
209
+ $result,
210
+ $this->_storeId,
211
+ $config->getParams()
212
+ );
213
+ $this->_cache[$key] = serialize($result);
214
+ } else {
215
+ $errors = array();
216
+ $errors[] = $this->__('Invalid ZIP/Postal Code.');
217
+ return $errors;
218
+ }
219
+
220
+ //normalization
221
+ if ($isAddressNormalizationOn && $result->getResultCode() == SeverityLevel::$Success) {
222
+ $responseAddress = $result->getValidAddresses();
223
+ $responseAddress = array_pop($responseAddress);
224
+ if ($responseAddress instanceof ValidAddress) {
225
+ $this->_responseAddress = $responseAddress;
226
+ $this->_convertResponseAddress();
227
+ } else {
228
+ throw new OnePica_AvaTax_Model_Avatax_Address_Exception($this->__('Invalid response address type.'));
229
+ }
230
+ }
231
+
232
+ //validation
233
+ if ($isAddressValidationOn == 1) {
234
+ if ($result->getResultCode() == SeverityLevel::$Success) {
235
+ $this->_mageAddress->setAddressValidated(true);
236
+ return true;
237
+ } else {
238
+ $errors = array();
239
+ foreach ($result->getMessages() as $message) {
240
+ $errors[] = $this->__($message->getSummary());
241
+ }
242
+ return $errors;
243
+ }
244
+ } elseif ($isAddressValidationOn == 2) {
245
+ $this->_mageAddress->setAddressValidated(true);
246
+ if ($result->getResultCode() == SeverityLevel::$Success) {
247
+ return true;
248
+ } else {
249
+ if (!$this->_mageAddress->getAddressNotified()) {
250
+ $this->_mageAddress->setAddressNotified(true);
251
+ foreach ($result->getMessages() as $message) {
252
+ Mage::getSingleton('core/session')->addNotice($this->__($message->getSummary()));
253
+ }
254
+ }
255
+ return true;
256
+ }
257
+
258
+ //a valid address isn't required, but Avalara has to say there is
259
+ //enough info to drill down to a tax jurisdiction to calc on
260
+ } elseif (!$isAddressValidationOn && $isAddressActionable) {
261
+ if ($result->isTaxable()) {
262
+ $this->_mageAddress->setAddressValidated(true);
263
+ return true;
264
+ } else {
265
+ $errors = array();
266
+ foreach ($result->getMessages() as $message) {
267
+ $errors[] = $this->__($message->getSummary());
268
+ }
269
+ return $errors;
270
+ }
271
+ }
272
+ return true;
273
+ }
274
+
275
+ /**
276
+ * Get data helper
277
+ *
278
+ * @return OnePica_AvaTax_Helper_Data
279
+ */
280
+ protected function _getDataHelper()
281
+ {
282
+ return Mage::helper('avatax');
283
+ }
284
+ }
app/code/community/OnePica/AvaTax/Model/Avatax/Estimate.php CHANGED
@@ -1,425 +1,447 @@
1
- <?php
2
-
3
- /**
4
- * OnePica_AvaTax
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0), a
9
- * copy of which is available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- *
12
- * @category OnePica
13
- * @package OnePica_AvaTax
14
- * @author OnePica Codemaster <codemaster@onepica.com>
15
- * @copyright Copyright (c) 2009 One Pica, Inc.
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
- */
18
- class OnePica_AvaTax_Model_Avatax_Estimate extends OnePica_AvaTax_Model_Avatax_Abstract {
19
- /**
20
- * Length of time in minutes for cached rates
21
- *
22
- * @var int
23
- */
24
- const CACHE_TTL = 120;
25
-
26
- /**
27
- * An array of rates that acts as a cache
28
- * Example: $_rates[$cachekey] = array(
29
- * 'timestamp' => 1325015952
30
- * 'summary' => array(
31
- * array('name'=>'NY STATE TAX', 'rate'=>4, 'amt'=>6),
32
- * array('name'=>'NY CITY TAX', 'rate'=>4.50, 'amt'=>6.75),
33
- * array('name'=>'NY SPECIAL TAX', 'rate'=>4.375, 'amt'=>0.56)
34
- * ),
35
- * 'items' => array(
36
- * 5 => array('rate'=>8.875, 'amt'=>13.31),
37
- * 'Shipping' => array('rate'=>0, 'amt'=>0)
38
- * )
39
- * )
40
- *
41
- * @var array
42
- */
43
- protected $_rates = array();
44
-
45
- /**
46
- * An array of line items
47
- *
48
- * @var array
49
- */
50
- protected $_lines = array();
51
-
52
- /**
53
- * An array of line numbers to quote item ids
54
- *
55
- * @var array
56
- */
57
- protected $_lineToLineId = array();
58
-
59
- /**
60
- * Loads any saved rates in session
61
- *
62
- */
63
- protected function _construct() {
64
- $rates = Mage::getSingleton('avatax/session')->getRates();
65
- if (is_array($rates)) {
66
- foreach ($rates as $key => $rate) {
67
- if ($rate['timestamp'] < strtotime('-' . self::CACHE_TTL . ' minutes')) {
68
- unset($rates[$key]);
69
- }
70
- }
71
- $this->_rates = $rates;
72
- }
73
- return parent::_construct();
74
- }
75
-
76
- /**
77
- * Estimates tax rate for one item.
78
- *
79
- * @param Varien_Object $item
80
- * @return int
81
- */
82
- public function getItemRate($item) {
83
- if ($this->isProductCalculated($item)) {
84
- return 0;
85
- } else {
86
- $key = $this->_getRates($item);
87
- $id = $item->getId();
88
- return isset($this->_rates[$key]['items'][$id]['rate']) ? $this->_rates[$key]['items'][$id]['rate'] : 0;
89
- }
90
- }
91
-
92
- /**
93
- * Estimates tax amount for one item. Does not trigger a call if the shipping
94
- * address has no postal code, or if the postal code is set to "-" (OneStepCheckout)
95
- *
96
- * @param Varien_Object $data
97
- * @return int
98
- */
99
- public function getItemTax($item) {
100
- if ($item->getAddress()->getPostcode() && $item->getAddress()->getPostcode() != '-') {
101
- if ($this->isProductCalculated($item)) {
102
- $tax = 0;
103
- foreach ($item->getChildren() as $child) {
104
- $child->setAddress($item->getAddress());
105
- $tax += $this->getItemTax($child);
106
- }
107
- return $tax;
108
- } else {
109
- $key = $this->_getRates($item);
110
- $id = $item->getId();
111
- return isset($this->_rates[$key]['items'][$id]['amt']) ? $this->_rates[$key]['items'][$id]['amt'] : 0;
112
- }
113
- }
114
- return 0;
115
- }
116
-
117
- /**
118
- * Get tax detail summary
119
- *
120
- * @return array
121
- */
122
- public function getSummary($addressId=null) {
123
- $summary = null;
124
-
125
- if ($addressId) {
126
- $timestamp = 0;
127
- foreach ($this->_rates as $row) {
128
- if (isset($row['address_id']) && $row['address_id'] == $addressId && $row['timestamp'] > $timestamp) {
129
- $summary = $row['summary'];
130
- $timestamp = $row['timestamp'];
131
- }
132
- }
133
- }
134
-
135
- if (is_null($summary)) {
136
- $requestKey = Mage::getSingleton('avatax/session')->getLastRequestKey();
137
- $summary = isset($this->_rates[$requestKey]['summary']) ? $this->_rates[$requestKey]['summary'] : array();
138
- }
139
-
140
- return $summary;
141
- }
142
-
143
- /**
144
- * Get rates from Avalara
145
- *
146
- * @param Varien_Object $data
147
- * @return string
148
- */
149
- protected function _getRates($item) {
150
- if (self::$_hasError) {
151
- return 'error';
152
- }
153
-
154
- $address = $item->getAddress();
155
- $this->_lines = array();
156
-
157
- //set up request
158
- $this->_request = new GetTaxRequest();
159
- $this->_request->setDocType(DocumentType::$SalesOrder);
160
- $this->_request->setDocCode('quote-' . $address->getId());
161
- $this->_addGeneralInfo($address);
162
- $this->_setOriginAddress($address->getStoreId());
163
- $this->_setDestinationAddress($address);
164
- $this->_request->setDetailLevel(DetailLevel::$Line);
165
- $this->_addCustomer($address);
166
- $this->_addItemsInCart($item);
167
- $this->_addShipping($address);
168
- //Added code for calculating tax for giftwrap items
169
- $this->_addGwOrderAmount($address);
170
- $this->_addGwItemsAmount($address);
171
- $this->_addGwPrintedCardAmount($address);
172
- //check to see if we can/need to make the request to Avalara
173
- $requestKey = $this->_genRequestKey();
174
- $makeRequest = !isset($this->_rates[$requestKey]['items'][$item->getId()]);
175
- $makeRequest &= count($this->_lineToLineId) ? true : false;
176
- $makeRequest &= $this->_request->getDestinationAddress() == '' ? false : true;
177
- $makeRequest &= $address->getId() ? true : false;
178
-
179
- //make request if needed and save results in cache
180
- if ($makeRequest) {
181
- $result = $this->_send($address->getStoreId());
182
-
183
- //success
184
- if ($result->getResultCode() == SeverityLevel::$Success) {
185
- $this->_rates[$requestKey] = array(
186
- 'timestamp' => time(),
187
- 'address_id' => $address->getId(),
188
- 'summary' => array(),
189
- 'items' => array()
190
- );
191
-
192
- foreach ($result->getTaxLines() as $ctl) {
193
- $id = $this->_lineToLineId[$ctl->getNo()];
194
- $this->_rates[$requestKey]['items'][$id] = array(
195
- 'rate' => ($ctl->getTax() ? $ctl->getRate() : 0) * 100,
196
- 'amt' => $ctl->getTax()
197
- );
198
- }
199
-
200
- foreach ($result->getTaxSummary() as $row) {
201
- $this->_rates[$requestKey]['summary'][] = array(
202
- 'name' => $row->getTaxName(),
203
- 'rate' => $row->getRate() * 100,
204
- 'amt' => $row->getTax()
205
- );
206
- }
207
-
208
- //failure
209
- } else {
210
- if (Mage::helper('avatax')->fullStopOnError($address->getStoreId())) {
211
- $address->getQuote()->setHasError(true);
212
- }
213
- }
214
-
215
- Mage::getSingleton('avatax/session')->setRates($this->_rates);
216
- }
217
-
218
- //return $requestKey so it doesn't have to be calculated again
219
- return $requestKey;
220
- }
221
-
222
- /**
223
- * Generates a hash key for the exact request
224
- *
225
- * @return string
226
- */
227
- protected function _genRequestKey() {
228
- $hash = sprintf("%u", crc32(serialize($this->_request)));
229
- Mage::getSingleton('avatax/session')->setLastRequestKey($hash);
230
- return $hash;
231
- }
232
-
233
- /**
234
- * Adds shipping cost to request as item
235
- *
236
- * @param Mage_Sales_Model_Quote_Address
237
- * @return int
238
- */
239
- protected function _addShipping($address) {
240
- $lineNumber = count($this->_lines);
241
- $storeId = Mage::app()->getStore()->getId();
242
- $taxClass = Mage::helper('tax')->getShippingTaxClass($storeId);
243
- $shippingAmount = (float) $address->getBaseShippingAmount();
244
-
245
- $line = new Line();
246
- $line->setNo($lineNumber);
247
- $shippingSku = Mage::helper('avatax')->getShippingSku($storeId);
248
- $line->setItemCode($shippingSku ? $shippingSku : 'Shipping');
249
- $line->setDescription('Shipping costs');
250
- $line->setTaxCode($taxClass);
251
- $line->setQty(1);
252
- $line->setAmount($shippingAmount);
253
- $line->setDiscounted(false);
254
-
255
- $this->_lines[$lineNumber] = $line;
256
- $this->_request->setLines($this->_lines);
257
- $this->_lineToLineId[$lineNumber] = Mage::helper('avatax')->getShippingSku($storeId);
258
- return $lineNumber;
259
- }
260
-
261
- /**
262
- * Adds giftwraporder cost to request as item
263
- *
264
- * @param Mage_Sales_Model_Quote_Address
265
- * @return int
266
- */
267
- protected function _addGwOrderAmount($address) {
268
- if(!$address->getGwPrice())
269
- return;
270
- $lineNumber = count($this->_lines);
271
- $storeId = Mage::app()->getStore()->getId();
272
- //Add gift wrapping price(for entire order)
273
- $gwOrderAmount = $address->getGwBasePrice();
274
-
275
- $line = new Line();
276
- $line->setNo($lineNumber);
277
- $gwOrderSku = Mage::helper('avatax')->getGwOrderSku($storeId);
278
- $line->setItemCode($gwOrderSku ? $gwOrderSku : 'GwOrderAmount');
279
- $line->setDescription('Gift Wrap Order Amount');
280
- $line->setTaxCode('');
281
- $line->setQty(1);
282
- $line->setAmount($gwOrderAmount);
283
- $line->setDiscounted(false);
284
-
285
- $this->_lines[$lineNumber] = $line;
286
- $this->_request->setLines($this->_lines);
287
- $this->_lineToLineId[$lineNumber] = Mage::helper('avatax')->getGwOrderSku($storeId);
288
- return $lineNumber;
289
- }
290
-
291
- /**
292
- * Adds giftwrapitems cost to request as item
293
- *
294
- * @param Mage_Sales_Model_Quote
295
- * @return int
296
- */
297
- protected function _addGwItemsAmount($address) {
298
- if(!$address->getGwItemsPrice())
299
- return;
300
- $lineNumber = count($this->_lines);
301
- $storeId = Mage::app()->getStore()->getId();
302
- //Add gift wrapping price(for individual items)
303
- $gwItemsAmount = $address->getGwItemsBasePrice();
304
-
305
- $line = new Line();
306
- $line->setNo($lineNumber);
307
- $gwItemsSku = Mage::helper('avatax')->getGwItemsSku($storeId);
308
- $line->setItemCode($gwItemsSku ? $gwItemsSku : 'GwItemsAmount');
309
- $line->setDescription('Gift Wrap Items Amount');
310
- $line->setTaxCode('');
311
- $line->setQty(1);
312
- $line->setAmount($gwItemsAmount);
313
- $line->setDiscounted(false);
314
-
315
- $this->_lines[$lineNumber] = $line;
316
- $this->_request->setLines($this->_lines);
317
- $this->_lineToLineId[$lineNumber] = Mage::helper('avatax')->getGwItemsSku($storeId);
318
- return $lineNumber;
319
- }
320
-
321
- /**
322
- * Adds giftwrap printed card cost to request as item
323
- *
324
- * @param Mage_Sales_Model_Quote
325
- * @return int
326
- */
327
- protected function _addGwPrintedCardAmount($address) {
328
- if(!$address->getGwPrintedCardPrice())
329
- return;
330
- $lineNumber = count($this->_lines);
331
- $storeId = Mage::app()->getStore()->getId();
332
- //Add printed card price
333
- $gwPrintedCardAmount = $address->getGwPrintedCardBasePrice();
334
-
335
- $line = new Line();
336
- $line->setNo($lineNumber);
337
- $gwPrintedCardSku = Mage::helper('avatax')->getGwPrintedCardSku($storeId);
338
- $line->setItemCode($gwPrintedCardSku ? $gwPrintedCardSku : 'GwPrintedCardAmount');
339
- $line->setDescription('Gift Wrap Printed Card Amount');
340
- $line->setTaxCode('');
341
- $line->setQty(1);
342
- $line->setAmount($gwPrintedCardAmount);
343
- $line->setDiscounted(false);
344
-
345
- $this->_lines[$lineNumber] = $line;
346
- $this->_request->setLines($this->_lines);
347
- $this->_lineToLineId[$lineNumber] = Mage::helper('avatax')->getGwPrintedCardSku($storeId);
348
- return $lineNumber;
349
- }
350
-
351
- /**
352
- * Adds all items in the cart to the request
353
- *
354
- * @param Mage_Sales_Model_Quote_item|Mage_Sales_Model_Quote_Address_item
355
- * @return int
356
- */
357
- protected function _addItemsInCart($item) {
358
- if ($item->getAddress() instanceof Mage_Sales_Model_Quote_Address) {
359
- $items = $item->getAddress()->getAllItems();
360
- } elseif ($item->getQuote() instanceof Mage_Sales_Model_Quote) {
361
- $items = $item->getQuote()->getAllItems();
362
- } else {
363
- $items = array();
364
- }
365
-
366
- if (count($items) > 0) {
367
- foreach ($items as $item) {
368
- $lineNum = $this->_newLine($item);
369
- }
370
- $this->_request->setLines($this->_lines);
371
- }
372
- return count($this->_lines);
373
- }
374
-
375
- /**
376
- * Makes a Line object from a product item object
377
- *
378
- * @param Varien_Object
379
- * @return int
380
- */
381
- protected function _newLine($item) {
382
- $product = $item->getProduct();
383
- $lineNumber = count($this->_lines);
384
- $line = new Line();
385
-
386
- if ($this->isProductCalculated($item)) {
387
- $price = 0;
388
- } else {
389
- $price = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
390
- }
391
-
392
- $line->setNo($lineNumber);
393
- $line->setItemCode(substr($product->getSku(), 0, 50));
394
- $line->setDescription($product->getName());
395
- $taxClass = Mage::getModel('tax/class')->load($product->getTaxClassId())->getOpAvataxCode();
396
- $line->setTaxCode($taxClass);
397
- $line->setQty($item->getQty());
398
- $line->setAmount($price);
399
- $line->setDiscounted($item->getDiscountAmount() ? true : false);
400
-
401
- $ref1Code = Mage::helper('avatax')->getRef1AttributeCode($product->getStoreId());
402
- if ($ref1Code && $product->getResource()->getAttribute($ref1Code)) {
403
- $ref1 = $product->getResource()->getAttribute($ref1Code)->getFrontend()->getValue($product);
404
- try {
405
- $line->setRef1((string) $ref1);
406
- } catch (Exception $e) {
407
-
408
- }
409
- }
410
- $ref2Code = Mage::helper('avatax')->getRef2AttributeCode($product->getStoreId());
411
- if ($ref2Code && $product->getResource()->getAttribute($ref2Code)) {
412
- $ref2 = $product->getResource()->getAttribute($ref2Code)->getFrontend()->getValue($product);
413
- try {
414
- $line->setRef2((string) $ref2);
415
- } catch (Exception $e) {
416
-
417
- }
418
- }
419
-
420
- $this->_lines[$lineNumber] = $line;
421
- $this->_lineToLineId[$lineNumber] = $item->getId();
422
- return $lineNumber;
423
- }
424
-
425
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * OnePica_AvaTax
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category OnePica
13
+ * @package OnePica_AvaTax
14
+ * @author OnePica Codemaster <codemaster@onepica.com>
15
+ * @copyright Copyright (c) 2009 One Pica, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * The AvaTax Address Estimate model
21
+ *
22
+ * @category OnePica
23
+ * @package OnePica_AvaTax
24
+ * @author OnePica Codemaster <codemaster@onepica.com>
25
+ */
26
+ class OnePica_AvaTax_Model_Avatax_Estimate extends OnePica_AvaTax_Model_Avatax_Abstract
27
+ {
28
+ /**
29
+ * Length of time in minutes for cached rates
30
+ *
31
+ * @var int
32
+ */
33
+ const CACHE_TTL = 120;
34
+
35
+ /**
36
+ * An array of rates that acts as a cache
37
+ * Example: $_rates[$cachekey] = array(
38
+ * 'timestamp' => 1325015952
39
+ * 'summary' => array(
40
+ * array('name'=>'NY STATE TAX', 'rate'=>4, 'amt'=>6),
41
+ * array('name'=>'NY CITY TAX', 'rate'=>4.50, 'amt'=>6.75),
42
+ * array('name'=>'NY SPECIAL TAX', 'rate'=>4.375, 'amt'=>0.56)
43
+ * ),
44
+ * 'items' => array(
45
+ * 5 => array('rate'=>8.875, 'amt'=>13.31),
46
+ * 'Shipping' => array('rate'=>0, 'amt'=>0)
47
+ * )
48
+ * )
49
+ *
50
+ * @var array
51
+ */
52
+ protected $_rates = array();
53
+
54
+ /**
55
+ * An array of line items
56
+ *
57
+ * @var array
58
+ */
59
+ protected $_lines = array();
60
+
61
+ /**
62
+ * An array of line numbers to quote item ids
63
+ *
64
+ * @var array
65
+ */
66
+ protected $_lineToLineId = array();
67
+
68
+ /**
69
+ * Loads any saved rates in session
70
+ */
71
+ protected function _construct()
72
+ {
73
+ $rates = Mage::getSingleton('avatax/session')->getRates();
74
+ if (is_array($rates)) {
75
+ foreach ($rates as $key => $rate) {
76
+ if ($rate['timestamp'] < strtotime('-' . self::CACHE_TTL . ' minutes')) {
77
+ unset($rates[$key]);
78
+ }
79
+ }
80
+ $this->_rates = $rates;
81
+ }
82
+ return parent::_construct();
83
+ }
84
+
85
+ /**
86
+ * Estimates tax rate for one item.
87
+ *
88
+ * @param Varien_Object $item
89
+ * @return int
90
+ */
91
+ public function getItemRate($item)
92
+ {
93
+ if ($this->isProductCalculated($item)) {
94
+ return 0;
95
+ } else {
96
+ $key = $this->_getRates($item);
97
+ $id = $item->getId();
98
+ return isset($this->_rates[$key]['items'][$id]['rate']) ? $this->_rates[$key]['items'][$id]['rate'] : 0;
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Estimates tax amount for one item. Does not trigger a call if the shipping
104
+ * address has no postal code, or if the postal code is set to "-" (OneStepCheckout)
105
+ *
106
+ * @param Varien_Object $item
107
+ * @return int
108
+ */
109
+ public function getItemTax($item)
110
+ {
111
+ if ($item->getAddress()->getPostcode() && $item->getAddress()->getPostcode() != '-') {
112
+ if ($this->isProductCalculated($item)) {
113
+ $tax = 0;
114
+ foreach ($item->getChildren() as $child) {
115
+ $child->setAddress($item->getAddress());
116
+ $tax += $this->getItemTax($child);
117
+ }
118
+ return $tax;
119
+ } else {
120
+ $key = $this->_getRates($item);
121
+ $id = $item->getId();
122
+ return isset($this->_rates[$key]['items'][$id]['amt']) ? $this->_rates[$key]['items'][$id]['amt'] : 0;
123
+ }
124
+ }
125
+ return 0;
126
+ }
127
+
128
+ /**
129
+ * Get tax detail summary
130
+ *
131
+ * @param int|null $addressId
132
+ * @return array
133
+ */
134
+ public function getSummary($addressId = null)
135
+ {
136
+ $summary = null;
137
+
138
+ if ($addressId) {
139
+ $timestamp = 0;
140
+ foreach ($this->_rates as $row) {
141
+ if (isset($row['address_id']) && $row['address_id'] == $addressId && $row['timestamp'] > $timestamp) {
142
+ $summary = $row['summary'];
143
+ $timestamp = $row['timestamp'];
144
+ }
145
+ }
146
+ }
147
+
148
+ if ($summary === null) {
149
+ $requestKey = Mage::getSingleton('avatax/session')->getLastRequestKey();
150
+ $summary = isset($this->_rates[$requestKey]['summary']) ? $this->_rates[$requestKey]['summary'] : array();
151
+ }
152
+
153
+ return $summary;
154
+ }
155
+
156
+ /**
157
+ * Get rates from Avalara
158
+ *
159
+ * @param Varien_Object $item
160
+ * @return string
161
+ */
162
+ protected function _getRates($item)
163
+ {
164
+ if (self::$_hasError) {
165
+ return 'error';
166
+ }
167
+
168
+ $address = $item->getAddress();
169
+ $this->_lines = array();
170
+
171
+ //set up request
172
+ $this->_request = new GetTaxRequest();
173
+ $this->_request->setDocType(DocumentType::$SalesOrder);
174
+ $this->_request->setDocCode('quote-' . $address->getId());
175
+ $this->_addGeneralInfo($address);
176
+ $this->_setOriginAddress($address->getStoreId());
177
+ $this->_setDestinationAddress($address);
178
+ $this->_request->setDetailLevel(DetailLevel::$Line);
179
+ $this->_addCustomer($address);
180
+ $this->_addItemsInCart($item);
181
+ $this->_addShipping($address);
182
+ //Added code for calculating tax for giftwrap items
183
+ $this->_addGwOrderAmount($address);
184
+ $this->_addGwItemsAmount($address);
185
+ $this->_addGwPrintedCardAmount($address);
186
+ //check to see if we can/need to make the request to Avalara
187
+ $requestKey = $this->_genRequestKey();
188
+ $makeRequest = !isset($this->_rates[$requestKey]['items'][$item->getId()]);
189
+ //@startSkipCommitHooks
190
+ $makeRequest &= count($this->_lineToLineId) ? true : false;
191
+ $makeRequest &= $this->_request->getDestinationAddress() == '' ? false : true;
192
+ $makeRequest &= $address->getId() ? true : false;
193
+ $makeRequest &= !isset($this->_rates[$requestKey]['failure']);
194
+ //@finishSkipCommitHooks
195
+
196
+ //make request if needed and save results in cache
197
+ if ($makeRequest) {
198
+ $result = $this->_send($address->getQuote()->getStoreId());
199
+
200
+ //success
201
+ if ($result->getResultCode() == SeverityLevel::$Success) {
202
+ $this->_rates[$requestKey] = array(
203
+ 'timestamp' => time(),
204
+ 'address_id' => $address->getId(),
205
+ 'summary' => array(),
206
+ 'items' => array()
207
+ );
208
+
209
+ foreach ($result->getTaxLines() as $ctl) {
210
+ $id = $this->_lineToLineId[$ctl->getNo()];
211
+ $this->_rates[$requestKey]['items'][$id] = array(
212
+ 'rate' => ($ctl->getTax() ? $ctl->getRate() : 0) * 100,
213
+ 'amt' => $ctl->getTax()
214
+ );
215
+ }
216
+
217
+ foreach ($result->getTaxSummary() as $row) {
218
+ $this->_rates[$requestKey]['summary'][] = array(
219
+ 'name' => $row->getTaxName(),
220
+ 'rate' => $row->getRate() * 100,
221
+ 'amt' => $row->getTax()
222
+ );
223
+ }
224
+ //failure
225
+ } else {
226
+ $this->_rates[$requestKey] = array(
227
+ 'timestamp' => time(),
228
+ 'address_id' => $address->getId(),
229
+ 'summary' => array(),
230
+ 'items' => array(),
231
+ 'failure' => true
232
+ );
233
+ if (Mage::helper('avatax')->fullStopOnError($address->getStoreId())) {
234
+ $address->getQuote()->setHasError(true);
235
+ }
236
+ }
237
+
238
+ Mage::getSingleton('avatax/session')->setRates($this->_rates);
239
+ }
240
+
241
+ //return $requestKey so it doesn't have to be calculated again
242
+ return $requestKey;
243
+ }
244
+
245
+ /**
246
+ * Generates a hash key for the exact request
247
+ *
248
+ * @return string
249
+ */
250
+ protected function _genRequestKey()
251
+ {
252
+ $hash = sprintf("%u", crc32(serialize($this->_request)));
253
+ Mage::getSingleton('avatax/session')->setLastRequestKey($hash);
254
+ return $hash;
255
+ }
256
+
257
+ /**
258
+ * Adds shipping cost to request as item
259
+ *
260
+ * @param Mage_Sales_Model_Quote_Address
261
+ * @return int
262
+ */
263
+ protected function _addShipping($address)
264
+ {
265
+ $lineNumber = count($this->_lines);
266
+ $storeId = Mage::app()->getStore()->getId();
267
+ $taxClass = Mage::helper('tax')->getShippingTaxClass($storeId);
268
+ $shippingAmount = (float) $address->getBaseShippingAmount();
269
+
270
+ $line = new Line();
271
+ $line->setNo($lineNumber);
272
+ $shippingSku = Mage::helper('avatax')->getShippingSku($storeId);
273
+ $line->setItemCode($shippingSku ? $shippingSku : 'Shipping');
274
+ $line->setDescription('Shipping costs');
275
+ $line->setTaxCode($taxClass);
276
+ $line->setQty(1);
277
+ $line->setAmount($shippingAmount);
278
+ $line->setDiscounted(false);
279
+
280
+ $this->_lines[$lineNumber] = $line;
281
+ $this->_request->setLines($this->_lines);
282
+ $this->_lineToLineId[$lineNumber] = Mage::helper('avatax')->getShippingSku($storeId);
283
+ return $lineNumber;
284
+ }
285
+
286
+ /**
287
+ * Adds giftwraporder cost to request as item
288
+ *
289
+ * @param Mage_Sales_Model_Quote_Address
290
+ * @return int|bool
291
+ */
292
+ protected function _addGwOrderAmount($address)
293
+ {
294
+ if (!$address->getGwPrice()) {
295
+ return false;
296
+ }
297
+ $lineNumber = count($this->_lines);
298
+ $storeId = Mage::app()->getStore()->getId();
299
+ //Add gift wrapping price(for entire order)
300
+ $gwOrderAmount = $address->getGwBasePrice();
301
+
302
+ $line = new Line();
303
+ $line->setNo($lineNumber);
304
+ $gwOrderSku = Mage::helper('avatax')->getGwOrderSku($storeId);
305
+ $line->setItemCode($gwOrderSku ? $gwOrderSku : 'GwOrderAmount');
306
+ $line->setDescription('Gift Wrap Order Amount');
307
+ $line->setTaxCode('');
308
+ $line->setQty(1);
309
+ $line->setAmount($gwOrderAmount);
310
+ $line->setDiscounted(false);
311
+
312
+ $this->_lines[$lineNumber] = $line;
313
+ $this->_request->setLines($this->_lines);
314
+ $this->_lineToLineId[$lineNumber] = Mage::helper('avatax')->getGwOrderSku($storeId);
315
+ return $lineNumber;
316
+ }
317
+
318
+ /**
319
+ * Adds giftwrapitems cost to request as item
320
+ *
321
+ * @param Mage_Sales_Model_Quote
322
+ * @return int|bool
323
+ */
324
+ protected function _addGwItemsAmount($address)
325
+ {
326
+ if (!$address->getGwItemsPrice()) {
327
+ return false;
328
+ }
329
+ $lineNumber = count($this->_lines);
330
+ $storeId = Mage::app()->getStore()->getId();
331
+ //Add gift wrapping price(for individual items)
332
+ $gwItemsAmount = $address->getGwItemsBasePrice();
333
+
334
+ $line = new Line();
335
+ $line->setNo($lineNumber);
336
+ $gwItemsSku = Mage::helper('avatax')->getGwItemsSku($storeId);
337
+ $line->setItemCode($gwItemsSku ? $gwItemsSku : 'GwItemsAmount');
338
+ $line->setDescription('Gift Wrap Items Amount');
339
+ $line->setTaxCode('');
340
+ $line->setQty(1);
341
+ $line->setAmount($gwItemsAmount);
342
+ $line->setDiscounted(false);
343
+
344
+ $this->_lines[$lineNumber] = $line;
345
+ $this->_request->setLines($this->_lines);
346
+ $this->_lineToLineId[$lineNumber] = Mage::helper('avatax')->getGwItemsSku($storeId);
347
+ return $lineNumber;
348
+ }
349
+
350
+ /**
351
+ * Adds giftwrap printed card cost to request as item
352
+ *
353
+ * @param Mage_Sales_Model_Quote
354
+ * @return int|bool
355
+ */
356
+ protected function _addGwPrintedCardAmount($address)
357
+ {
358
+ if (!$address->getGwPrintedCardPrice()) {
359
+ return false;
360
+ }
361
+ $lineNumber = count($this->_lines);
362
+ $storeId = Mage::app()->getStore()->getId();
363
+ //Add printed card price
364
+ $gwPrintedCardAmount = $address->getGwPrintedCardBasePrice();
365
+
366
+ $line = new Line();
367
+ $line->setNo($lineNumber);
368
+ $gwPrintedCardSku = Mage::helper('avatax')->getGwPrintedCardSku($storeId);
369
+ $line->setItemCode($gwPrintedCardSku ? $gwPrintedCardSku : 'GwPrintedCardAmount');
370
+ $line->setDescription('Gift Wrap Printed Card Amount');
371
+ $line->setTaxCode('');
372
+ $line->setQty(1);
373
+ $line->setAmount($gwPrintedCardAmount);
374
+ $line->setDiscounted(false);
375
+
376
+ $this->_lines[$lineNumber] = $line;
377
+ $this->_request->setLines($this->_lines);
378
+ $this->_lineToLineId[$lineNumber] = Mage::helper('avatax')->getGwPrintedCardSku($storeId);
379
+ return $lineNumber;
380
+ }
381
+
382
+ /**
383
+ * Adds all items in the cart to the request
384
+ *
385
+ * @param Mage_Sales_Model_Quote_item|Mage_Sales_Model_Quote_Address_item
386
+ * @return int
387
+ */
388
+ protected function _addItemsInCart($item)
389
+ {
390
+ if ($item->getAddress() instanceof Mage_Sales_Model_Quote_Address) {
391
+ $items = $item->getAddress()->getAllItems();
392
+ } elseif ($item->getQuote() instanceof Mage_Sales_Model_Quote) {
393
+ $items = $item->getQuote()->getAllItems();
394
+ } else {
395
+ $items = array();
396
+ }
397
+
398
+ if (count($items) > 0) {
399
+ $this->_initProductCollection($items);
400
+ $this->_initTaxClassCollection();
401
+ foreach ($items as $item) {
402
+ $this->_newLine($item);
403
+ }
404
+ $this->_request->setLines($this->_lines);
405
+ }
406
+ return count($this->_lines);
407
+ }
408
+
409
+ /**
410
+ * Makes a Line object from a product item object
411
+ *
412
+ * @param Varien_Object $item
413
+ * @return int|bool
414
+ */
415
+ protected function _newLine($item)
416
+ {
417
+ if ($this->isProductCalculated($item)) {
418
+ return false;
419
+ }
420
+ $product = $this->_getProductByProductId($item->getProductId());
421
+ $taxClass = $this->_getTaxClassByProduct($product);
422
+ $price = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
423
+ $lineNumber = count($this->_lines);
424
+ $line = new Line();
425
+ $line->setNo($lineNumber);
426
+ $line->setItemCode(substr($product->getSku(), 0, 50));
427
+ $line->setDescription($product->getName());
428
+ $line->setQty($item->getQty());
429
+ $line->setAmount($price);
430
+ $line->setDiscounted($item->getDiscountAmount() ? true : false);
431
+ if ($taxClass) {
432
+ $line->setTaxCode($taxClass);
433
+ }
434
+ $ref1Value = $this->_getRefValueByProductAndNumber($product, 1);
435
+ if ($ref1Value) {
436
+ $line->setRef1($ref1Value);
437
+ }
438
+ $ref2Value = $this->_getRefValueByProductAndNumber($product, 2);
439
+ if ($ref2Value) {
440
+ $line->setRef2($ref2Value);
441
+ }
442
+
443
+ $this->_lines[$lineNumber] = $line;
444
+ $this->_lineToLineId[$lineNumber] = $item->getId();
445
+ return $lineNumber;
446
+ }
447
+ }
app/code/community/OnePica/AvaTax/Model/Avatax/Exception/Address.php CHANGED
@@ -1,21 +1,25 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * The AvaTax Validation Exception class.
20
- */
21
- class OnePica_AvaTax_Model_Avatax_Address_Exception extends Exception {}
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The AvaTax Validation Exception class
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Avatax_Address_Exception extends Exception {}
app/code/community/OnePica/AvaTax/Model/Avatax/Exception/Commitfailure.php CHANGED
@@ -1,21 +1,25 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * UnbalancedException
20
- */
21
- class OnePica_AvaTax_Model_Avatax_Exception_Commitfailure extends Exception {}
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Commit Failure Exception class
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Avatax_Exception_Commitfailure extends Exception {}
app/code/community/OnePica/AvaTax/Model/Avatax/Exception/Unbalanced.php CHANGED
@@ -1,21 +1,25 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * UnbalancedException
20
- */
21
- class OnePica_AvaTax_Model_Avatax_Exception_Unbalanced extends Exception {}
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Unbalanced Exception class
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Avatax_Exception_Unbalanced extends Exception {}
app/code/community/OnePica/AvaTax/Model/Avatax/Invoice.php CHANGED
@@ -1,438 +1,459 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Avatax_Invoice extends OnePica_AvaTax_Model_Avatax_Abstract
20
- {
21
-
22
- /**
23
- * An array of line items
24
- *
25
- * @var array
26
- */
27
- protected $_lines = array();
28
-
29
- /**
30
- * An array of line numbers to product ids
31
- *
32
- * @var array
33
- */
34
- protected $_lineToItemId = array();
35
-
36
- /**
37
- * Save order in AvaTax system
38
- *
39
- * @see OnePica_AvaTax_Model_Observer::salesOrderPlaceAfter()
40
- * @param Mage_Sales_Model_Order_Invoice $invoice
41
- * @return array
42
- */
43
- public function invoice($invoice, $queue) {
44
- $order = $invoice->getOrder();
45
- $invoiceDate = $order->getInvoiceCollection()->getFirstItem()->getCreatedAt();
46
- $orderDate = $order->getCreatedAt();
47
- $statusDate = $queue->getUpdatedAt();
48
-
49
- $shippingAddress = ($order->getShippingAddress()) ? $order->getShippingAddress() : $order->getBillingAddress();
50
- if(!$shippingAddress) {
51
- throw new Exception($this->__('There is no address attached to this order'));
52
- }
53
-
54
- $this->_request = new GetTaxRequest();
55
- $this->_request->setDocCode($invoice->getIncrementId());
56
- $this->_request->setDocType(DocumentType::$SalesInvoice);
57
-
58
- $this->_addGeneralInfo($order);
59
- $this->_addShipping($invoice);
60
- //Added code for calculating tax for giftwrap items
61
- $this->_addGwOrderAmount($invoice);
62
- $this->_addGwItemsAmount($invoice);
63
- $this->_addGwPrintedCardAmount($invoice);
64
-
65
- $this->_setOriginAddress($order->getStoreId());
66
- $this->_setDestinationAddress($shippingAddress);
67
- //$this->_request->setPaymentDate(date('Y-m-d'));
68
- $this->_request->setDocDate(substr($invoiceDate, 0, 10));
69
- $this->_request->setPaymentDate(substr($invoiceDate, 0, 10));
70
- $this->_request->setTaxDate(substr($orderDate, 0, 10));
71
- $this->_request->setStatusDate(substr($statusDate, 0, 10));
72
-
73
- $configAction = Mage::getStoreConfig('tax/avatax/action', $order->getStoreId());
74
- $commitAction = OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT_COMMIT;
75
- $this->_request->setCommit(($configAction==$commitAction) ? true : false);
76
-
77
- foreach($invoice->getItemsCollection() as $item) {
78
- $this->_newLine($item);
79
- }
80
- $this->_request->setLines($this->_lines);
81
-
82
- //send to AvaTax
83
- $result = $this->_send($order->getStoreId());
84
-
85
- //if successful
86
- if($result->getResultCode() == SeverityLevel::$Success) {
87
- $message = Mage::helper('avatax')->__('Invoice #%s was saved to AvaTax', $result->getDocCode());
88
- $this->_addStatusHistoryComment($order, $message);
89
-
90
- if($result->getTotalTax() != $invoice->getBaseTaxAmount()) {
91
- throw new OnePica_AvaTax_Model_Avatax_Exception_Unbalanced('Collected: ' . $invoice->getBaseTaxAmount() . ', Actual: ' . $result->getTotalTax());
92
- }
93
-
94
- //if not successful
95
- } else {
96
- $messages = array();
97
- foreach($result->getMessages() as $message) $messages[] = $message->getSummary();
98
- throw new OnePica_AvaTax_Model_Avatax_Exception_Commitfailure(implode(' // ', $messages));
99
- }
100
-
101
- return true;
102
- }
103
-
104
- /**
105
- * Save order in AvaTax system
106
- *
107
- * @see OnePica_AvaTax_Model_Observer::salesOrderPlaceAfter()
108
- * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
109
- */
110
- public function creditmemo($creditmemo, $queue) {
111
- $order = $creditmemo->getOrder();
112
- $orderDate = $order->getCreatedAt();
113
- $statusDate = $queue->getUpdatedAt();
114
- $creditmemoDate = $order->getCreditmemosCollection()->getFirstItem()->getCreatedAt();
115
-
116
- $shippingAddress = ($order->getShippingAddress()) ? $order->getShippingAddress() : $order->getBillingAddress();
117
- if(!$shippingAddress) {
118
- throw new Exception($this->__('There is no address attached to this order'));
119
- }
120
-
121
- $this->_request = new GetTaxRequest();
122
- $this->_request->setDocCode($creditmemo->getIncrementId());
123
- $this->_request->setDocType(DocumentType::$ReturnInvoice);
124
-
125
- $this->_addGeneralInfo($order);
126
- $this->_addShipping($creditmemo, true);
127
- //Added code for calculating tax for giftwrap items
128
- $this->_addGwOrderAmount($creditmemo);
129
- $this->_addGwItemsAmount($creditmemo);
130
- $this->_addGwPrintedCardAmount($creditmemo);
131
-
132
- $this->_addAdjustments($creditmemo->getAdjustmentPositive(), $creditmemo->getAdjustmentNegative());
133
- $this->_setOriginAddress($order->getStoreId());
134
- $this->_setDestinationAddress($shippingAddress);
135
-
136
- // Set the tax date for calculation.
137
- //$invoiceDate = $order->getInvoiceCollection()->getFirstItem()->getCreatedAt();
138
- $override = new TaxOverride();
139
- //$override->setTaxDate(substr($invoiceDate, 0, 10));
140
- $override->setTaxDate(substr($orderDate, 0, 10));
141
- $override->setTaxOverrideType(TaxOverrideType::$TaxDate);
142
- $override->setReason('Credit memo - refund');
143
- $this->_request->setTaxOverride($override);
144
-
145
- $this->_request->setDocDate(substr($creditmemoDate, 0, 10));
146
- $this->_request->setPaymentDate(substr($creditmemoDate, 0, 10));
147
- $this->_request->setTaxDate(substr($orderDate, 0, 10));
148
- $this->_request->setStatusDate(substr($statusDate, 0, 10));
149
-
150
- $configAction = Mage::getStoreConfig('tax/avatax/action', $order->getStoreId());
151
- $commitAction = OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT_COMMIT;
152
- $this->_request->setCommit(($configAction==$commitAction) ? true : false);
153
-
154
- foreach($creditmemo->getAllItems() as $item) {
155
- $this->_newLine($item, true);
156
- }
157
- $this->_request->setLines($this->_lines);
158
-
159
- //send to AvaTax
160
- $result = $this->_send($order->getStoreId());
161
-
162
- //if successful
163
- if($result->getResultCode() == SeverityLevel::$Success) {
164
- $message = Mage::helper('avatax')->__('Credit memo #%s was saved to AvaTax', $result->getDocCode());
165
- $this->_addStatusHistoryComment($order, $message);
166
-
167
- if($result->getTotalTax() != ($creditmemo->getTaxAmount()*-1)) {
168
- throw new OnePica_AvaTax_Model_Avatax_Exception_Unbalanced('Collected: ' . $creditmemo->getTaxAmount() . ', Actual: ' . $result->getTotalTax());
169
- }
170
-
171
- //if not successful
172
- } else {
173
- $messages = array();
174
- foreach($result->getMessages() as $message) $messages[] = $message->getSummary();
175
- throw new OnePica_AvaTax_Model_Avatax_Exception_Commitfailure(implode(' // ', $messages));
176
- }
177
-
178
- return $result;
179
- }
180
-
181
- /**
182
- * Adds shipping cost to request as item
183
- *
184
- * @param int $shippingAmount
185
- * @return int
186
- */
187
- protected function _addShipping($object, $credit=false) {
188
- if($object->getBaseShippingAmount() == 0) {
189
- return false;
190
- }
191
-
192
- $lineNumber = count($this->_lines);
193
- $storeId = Mage::app()->getStore()->getId();
194
- $taxClass = Mage::helper('tax')->getShippingTaxClass($storeId);
195
-
196
- $amount = $object->getBaseShippingAmount();
197
- if($credit) $amount *= -1;
198
-
199
- $line = new Line();
200
- $line->setNo($lineNumber);
201
- $line->setItemCode(Mage::helper('avatax')->getShippingSku($storeId));
202
- $line->setDescription('Shipping costs');
203
- $line->setTaxCode($taxClass);
204
- $line->setQty(1);
205
- $line->setAmount($amount);
206
- $line->setDiscounted(false);
207
-
208
- $this->_lineToItemId[$lineNumber] = 'shipping';
209
- $this->_lines[$lineNumber] = $line;
210
- $this->_request->setLines($this->_lines);
211
- return $lineNumber;
212
- }
213
-
214
- /**
215
- * Adds giftwraporder cost to request as item
216
- *
217
- * @param int $shippingAmount
218
- * @return int
219
- */
220
- protected function _addGwOrderAmount($object, $credit=false) {
221
- if($object->getGwPrice() == 0) {
222
- return false;
223
- }
224
-
225
- $lineNumber = count($this->_lines);
226
- $storeId = Mage::app()->getStore()->getId();
227
- $taxClass = Mage::helper('tax')->getShippingTaxClass($storeId);
228
-
229
- $amount = $object->getGwBasePrice();
230
- if($credit) $amount *= -1;
231
-
232
- $line = new Line();
233
- $line->setNo($lineNumber);
234
- $line->setItemCode(Mage::helper('avatax')->getGwOrderSku($storeId));
235
- $line->setDescription('Gift Wrap Order Amount');
236
- $line->setTaxCode('');
237
- $line->setQty(1);
238
- $line->setAmount($amount);
239
- $line->setDiscounted(false);
240
-
241
- $this->_lineToItemId[$lineNumber] = Mage::helper('avatax')->getGwOrderSku($storeId);
242
- $this->_lines[$lineNumber] = $line;
243
- $this->_request->setLines($this->_lines);
244
- return $lineNumber;
245
- }
246
-
247
- /**
248
- * Adds giftwrapitems cost to request as item
249
- *
250
- * @param int $shippingAmount
251
- * @return int
252
- */
253
- protected function _addGwItemsAmount($object, $credit=false) {
254
- if($object->getGwItemsPrice() == 0) {
255
- return false;
256
- }
257
-
258
- $lineNumber = count($this->_lines);
259
- $storeId = Mage::app()->getStore()->getId();
260
-
261
- $amount = $object->getGwItemsBasePrice();
262
- if($credit) $amount *= -1;
263
-
264
- $line = new Line();
265
- $line->setNo($lineNumber);
266
- $line->setItemCode(Mage::helper('avatax')->getGwItemsSku($storeId));
267
- $line->setDescription('Gift Wrap Items Amount');
268
- $line->setTaxCode('');
269
- $line->setQty(1);
270
- $line->setAmount($amount);
271
- $line->setDiscounted(false);
272
-
273
- $this->_lineToItemId[$lineNumber] = Mage::helper('avatax')->getGwItemsSku($storeId);
274
- $this->_lines[$lineNumber] = $line;
275
- $this->_request->setLines($this->_lines);
276
- return $lineNumber;
277
- }
278
-
279
- /**
280
- * Adds giftwrap printed card cost to request as item
281
- *
282
- * @param int $shippingAmount
283
- * @return int
284
- */
285
- protected function _addGwPrintedCardAmount($object, $credit=false) {
286
- if($object->getGwPrintedCardSku() == 0) {
287
- return false;
288
- }
289
-
290
- $lineNumber = count($this->_lines);
291
- $storeId = Mage::app()->getStore()->getId();
292
-
293
- $amount = $object->getGwPrintedCardBasePrice();
294
- if($credit) $amount *= -1;
295
-
296
- $line = new Line();
297
- $line->setNo($lineNumber);
298
- $line->setItemCode(Mage::helper('avatax')->getGwPrintedCardSku($storeId));
299
- $line->setDescription('Gift Wrap Printed Card Amount');
300
- $line->setTaxCode('');
301
- $line->setQty(1);
302
- $line->setAmount($amount);
303
- $line->setDiscounted(false);
304
-
305
- $this->_lineToItemId[$lineNumber] = Mage::helper('avatax')->getGwPrintedCardSku($storeId);
306
- $this->_lines[$lineNumber] = $line;
307
- $this->_request->setLines($this->_lines);
308
- return $lineNumber;
309
- }
310
-
311
- /**
312
- * Adds shipping cost to request as item
313
- *
314
- * Not used...?
315
- *
316
- * @param int $shippingAmount
317
- * @return int
318
- */
319
- /*
320
- protected function _addGiftAmount($object, $credit=false) {
321
- if($object->getGiftCardsAmount() == 0) {
322
- return false;
323
- }
324
-
325
- $lineNumber = count($this->_lines);
326
- $storeId = Mage::app()->getStore()->getId();
327
-
328
- $giftAmount = $object->getShippingAmount();
329
- if($credit) $amount *= -1;
330
- $line = new Line();
331
- $line->setNo($lineNumber);
332
- $giftSku = Mage::helper('avatax')->getGiftSku($storeId);
333
- $line->setItemCode($giftSku ? $giftSku : 'GiftAmount');
334
- $line->setDescription('Gift Amount');
335
- $line->setTaxCode('');
336
- $line->setQty(1);
337
- $line->setAmount($giftAmount);
338
- $line->setDiscounted(false);
339
-
340
- $this->_lineToItemId[$lineNumber] = Mage::helper('avatax')->getGiftSku($storeId);
341
- $this->_lines[$lineNumber] = $line;
342
- $this->_request->setLines($this->_lines);
343
- return $lineNumber;
344
- }
345
- */
346
-
347
- /**
348
- * Adds adjustments to request as items
349
- *
350
- * @param float $positive
351
- * @param float $negative
352
- * @return array
353
- */
354
- protected function _addAdjustments($positive, $negative) {
355
- $storeId = Mage::app()->getStore()->getId();
356
-
357
- if($positive != 0) {
358
- $lineNumber = count($this->_lines);
359
- $identifier = Mage::helper('avatax')->getPositiveAdjustmentSku($storeId);
360
-
361
- $line = new Line();
362
- $line->setNo($lineNumber);
363
- $line->setItemCode($identifier ? $identifier : 'adjustment');
364
- $line->setDescription('Adjustment refund');
365
- $line->setTaxCode($identifier);
366
- $line->setQty(1);
367
- $line->setAmount($positive*-1);
368
- $line->setDiscounted(false);
369
- $line->setTaxIncluded(true);
370
- $this->_lineToItemId[$lineNumber] = 'positive-adjustment';
371
- $this->_lines[$lineNumber] = $line;
372
- $this->_request->setLines($this->_lines);
373
- }
374
-
375
- if($negative != 0) {
376
- $lineNumber = count($this->_lines);
377
- $identifier = Mage::helper('avatax')->getNegativeAdjustmentSku($storeId);
378
-
379
- $line = new Line();
380
- $line->setNo($lineNumber);
381
- $line->setItemCode($identifier ? $identifier : 'adjustment');
382
- $line->setDescription('Adjustment fee');
383
- $line->setTaxCode($identifier);
384
- $line->setQty(1);
385
- $line->setAmount($negative);
386
- $line->setDiscounted(false);
387
- $line->setTaxIncluded(true);
388
- $this->_lineToItemId[$lineNumber] = 'negative-adjustment';
389
- $this->_lines[$lineNumber] = $line;
390
- $this->_request->setLines($this->_lines);
391
- }
392
- }
393
-
394
- /**
395
- * Makes a Line object from a product item object
396
- *
397
- * @param Varien_Object $item
398
- * @return null
399
- */
400
- protected function _newLine($item, $credit=false) {
401
- if($this->isProductCalculated($item->getOrderItem())) {
402
- return false;
403
- }
404
- if($item->getQty() == 0) {
405
- return false;
406
- }
407
-
408
- $price = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
409
- if($credit) $price *= -1;
410
-
411
- $line = new Line();
412
- $line->setNo(count($this->_lines));
413
- $line->setItemCode(substr($item->getSku(), 0, 50));
414
- $line->setDescription($item->getName());
415
- $line->setQty($item->getQty());
416
- $line->setAmount($price);
417
- $line->setDiscounted($item->getBaseDiscountAmount() ? true : false);
418
-
419
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
420
- $taxClass = Mage::getModel('tax/class')->load($product->getTaxClassId())->getOpAvataxCode();
421
- $line->setTaxCode($taxClass);
422
-
423
- $ref1Code = Mage::helper('avatax')->getRef1AttributeCode($product->getStoreId());
424
- if($ref1Code && $product->getResource()->getAttribute($ref1Code)) {
425
- $ref1 = $product->getResource()->getAttribute($ref1Code)->getFrontend()->getValue($product);
426
- try { $line->setRef1((string)$ref1); } catch(Exception $e) { }
427
- }
428
- $ref2Code = Mage::helper('avatax')->getRef2AttributeCode($product->getStoreId());
429
- if($ref2Code && $product->getResource()->getAttribute($ref2Code)) {
430
- $ref2 = $product->getResource()->getAttribute($ref2Code)->getFrontend()->getValue($product);
431
- try { $line->setRef2((string)$ref2); } catch(Exception $e) { }
432
- }
433
-
434
- $this->_lineToItemId[count($this->_lines)] = $item->getOrderItemId();
435
- $this->_lines[] = $line;
436
- }
437
-
438
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The AvaTax Address Invoice model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Avatax_Invoice extends OnePica_AvaTax_Model_Avatax_Abstract
26
+ {
27
+ /**
28
+ * An array of line items
29
+ *
30
+ * @var array
31
+ */
32
+ protected $_lines = array();
33
+
34
+ /**
35
+ * An array of line numbers to product ids
36
+ *
37
+ * @var array
38
+ */
39
+ protected $_lineToItemId = array();
40
+
41
+ /**
42
+ * Save order in AvaTax system
43
+ *
44
+ * @see OnePica_AvaTax_Model_Observer::salesOrderPlaceAfter()
45
+ * @param Mage_Sales_Model_Order_Invoice $invoice
46
+ * @param OnePica_AvaTax_Model_Records_Queue $queue
47
+ * @return bool
48
+ * @throws Exception
49
+ * @throws OnePica_AvaTax_Model_Avatax_Exception_Commitfailure
50
+ * @throws OnePica_AvaTax_Model_Avatax_Exception_Unbalanced
51
+ */
52
+ public function invoice($invoice, $queue)
53
+ {
54
+ $order = $invoice->getOrder();
55
+ $invoiceDate = $order->getInvoiceCollection()->getFirstItem()->getCreatedAt();
56
+ $orderDate = $order->getCreatedAt();
57
+ $statusDate = $queue->getUpdatedAt();
58
+
59
+ $shippingAddress = ($order->getShippingAddress()) ? $order->getShippingAddress() : $order->getBillingAddress();
60
+ if (!$shippingAddress) {
61
+ throw new Exception($this->__('There is no address attached to this order'));
62
+ }
63
+
64
+ $this->_request = new GetTaxRequest();
65
+ $this->_request->setDocCode($invoice->getIncrementId());
66
+ $this->_request->setDocType(DocumentType::$SalesInvoice);
67
+
68
+ $this->_addGeneralInfo($order);
69
+ $this->_addShipping($invoice);
70
+ //Added code for calculating tax for giftwrap items
71
+ $this->_addGwOrderAmount($invoice);
72
+ $this->_addGwItemsAmount($invoice);
73
+ $this->_addGwPrintedCardAmount($invoice);
74
+
75
+ $this->_setOriginAddress($order->getStoreId());
76
+ $this->_setDestinationAddress($shippingAddress);
77
+ //$this->_request->setPaymentDate(date('Y-m-d'));
78
+ $this->_request->setDocDate(substr($invoiceDate, 0, 10));
79
+ $this->_request->setPaymentDate(substr($invoiceDate, 0, 10));
80
+ $this->_request->setTaxDate(substr($orderDate, 0, 10));
81
+ $this->_request->setStatusDate(substr($statusDate, 0, 10));
82
+
83
+ $configAction = Mage::getStoreConfig('tax/avatax/action', $order->getStoreId());
84
+ $commitAction = OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT_COMMIT;
85
+ $this->_request->setCommit(($configAction == $commitAction) ? true : false);
86
+
87
+ $items = $invoice->getItemsCollection();
88
+ $this->_initProductCollection($items);
89
+ $this->_initTaxClassCollection();
90
+ foreach ($items as $item) {
91
+ /** @var Mage_Sales_Model_Order_Invoice_Item $item */
92
+ $this->_newLine($item);
93
+ }
94
+ $this->_request->setLines($this->_lines);
95
+
96
+ //send to AvaTax
97
+ $result = $this->_send($order->getStoreId());
98
+
99
+ //if successful
100
+ if ($result->getResultCode() == SeverityLevel::$Success) {
101
+ $message = Mage::helper('avatax')->__('Invoice #%s was saved to AvaTax', $result->getDocCode());
102
+ $this->_addStatusHistoryComment($order, $message);
103
+
104
+ if ($result->getTotalTax() != $invoice->getBaseTaxAmount()) {
105
+ throw new OnePica_AvaTax_Model_Avatax_Exception_Unbalanced(
106
+ 'Collected: '. $invoice->getBaseTaxAmount() . ', Actual: ' . $result->getTotalTax()
107
+ );
108
+ }
109
+
110
+ //if not successful
111
+ } else {
112
+ $messages = array();
113
+ foreach ($result->getMessages() as $message) {
114
+ $messages[] = $message->getSummary();
115
+ }
116
+ throw new OnePica_AvaTax_Model_Avatax_Exception_Commitfailure(implode(' // ', $messages));
117
+ }
118
+
119
+ return true;
120
+ }
121
+
122
+ /**
123
+ * Save order in AvaTax system
124
+ *
125
+ * @see OnePica_AvaTax_Model_Observer::salesOrderPlaceAfter()
126
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
127
+ * @param OnePica_AvaTax_Model_Records_Queue $queue
128
+ * @return mixed
129
+ * @throws Exception
130
+ * @throws OnePica_AvaTax_Model_Avatax_Exception_Commitfailure
131
+ * @throws OnePica_AvaTax_Model_Avatax_Exception_Unbalanced
132
+ */
133
+ public function creditmemo($creditmemo, $queue)
134
+ {
135
+ $order = $creditmemo->getOrder();
136
+ $orderDate = $order->getCreatedAt();
137
+ $statusDate = $queue->getUpdatedAt();
138
+ $creditmemoDate = $order->getCreditmemosCollection()->getFirstItem()->getCreatedAt();
139
+
140
+ $shippingAddress = ($order->getShippingAddress()) ? $order->getShippingAddress() : $order->getBillingAddress();
141
+ if (!$shippingAddress) {
142
+ throw new Exception($this->__('There is no address attached to this order'));
143
+ }
144
+
145
+ $this->_request = new GetTaxRequest();
146
+ $this->_request->setDocCode($creditmemo->getIncrementId());
147
+ $this->_request->setDocType(DocumentType::$ReturnInvoice);
148
+
149
+ $this->_addGeneralInfo($order);
150
+ $this->_addShipping($creditmemo, true);
151
+ //Added code for calculating tax for giftwrap items
152
+ $this->_addGwOrderAmount($creditmemo);
153
+ $this->_addGwItemsAmount($creditmemo);
154
+ $this->_addGwPrintedCardAmount($creditmemo);
155
+
156
+ $this->_addAdjustments($creditmemo->getAdjustmentPositive(), $creditmemo->getAdjustmentNegative());
157
+ $this->_setOriginAddress($order->getStoreId());
158
+ $this->_setDestinationAddress($shippingAddress);
159
+
160
+ // Set the tax date for calculation.
161
+ //$invoiceDate = $order->getInvoiceCollection()->getFirstItem()->getCreatedAt();
162
+ $override = new TaxOverride();
163
+ //$override->setTaxDate(substr($invoiceDate, 0, 10));
164
+ $override->setTaxDate(substr($orderDate, 0, 10));
165
+ $override->setTaxOverrideType(TaxOverrideType::$TaxDate);
166
+ $override->setReason('Credit memo - refund');
167
+ $this->_request->setTaxOverride($override);
168
+
169
+ $this->_request->setDocDate(substr($creditmemoDate, 0, 10));
170
+ $this->_request->setPaymentDate(substr($creditmemoDate, 0, 10));
171
+ $this->_request->setTaxDate(substr($orderDate, 0, 10));
172
+ $this->_request->setStatusDate(substr($statusDate, 0, 10));
173
+
174
+ $configAction = Mage::getStoreConfig('tax/avatax/action', $order->getStoreId());
175
+ $commitAction = OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT_COMMIT;
176
+ $this->_request->setCommit(($configAction == $commitAction) ? true : false);
177
+
178
+ $items = $creditmemo->getAllItems();
179
+ $this->_initProductCollection($items);
180
+ $this->_initTaxClassCollection();
181
+ foreach ($items as $item) {
182
+ /** @var Mage_Sales_Model_Order_Creditmemo_Item $item */
183
+ $this->_newLine($item, true);
184
+ }
185
+ $this->_request->setLines($this->_lines);
186
+
187
+ //send to AvaTax
188
+ $result = $this->_send($order->getStoreId());
189
+
190
+ //if successful
191
+ if ($result->getResultCode() == SeverityLevel::$Success) {
192
+ $message = Mage::helper('avatax')->__('Credit memo #%s was saved to AvaTax', $result->getDocCode());
193
+ $this->_addStatusHistoryComment($order, $message);
194
+
195
+ if ($result->getTotalTax() != ($creditmemo->getTaxAmount() * -1)) {
196
+ throw new OnePica_AvaTax_Model_Avatax_Exception_Unbalanced(
197
+ 'Collected: ' . $creditmemo->getTaxAmount() . ', Actual: ' . $result->getTotalTax()
198
+ );
199
+ }
200
+ //if not successful
201
+ } else {
202
+ $messages = array();
203
+ foreach ($result->getMessages() as $message) {
204
+ $messages[] = $message->getSummary();
205
+ }
206
+ throw new OnePica_AvaTax_Model_Avatax_Exception_Commitfailure(implode(' // ', $messages));
207
+ }
208
+
209
+ return $result;
210
+ }
211
+
212
+ /**
213
+ * Adds shipping cost to request as item
214
+ *
215
+ * @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
216
+ * @param bool $credit
217
+ * @return int|bool
218
+ */
219
+ protected function _addShipping($object, $credit = false)
220
+ {
221
+ if ($object->getBaseShippingAmount() == 0) {
222
+ return false;
223
+ }
224
+
225
+ $lineNumber = count($this->_lines);
226
+ $storeId = Mage::app()->getStore()->getId();
227
+ $taxClass = Mage::helper('tax')->getShippingTaxClass($storeId);
228
+
229
+ $amount = $object->getBaseShippingAmount();
230
+ if ($credit) {
231
+ //@startSkipCommitHooks
232
+ $amount *= -1;
233
+ //@finishSkipCommitHooks
234
+ }
235
+
236
+ $line = new Line();
237
+ $line->setNo($lineNumber);
238
+ $line->setItemCode(Mage::helper('avatax')->getShippingSku($storeId));
239
+ $line->setDescription('Shipping costs');
240
+ $line->setTaxCode($taxClass);
241
+ $line->setQty(1);
242
+ $line->setAmount($amount);
243
+ $line->setDiscounted(false);
244
+
245
+ $this->_lineToItemId[$lineNumber] = 'shipping';
246
+ $this->_lines[$lineNumber] = $line;
247
+ $this->_request->setLines($this->_lines);
248
+ return $lineNumber;
249
+ }
250
+
251
+ /**
252
+ * Adds giftwraporder cost to request as item
253
+ *
254
+ * @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
255
+ * @param bool $credit
256
+ * @return int|bool
257
+ */
258
+ protected function _addGwOrderAmount($object, $credit = false) {
259
+ if ($object->getGwPrice() == 0) {
260
+ return false;
261
+ }
262
+
263
+ $lineNumber = count($this->_lines);
264
+ $storeId = Mage::app()->getStore()->getId();
265
+
266
+ $amount = $object->getGwBasePrice();
267
+ if ($credit) {
268
+ //@startSkipCommitHooks
269
+ $amount *= -1;
270
+ //@finishSkipCommitHooks
271
+ }
272
+
273
+ $line = new Line();
274
+ $line->setNo($lineNumber);
275
+ $line->setItemCode(Mage::helper('avatax')->getGwOrderSku($storeId));
276
+ $line->setDescription('Gift Wrap Order Amount');
277
+ $line->setTaxCode('');
278
+ $line->setQty(1);
279
+ $line->setAmount($amount);
280
+ $line->setDiscounted(false);
281
+
282
+ $this->_lineToItemId[$lineNumber] = Mage::helper('avatax')->getGwOrderSku($storeId);
283
+ $this->_lines[$lineNumber] = $line;
284
+ $this->_request->setLines($this->_lines);
285
+ return $lineNumber;
286
+ }
287
+
288
+ /**
289
+ * Adds giftwrapitems cost to request as item
290
+ *
291
+ * @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
292
+ * @param bool $credit
293
+ * @return int|bool
294
+ */
295
+ protected function _addGwItemsAmount($object, $credit = false)
296
+ {
297
+ if ($object->getGwItemsPrice() == 0) {
298
+ return false;
299
+ }
300
+
301
+ $lineNumber = count($this->_lines);
302
+ $storeId = Mage::app()->getStore()->getId();
303
+
304
+ $amount = $object->getGwItemsBasePrice();
305
+ if ($credit) {
306
+ //@startSkipCommitHooks
307
+ $amount *= -1;
308
+ //@finishSkipCommitHooks
309
+ }
310
+
311
+ $line = new Line();
312
+ $line->setNo($lineNumber);
313
+ $line->setItemCode(Mage::helper('avatax')->getGwItemsSku($storeId));
314
+ $line->setDescription('Gift Wrap Items Amount');
315
+ $line->setTaxCode('');
316
+ $line->setQty(1);
317
+ $line->setAmount($amount);
318
+ $line->setDiscounted(false);
319
+
320
+ $this->_lineToItemId[$lineNumber] = Mage::helper('avatax')->getGwItemsSku($storeId);
321
+ $this->_lines[$lineNumber] = $line;
322
+ $this->_request->setLines($this->_lines);
323
+ return $lineNumber;
324
+ }
325
+
326
+ /**
327
+ * Adds giftwrap printed card cost to request as item
328
+ *
329
+ * @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
330
+ * @param bool $credit
331
+ * @return int|bool
332
+ */
333
+ protected function _addGwPrintedCardAmount($object, $credit = false)
334
+ {
335
+ if ($object->getGwPrintedCardSku() == 0) {
336
+ return false;
337
+ }
338
+
339
+ $lineNumber = count($this->_lines);
340
+ $storeId = Mage::app()->getStore()->getId();
341
+
342
+ $amount = $object->getGwPrintedCardBasePrice();
343
+ if ($credit) {
344
+ //@startSkipCommitHooks
345
+ $amount *= -1;
346
+ //@finishSkipCommitHooks
347
+ }
348
+
349
+ $line = new Line();
350
+ $line->setNo($lineNumber);
351
+ $line->setItemCode(Mage::helper('avatax')->getGwPrintedCardSku($storeId));
352
+ $line->setDescription('Gift Wrap Printed Card Amount');
353
+ $line->setTaxCode('');
354
+ $line->setQty(1);
355
+ $line->setAmount($amount);
356
+ $line->setDiscounted(false);
357
+
358
+ $this->_lineToItemId[$lineNumber] = Mage::helper('avatax')->getGwPrintedCardSku($storeId);
359
+ $this->_lines[$lineNumber] = $line;
360
+ $this->_request->setLines($this->_lines);
361
+ return $lineNumber;
362
+ }
363
+
364
+ /**
365
+ * Adds adjustments to request as items
366
+ *
367
+ * @param float $positive
368
+ * @param float $negative
369
+ * @return array
370
+ */
371
+ protected function _addAdjustments($positive, $negative)
372
+ {
373
+ $storeId = Mage::app()->getStore()->getId();
374
+
375
+ if ($positive != 0) {
376
+ $lineNumber = count($this->_lines);
377
+ $identifier = Mage::helper('avatax')->getPositiveAdjustmentSku($storeId);
378
+
379
+ $line = new Line();
380
+ $line->setNo($lineNumber);
381
+ $line->setItemCode($identifier ? $identifier : 'adjustment');
382
+ $line->setDescription('Adjustment refund');
383
+ $line->setTaxCode($identifier);
384
+ $line->setQty(1);
385
+ $line->setAmount($positive * -1);
386
+ $line->setDiscounted(false);
387
+ $line->setTaxIncluded(true);
388
+ $this->_lineToItemId[$lineNumber] = 'positive-adjustment';
389
+ $this->_lines[$lineNumber] = $line;
390
+ $this->_request->setLines($this->_lines);
391
+ }
392
+
393
+ if ($negative != 0) {
394
+ $lineNumber = count($this->_lines);
395
+ $identifier = Mage::helper('avatax')->getNegativeAdjustmentSku($storeId);
396
+
397
+ $line = new Line();
398
+ $line->setNo($lineNumber);
399
+ $line->setItemCode($identifier ? $identifier : 'adjustment');
400
+ $line->setDescription('Adjustment fee');
401
+ $line->setTaxCode($identifier);
402
+ $line->setQty(1);
403
+ $line->setAmount($negative);
404
+ $line->setDiscounted(false);
405
+ $line->setTaxIncluded(true);
406
+ $this->_lineToItemId[$lineNumber] = 'negative-adjustment';
407
+ $this->_lines[$lineNumber] = $line;
408
+ $this->_request->setLines($this->_lines);
409
+ }
410
+ }
411
+
412
+ /**
413
+ * Makes a Line object from a product item object
414
+ *
415
+ * @param Mage_Sales_Model_Order_Invoice_Item|Mage_Sales_Model_Order_Creditmemo_Item $item
416
+ * @param bool $credit
417
+ * @return null
418
+ */
419
+ protected function _newLine($item, $credit = false)
420
+ {
421
+ if ($this->isProductCalculated($item->getOrderItem())) {
422
+ return false;
423
+ }
424
+ if ($item->getQty() == 0) {
425
+ return false;
426
+ }
427
+
428
+ $product = $this->_getProductByProductId($item->getProductId());
429
+ $taxClass = $this->_getTaxClassByProduct($product);
430
+ $price = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
431
+ if ($credit) {
432
+ //@startSkipCommitHooks
433
+ $price *= -1;
434
+ //@finishSkipCommitHooks
435
+ }
436
+
437
+ $line = new Line();
438
+ $line->setNo(count($this->_lines));
439
+ $line->setItemCode(substr($item->getSku(), 0, 50));
440
+ $line->setDescription($item->getName());
441
+ $line->setQty($item->getQty());
442
+ $line->setAmount($price);
443
+ $line->setDiscounted($item->getBaseDiscountAmount() ? true : false);
444
+ if ($taxClass) {
445
+ $line->setTaxCode($taxClass);
446
+ }
447
+ $ref1Value = $this->_getRefValueByProductAndNumber($product, 1);
448
+ if ($ref1Value) {
449
+ $line->setRef1($ref1Value);
450
+ }
451
+ $ref2Value = $this->_getRefValueByProductAndNumber($product, 2);
452
+ if ($ref2Value) {
453
+ $line->setRef2($ref2Value);
454
+ }
455
+
456
+ $this->_lineToItemId[count($this->_lines)] = $item->getOrderItemId();
457
+ $this->_lines[] = $line;
458
+ }
459
+ }
app/code/community/OnePica/AvaTax/Model/Avatax/Ping.php CHANGED
@@ -1,49 +1,65 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Avatax_Ping extends OnePica_AvaTax_Model_Avatax_Abstract
20
- {
21
-
22
- /**
23
- * Tries to ping AvaTax service with provided credentials
24
- *
25
- * @param int $storeId
26
- * @return bool|array
27
- */
28
- public function ping($storeId = null) {
29
- $config = Mage::getSingleton('avatax/config')->init($storeId);
30
- $connection = $config->getTaxConnection();
31
- $result = null;
32
- $message = null;
33
-
34
- try { $result = $connection->ping(); }
35
- catch(Exception $exception) { $message = $exception->getMessage(); }
36
-
37
- if(!isset($result) || !is_object($result) || !$result->getResultCode()) {
38
- $actualResult = $result;
39
- $result = new Varien_Object;
40
- $result->setResultCode(SeverityLevel::$Exception);
41
- $result->setActualResult($actualResult);
42
- $result->setMessage($message);
43
- }
44
-
45
- $this->_log(new stdClass(), $result, $storeId);
46
- return ($result->getResultCode() == SeverityLevel::$Success) ? true : $result->getMessage();
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The AvaTax Address Ping model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Avatax_Ping extends OnePica_AvaTax_Model_Avatax_Abstract
26
+ {
27
+ /**
28
+ * Tries to ping AvaTax service with provided credentials
29
+ *
30
+ * @param int $storeId
31
+ * @return bool|array
32
+ */
33
+ public function ping($storeId = null)
34
+ {
35
+ /** @var OnePica_AvaTax_Model_Config $config */
36
+ $config = Mage::getSingleton('avatax/config')->init($storeId);
37
+ $connection = $config->getTaxConnection();
38
+ $result = null;
39
+ $message = null;
40
+
41
+ try {
42
+ $result = $connection->ping();
43
+ } catch (Exception $exception) {
44
+ $message = $exception->getMessage();
45
+ }
46
+
47
+ if (!isset($result) || !is_object($result) || !$result->getResultCode()) {
48
+ $actualResult = $result;
49
+ $result = new Varien_Object();
50
+ $result->setResultCode(SeverityLevel::$Exception);
51
+ $result->setActualResult($actualResult);
52
+ $result->setMessage($message);
53
+ }
54
+
55
+ $this->_log(
56
+ OnePica_AvaTax_Model_Source_Logtype::PING,
57
+ new stdClass(),
58
+ $result,
59
+ $storeId,
60
+ $config->getParams()
61
+ );
62
+
63
+ return ($result->getResultCode() == SeverityLevel::$Success) ? true : $result->getMessage();
64
+ }
65
+ }
app/code/community/OnePica/AvaTax/Model/Config.php CHANGED
@@ -1,240 +1,233 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- require_once(Mage::getModuleDir('', 'OnePica_AvaTax').DS.'lib'.DS.'functions.php');
20
-
21
- /**
22
- * The AvaTax Config Model, which registers config settings with the AvaTax SDK.
23
- */
24
- class OnePica_AvaTax_Model_Config extends Varien_Object
25
- {
26
- const CONFIG_KEY = 'Magento';
27
- const APP_NAME = 'OP_AvaTax by One Pica';
28
-
29
- /**
30
- * Values for the admin config action options
31
- */
32
- const ACTION_DISABLE = 0;
33
- const ACTION_CALC = 1;
34
- const ACTION_CALC_SUBMIT = 2;
35
- const ACTION_CALC_SUBMIT_COMMIT = 3;
36
-
37
- /**
38
- * Values for the admin config action options
39
- */
40
- const REGIONFILTER_OFF = 0;
41
- const REGIONFILTER_TAX = 1;
42
- const REGIONFILTER_ALL = 2;
43
-
44
- /**
45
- * Number of times a queue item will try to send
46
- */
47
- const QUEUE_ATTEMPT_MAX = 5;
48
-
49
- /**
50
- * The AvaTax ATConfig object.
51
- *
52
- * @var ATConfig
53
- */
54
- protected $_config = null;
55
-
56
- /**
57
- * The AvaTax TaxServiceSoap object.
58
- *
59
- * @var TaxServiceSoap
60
- */
61
- protected $_taxConnection;
62
-
63
- /**
64
- * The AvaTax AddressServiceSoap object.
65
- *
66
- * @var AddressServiceSoap
67
- */
68
- protected $_addressConnection;
69
-
70
- /**
71
- * Constructor. Loads all required AvaTax classes.
72
- *
73
- * @return null
74
- */
75
- protected function _construct ()
76
- {
77
- $helper = Mage::helper('avatax');
78
-
79
- // AvaTax functions
80
- require_once $helper->getLibPath() . DS . 'functions.php';
81
-
82
- // AvaTax classes
83
- $helper->loadClasses(array(
84
- 'TaxRequest',
85
- 'PostTaxRequest',
86
- 'PostTaxResult',
87
- 'CommitTaxRequest',
88
- 'CommitTaxResult',
89
- 'CancelTaxRequest',
90
- 'CancelTaxResult',
91
- 'Enum',
92
- 'CancelCode',
93
- 'ATConfig',
94
- 'ATObject',
95
- 'DynamicSoapClient',
96
- 'AvalaraSoapClient',
97
- 'AddressServiceSoap',
98
- 'Address',
99
- 'Enum',
100
- 'TextCase',
101
- 'Message',
102
- 'SeverityLevel',
103
- 'ValidateRequest',
104
- 'ValidateResult',
105
- 'ValidAddress',
106
- 'TaxServiceSoap',
107
- 'GetTaxRequest',
108
- 'DocumentType',
109
- 'DetailLevel',
110
- 'Line',
111
- 'ServiceMode',
112
- 'GetTaxResult',
113
- 'TaxLine',
114
- 'TaxDetail',
115
- 'PingResult',
116
- 'TaxOverride',
117
- 'TaxOverrideType'
118
- ));
119
- }
120
-
121
- /**
122
- * Initializes the AvaTax SDK with connection settings found in the Admin config.
123
- *
124
- * @param int $storeId
125
- * @return OnePica_AvaTax_Model_Config
126
- */
127
- public function init ($storeId)
128
- {
129
- if (!$this->_config) {
130
- $this->_config = new ATConfig(self::CONFIG_KEY, array(
131
- 'url' => $this->getConfig('url', $storeId),
132
- 'account' => $this->getConfig('account', $storeId),
133
- 'license' => $this->getConfig('license', $storeId),
134
- 'trace' => (Mage::helper('avatax')->getLogMode($storeId) == OnePica_AvaTax_Model_Source_Logmode::DEBUG) ? true : false,
135
- 'client' => $this->getClientName()
136
- ));
137
- }
138
- return $this;
139
- }
140
-
141
- /**
142
- * Generates client name to pass with communications
143
- *
144
- * Parts:
145
- * - MyERP: the ERP that this connector is for (not always applicable)
146
- * - Majver: version info for the ERP (not always applicable)
147
- * - MinVer: version info for the ERP (not always applicable)
148
- * - MyConnector: Name of the OEM�s connector AND the name of the OEM (company) *required*
149
- * - Majver: OEM�s connector version *required*
150
- * - MinVer: OEM�s connector version *required*
151
- *
152
- * @example Magento,1.4,.0.1,OP_AvaTax by One Pica,2,0.1
153
- * @return string
154
- */
155
- public function getClientName() {
156
- $mageVersion = Mage::getVersion();
157
- $mageVerParts = explode('.', $mageVersion, 2);
158
-
159
- $opVersion = Mage::getResourceModel('core/resource')->getDbVersion('avatax_records_setup');
160
- $opVerParts = explode('.', $opVersion, 2);
161
-
162
- $part = array();
163
- $part[] = self::CONFIG_KEY;
164
- $part[] = $mageVerParts[0];
165
- $part[] = $mageVerParts[1];
166
- $part[] = self::APP_NAME;
167
- $part[] = $opVerParts[0];
168
- $part[] = $opVerParts[1];
169
- return implode(',', $part);
170
- }
171
-
172
- /**
173
- * Returns the AvaTax Address soap connection client.
174
- *
175
- * @return AddressServiceSoap
176
- */
177
- public function getAddressConnection ()
178
- {
179
- if (!$this->_addressConnection) {
180
- $this->_addressConnection = new AddressServiceSoap(self::CONFIG_KEY);
181
- }
182
- return $this->_addressConnection;
183
- }
184
-
185
- /**
186
- * Returns the AvaTax Address soap connection client.
187
- *
188
- * @return AddressServiceSoap
189
- */
190
- public function getTaxConnection ()
191
- {
192
- if (!$this->_taxConnection) {
193
- $this->_taxConnection = new TaxServiceSoap(self::CONFIG_KEY);
194
- }
195
- return $this->_taxConnection;
196
- }
197
-
198
- /**
199
- * Returns a parameter from the AvaTax ATConfig object.
200
- *
201
- * @return string
202
- */
203
- public function getParam ($param)
204
- {
205
- return $this->_avataxConfig->$param;
206
- }
207
-
208
- /**
209
- * Returns data from the admin system config.
210
- *
211
- * @param string $path
212
- * @param int $store
213
- * @return string
214
- */
215
- public function getConfig ($path, $store=null)
216
- {
217
- return Mage::getStoreConfig('tax/avatax/' . $path, $store);
218
- }
219
-
220
- /**
221
- * Returns true if the admin is configured to normalize addresses.
222
- *
223
- * @return boolean
224
- */
225
- public function normalizeAddress ()
226
- {
227
- $storeId = Mage::app()->getStore()->getId();
228
- return $this->getConfig('normalize_address', $storeId);
229
- }
230
-
231
- /**
232
- * Returns the company code to use from the AvaTax dashboard
233
- *
234
- * @return string
235
- */
236
- public function getCompanyCode ($store=null)
237
- {
238
- return $this->getConfig('company_code', $store);
239
- }
240
- }
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ require_once(Mage::getModuleDir('', 'OnePica_AvaTax') . DS . 'lib' . DS.'functions.php');
19
+
20
+ /**
21
+ * The AvaTax Config Model, which registers config settings with the AvaTax SDK
22
+ *
23
+ * @category OnePica
24
+ * @package OnePica_AvaTax
25
+ * @author OnePica Codemaster <codemaster@onepica.com>
26
+ */
27
+ class OnePica_AvaTax_Model_Config extends Varien_Object
28
+ {
29
+ /**
30
+ * Config key
31
+ */
32
+ const CONFIG_KEY = 'Magento';
33
+
34
+ /**
35
+ * App name
36
+ */
37
+ const APP_NAME = 'OP_AvaTax by One Pica';
38
+
39
+ /**
40
+ * Disable action
41
+ */
42
+ const ACTION_DISABLE = 0;
43
+
44
+ /**
45
+ * Calculate action
46
+ */
47
+ const ACTION_CALC = 1;
48
+
49
+ /**
50
+ * Calculate, submit action
51
+ */
52
+ const ACTION_CALC_SUBMIT = 2;
53
+
54
+ /**
55
+ * Calculate, submit, commit action
56
+ */
57
+ const ACTION_CALC_SUBMIT_COMMIT = 3;
58
+
59
+ /**
60
+ * Region filter disable mode
61
+ */
62
+ const REGIONFILTER_OFF = 0;
63
+
64
+ /**
65
+ * Region filter tax mode
66
+ */
67
+ const REGIONFILTER_TAX = 1;
68
+
69
+ /**
70
+ * Region filter all mode
71
+ */
72
+ const REGIONFILTER_ALL = 2;
73
+
74
+ /**
75
+ * Number of times a queue item will try to send
76
+ */
77
+ const QUEUE_ATTEMPT_MAX = 5;
78
+
79
+ /**
80
+ * The AvaTax ATConfig object.
81
+ *
82
+ * @var ATConfig
83
+ */
84
+ protected $_config = null;
85
+
86
+ /**
87
+ * The AvaTax TaxServiceSoap object.
88
+ *
89
+ * @var TaxServiceSoap
90
+ */
91
+ protected $_taxConnection;
92
+
93
+ /**
94
+ * The AvaTax AddressServiceSoap object.
95
+ *
96
+ * @var AddressServiceSoap
97
+ */
98
+ protected $_addressConnection;
99
+
100
+ /**
101
+ * Initializes the AvaTax SDK with connection settings found in the Admin config.
102
+ *
103
+ * @param int $storeId
104
+ * @return OnePica_AvaTax_Model_Config
105
+ */
106
+ public function init($storeId)
107
+ {
108
+ if (!$this->_config) {
109
+ $this->_config = new ATConfig(self::CONFIG_KEY, array(
110
+ 'url' => $this->getConfig('url', $storeId),
111
+ 'account' => $this->getConfig('account', $storeId),
112
+ 'license' => $this->getConfig('license', $storeId),
113
+ 'trace' => (Mage::helper('avatax')
114
+ ->getLogMode($storeId) == OnePica_AvaTax_Model_Source_Logmode::DEBUG) ? true : false,
115
+ 'client' => $this->getClientName()
116
+ ));
117
+ }
118
+ return $this;
119
+ }
120
+
121
+ /**
122
+ * Generates client name to pass with communications
123
+ *
124
+ * Parts:
125
+ * - MyERP: the ERP that this connector is for (not always applicable)
126
+ * - Majver: version info for the ERP (not always applicable)
127
+ * - MinVer: version info for the ERP (not always applicable)
128
+ * - MyConnector: Name of the OEM�s connector AND the name of the OEM (company) *required*
129
+ * - Majver: OEM�s connector version *required*
130
+ * - MinVer: OEM�s connector version *required*
131
+ *
132
+ * @example Magento,1.4,.0.1,OP_AvaTax by One Pica,2,0.1
133
+ * @return string
134
+ */
135
+ public function getClientName()
136
+ {
137
+ $mageVersion = Mage::getVersion();
138
+ $mageVerParts = explode('.', $mageVersion, 2);
139
+
140
+ $opVersion = Mage::getResourceModel('core/resource')->getDbVersion('avatax_records_setup');
141
+ $opVerParts = explode('.', $opVersion, 2);
142
+
143
+ $part = array();
144
+ $part[] = self::CONFIG_KEY;
145
+ $part[] = $mageVerParts[0];
146
+ $part[] = $mageVerParts[1];
147
+ $part[] = self::APP_NAME;
148
+ $part[] = $opVerParts[0];
149
+ $part[] = $opVerParts[1];
150
+ return implode(',', $part);
151
+ }
152
+
153
+ /**
154
+ * Returns the AvaTax Address soap connection client.
155
+ *
156
+ * @return AddressServiceSoap
157
+ */
158
+ public function getAddressConnection()
159
+ {
160
+ if (!$this->_addressConnection) {
161
+ $this->_addressConnection = new AddressServiceSoap(self::CONFIG_KEY);
162
+ }
163
+ return $this->_addressConnection;
164
+ }
165
+
166
+ /**
167
+ * Returns the AvaTax Address soap connection client.
168
+ *
169
+ * @return AddressServiceSoap
170
+ */
171
+ public function getTaxConnection()
172
+ {
173
+ if (!$this->_taxConnection) {
174
+ $this->_taxConnection = new TaxServiceSoap(self::CONFIG_KEY);
175
+ }
176
+ return $this->_taxConnection;
177
+ }
178
+
179
+ /**
180
+ * Returns a parameter from the AvaTax ATConfig object.
181
+ *
182
+ * @param string $param
183
+ * @return string
184
+ */
185
+ public function getParam($param)
186
+ {
187
+ return $this->_config->$param;
188
+ }
189
+
190
+ /**
191
+ * Returns the AvaTax ATConfig object
192
+ *
193
+ * @return ATConfig
194
+ */
195
+ public function getParams()
196
+ {
197
+ return $this->_config;
198
+ }
199
+
200
+ /**
201
+ * Returns data from the admin system config.
202
+ *
203
+ * @param string $path
204
+ * @param int $store
205
+ * @return string
206
+ */
207
+ public function getConfig($path, $store = null)
208
+ {
209
+ return Mage::getStoreConfig('tax/avatax/' . $path, $store);
210
+ }
211
+
212
+ /**
213
+ * Returns true if the admin is configured to normalize addresses.
214
+ *
215
+ * @return boolean
216
+ */
217
+ public function normalizeAddress()
218
+ {
219
+ $storeId = Mage::app()->getStore()->getId();
220
+ return $this->getConfig('normalize_address', $storeId);
221
+ }
222
+
223
+ /**
224
+ * Returns the company code to use from the AvaTax dashboard
225
+ *
226
+ * @param null|bool|int|Mage_Core_Model_Store $store
227
+ * @return string
228
+ */
229
+ public function getCompanyCode($store = null)
230
+ {
231
+ return $this->getConfig('company_code', $store);
232
+ }
233
+ }
 
 
 
 
 
 
 
app/code/community/OnePica/AvaTax/{sql/avatax_records_setup/mysql4-upgrade-2.2.0-2.2.1.php → Model/Exception.php} RENAMED
@@ -1,29 +1,25 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- $installer = $this;
20
-
21
- $this->startSetup();
22
-
23
- $installer->run("
24
- UPDATE `" . $this->getTable('tax/tax_class') . "`
25
- SET `class_name`='Shipping (not used by AvaTax)'
26
- WHERE `class_name`='Shipping' AND `class_type`='" . Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT . "';
27
- ");
28
-
29
- $this->endSetup();
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The AvaTax Exception class
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Exception extends Mage_Core_Exception {}
 
 
 
 
app/code/community/OnePica/AvaTax/Model/Export.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Export model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Export
26
+ {
27
+ /**
28
+ * Entity
29
+ *
30
+ * @var OnePica_AvaTax_Model_Export_Entity_Abstract
31
+ */
32
+ protected $_entity = null;
33
+
34
+ /**
35
+ * Adapter
36
+ *
37
+ * @var OnePica_AvaTax_Model_Export_Adapter_Abstract
38
+ */
39
+ protected $_adapter = null;
40
+
41
+ /**
42
+ * Get entity
43
+ *
44
+ * @return OnePica_AvaTax_Model_Export_Entity_Abstract
45
+ */
46
+ public function getEntity()
47
+ {
48
+ return $this->_entity;
49
+ }
50
+
51
+ /**
52
+ * Set entity
53
+ *
54
+ * @param OnePica_AvaTax_Model_Export_Entity_Abstract $entity
55
+ * @return $this
56
+ */
57
+ public function setEntity($entity)
58
+ {
59
+ $this->_entity = $entity;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Get adapter
65
+ *
66
+ * @return OnePica_AvaTax_Model_Export_Adapter_Abstract
67
+ */
68
+ public function getAdapter()
69
+ {
70
+ return $this->_adapter;
71
+ }
72
+
73
+ /**
74
+ * Set adapter
75
+ *
76
+ * @param OnePica_AvaTax_Model_Export_Adapter_Abstract $adapter
77
+ * @return $this
78
+ */
79
+ public function setAdapter($adapter)
80
+ {
81
+ $this->_adapter = $adapter;
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * Get export content
87
+ *
88
+ * @return string
89
+ * @throws OnePica_AvaTax_Model_Exception
90
+ */
91
+ public function getContent()
92
+ {
93
+ if (!$this->getEntity()) {
94
+ throw new OnePica_AvaTax_Model_Exception('Entity should be set before export process');
95
+ }
96
+
97
+ if (!$this->getAdapter()) {
98
+ throw new OnePica_AvaTax_Model_Exception('Adapter should be set before export process');
99
+ }
100
+
101
+ return $this->getEntity()
102
+ ->setAdapter($this->getAdapter())
103
+ ->getContent();
104
+ }
105
+ }
app/code/community/OnePica/AvaTax/Model/Export/Adapter/Abstract.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Abstract export adapter
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ abstract class OnePica_AvaTax_Model_Export_Adapter_Abstract
26
+ {
27
+ /**
28
+ * Collection to export
29
+ *
30
+ * @var Mage_Core_Model_Mysql4_Collection_Abstract
31
+ */
32
+ protected $_collection;
33
+
34
+ /**
35
+ * Get collection
36
+ *
37
+ * @return Mage_Core_Model_Mysql4_Collection_Abstract
38
+ */
39
+ public function getCollection()
40
+ {
41
+ return $this->_collection;
42
+ }
43
+
44
+ /**
45
+ * Set collection
46
+ *
47
+ * @param Mage_Core_Model_Mysql4_Collection_Abstract $collection
48
+ * @return $this
49
+ */
50
+ public function setCollection($collection)
51
+ {
52
+ $this->_collection = $collection;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Generate content
58
+ *
59
+ * @return string
60
+ */
61
+ abstract public function getContent();
62
+ }
app/code/community/OnePica/AvaTax/Model/Export/Adapter/Sql.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Sql export adapter
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Export_Adapter_Sql extends OnePica_AvaTax_Model_Export_Adapter_Abstract
26
+ {
27
+ /**
28
+ * Columns to export
29
+ *
30
+ * @var array
31
+ */
32
+ protected $_columns = null;
33
+
34
+ /**
35
+ * Get content
36
+ *
37
+ * @return string
38
+ * @throws OnePica_AvaTax_Model_Exception
39
+ */
40
+ public function getContent()
41
+ {
42
+ if (!$this->getCollection()) {
43
+ throw new OnePica_AvaTax_Model_Exception('Collection should be set before export process');
44
+ }
45
+
46
+ $content = $this->_getExportHeader();
47
+ $content .= $this->_getExportQueries();
48
+ return $content;
49
+ }
50
+
51
+ /**
52
+ * Get export header
53
+ *
54
+ * @return string
55
+ */
56
+ protected function _getExportHeader()
57
+ {
58
+ $version = Mage::getResourceModel('core/resource')->getDbVersion('avatax_records_setup');
59
+ $stores = count(Mage::app()->getStores());
60
+ $content = '-- ' . strtoupper($this->getCollection()->getMainTable()) . " EXPORT\n";
61
+ $content .= '-- Created at: ' . gmdate(DATE_W3C) . "\n";
62
+ $content .= '-- Created by: ' . Mage::getUrl('/') . "\n";
63
+ $content .= '-- Magento v' . Mage::getVersion() . ' // OP_AvaTax v' . $version . ' // Stores: ' . $stores . "\n";
64
+ $content .= '-- Total rows: ' . $this->getCollection()->count() . "\n\n";
65
+ return $content;
66
+ }
67
+
68
+ /**
69
+ * Get columns to export
70
+ *
71
+ * @return array
72
+ */
73
+ protected function _getColumns()
74
+ {
75
+ if ($this->_columns === null) {
76
+ $this->_columns = array_keys($this->getCollection()->getFirstItem()->getData());
77
+ }
78
+ return $this->_columns;
79
+ }
80
+
81
+ /**
82
+ * Get export queries
83
+ *
84
+ * @return string
85
+ */
86
+ protected function _getExportQueries()
87
+ {
88
+ $content = '';
89
+ $chunks = array_chunk($this->_getInsertValues(), 50);
90
+ foreach ($chunks as $chunk) {
91
+ $content .= 'INSERT INTO `' . $this->getCollection()->getMainTable()
92
+ . '` (`'. implode('`, `', $this->_getColumns()) . '`) VALUES ';
93
+ $content .= "\n" . implode(",\n", $chunk);
94
+ $content .= ";\n\n";
95
+ }
96
+ return $content;
97
+ }
98
+
99
+ /**
100
+ * Get array with insert values
101
+ *
102
+ * @return array
103
+ */
104
+ protected function _getInsertValues()
105
+ {
106
+ $items = $this->getCollection();
107
+ $rows = array();
108
+ foreach ($items as $item) {
109
+ $values = array();
110
+ foreach ($this->_getColumns() as $column) {
111
+ $values[] = $this->getCollection()->getResource()->getReadConnection()->quote($item->getData($column));
112
+ }
113
+ $rows[] = "(" . implode(", ", $values) . ")";
114
+ }
115
+ return $rows;
116
+ }
117
+ }
app/code/community/OnePica/AvaTax/Model/Export/Entity/Abstract.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Abstract export entity model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ abstract class OnePica_AvaTax_Model_Export_Entity_Abstract
26
+ {
27
+ /**
28
+ * Adapter
29
+ *
30
+ * @var OnePica_AvaTax_Model_Export_Adapter_Abstract
31
+ */
32
+ protected $_adapter;
33
+
34
+ /**
35
+ * Collection
36
+ *
37
+ * @var Mage_Core_Model_Mysql4_Collection_Abstract
38
+ */
39
+ protected $_collection = null;
40
+
41
+ /**
42
+ * Get adapter
43
+ *
44
+ * @return OnePica_AvaTax_Model_Export_Adapter_Abstract
45
+ */
46
+ public function getAdapter()
47
+ {
48
+ return $this->_adapter;
49
+ }
50
+
51
+ /**
52
+ * Set adapter
53
+ *
54
+ * @param OnePica_AvaTax_Model_Export_Adapter_Abstract $adapter
55
+ * @return $this
56
+ */
57
+ public function setAdapter($adapter)
58
+ {
59
+ $this->_adapter = $adapter;
60
+ return $this;
61
+ }
62
+ /**
63
+ * Get export columns list
64
+ *
65
+ * @return array
66
+ */
67
+ abstract protected function _getExportColumns();
68
+
69
+ /**
70
+ * Get collection
71
+ *
72
+ * @return Mage_Core_Model_Mysql4_Collection_Abstract
73
+ */
74
+ abstract protected function _getCollection();
75
+
76
+ /**
77
+ * Get collection
78
+ *
79
+ * @return Mage_Core_Model_Mysql4_Collection_Abstract
80
+ */
81
+ public function getCollection()
82
+ {
83
+ if ($this->_collection === null) {
84
+ $this->_collection = $this->_getCollection();
85
+ }
86
+ return $this->_collection;
87
+ }
88
+
89
+ /**
90
+ * Get content
91
+ *
92
+ * @return string
93
+ * @throws OnePica_AvaTax_Model_Exception
94
+ */
95
+ public function getContent()
96
+ {
97
+ if (!$this->getAdapter()) {
98
+ throw new OnePica_AvaTax_Model_Exception('Adapter should be set before export process');
99
+ }
100
+
101
+ if (!$this->getCollection()) {
102
+ throw new OnePica_AvaTax_Model_Exception('Collection should be set before export process');
103
+ }
104
+
105
+ $collection = $this->getCollection()
106
+ ->addFieldToSelect($this->_getExportColumns())
107
+ ->setOrder($this->getCollection()->getResource()->getIdFieldName(), 'DESC');
108
+
109
+ return $this->getAdapter()
110
+ ->setCollection($collection)
111
+ ->getContent();
112
+ }
113
+ }
app/code/community/OnePica/AvaTax/Model/Export/Entity/Log.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Log export entity model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Export_Entity_Log extends OnePica_AvaTax_Model_Export_Entity_Abstract
26
+ {
27
+ /**
28
+ * Get export columns list
29
+ *
30
+ * @return array
31
+ */
32
+ protected function _getExportColumns()
33
+ {
34
+ return array(
35
+ 'log_id',
36
+ 'store_id',
37
+ 'level',
38
+ 'type',
39
+ 'created_at'
40
+ );
41
+ }
42
+
43
+ /**
44
+ * Get collection
45
+ *
46
+ * @return Mage_Core_Model_Mysql4_Collection_Abstract
47
+ */
48
+ protected function _getCollection()
49
+ {
50
+ return Mage::getResourceModel('avatax_records/log_collection');
51
+ }
52
+ }
app/code/community/OnePica/AvaTax/Model/Export/Entity/Queue.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Queue export entity model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Export_Entity_Queue extends OnePica_AvaTax_Model_Export_Entity_Abstract
26
+ {
27
+ /**
28
+ * Get export columns list
29
+ *
30
+ * @return array
31
+ */
32
+ protected function _getExportColumns()
33
+ {
34
+ return array(
35
+ 'queue_id',
36
+ 'store_id',
37
+ 'entity_id',
38
+ 'entity_increment_id',
39
+ 'type',
40
+ 'status',
41
+ 'attempt',
42
+ 'message',
43
+ 'created_at',
44
+ 'updated_at'
45
+ );
46
+ }
47
+
48
+ /**
49
+ * Get collection
50
+ *
51
+ * @return Mage_Core_Model_Mysql4_Collection_Abstract
52
+ */
53
+ protected function _getCollection()
54
+ {
55
+ return Mage::getResourceModel('avatax_records/queue_collection');
56
+ }
57
+ }
app/code/community/OnePica/AvaTax/Model/Observer.php CHANGED
@@ -1,212 +1,345 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Observer extends Mage_Core_Model_Abstract
20
- {
21
-
22
- /**
23
- * Sets the collectTotals tax node based on the extensions enabled/disabled status
24
- *
25
- * @param Varien_Event_Observer $observer
26
- */
27
- public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer) {
28
- $storeId = $observer->getEvent()->getQuote()->getStoreId();
29
- if(Mage::getStoreConfig('tax/avatax/action', $storeId) != OnePica_AvaTax_Model_Config::ACTION_DISABLE) {
30
- Mage::getConfig()->setNode('global/sales/quote/totals/tax/class', 'avatax/sales_quote_address_total_tax');
31
- }
32
- }
33
-
34
- /**
35
- * Create a sales invoice record in Avalara
36
- *
37
- * @param Varien_Event_Observer $observer
38
- */
39
- public function salesOrderInvoiceSaveAfter(Varien_Event_Observer $observer) {
40
- /** @var Mage_Sales_Model_Order_Invoice $invoice */
41
- $invoice = $observer->getEvent()->getInvoice();
42
-
43
- $existingInvoiceInQueue = Mage::getModel('avatax_records/queue')->loadInvoiceByIncrementId($invoice->getIncrementId());
44
- if ($existingInvoiceInQueue->getId()) {
45
- return $this;
46
- }
47
-
48
- if(!$invoice->getOrigData($invoice->getIdFieldName()) && Mage::helper('avatax')->isObjectActionable($invoice)) {
49
- Mage::getModel('avatax_records/queue')
50
- ->setEntity($invoice)
51
- ->setType(OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_INVOICE)
52
- ->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_PENDING)
53
- ->save();
54
- }
55
- }
56
-
57
- /**
58
- * Create a return invoice record in Avalara
59
- *
60
- * @param Varien_Event_Observer $observer
61
- */
62
- public function salesOrderCreditmemoSaveAfter(Varien_Event_Observer $observer) {
63
- $creditmemo = $observer->getEvent()->getCreditmemo();
64
- if(!$creditmemo->getOrigData($creditmemo->getIdFieldName()) && Mage::helper('avatax')->isObjectActionable($creditmemo)) {
65
- Mage::getModel('avatax_records/queue')
66
- ->setEntity($creditmemo)
67
- ->setType(OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_CREDITMEMEO)
68
- ->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_PENDING)
69
- ->save();
70
- }
71
- }
72
-
73
- public function multishippingSetShippingItems(Varien_Event_Observer $observer) {
74
- /* @var $quote Mage_Sales_Model_Quote */
75
- $quote = $observer->getEvent()->getQuote();
76
-
77
- $errors = array();
78
- $normalized = false;
79
- $store = Mage::getModel('core/store')->load($quote->getStoreId());
80
- $addresses = $quote->getAllShippingAddresses();
81
- $message = Mage::getStoreConfig('tax/avatax/validate_address_message', $store);
82
- foreach ($addresses as $address) {
83
- /* @var $address OnePica_AvaTax_Model_Sales_Quote_Address */
84
- if ($address->validate() !== true) {
85
- $errors[] = sprintf($message, $address->format('oneline'));
86
- }
87
- if ($address->getAddressNormalized()) {
88
- $normalized = true;
89
- }
90
- }
91
-
92
- $session = Mage::getSingleton('checkout/session');
93
- if ($normalized) {
94
- $session->addNotice(Mage::getStoreConfig('tax/avatax/multiaddress_normalize_message', $store));
95
- }
96
-
97
- if (!empty($errors)) {
98
- Mage::throwException(implode('<br />', $errors));
99
- }
100
- }
101
-
102
- /**
103
- * Observer push data to Avalara
104
- *
105
- * @param Mage_Cron_Model_Schedule $schedule
106
- * @return null
107
- */
108
- public function processQueue($schedule) {
109
- Mage::getModel('avatax_records/queue_process')->run();
110
- }
111
-
112
- /**
113
- * Test for required values when admin config setting related to the this extension are changed
114
- *
115
- * @param Mage_Cron_Model_Schedule $schedule
116
- * @return bool
117
- */
118
- public function adminSystemConfigChangedSectionTax($schedule) {
119
- Mage::app()->cleanCache('block_html');
120
-
121
- $session = Mage::getSingleton('adminhtml/session');
122
- $storeId = Mage::getModel('core/store')->load($schedule->getEvent()->getStore())->getStoreId();
123
- $warnings = array();
124
- $errors = array();
125
-
126
- if(strpos(Mage::getStoreConfig('tax/avatax/url', $storeId), 'development.avalara.net') !== false) {
127
- $warnings[] = Mage::helper('avatax')->__('You are using the AvaTax development connection URL. If you are receiving errors about authentication, please ensure that you have a development account.');
128
- }
129
- if(Mage::getStoreConfig('tax/avatax/action', $storeId) == OnePica_AvaTax_Model_Config::ACTION_DISABLE) {
130
- $warnings[] = Mage::helper('avatax')->__('All AvaTax services are disabled');
131
- }
132
- if(Mage::getStoreConfig('tax/avatax/action', $storeId) == OnePica_AvaTax_Model_Config::ACTION_CALC) {
133
- $warnings[] = Mage::helper('avatax')->__('Orders will not be sent to the AvaTax system');
134
- }
135
- if(Mage::getStoreConfig('tax/avatax/action', $storeId) == OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT) {
136
- $warnings[] = Mage::helper('avatax')->__('Orders will be sent but never committed to the AvaTax system');
137
- }
138
-
139
- $ping = Mage::getSingleton('avatax/avatax_ping')->ping($storeId);
140
- if($ping !== true) {
141
- $errors[] = $ping;
142
- }
143
- if(!Mage::getStoreConfig('tax/avatax/url', $storeId)) {
144
- $errors[] = Mage::helper('avatax')->__('You must enter a connection URL');
145
- }
146
- if(!Mage::getStoreConfig('tax/avatax/account', $storeId)) {
147
- $errors[] = Mage::helper('avatax')->__('You must enter an account number');
148
- }
149
- if(!Mage::getStoreConfig('tax/avatax/license', $storeId)) {
150
- $errors[] = Mage::helper('avatax')->__('You must enter a license key');
151
- }
152
- if(!is_numeric(Mage::getStoreConfig('tax/avatax/log_lifetime'))) {
153
- $errors[] = Mage::helper('avatax')->__('You must enter the number of days to keep log entries');
154
- }
155
- if(!Mage::getStoreConfig('tax/avatax/company_code', $storeId)) {
156
- $errors[] = Mage::helper('avatax')->__('You must enter a company code');
157
- }
158
- if(!Mage::getStoreConfig('tax/avatax/shipping_sku', $storeId)) {
159
- $errors[] = Mage::helper('avatax')->__('You must enter a shipping sku');
160
- }
161
- if(!Mage::getStoreConfig('tax/avatax/adjustment_positive_sku', $storeId)) {
162
- $errors[] = Mage::helper('avatax')->__('You must enter an adjustment refund sku');
163
- }
164
- if(!Mage::getStoreConfig('tax/avatax/adjustment_negative_sku', $storeId)) {
165
- $errors[] = Mage::helper('avatax')->__('You must enter an adjustment fee sku');
166
- }
167
-
168
- if(!class_exists('SoapClient')) {
169
- $errors[] = Mage::helper('avatax')->__('The PHP class SoapClient is missing. It must be enabled to use this extension. See %s for details.', '<a href="http://www.php.net/manual/en/book.soap.php" target="_blank">http://www.php.net/manual/en/book.soap.php</a>');
170
- }
171
-
172
- if(!function_exists('openssl_sign') && count($errors)) {
173
- $key = array_search(Mage::helper('avatax')->__('SSL support is not available in this build'), $errors);
174
- if(isset($errors[$key])) unset($errors[$key]);
175
- $errors[] = Mage::helper('avatax')->__('SSL must be enabled in PHP to use this extension. Typically, OpenSSL is used but it is not enabled on your server. This may not be a problem if you have some other form of SSL in place. For more information about OpenSSL, see %s.', '<a href="http://www.php.net/manual/en/book.openssl.php" target="_blank">http://www.php.net/manual/en/book.openssl.php</a>');
176
- }
177
-
178
- if(!Mage::getResourceModel('cron/schedule_collection')->count()) {
179
- $warnings[] = Mage::helper('avatax')->__('It appears that Magento\'s cron scheduler is not running. For more information, see %s.', '<a href="http://www.magentocommerce.com/wiki/how_to_setup_a_cron_job" target="_black">How to Set Up a Cron Job</a>');
180
- }
181
-
182
-
183
- if(count($errors) == 1) {
184
- $session->addError(implode('', $errors));
185
- } elseif(count($errors)) {
186
- $session->addError(Mage::helper('avatax')->__('Please fix the following issues:') . '<br /> - ' . implode('<br /> - ', $errors));
187
- }
188
-
189
- if(count($warnings) == 1) {
190
- $session->addWarning(implode('', $warnings));
191
- } elseif(count($warnings)) {
192
- $session->addWarning(Mage::helper('avatax')->__('Please be aware of the following warnings:') . '<br /> - ' . implode('<br /> - ', $warnings));
193
- }
194
- }
195
-
196
- /**
197
- * Observer to clean the log every so often so it does not get too big.
198
- *
199
- * @param Mage_Cron_Model_Schedule $schedule
200
- * @return (none)
201
- */
202
- public function cleanLog($schedule) {
203
- $days = floatval(Mage::getStoreConfig('tax/avatax/log_lifetime'));
204
-
205
- $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
206
- $connection->delete(
207
- Mage::getResourceModel('avatax_records/log')->getTable('avatax_records/log'),
208
- $connection->quoteInto('created_at < DATE_SUB(UTC_DATE(), INTERVAL ? DAY)', $days)
209
- );
210
- }
211
-
212
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Avatax Observer
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Observer extends Mage_Core_Model_Abstract
26
+ {
27
+ /**
28
+ * Avalara lib classes
29
+ *
30
+ * @var array
31
+ */
32
+ protected static $_classes = array(
33
+ 'TaxRequest',
34
+ 'PostTaxRequest',
35
+ 'PostTaxResult',
36
+ 'CommitTaxRequest',
37
+ 'CommitTaxResult',
38
+ 'CancelTaxRequest',
39
+ 'CancelTaxResult',
40
+ 'Enum',
41
+ 'CancelCode',
42
+ 'ATConfig',
43
+ 'ATObject',
44
+ 'DynamicSoapClient',
45
+ 'AvalaraSoapClient',
46
+ 'AddressServiceSoap',
47
+ 'Address',
48
+ 'Enum',
49
+ 'TextCase',
50
+ 'Message',
51
+ 'SeverityLevel',
52
+ 'ValidateRequest',
53
+ 'ValidateResult',
54
+ 'ValidAddress',
55
+ 'TaxServiceSoap',
56
+ 'GetTaxRequest',
57
+ 'DocumentType',
58
+ 'DetailLevel',
59
+ 'Line',
60
+ 'ServiceMode',
61
+ 'GetTaxResult',
62
+ 'TaxLine',
63
+ 'TaxDetail',
64
+ 'PingResult',
65
+ 'TaxOverride',
66
+ 'TaxOverrideType'
67
+ );
68
+
69
+ /**
70
+ * Sets the collectTotals tax node based on the extensions enabled/disabled status
71
+ *
72
+ * @param Varien_Event_Observer $observer
73
+ * @return $this
74
+ */
75
+ public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer)
76
+ {
77
+ $storeId = $observer->getEvent()->getQuote()->getStoreId();
78
+ if (Mage::getStoreConfig('tax/avatax/action', $storeId) != OnePica_AvaTax_Model_Config::ACTION_DISABLE) {
79
+ Mage::getConfig()->setNode('global/sales/quote/totals/tax/class', 'avatax/sales_quote_address_total_tax');
80
+ }
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Create a sales invoice record in Avalara
86
+ *
87
+ * @param Varien_Event_Observer $observer
88
+ * @return $this
89
+ */
90
+ public function salesOrderInvoiceSaveAfter(Varien_Event_Observer $observer)
91
+ {
92
+ /** @var Mage_Sales_Model_Order_Invoice $invoice */
93
+ $invoice = $observer->getEvent()->getInvoice();
94
+
95
+ $existingInvoiceInQueue = Mage::getModel('avatax_records/queue')
96
+ ->loadInvoiceByIncrementId($invoice->getIncrementId());
97
+ if ($existingInvoiceInQueue->getId()) {
98
+ return $this;
99
+ }
100
+
101
+ /* do not post pending or cancelled invoices */
102
+ if ($invoice->getState() != Mage_Sales_Model_Order_Invoice::STATE_PAID) {
103
+ return $this;
104
+ }
105
+ /* if the previous state was unpaid, process now */
106
+ if (!$invoice->getOrigData($invoice->getIdFieldName()
107
+ && $invoice->getOrigData('state') != Mage_Sales_Model_Order_Invoice::STATE_OPEN)
108
+ && Mage::helper('avatax')->isObjectActionable($invoice)) {
109
+ Mage::getModel('avatax_records/queue')
110
+ ->setEntity($invoice)
111
+ ->setType(OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_INVOICE)
112
+ ->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_PENDING)
113
+ ->save();
114
+ }
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * Create a return invoice record in Avalara
120
+ *
121
+ * @param Varien_Event_Observer $observer
122
+ * @return $this
123
+ */
124
+ public function salesOrderCreditmemoSaveAfter(Varien_Event_Observer $observer)
125
+ {
126
+ /* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
127
+ $creditmemo = $observer->getEvent()->getCreditmemo();
128
+ if(!$creditmemo->getOrigData($creditmemo->getIdFieldName())
129
+ && Mage::helper('avatax')->isObjectActionable($creditmemo)) {
130
+ Mage::getModel('avatax_records/queue')
131
+ ->setEntity($creditmemo)
132
+ ->setType(OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_CREDITMEMEO)
133
+ ->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_PENDING)
134
+ ->save();
135
+ }
136
+ return $this;
137
+ }
138
+
139
+ /**
140
+ * Validate addresses when multishipping checkout on set shipping items
141
+ *
142
+ * @param Varien_Event_Observer $observer
143
+ * @return $this
144
+ * @throws Mage_Core_Exception
145
+ */
146
+ public function multishippingSetShippingItems(Varien_Event_Observer $observer)
147
+ {
148
+ /* @var $quote Mage_Sales_Model_Quote */
149
+ $quote = $observer->getEvent()->getQuote();
150
+
151
+ $errors = array();
152
+ $normalized = false;
153
+ $store = Mage::getModel('core/store')->load($quote->getStoreId());
154
+ $addresses = $quote->getAllShippingAddresses();
155
+ $message = Mage::getStoreConfig('tax/avatax/validate_address_message', $store);
156
+ foreach ($addresses as $address) {
157
+ /* @var $address OnePica_AvaTax_Model_Sales_Quote_Address */
158
+ if ($address->validate() !== true) {
159
+ $errors[] = sprintf($message, $address->format('oneline'));
160
+ }
161
+ if ($address->getAddressNormalized()) {
162
+ $normalized = true;
163
+ }
164
+ }
165
+
166
+ $session = Mage::getSingleton('checkout/session');
167
+ if ($normalized) {
168
+ $session->addNotice(Mage::getStoreConfig('tax/avatax/multiaddress_normalize_message', $store));
169
+ }
170
+
171
+ if (!empty($errors)) {
172
+ throw new Mage_Core_Exception(implode('<br />', $errors));
173
+ }
174
+ return $this;
175
+ }
176
+
177
+ /**
178
+ * Observer push data to Avalara
179
+ *
180
+ * @param Mage_Cron_Model_Schedule $schedule
181
+ * @return $this;
182
+ */
183
+ public function processQueue($schedule)
184
+ {
185
+ Mage::getModel('avatax_records/queue_process')->run();
186
+ return $this;
187
+ }
188
+
189
+ /**
190
+ * Test for required values when admin config setting related to the this extension are changed
191
+ *
192
+ * @param Varien_Event_Observer $observer
193
+ * @return bool
194
+ */
195
+ public function adminSystemConfigChangedSectionTax(Varien_Event_Observer $observer)
196
+ {
197
+ Mage::app()->cleanCache('block_html');
198
+
199
+ $session = Mage::getSingleton('adminhtml/session');
200
+ $storeId = Mage::getModel('core/store')->load($observer->getEvent()->getStore())->getStoreId();
201
+ $warnings = array();
202
+ $errors = array();
203
+
204
+ if (strpos(Mage::getStoreConfig('tax/avatax/url', $storeId), 'development.avalara.net') !== false) {
205
+ $warnings[] = Mage::helper('avatax')->__('You are using the AvaTax development connection URL. If you are receiving errors about authentication, please ensure that you have a development account.');
206
+ }
207
+ if (Mage::getStoreConfig('tax/avatax/action', $storeId) == OnePica_AvaTax_Model_Config::ACTION_DISABLE) {
208
+ $warnings[] = Mage::helper('avatax')->__('All AvaTax services are disabled');
209
+ }
210
+ if (Mage::getStoreConfig('tax/avatax/action', $storeId) == OnePica_AvaTax_Model_Config::ACTION_CALC) {
211
+ $warnings[] = Mage::helper('avatax')->__('Orders will not be sent to the AvaTax system');
212
+ }
213
+ if (Mage::getStoreConfig('tax/avatax/action', $storeId) == OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT) {
214
+ $warnings[] = Mage::helper('avatax')->__('Orders will be sent but never committed to the AvaTax system');
215
+ }
216
+
217
+ $ping = Mage::getSingleton('avatax/avatax_ping')->ping($storeId);
218
+ if ($ping !== true) {
219
+ $errors[] = $ping;
220
+ }
221
+ if (!Mage::getStoreConfig('tax/avatax/url', $storeId)) {
222
+ $errors[] = Mage::helper('avatax')->__('You must enter a connection URL');
223
+ }
224
+ if (!Mage::getStoreConfig('tax/avatax/account', $storeId)) {
225
+ $errors[] = Mage::helper('avatax')->__('You must enter an account number');
226
+ }
227
+ if (!Mage::getStoreConfig('tax/avatax/license', $storeId)) {
228
+ $errors[] = Mage::helper('avatax')->__('You must enter a license key');
229
+ }
230
+ if (!is_numeric(Mage::getStoreConfig('tax/avatax/log_lifetime'))) {
231
+ $errors[] = Mage::helper('avatax')->__('You must enter the number of days to keep log entries');
232
+ }
233
+ if (!Mage::getStoreConfig('tax/avatax/company_code', $storeId)) {
234
+ $errors[] = Mage::helper('avatax')->__('You must enter a company code');
235
+ }
236
+ if (!Mage::getStoreConfig('tax/avatax/shipping_sku', $storeId)) {
237
+ $errors[] = Mage::helper('avatax')->__('You must enter a shipping sku');
238
+ }
239
+ if (!Mage::getStoreConfig('tax/avatax/adjustment_positive_sku', $storeId)) {
240
+ $errors[] = Mage::helper('avatax')->__('You must enter an adjustment refund sku');
241
+ }
242
+ if (!Mage::getStoreConfig('tax/avatax/adjustment_negative_sku', $storeId)) {
243
+ $errors[] = Mage::helper('avatax')->__('You must enter an adjustment fee sku');
244
+ }
245
+
246
+ if (!class_exists('SoapClient')) {
247
+ $errors[] = Mage::helper('avatax')->__('The PHP class SoapClient is missing. It must be enabled to use this extension. See %s for details.', '<a href="http://www.php.net/manual/en/book.soap.php" target="_blank">http://www.php.net/manual/en/book.soap.php</a>');
248
+ }
249
+
250
+ if (!function_exists('openssl_sign') && count($errors)) {
251
+ $key = array_search(Mage::helper('avatax')->__('SSL support is not available in this build'), $errors);
252
+ if (isset($errors[$key])) {
253
+ unset($errors[$key]);
254
+ }
255
+ $errors[] = Mage::helper('avatax')->__('SSL must be enabled in PHP to use this extension. Typically, OpenSSL is used but it is not enabled on your server. This may not be a problem if you have some other form of SSL in place. For more information about OpenSSL, see %s.', '<a href="http://www.php.net/manual/en/book.openssl.php" target="_blank">http://www.php.net/manual/en/book.openssl.php</a>');
256
+ }
257
+
258
+ if (!Mage::getResourceModel('cron/schedule_collection')->count()) {
259
+ $warnings[] = Mage::helper('avatax')->__('It appears that Magento\'s cron scheduler is not running. For more information, see %s.', '<a href="http://www.magentocommerce.com/wiki/how_to_setup_a_cron_job" target="_black">How to Set Up a Cron Job</a>');
260
+ }
261
+
262
+ if (count($errors) == 1) {
263
+ $session->addError(implode('', $errors));
264
+ } elseif (count($errors)) {
265
+ $session->addError(Mage::helper('avatax')->__('Please fix the following issues:') . '<br /> - '
266
+ . implode('<br /> - ', $errors));
267
+ }
268
+
269
+ if (count($warnings) == 1) {
270
+ $session->addWarning(implode('', $warnings));
271
+ } elseif (count($warnings)) {
272
+ $session->addWarning(Mage::helper('avatax')->__('Please be aware of the following warnings:')
273
+ . '<br /> - '
274
+ . implode('<br /> - ', $warnings));
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Observer to clean the log every so often so it does not get too big.
280
+ *
281
+ * @param Mage_Cron_Model_Schedule $schedule
282
+ * @return $this
283
+ */
284
+ public function cleanLog($schedule)
285
+ {
286
+ $days = floatval(Mage::getStoreConfig('tax/avatax/log_lifetime'));
287
+ Mage::getModel('avatax_records/log')->deleteLogsByInterval($days);
288
+ return $this;
289
+ }
290
+
291
+ /**
292
+ * This an observer function for the event 'controller_front_init_before' and 'default'
293
+ * It prepends our autoloader, so we can load the extra libraries.
294
+ *
295
+ * @param Varien_Event_Observer $observer
296
+ * @return $this
297
+ */
298
+ public function loadAvaTaxExternalLib(Varien_Event_Observer $observer)
299
+ {
300
+ spl_autoload_register(array($this, 'loadLib'), true, true);
301
+ return $this;
302
+ }
303
+
304
+ /**
305
+ * This function can autoloads classes to work with Avalara API
306
+ *
307
+ * @param string $class
308
+ */
309
+ public static function loadLib($class)
310
+ {
311
+ if (in_array($class, self::$_classes)) {
312
+ /** @var OnePica_AvaTax_Helper_Data $helper */
313
+ $helper = Mage::helper('avatax');
314
+ $helper->loadFunctions();
315
+ $helper->loadClass($class);
316
+ }
317
+ return;
318
+ }
319
+
320
+ /**
321
+ * Set post type for checkout session when 'controller_action_predispatch_checkout_cart_estimatePost' event
322
+ *
323
+ * @param Varien_Event_Observer $observer
324
+ * @return $this
325
+ */
326
+ public function controllerActionPredispatchCheckoutCartEstimatePost(Varien_Event_Observer $observer)
327
+ {
328
+ $session = Mage::getSingleton('checkout/session');
329
+ $session->setPostType('estimate');
330
+ return $this;
331
+ }
332
+
333
+ /**
334
+ * Set post type for checkout session when 'controller_action_predispatch_checkout_onepage_index' event
335
+ *
336
+ * @param Varien_Event_Observer $observer
337
+ * @return $this
338
+ */
339
+ public function controllerActionPredispatchCheckoutOnepageIndex(Varien_Event_Observer $observer)
340
+ {
341
+ $session = Mage::getSingleton('checkout/session');
342
+ $session->setPostType('onepage');
343
+ return $this;
344
+ }
345
+ }
app/code/community/OnePica/AvaTax/Model/Records/.DS_Store DELETED
Binary file
app/code/community/OnePica/AvaTax/Model/Records/Log.php CHANGED
@@ -1,55 +1,103 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Records_Log extends Mage_Core_Model_Abstract
20
- {
21
-
22
- const LOG_LEVEL_SUCCESS = 'Success';
23
- const LOG_LEVEL_ERROR = 'Error';
24
-
25
- public function _construct()
26
- {
27
- parent::_construct();
28
- $this->_init('avatax_records/log');
29
- }
30
-
31
- public function setAdditional($value=null) {
32
- if($value) {
33
- $value = str_replace(Mage::getStoreConfig('tax/avatax/license'), '[MASKED::LICENSE_KEY]', print_r($value, true));
34
- }
35
- $this->setData('additional', $value);
36
- return $this;
37
- }
38
-
39
- public function getTypeOptions() {
40
- $storeId = Mage::app()->getStore()->getId();
41
- $types = Mage::helper('avatax')->getLogType($storeId);
42
- foreach ($types as $key => $value)
43
- {
44
- $result[$value] = $value;
45
- }
46
- return $result;
47
- }
48
-
49
- public function getLevelOptions() {
50
- return array(
51
- self::LOG_LEVEL_SUCCESS => self::LOG_LEVEL_SUCCESS,
52
- self::LOG_LEVEL_ERROR => self::LOG_LEVEL_ERROR
53
- );
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Log model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Records_Log extends Mage_Core_Model_Abstract
26
+ {
27
+ /**
28
+ * Success log level
29
+ */
30
+ const LOG_LEVEL_SUCCESS = 'Success';
31
+
32
+ /**
33
+ * Error log level
34
+ */
35
+ const LOG_LEVEL_ERROR = 'Error';
36
+
37
+ /**
38
+ * Internal constructor
39
+ */
40
+ protected function _construct()
41
+ {
42
+ parent::_construct();
43
+ $this->_init('avatax_records/log');
44
+ }
45
+
46
+ /**
47
+ * Set additional data
48
+ *
49
+ * @param string|null $value
50
+ * @return $this
51
+ */
52
+ public function setAdditional($value = null)
53
+ {
54
+ if ($value) {
55
+ $value = str_replace(
56
+ Mage::getStoreConfig('tax/avatax/license'),
57
+ '[MASKED::LICENSE_KEY]',
58
+ print_r($value, true)
59
+ );
60
+ }
61
+ $this->setData('additional', $value);
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Get type options
67
+ *
68
+ * @return array
69
+ */
70
+ public function getTypeOptions()
71
+ {
72
+ $result = array();
73
+ $storeId = Mage::app()->getStore()->getId();
74
+ $types = Mage::helper('avatax')->getLogType($storeId);
75
+ foreach ($types as $key => $value) {
76
+ $result[$value] = $value;
77
+ }
78
+ return $result;
79
+ }
80
+
81
+ /**
82
+ * Get level options
83
+ *
84
+ * @return array
85
+ */
86
+ public function getLevelOptions() {
87
+ return array(
88
+ self::LOG_LEVEL_SUCCESS => self::LOG_LEVEL_SUCCESS,
89
+ self::LOG_LEVEL_ERROR => self::LOG_LEVEL_ERROR
90
+ );
91
+ }
92
+
93
+ /**
94
+ * Delete logs for given interval
95
+ *
96
+ * @param int $days
97
+ * @return int
98
+ */
99
+ public function deleteLogsByInterval($days)
100
+ {
101
+ return $this->getResource()->deleteLogsByInterval($days);
102
+ }
103
+ }
app/code/community/OnePica/AvaTax/Model/Records/Mysql4/Log.php CHANGED
@@ -1,38 +1,63 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Records_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
20
- {
21
- protected function _construct() {
22
- $this->_init('avatax_records/log', 'log_id');
23
- }
24
-
25
- /**
26
- * Sets various dates before the model is saved.
27
- *
28
- * @param Mage_Core_Model_Abstract $object
29
- * @return OnePica_AvaTax_Model_Mysql4_Log
30
- */
31
- protected function _beforeSave(Mage_Core_Model_Abstract $object) {
32
- $object->setCreatedAt(gmdate('Y-m-d H:i:s'));
33
- if(!$object->getLevel()) {
34
- $object->setLevel('Unknown');
35
- }
36
- return $this;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Log resource model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Records_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
26
+ {
27
+ /**
28
+ * Construct
29
+ */
30
+ protected function _construct()
31
+ {
32
+ $this->_init('avatax_records/log', 'log_id');
33
+ }
34
+
35
+ /**
36
+ * Sets various dates before the model is saved.
37
+ *
38
+ * @param Mage_Core_Model_Abstract $object
39
+ * @return $this
40
+ */
41
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
42
+ {
43
+ $object->setCreatedAt(gmdate('Y-m-d H:i:s'));
44
+ if ($object->getLevel() != OnePica_AvaTax_Model_Records_Log::LOG_LEVEL_SUCCESS) {
45
+ $object->setLevel(OnePica_AvaTax_Model_Records_Log::LOG_LEVEL_ERROR);
46
+ }
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * Delete logs for given interval
52
+ *
53
+ * @param int $days
54
+ * @return int
55
+ */
56
+ public function deleteLogsByInterval($days)
57
+ {
58
+ return $this->_getWriteAdapter()->delete(
59
+ $this->getTable('avatax_records/log'),
60
+ $this->_getWriteAdapter()->quoteInto('created_at < DATE_SUB(UTC_DATE(), INTERVAL ? DAY)', $days)
61
+ );
62
+ }
63
+ }
app/code/community/OnePica/AvaTax/Model/Records/Mysql4/Log/Collection.php CHANGED
@@ -1,25 +1,35 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Records_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
20
- {
21
- public function _construct() {
22
- parent::_construct();
23
- $this->_init('avatax_records/log');
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Log collection model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Records_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
26
+ {
27
+ /**
28
+ * Construct
29
+ */
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('avatax_records/log');
34
+ }
35
+ }
app/code/community/OnePica/AvaTax/Model/Records/Mysql4/Queue.php CHANGED
@@ -1,105 +1,130 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Records_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
20
- {
21
- protected function _construct() {
22
- $this->_init('avatax_records/queue', 'id');
23
- }
24
-
25
- /**
26
- * Sets various dates before the model is saved.
27
- *
28
- * @param Mage_Core_Model_Abstract $object
29
- * @return OnePica_AvaTax_Model_Mysql4_Queue
30
- */
31
- protected function _beforeSave(Mage_Core_Model_Abstract $object) {
32
- if(!$object->hasCreatedAt()) {
33
- $object->setCreatedAt(gmdate('Y-m-d H:i:s'));
34
- }
35
- $object->setUpdatedAt(gmdate('Y-m-d H:i:s'));
36
- return $this;
37
- }
38
-
39
- /**
40
- * Log the save
41
- *
42
- * @param Mage_Core_Model_Abstract $object
43
- * @return OnePica_AvaTax_Model_Mysql4_Queue
44
- */
45
- protected function _afterSave(Mage_Core_Model_Abstract $object) {
46
- $storeId = $object->getStoreId();
47
- $logStatus = Mage::getStoreConfig('tax/avatax/log_status', $object->getStoreId());
48
- if($logStatus) {
49
- if (in_array('Queue', Mage::helper('avatax')->getLogType($storeId)))
50
- {
51
- Mage::getModel('avatax_records/log')
52
- ->setStoreId($object->getStoreId())
53
- ->setLevel('Success')
54
- ->setType('Queue')
55
- ->setRequest(print_r($object->getData(), true))
56
- ->setResult('Saved')
57
- ->save();
58
- }
59
- }
60
- return $this;
61
- }
62
-
63
- /**
64
- * Log the delete
65
- *
66
- * @param Mage_Core_Model_Abstract $object
67
- * @return OnePica_AvaTax_Model_Mysql4_Queue
68
- */
69
- protected function _afterDelete(Mage_Core_Model_Abstract $object) {
70
- $storeId = $object->getStoreId();
71
- $logStatus = Mage::getStoreConfig('tax/avatax/log_status', $object->getStoreId());
72
- if($logStatus) {
73
- if (in_array('Queue', Mage::helper('avatax')->getLogType($storeId)))
74
- {
75
- Mage::getModel('avatax_records/log')
76
- ->setStoreId($object->getStoreId())
77
- ->setLevel('Success')
78
- ->setType('Queue')
79
- ->setRequest(print_r($object->getData(), true))
80
- ->setResult('Deleted')
81
- ->save();
82
- }
83
- }
84
- return $this;
85
- }
86
-
87
- /**
88
- * @param $queue OnePica_AvaTax_Model_Records_Queue
89
- * @param $invoiceIncrementId
90
- * @return $this
91
- */
92
- public function loadInvoiceByIncrementId($queue, $invoiceIncrementId)
93
- {
94
- $adapter = $this->_getReadAdapter();
95
- $select = $adapter->select()
96
- ->from($this->getMainTable())
97
- ->where('entity_increment_id = ?', $invoiceIncrementId)
98
- ->where('type = ?', OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_INVOICE);
99
-
100
- $data = $adapter->fetchRow($select);
101
- $queue->setData($data);
102
-
103
- return $this;
104
- }
105
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Queue resource model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Records_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
26
+ {
27
+ /**
28
+ * Saved result
29
+ */
30
+ const SAVED_RESULT = 'Saved';
31
+
32
+ /**
33
+ * Deleted result
34
+ */
35
+ const DELETED_RESULT = 'Deleted';
36
+
37
+ /**
38
+ * Construct
39
+ */
40
+ protected function _construct()
41
+ {
42
+ $this->_init('avatax_records/queue', 'queue_id');
43
+ }
44
+
45
+ /**
46
+ * Sets various dates before the model is saved.
47
+ *
48
+ * @param Mage_Core_Model_Abstract $object
49
+ * @return $this
50
+ */
51
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
52
+ {
53
+ if (!$object->hasCreatedAt()) {
54
+ $object->setCreatedAt(gmdate('Y-m-d H:i:s'));
55
+ }
56
+ $object->setUpdatedAt(gmdate('Y-m-d H:i:s'));
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Log the save
62
+ *
63
+ * @param Mage_Core_Model_Abstract $object
64
+ * @return $this
65
+ */
66
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
67
+ {
68
+ $this->_logAction($object, self::SAVED_RESULT);
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * Log the delete
74
+ *
75
+ * @param Mage_Core_Model_Abstract $object
76
+ * @return $this
77
+ */
78
+ protected function _afterDelete(Mage_Core_Model_Abstract $object)
79
+ {
80
+ $this->_logAction($object, self::DELETED_RESULT);
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Log action
86
+ *
87
+ * @param Mage_Core_Model_Abstract $object
88
+ * @param string $result
89
+ * @return $this
90
+ */
91
+ protected function _logAction(Mage_Core_Model_Abstract $object, $result)
92
+ {
93
+ $storeId = $object->getStoreId();
94
+ $logStatus = Mage::getStoreConfig('tax/avatax/log_status', $storeId);
95
+ if ($logStatus) {
96
+ $logTypes = Mage::helper('avatax')->getLogType($storeId);
97
+ if (in_array(OnePica_AvaTax_Model_Source_Logtype::QUEUE, $logTypes)) {
98
+ Mage::getModel('avatax_records/log')
99
+ ->setStoreId($object->getStoreId())
100
+ ->setLevel(OnePica_AvaTax_Model_Records_Log::LOG_LEVEL_SUCCESS)
101
+ ->setType(OnePica_AvaTax_Model_Source_Logtype::QUEUE)
102
+ ->setRequest(print_r($object->getData(), true))
103
+ ->setResult($result)
104
+ ->save();
105
+ }
106
+ }
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Load invoice by increment id
112
+ *
113
+ * @param OnePica_AvaTax_Model_Records_Queue $queue
114
+ * @param int $invoiceIncrementId
115
+ * @return $this
116
+ */
117
+ public function loadInvoiceByIncrementId($queue, $invoiceIncrementId)
118
+ {
119
+ $adapter = $this->_getReadAdapter();
120
+ $select = $adapter->select()
121
+ ->from($this->getMainTable())
122
+ ->where('entity_increment_id = ?', $invoiceIncrementId)
123
+ ->where('type = ?', OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_INVOICE);
124
+
125
+ $data = $adapter->fetchRow($select);
126
+ $queue->setData($data);
127
+
128
+ return $this;
129
+ }
130
+ }
app/code/community/OnePica/AvaTax/Model/Records/Mysql4/Queue/Collection.php CHANGED
@@ -1,25 +1,35 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
20
- {
21
- public function _construct() {
22
- parent::_construct();
23
- $this->_init('avatax_records/queue');
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Queue collection model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
26
+ {
27
+ /**
28
+ * Construct
29
+ */
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('avatax_records/queue');
34
+ }
35
+ }
app/code/community/OnePica/AvaTax/Model/Records/Queue.php CHANGED
@@ -1,70 +1,130 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- *
17
- * @method OnePica_AvaTax_Model_Records_Mysql4_Queue _getResource()
18
- */
19
-
20
-
21
- class OnePica_AvaTax_Model_Records_Queue extends Mage_Core_Model_Abstract
22
- {
23
- const QUEUE_TYPE_INVOICE = 'Invoice';
24
- const QUEUE_TYPE_CREDITMEMEO = 'Credit memo';
25
-
26
- const QUEUE_STATUS_PENDING = 'Pending';
27
- const QUEUE_STATUS_RETRY = 'Retry pending';
28
- const QUEUE_STATUS_FAILED = 'Failed';
29
- const QUEUE_STATUS_COMPLETE = 'Complete';
30
- const QUEUE_STATUS_UNBALANCED = 'Unbalanced';
31
-
32
- public function _construct()
33
- {
34
- parent::_construct();
35
- $this->_init('avatax_records/queue');
36
- }
37
-
38
- public function setEntity($object) {
39
- $this->setEntityId($object->getId());
40
- $this->setEntityIncrementId($object->getIncrementId());
41
- $this->setStoreId($object->getStoreId());
42
- return $this;
43
- }
44
-
45
- public function getTypeOptions() {
46
- return array(
47
- self::QUEUE_TYPE_INVOICE => self::QUEUE_TYPE_INVOICE,
48
- self::QUEUE_TYPE_CREDITMEMEO => self::QUEUE_TYPE_CREDITMEMEO
49
- );
50
- }
51
-
52
- public function getStatusOptions() {
53
- return array(
54
- self::QUEUE_STATUS_PENDING => self::QUEUE_STATUS_PENDING,
55
- self::QUEUE_STATUS_RETRY => self::QUEUE_STATUS_RETRY,
56
- self::QUEUE_STATUS_FAILED => self::QUEUE_STATUS_FAILED,
57
- self::QUEUE_STATUS_COMPLETE => self::QUEUE_STATUS_COMPLETE,
58
- self::QUEUE_STATUS_UNBALANCED => self::QUEUE_STATUS_UNBALANCED
59
- );
60
- }
61
-
62
- public function loadInvoiceByIncrementId($incrementId)
63
- {
64
- $this->_getResource()->loadInvoiceByIncrementId($this, $incrementId);
65
- $this->_afterLoad();
66
- $this->setOrigData();
67
-
68
- return $this;
69
- }
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ *
17
+ * @method OnePica_AvaTax_Model_Records_Mysql4_Queue _getResource()
18
+ */
19
+
20
+ /**
21
+ * Queue model
22
+ *
23
+ * @category OnePica
24
+ * @package OnePica_AvaTax
25
+ * @author OnePica Codemaster <codemaster@onepica.com>
26
+ */
27
+ class OnePica_AvaTax_Model_Records_Queue extends Mage_Core_Model_Abstract
28
+ {
29
+ /**
30
+ * Invoice type
31
+ */
32
+ const QUEUE_TYPE_INVOICE = 'Invoice';
33
+
34
+ /**
35
+ * Credit memo type
36
+ */
37
+ const QUEUE_TYPE_CREDITMEMEO = 'Credit memo';
38
+
39
+ /**
40
+ * Pending status
41
+ */
42
+ const QUEUE_STATUS_PENDING = 'Pending';
43
+
44
+ /**
45
+ * Retry status
46
+ */
47
+ const QUEUE_STATUS_RETRY = 'Retry pending';
48
+
49
+ /**
50
+ * Failed status
51
+ */
52
+ const QUEUE_STATUS_FAILED = 'Failed';
53
+
54
+ /**
55
+ * Complete status
56
+ */
57
+ const QUEUE_STATUS_COMPLETE = 'Complete';
58
+
59
+ /**
60
+ * Unbalanced status
61
+ */
62
+ const QUEUE_STATUS_UNBALANCED = 'Unbalanced';
63
+
64
+ /**
65
+ * Internal constructor
66
+ */
67
+ protected function _construct()
68
+ {
69
+ parent::_construct();
70
+ $this->_init('avatax_records/queue');
71
+ }
72
+
73
+ /**
74
+ * Set entity
75
+ *
76
+ * @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
77
+ * @return $this
78
+ */
79
+ public function setEntity($object)
80
+ {
81
+ $this->setEntityId($object->getId());
82
+ $this->setEntityIncrementId($object->getIncrementId());
83
+ $this->setStoreId($object->getStoreId());
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Get type options
89
+ *
90
+ * @return array
91
+ */
92
+ public function getTypeOptions()
93
+ {
94
+ return array(
95
+ self::QUEUE_TYPE_INVOICE => self::QUEUE_TYPE_INVOICE,
96
+ self::QUEUE_TYPE_CREDITMEMEO => self::QUEUE_TYPE_CREDITMEMEO
97
+ );
98
+ }
99
+
100
+ /**
101
+ * Get status options
102
+ *
103
+ * @return array
104
+ */
105
+ public function getStatusOptions()
106
+ {
107
+ return array(
108
+ self::QUEUE_STATUS_PENDING => self::QUEUE_STATUS_PENDING,
109
+ self::QUEUE_STATUS_RETRY => self::QUEUE_STATUS_RETRY,
110
+ self::QUEUE_STATUS_FAILED => self::QUEUE_STATUS_FAILED,
111
+ self::QUEUE_STATUS_COMPLETE => self::QUEUE_STATUS_COMPLETE,
112
+ self::QUEUE_STATUS_UNBALANCED => self::QUEUE_STATUS_UNBALANCED
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Load invoice by increment id
118
+ *
119
+ * @param int $incrementId
120
+ * @return $this
121
+ */
122
+ public function loadInvoiceByIncrementId($incrementId)
123
+ {
124
+ $this->_getResource()->loadInvoiceByIncrementId($this, $incrementId);
125
+ $this->_afterLoad();
126
+ $this->setOrigData();
127
+
128
+ return $this;
129
+ }
130
+ }
app/code/community/OnePica/AvaTax/Model/Records/Queue/Process.php CHANGED
@@ -1,143 +1,210 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- class OnePica_AvaTax_Model_Records_Queue_Process extends OnePica_AvaTax_Model_Abstract
19
- {
20
- /**
21
- * Remove the Failed process
22
- *
23
- * @return self
24
- */
25
- public function clear() {
26
- $queue = Mage::getModel('avatax_records/queue')->getCollection()
27
- ->addFieldToFilter('status', OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED);
28
-
29
- foreach($queue as $item) {
30
- $item->delete();
31
- }
32
-
33
- return $this;
34
- }
35
-
36
- /**
37
- * Run the complete process
38
- *
39
- * @return self
40
- */
41
- public function run() {
42
- $this->_cleanCompleted()
43
- ->_cleanFailed()
44
- ->_parseInvoices()
45
- ->_parseCreditMemos();
46
- return $this;
47
- }
48
-
49
- /**
50
- * Delete any queue items that have been completed. Items stay in queue for some
51
- * transparency into the process.
52
- *
53
- * @return self
54
- */
55
- protected function _cleanCompleted() {
56
- $days = intval(Mage::getStoreConfig('tax/avatax/queue_success_lifetime'));
57
- $queue = Mage::getModel('avatax_records/queue')->getCollection()
58
- ->addFieldToFilter('status', OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE)
59
- ->addFieldToFilter('updated_at', array('lt' => gmdate('Y-m-d H:i:s', strtotime('-' . $days . ' days'))));
60
-
61
- foreach($queue as $item) {
62
- $item->delete();
63
- }
64
-
65
- return $this;
66
- }
67
-
68
- /**
69
- * Delete any queue items that have failed. Items stay in queue for some
70
- * transparency into the process.
71
- *
72
- * @return self
73
- */
74
- protected function _cleanFailed() {
75
- $days = intval(Mage::getStoreConfig('tax/avatax/queue_failed_lifetime'));
76
- $queue = Mage::getModel('avatax_records/queue')->getCollection()
77
- ->addFieldToFilter('status', OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED)
78
- ->addFieldToFilter('updated_at', array('lt' => gmdate('Y-m-d H:i:s', strtotime('-' . $days . ' days'))));
79
-
80
- foreach($queue as $item) {
81
- $item->delete();
82
- }
83
-
84
- return $this;
85
- }
86
-
87
- /**
88
- * Attempt to send any pending invoices to Avalara
89
- *
90
- * @return self
91
- */
92
- protected function _parseInvoices() {
93
- $queue = Mage::getModel('avatax_records/queue')->getCollection()
94
- ->addFieldToFilter('type', OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_INVOICE)
95
- ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED))
96
- ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE))
97
- ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED));
98
- foreach($queue as $item) {
99
- $item->setAttempt($item->getAttempt() + 1);
100
- try {
101
- $invoice = Mage::getModel('sales/order_invoice')->load($item->getEntityId());
102
- if($invoice->getId()) Mage::getModel('avatax/avatax_invoice')->invoice($invoice, $item);
103
- $item->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE)->setMessage(null)->save();
104
- } catch (OnePica_AvaTax_Model_Avatax_Exception_Unbalanced $e) {
105
- $item->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED)->setMessage($e->getMessage())->save();
106
- } catch (Exception $e) {
107
- $status = ($item->getAttempt() >= OnePica_AvaTax_Model_Config::QUEUE_ATTEMPT_MAX) ? OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED : OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_RETRY;
108
- $item->setStatus($status)->setMessage($e->getMessage())->save();
109
- }
110
- }
111
-
112
- return $this;
113
- }
114
-
115
- /**
116
- * Attempt to send any pending credit memos to Avalara
117
- *
118
- * @return self
119
- */
120
- protected function _parseCreditMemos() {
121
- $queue = Mage::getModel('avatax_records/queue')->getCollection()
122
- ->addFieldToFilter('type', OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_CREDITMEMEO)
123
- ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED))
124
- ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE))
125
- ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED));
126
- foreach($queue as $item) {
127
- $item->setAttempt($item->getAttempt() + 1);
128
- try {
129
- $creditmemo = Mage::getModel('sales/order_creditmemo')->load($item->getEntityId());
130
- if($creditmemo->getId()) Mage::getModel('avatax/avatax_invoice')->creditmemo($creditmemo, $item);
131
- $item->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE)->setMessage(null)->save();
132
- } catch (OnePica_AvaTax_Model_Avatax_Exception_Unbalanced $e) {
133
- $item->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED)->setMessage($e->getMessage())->save();
134
- } catch (Exception $e) {
135
- $status = ($item->getAttempt() >= OnePica_AvaTax_Model_Config::QUEUE_ATTEMPT_MAX) ? OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED : OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_RETRY;
136
- $item->setStatus($status)->setMessage($e->getMessage())->save();
137
- }
138
- }
139
-
140
- return $this;
141
- }
142
-
143
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Queue process model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Records_Queue_Process extends OnePica_AvaTax_Model_Abstract
26
+ {
27
+ /**
28
+ * Remove the Failed process
29
+ *
30
+ * @return $this
31
+ */
32
+ public function clear()
33
+ {
34
+ /** @var OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection $queue */
35
+ $queue = Mage::getModel('avatax_records/queue')->getCollection()
36
+ ->addFieldToFilter('status', array(
37
+ 'in' => array(
38
+ OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED,
39
+ OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED,
40
+ OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE
41
+ )
42
+ )
43
+ );
44
+
45
+ /** @var OnePica_AvaTax_Model_Records_Queue $item */
46
+ foreach ($queue as $item) {
47
+ $item->delete();
48
+ }
49
+
50
+ return $this;
51
+ }
52
+
53
+ /**
54
+ * Run the complete process
55
+ *
56
+ * @throws \Exception
57
+ * @return $this
58
+ */
59
+ public function run()
60
+ {
61
+ $this->_cleanCompleted()
62
+ ->_cleanFailed()
63
+ ->_cleanUnbalanced()
64
+ ->_parseInvoices()
65
+ ->_parseCreditMemos();
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * Delete any queue items that have been completed. Items stay in queue for some
71
+ * transparency into the process.
72
+ *
73
+ * @return $this
74
+ */
75
+ protected function _cleanCompleted()
76
+ {
77
+ $days = intval(Mage::getStoreConfig('tax/avatax/queue_success_lifetime'));
78
+ /** @var OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection $queue */
79
+ $queue = Mage::getModel('avatax_records/queue')->getCollection()
80
+ ->addFieldToFilter('status', OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE)
81
+ ->addFieldToFilter('updated_at', array('lt' => gmdate('Y-m-d H:i:s', strtotime('-' . $days . ' days'))));
82
+
83
+ foreach ($queue as $item) {
84
+ $item->delete();
85
+ }
86
+
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Delete any queue items that have failed. Items stay in queue for some
92
+ * transparency into the process.
93
+ *
94
+ * @return $this
95
+ */
96
+ protected function _cleanFailed()
97
+ {
98
+ $days = intval(Mage::getStoreConfig('tax/avatax/queue_failed_lifetime'));
99
+ /** @var OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection $queue */
100
+ $queue = Mage::getModel('avatax_records/queue')->getCollection()
101
+ ->addFieldToFilter('status', OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED)
102
+ ->addFieldToFilter('updated_at', array('lt' => gmdate('Y-m-d H:i:s', strtotime('-' . $days . ' days'))));
103
+
104
+ foreach ($queue as $item) {
105
+ $item->delete();
106
+ }
107
+
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * Delete any queue items that have unbalanced status
113
+ *
114
+ * @return $this
115
+ * @throws \Exception
116
+ */
117
+ protected function _cleanUnbalanced()
118
+ {
119
+ $days = (int)Mage::getStoreConfig('tax/avatax/queue_failed_lifetime');
120
+ /** @var OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection $queue */
121
+ $queue = Mage::getModel('avatax_records/queue')->getCollection()
122
+ ->addFieldToFilter('status', OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED)
123
+ ->addFieldToFilter('updated_at', array('lt' => gmdate('Y-m-d H:i:s', strtotime('-' . $days . ' days'))));
124
+
125
+ /** @var OnePica_AvaTax_Model_Records_Queue $item */
126
+ foreach ($queue as $item) {
127
+ $item->delete();
128
+ }
129
+
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Attempt to send any pending invoices to Avalara
135
+ *
136
+ * @return $this
137
+ */
138
+ protected function _parseInvoices()
139
+ {
140
+ /** @var OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection $queue */
141
+ $queue = Mage::getModel('avatax_records/queue')->getCollection()
142
+ ->addFieldToFilter('type', OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_INVOICE)
143
+ ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED))
144
+ ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE))
145
+ ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED));
146
+ foreach ($queue as $item) {
147
+ $item->setAttempt($item->getAttempt() + 1);
148
+ try {
149
+ $invoice = Mage::getModel('sales/order_invoice')->load($item->getEntityId());
150
+ if ($invoice->getId()) {
151
+ Mage::getModel('avatax/avatax_invoice')->invoice($invoice, $item);
152
+ }
153
+ $item->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE)->setMessage(null)->save();
154
+ } catch (OnePica_AvaTax_Model_Avatax_Exception_Unbalanced $e) {
155
+ $item->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED)
156
+ ->setMessage($e->getMessage())
157
+ ->save();
158
+ } catch (Exception $e) {
159
+ $status = ($item->getAttempt() >= OnePica_AvaTax_Model_Config::QUEUE_ATTEMPT_MAX) ?
160
+ OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED :
161
+ OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_RETRY;
162
+ $item->setStatus($status)
163
+ ->setMessage($e->getMessage())
164
+ ->save();
165
+ }
166
+ }
167
+
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * Attempt to send any pending credit memos to Avalara
173
+ *
174
+ * @return $this
175
+ */
176
+ protected function _parseCreditMemos()
177
+ {
178
+ /** @var OnePica_AvaTax_Model_Records_Mysql4_Queue_Collection $queue */
179
+ $queue = Mage::getModel('avatax_records/queue')->getCollection()
180
+ ->addFieldToFilter('type', OnePica_AvaTax_Model_Records_Queue::QUEUE_TYPE_CREDITMEMEO)
181
+ ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED))
182
+ ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE))
183
+ ->addFieldToFilter('status', array('neq' => OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED));
184
+ foreach ($queue as $item) {
185
+ $item->setAttempt($item->getAttempt() + 1);
186
+ try {
187
+ $creditmemo = Mage::getModel('sales/order_creditmemo')->load($item->getEntityId());
188
+ if ($creditmemo->getId()) {
189
+ Mage::getModel('avatax/avatax_invoice')->creditmemo($creditmemo, $item);
190
+ }
191
+ $item->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_COMPLETE)
192
+ ->setMessage(null)
193
+ ->save();
194
+ } catch (OnePica_AvaTax_Model_Avatax_Exception_Unbalanced $e) {
195
+ $item->setStatus(OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_UNBALANCED)
196
+ ->setMessage($e->getMessage())
197
+ ->save();
198
+ } catch (Exception $e) {
199
+ $status = ($item->getAttempt() >= OnePica_AvaTax_Model_Config::QUEUE_ATTEMPT_MAX) ?
200
+ OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_FAILED :
201
+ OnePica_AvaTax_Model_Records_Queue::QUEUE_STATUS_RETRY;
202
+ $item->setStatus($status)
203
+ ->setMessage($e->getMessage())
204
+ ->save();
205
+ }
206
+ }
207
+
208
+ return $this;
209
+ }
210
+ }
app/code/community/OnePica/AvaTax/Model/Sales/Quote/Address.php CHANGED
@@ -1,203 +1,221 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * The Sales Quote Address model.
20
- */
21
- class OnePica_AvaTax_Model_Sales_Quote_Address extends Mage_Sales_Model_Quote_Address
22
- {
23
- /**
24
- * Avatax address validator instance
25
- *
26
- * @var OnePica_AvaTax_Model_Avatax_Address
27
- */
28
- protected $_avataxValidator = null;
29
-
30
- /**
31
- * Validation results array (to avoid double valiadation of same address)
32
- *
33
- * @var array
34
- */
35
- static protected $_validationResult = array();
36
-
37
- /**
38
- * Avatax address validator accessor method
39
- *
40
- * @return OnePica_AvaTax_Model_Avatax_Address
41
- */
42
- public function getAvataxValidator() {
43
- return $this->_avataxValidator;
44
- }
45
-
46
- /**
47
- * Avatax address validator mutator method
48
- *
49
- * @return OnePica_AvaTax_Model_Avatax_Address
50
- * @return self
51
- */
52
- public function setAvataxValidator(OnePica_AvaTax_Model_Avatax_Address $object) {
53
- $this->_avataxValidator = $object;
54
- return $this;
55
- }
56
-
57
- /**
58
- * Creates a hash key based on only address data for caching
59
- *
60
- * @return string
61
- */
62
- public function getCacheHashKey() {
63
- if(!$this->getData('cache_hash_key')) {
64
- $this->setData('cache_hash_key', hash('md4', $this->format('text')));
65
- }
66
- return $this->getData('cache_hash_key');
67
- }
68
-
69
- /**
70
- * Validates the address. AvaTax validation is invoked if the this is a ship-to address.
71
- * Returns true on success and an array with an error on failure.
72
- *
73
- * @return true|array
74
- */
75
- public function validate () {
76
-
77
- if (! Mage::helper('avatax')->fullStopOnError()) {
78
- return true;
79
- }
80
-
81
- $result = parent::validate();
82
-
83
- //if base validation fails, don't bother with additional validation
84
- if ($result !== true) {
85
- return $result;
86
- }
87
-
88
- //if ship-to address, do AvaTax validation
89
- $data = Mage::app()->getRequest()->getPost('billing', array());
90
- $useForShipping = isset($data['use_for_shipping']) ? (int)$data['use_for_shipping'] : 0;
91
-
92
- if($this->getAddressType() == self::TYPE_SHIPPING || $this->getUseForShipping() /* <1.9 */ || $useForShipping /* >=1.9 */) {
93
- if (!isset(self::$_validationResult[$this->getAddressId()])) {
94
- if(!$this->getAvataxValidator()) {
95
- $validator = Mage::getModel('avatax/avatax_address')->setAddress($this);
96
- $this->setAvataxValidator($validator);
97
- }
98
-
99
- self::$_validationResult[$this->getAddressId()] = $this->getAvataxValidator()->validate();
100
- }
101
-
102
- return self::$_validationResult[$this->getAddressId()];
103
- }
104
-
105
- return $result;
106
- }
107
-
108
-
109
- /* BELOW ARE MAGE CORE PROPERTIES AND METHODS ADDED FOR OLDER VERSION COMPATABILITY */
110
-
111
- protected $_totalAmounts = array();
112
- protected $_baseTotalAmounts = array();
113
-
114
- /**
115
- * Add amount total amount value
116
- *
117
- * @param string $code
118
- * @param float $amount
119
- * @return Mage_Sales_Model_Quote_Address
120
- */
121
- public function addTotalAmount($code, $amount)
122
- {
123
- $amount = $this->getTotalAmount($code)+$amount;
124
- $this->setTotalAmount($code, $amount);
125
- return $this;
126
- }
127
-
128
- /**
129
- * Add amount total amount value in base store currency
130
- *
131
- * @param string $code
132
- * @param float $amount
133
- * @return Mage_Sales_Model_Quote_Address
134
- */
135
- public function addBaseTotalAmount($code, $amount)
136
- {
137
- $amount = $this->getBaseTotalAmount($code)+$amount;
138
- $this->setBaseTotalAmount($code, $amount);
139
- return $this;
140
- }
141
-
142
- /**
143
- * Set total amount value
144
- *
145
- * @param string $code
146
- * @param float $amount
147
- * @return Mage_Sales_Model_Quote_Address
148
- */
149
- public function setTotalAmount($code, $amount)
150
- {
151
- $this->_totalAmounts[$code] = $amount;
152
- if ($code != 'subtotal') {
153
- $code = $code.'_amount';
154
- }
155
- $this->setData($code, $amount);
156
- return $this;
157
- }
158
-
159
- /**
160
- * Set total amount value in base store currency
161
- *
162
- * @param string $code
163
- * @param float $amount
164
- * @return Mage_Sales_Model_Quote_Address
165
- */
166
- public function setBaseTotalAmount($code, $amount)
167
- {
168
- $this->_baseTotalAmounts[$code] = $amount;
169
- if ($code != 'subtotal') {
170
- $code = $code.'_amount';
171
- }
172
- $this->setData('base_'.$code, $amount);
173
- return $this;
174
- }
175
-
176
- /**
177
- * Get total amount value by code
178
- *
179
- * @param string $code
180
- * @return float
181
- */
182
- public function getTotalAmount($code)
183
- {
184
- if (isset($this->_totalAmounts[$code])) {
185
- return $this->_totalAmounts[$code];
186
- }
187
- return 0;
188
- }
189
-
190
- /**
191
- * Get total amount value by code in base store curncy
192
- *
193
- * @param string $code
194
- * @return float
195
- */
196
- public function getBaseTotalAmount($code)
197
- {
198
- if (isset($this->_baseTotalAmounts[$code])) {
199
- return $this->_baseTotalAmounts[$code];
200
- }
201
- return 0;
202
- }
203
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The Sales Quote Address model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Sales_Quote_Address extends Mage_Sales_Model_Quote_Address
26
+ {
27
+ /**
28
+ * Avatax address validator instance
29
+ *
30
+ * @var OnePica_AvaTax_Model_Avatax_Address
31
+ */
32
+ protected $_avataxValidator = null;
33
+
34
+ /**
35
+ * Validation results array (to avoid double valiadation of same address)
36
+ *
37
+ * @var array
38
+ */
39
+ static protected $_validationResult = array();
40
+
41
+ /**
42
+ * Avatax address validator accessor method
43
+ *
44
+ * @return OnePica_AvaTax_Model_Avatax_Address
45
+ */
46
+ public function getAvataxValidator()
47
+ {
48
+ return $this->_avataxValidator;
49
+ }
50
+
51
+ /**
52
+ * Avatax address validator mutator method
53
+ *
54
+ * @param OnePica_AvaTax_Model_Avatax_Address $object
55
+ * @return $this
56
+ */
57
+ public function setAvataxValidator(OnePica_AvaTax_Model_Avatax_Address $object)
58
+ {
59
+ $this->_avataxValidator = $object;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Creates a hash key based on only address data for caching
65
+ *
66
+ * @return string
67
+ */
68
+ public function getCacheHashKey()
69
+ {
70
+ if (!$this->getData('cache_hash_key')) {
71
+ $this->setData('cache_hash_key', hash('md4', $this->format('text')));
72
+ }
73
+ return $this->getData('cache_hash_key');
74
+ }
75
+
76
+ /**
77
+ * Validates the address. AvaTax validation is invoked if the this is a ship-to address.
78
+ * Returns true on success and an array with an error on failure.
79
+ *
80
+ * @return true|array
81
+ */
82
+ public function validate()
83
+ {
84
+ if (!Mage::helper('avatax')->fullStopOnError()) {
85
+ return true;
86
+ }
87
+
88
+ $result = parent::validate();
89
+
90
+ //if base validation fails, don't bother with additional validation
91
+ if ($result !== true) {
92
+ return $result;
93
+ }
94
+
95
+ //if ship-to address, do AvaTax validation
96
+ $data = Mage::app()->getRequest()->getPost('billing', array());
97
+ $useForShipping = isset($data['use_for_shipping']) ? (int)$data['use_for_shipping'] : 0;
98
+
99
+ if ($this->getAddressType() == self::TYPE_SHIPPING
100
+ || $this->getUseForShipping()/* <1.9 */ || $useForShipping/* >=1.9 */) {
101
+ if (!isset(self::$_validationResult[$this->getAddressId()])) {
102
+ if (!$this->getAvataxValidator()) {
103
+ $validator = Mage::getModel('avatax/avatax_address')->setAddress($this);
104
+ $this->setAvataxValidator($validator);
105
+ }
106
+
107
+ self::$_validationResult[$this->getAddressId()] = $this->getAvataxValidator()->validate();
108
+ }
109
+
110
+ return self::$_validationResult[$this->getAddressId()];
111
+ }
112
+
113
+ return $result;
114
+ }
115
+
116
+ /* BELOW ARE MAGE CORE PROPERTIES AND METHODS ADDED FOR OLDER VERSION COMPATABILITY */
117
+
118
+ /**
119
+ * Total amount
120
+ *
121
+ * @var array
122
+ */
123
+ protected $_totalAmounts = array();
124
+
125
+ /**
126
+ * Base total amount
127
+ *
128
+ * @var array
129
+ */
130
+ protected $_baseTotalAmounts = array();
131
+
132
+ /**
133
+ * Add amount total amount value
134
+ *
135
+ * @param string $code
136
+ * @param float $amount
137
+ * @return Mage_Sales_Model_Quote_Address
138
+ */
139
+ public function addTotalAmount($code, $amount)
140
+ {
141
+ $amount = $this->getTotalAmount($code)+$amount;
142
+ $this->setTotalAmount($code, $amount);
143
+ return $this;
144
+ }
145
+
146
+ /**
147
+ * Add amount total amount value in base store currency
148
+ *
149
+ * @param string $code
150
+ * @param float $amount
151
+ * @return Mage_Sales_Model_Quote_Address
152
+ */
153
+ public function addBaseTotalAmount($code, $amount)
154
+ {
155
+ $amount = $this->getBaseTotalAmount($code)+$amount;
156
+ $this->setBaseTotalAmount($code, $amount);
157
+ return $this;
158
+ }
159
+
160
+ /**
161
+ * Set total amount value
162
+ *
163
+ * @param string $code
164
+ * @param float $amount
165
+ * @return Mage_Sales_Model_Quote_Address
166
+ */
167
+ public function setTotalAmount($code, $amount)
168
+ {
169
+ $this->_totalAmounts[$code] = $amount;
170
+ if ($code != 'subtotal') {
171
+ $code = $code.'_amount';
172
+ }
173
+ $this->setData($code, $amount);
174
+ return $this;
175
+ }
176
+
177
+ /**
178
+ * Set total amount value in base store currency
179
+ *
180
+ * @param string $code
181
+ * @param float $amount
182
+ * @return Mage_Sales_Model_Quote_Address
183
+ */
184
+ public function setBaseTotalAmount($code, $amount)
185
+ {
186
+ $this->_baseTotalAmounts[$code] = $amount;
187
+ if ($code != 'subtotal') {
188
+ $code = $code.'_amount';
189
+ }
190
+ $this->setData('base_'.$code, $amount);
191
+ return $this;
192
+ }
193
+
194
+ /**
195
+ * Get total amount value by code
196
+ *
197
+ * @param string $code
198
+ * @return float
199
+ */
200
+ public function getTotalAmount($code)
201
+ {
202
+ if (isset($this->_totalAmounts[$code])) {
203
+ return $this->_totalAmounts[$code];
204
+ }
205
+ return 0;
206
+ }
207
+
208
+ /**
209
+ * Get total amount value by code in base store curncy
210
+ *
211
+ * @param string $code
212
+ * @return float
213
+ */
214
+ public function getBaseTotalAmount($code)
215
+ {
216
+ if (isset($this->_baseTotalAmounts[$code])) {
217
+ return $this->_baseTotalAmounts[$code];
218
+ }
219
+ return 0;
220
+ }
221
+ }
app/code/community/OnePica/AvaTax/Model/Sales/Quote/Address/Total/Grand.php CHANGED
@@ -17,28 +17,44 @@
17
 
18
  /**
19
  * Grand totals calculation model
 
 
 
 
20
  */
21
  class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Grand extends Mage_Sales_Model_Quote_Address_Total_Grand
22
  {
23
-
24
  /**
25
  * Collect grand total address amount
26
  *
27
- * @param Mage_Sales_Model_Quote_Address $address
28
- * @return OnePica_AvaTax_Model_Sales_Quote_Address_Total_Grand
29
  */
30
- public function collect(Mage_Sales_Model_Quote_Address $address) {
31
- $grandTotal = $address->getGrandTotal();
 
32
  parent::collect($address);
33
-
34
- if(Mage::helper('avatax')->isAddressActionable($address->getQuote()->getShippingAddress(), $address->getQuote()->getStoreId())) {
35
- if($address->getGrandTotal() == $grandTotal) {
36
- $address->setGrandTotal($address->getGrandTotal() + $address->getTaxAmount());
37
- $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseTaxAmount());
38
- }
39
  }
40
-
41
  return $this;
42
  }
43
-
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
17
 
18
  /**
19
  * Grand totals calculation model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
  */
25
  class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Grand extends Mage_Sales_Model_Quote_Address_Total_Grand
26
  {
 
27
  /**
28
  * Collect grand total address amount
29
  *
30
+ * @param Mage_Sales_Model_Quote_Address $address
31
+ * @return OnePica_AvaTax_Model_Sales_Quote_Address_Total_Grand
32
  */
33
+ public function collect(Mage_Sales_Model_Quote_Address $address)
34
+ {
35
+ $grandTotal = $address->getGrandTotal();
36
  parent::collect($address);
37
+
38
+ $shippingAddress = $address->getQuote()->getShippingAddress();
39
+ if ($this->_isAddressActionable($shippingAddress) && $address->getGrandTotal() == $grandTotal) {
40
+ $address->setGrandTotal($address->getGrandTotal() + $address->getTaxAmount());
41
+ $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseTaxAmount());
 
42
  }
43
+
44
  return $this;
45
  }
46
+
47
+ /**
48
+ * Check if address actionable to calculate tax
49
+ *
50
+ * @param Mage_Sales_Model_Quote_Address $address
51
+ * @return bool
52
+ */
53
+ protected function _isAddressActionable($address)
54
+ {
55
+ /** @var OnePica_AvaTax_Helper_Data $helper */
56
+ $helper = Mage::helper('avatax');
57
+ $storeId = $address->getQuote()->getStoreId();
58
+ return $helper->isAddressActionable($address, $storeId, OnePica_AvaTax_Model_Config::REGIONFILTER_TAX);
59
+ }
60
  }
app/code/community/OnePica/AvaTax/Model/Sales/Quote/Address/Total/Tax.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * OnePica_AvaTax
5
  *
@@ -18,147 +17,169 @@
18
 
19
  /**
20
  * Tax totals calculation model
 
 
 
 
21
  */
22
- class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Tax extends Mage_Sales_Model_Quote_Address_Total_Abstract {
23
-
24
  /**
25
  * Class constructor
26
  */
27
- public function __construct() {
 
28
  $this->setCode('tax');
29
  }
30
 
31
  /**
32
  * Collect tax totals for quote address. If quote address doesn't have a
33
- * postal code or postal code is "-" (OneStepCheckout), no tax is requested
34
- * from Avatax. When selling to a country that doesn't require postal code
35
- * this could be a problem, but Avatax doesn't support those locations yet.
36
  *
37
  * @param Mage_Sales_Model_Quote_Address $address
38
  * @return Mage_Tax_Model_Sales_Total_Quote
39
  */
40
- public function collect(Mage_Sales_Model_Quote_Address $address) {
 
41
  $this->_setAddress($address);
42
  parent::collect($address);
43
 
44
- $session = Mage::getSingleton('checkout/session');
45
-
46
- if($address->getPostcode() && $address->getPostcode() !='-'){
47
- $store = $address->getQuote()->getStore();
48
- $customer = $address->getQuote()->getCustomer();
49
- $calculator = Mage::getModel('avatax/avatax_estimate');
50
-
51
- $address->setTotalAmount($this->getCode(), 0);
52
- $address->setBaseTotalAmount($this->getCode(), 0);
53
-
54
- $address->setTaxAmount(0);
55
- $address->setBaseTaxAmount(0);
56
- $address->setShippingTaxAmount(0);
57
- $address->setBaseShippingTaxAmount(0);
58
-
59
- if(Mage::helper('avatax')->isAddressActionable($address->getQuote()->getShippingAddress(), $address->getQuote()->getStoreId())){ //Added check for calculating tax for regions filtered in the admin
60
-
61
- foreach ($address->getAllItems() as $item) {
62
- $item->setAddress($address);
63
- $baseAmount = $calculator->getItemTax($item);
64
- $amount = Mage::app()->getStore()->convertPrice($baseAmount);
65
- $percent = $calculator->getItemRate($item);
66
-
67
- $item->setTaxAmount($amount);
68
- $item->setBaseTaxAmount($baseAmount);
69
- $item->setTaxPercent($percent);
70
-
71
- $item->setPriceInclTax($item->getPrice() + ($amount / $item->getQty()));
72
- $item->setBasePriceInclTax($item->getBasePrice() + ($baseAmount / $item->getQty()));
73
- $item->setRowTotalInclTax($item->getRowTotal() + $amount);
74
- $item->setBaseRowTotalInclTax($item->getBaseRowTotal() + $baseAmount);
75
-
76
- if (!$calculator->isProductCalculated($item)) {
77
- $this->_addAmount($amount);
78
- $this->_addBaseAmount($baseAmount);
79
- }
80
- }
81
-
82
- if ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING || $address->getUseForShipping()) {
83
- $shippingItem = new Varien_Object();
84
- $shippingItem->setId(Mage::helper('avatax')->getShippingSku($store->getId()));
85
- $shippingItem->setProductId(Mage::helper('avatax')->getShippingSku($store->getId()));
86
- $shippingItem->setAddress($address);
87
- $baseShippingTax = $calculator->getItemTax($shippingItem);
88
- $shippingTax = Mage::app()->getStore()->convertPrice($baseShippingTax);
89
-
90
- $shippingAmt = $address->getTotalAmount('shipping');
91
- $baseShippingAmt = $address->getBaseTotalAmount('shipping');
92
-
93
- $address->setShippingTaxAmount($shippingTax);
94
- $address->setBaseShippingTaxAmount($baseShippingTax);
95
- $address->setShippingInclTax($shippingAmt + $shippingTax);
96
- $address->setBaseShippingInclTax($baseShippingAmt + $baseShippingTax);
97
- $address->setShippingTaxable($shippingTax ? $shippingAmt : 0);
98
- $address->setBaseShippingTaxable($baseShippingTax ? $baseShippingAmt : 0);
99
- $address->setIsShippingInclTax(false);
100
-
101
- $this->_addAmount($shippingTax);
102
- $this->_addBaseAmount($baseShippingTax);
103
- }
104
-
105
- if($address->getGwPrice()) {
106
- $gwOrderItem = new Varien_Object();
107
- $gwOrderItem->setId(Mage::helper('avatax')->getGwOrderSku($store->getId()));
108
- $gwOrderItem->setProductId(Mage::helper('avatax')->getGwOrderSku($store->getId()));
109
- $gwOrderItem->setAddress($address);
110
- $baseGwOrderTax = $calculator->getItemTax($gwOrderItem);
111
- $gwOrderTax = Mage::app()->getStore()->convertPrice($gwOrderItem);
112
-
113
- $address->setGwBaseTaxAmount($address->getGwBasePrice()+$baseGwOrderTax);
114
- $address->setGwTaxAmount($address->getGwPrice()+$gwOrderTax);
115
-
116
- $this->_addAmount($gwOrderTax);
117
- $this->_addBaseAmount($baseGwOrderTax);
118
- }
119
-
120
- if($address->getGwItemsPrice()) {
121
- $gwIndividualItem = new Varien_Object();
122
- $gwIndividualItem->setId(Mage::helper('avatax')->getGwItemsSku($store->getId()));
123
- $gwIndividualItem->setProductId(Mage::helper('avatax')->getGwItemsSku($store->getId()));
124
- $gwIndividualItem->setAddress($address);
125
- $baseGwItemsTax = $calculator->getItemTax($gwIndividualItem);
126
- $gwItemsTax = Mage::app()->getStore()->convertPrice($baseGwItemsTax);
127
-
128
- $address->setGwItemsBaseTaxAmount($address->getGwItemsBasePrice()+$baseGwItemsTax);
129
- $address->setGwItemsTaxAmount($address->getGwItemsPrice()+$gwItemsTax);
130
-
131
- $this->_addAmount($gwItemsTax);
132
- $this->_addBaseAmount($baseGwItemsTax);
133
- }
134
-
135
- if($address->getGwAddPrintedCard()) {
136
- $gwPrintedCardItem = new Varien_Object();
137
- $gwPrintedCardItem->setId(Mage::helper('avatax')->getGwPrintedCardSku($store->getId()));
138
- $gwPrintedCardItem->setProductId(Mage::helper('avatax')->getGwPrintedCardSku($store->getId()));
139
- $gwPrintedCardItem->setAddress($address);
140
- $baseGwPrintedCardTax = $calculator->getItemTax($gwPrintedCardItem);
141
- $gwPrintedCardTax = Mage::app()->getStore()->convertPrice($baseGwPrintedCardTax);
142
-
143
- $address->setGwPrintedCardBaseTaxAmount($address->getGwPrintedCardBasePrice()+$baseGwPrintedCardTax);
144
- $address->setGwPrintedCardTaxAmount($address->getGwPrintedCardPrice()+$gwPrintedCardTax);
145
-
146
- $this->_addAmount($gwPrintedCardTax);
147
- $this->_addBaseAmount($baseGwPrintedCardTax);
148
- }
149
- }
150
- }
151
-
 
152
  return $this;
153
  }
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  /**
156
  * Add tax totals information to address object
157
  *
158
  * @param Mage_Sales_Model_Quote_Address $address
159
  * @return Mage_Tax_Model_Sales_Total_Quote
160
  */
161
- public function fetch(Mage_Sales_Model_Quote_Address $address) {
 
162
  $config = Mage::getSingleton('tax/config');
163
  $quote = $address->getQuote();
164
  $store = $quote->getStore();
@@ -171,12 +192,12 @@ class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Tax extends Mage_Sales_Mode
171
  $id = 'avatax-' . $key;
172
  $fullInfo[$id] = array(
173
  'rates' => array(array(
174
- 'code' => $row['name'],
175
- 'title' => $row['name'],
176
- 'percent' => $row['rate'],
177
- 'position' => $key,
178
- 'priority' => $key,
179
- 'rule_id' => 0
180
  )),
181
  'percent' => $row['rate'],
182
  'id' => $id,
@@ -199,8 +220,8 @@ class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Tax extends Mage_Sales_Mode
199
  /**
200
  * Modify subtotal
201
  */
202
- if ( method_exists($config, "displayCartSubtotalBoth") && method_exists($config, "displayCartSubtotalInclTax")
203
- && ($config->displayCartSubtotalBoth($store) || $config->displayCartSubtotalInclTax($store))) {
204
  $subtotalInclTax = $address->getSubtotal() + $address->getTaxAmount() - $address->getShippingTaxAmount();
205
  $address->setSubtotalInclTax($subtotalInclTax);
206
 
@@ -224,15 +245,22 @@ class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Tax extends Mage_Sales_Mode
224
  * @var string
225
  */
226
  protected $_code;
 
 
 
 
 
 
227
  protected $_address = null;
228
 
229
  /**
230
  * Add total model amount value to address
231
  *
232
- * @param float $amount
233
- * @return Mage_Sales_Model_Quote_Address_Total_Abstract
234
  */
235
- protected function _addAmount($amount) {
 
236
  $this->_getAddress()->addTotalAmount($this->getCode(), $amount);
237
  return $this;
238
  }
@@ -240,21 +268,23 @@ class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Tax extends Mage_Sales_Mode
240
  /**
241
  * Add total model base amount value to address
242
  *
243
- * @param float $amount
244
- * @return Mage_Sales_Model_Quote_Address_Total_Abstract
245
  */
246
- protected function _addBaseAmount($baseAmount) {
 
247
  $this->_getAddress()->addBaseTotalAmount($this->getCode(), $baseAmount);
248
  return $this;
249
  }
250
 
251
  /**
252
- * Set address shich can be used inside totals calculation
253
  *
254
  * @param Mage_Sales_Model_Quote_Address $address
255
  * @return Mage_Sales_Model_Quote_Address_Total_Abstract
256
  */
257
- protected function _setAddress(Mage_Sales_Model_Quote_Address $address) {
 
258
  $this->_address = $address;
259
  return $this;
260
  }
@@ -262,16 +292,14 @@ class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Tax extends Mage_Sales_Mode
262
  /**
263
  * Get quote address object
264
  *
265
- * @throw Mage_Core_Exception if address not declared
266
- * @return Mage_Sales_Model_Quote_Address
267
  */
268
- protected function _getAddress() {
 
269
  if ($this->_address === null) {
270
- Mage::throwException(
271
- Mage::helper('sales')->__('Address model is not defined')
272
- );
273
  }
274
  return $this->_address;
275
  }
276
-
277
  }
1
  <?php
 
2
  /**
3
  * OnePica_AvaTax
4
  *
17
 
18
  /**
19
  * Tax totals calculation model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
  */
25
+ class OnePica_AvaTax_Model_Sales_Quote_Address_Total_Tax extends Mage_Sales_Model_Quote_Address_Total_Abstract
26
+ {
27
  /**
28
  * Class constructor
29
  */
30
+ public function __construct()
31
+ {
32
  $this->setCode('tax');
33
  }
34
 
35
  /**
36
  * Collect tax totals for quote address. If quote address doesn't have a
37
+ * postal code or postal code is "-" (OneStepCheckout), no tax is requested
38
+ * from Avatax. When selling to a country that doesn't require postal code
39
+ * this could be a problem, but Avatax doesn't support those locations yet.
40
  *
41
  * @param Mage_Sales_Model_Quote_Address $address
42
  * @return Mage_Tax_Model_Sales_Total_Quote
43
  */
44
+ public function collect(Mage_Sales_Model_Quote_Address $address)
45
+ {
46
  $this->_setAddress($address);
47
  parent::collect($address);
48
 
49
+ if ($address->getPostcode() && $address->getPostcode() != '-') {
50
+ $store = $address->getQuote()->getStore();
51
+ /** @var OnePica_AvaTax_Model_Avatax_Estimate $calculator */
52
+ $calculator = Mage::getModel('avatax/avatax_estimate');
53
+
54
+ $address->setTotalAmount($this->getCode(), 0);
55
+ $address->setBaseTotalAmount($this->getCode(), 0);
56
+
57
+ $address->setTaxAmount(0);
58
+ $address->setBaseTaxAmount(0);
59
+ $address->setShippingTaxAmount(0);
60
+ $address->setBaseShippingTaxAmount(0);
61
+
62
+ //Added check for calculating tax for regions filtered in the admin
63
+ if ($this->_isAddressActionable($address)) {
64
+ foreach ($address->getAllItems() as $item) {
65
+ $item->setAddress($address);
66
+ $baseAmount = $calculator->getItemTax($item);
67
+ $amount = Mage::app()->getStore()->convertPrice($baseAmount);
68
+ $percent = $calculator->getItemRate($item);
69
+
70
+ $item->setTaxAmount($amount);
71
+ $item->setBaseTaxAmount($baseAmount);
72
+ $item->setTaxPercent($percent);
73
+
74
+ $item->setPriceInclTax($item->getPrice() + ($amount / $item->getQty()));
75
+ $item->setBasePriceInclTax($item->getBasePrice() + ($baseAmount / $item->getQty()));
76
+ $item->setRowTotalInclTax($item->getRowTotal() + $amount);
77
+ $item->setBaseRowTotalInclTax($item->getBaseRowTotal() + $baseAmount);
78
+
79
+ if (!$calculator->isProductCalculated($item)) {
80
+ $this->_addAmount($amount);
81
+ $this->_addBaseAmount($baseAmount);
82
+ }
83
+ }
84
+
85
+ if ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
86
+ || $address->getUseForShipping()) {
87
+ $shippingItem = new Varien_Object();
88
+ $shippingItem->setId(Mage::helper('avatax')->getShippingSku($store->getId()));
89
+ $shippingItem->setProductId(Mage::helper('avatax')->getShippingSku($store->getId()));
90
+ $shippingItem->setAddress($address);
91
+ $baseShippingTax = $calculator->getItemTax($shippingItem);
92
+ $shippingTax = Mage::app()->getStore()->convertPrice($baseShippingTax);
93
+
94
+ $shippingAmt = $address->getTotalAmount('shipping');
95
+ $baseShippingAmt = $address->getBaseTotalAmount('shipping');
96
+
97
+ $address->setShippingTaxAmount($shippingTax);
98
+ $address->setBaseShippingTaxAmount($baseShippingTax);
99
+ $address->setShippingInclTax($shippingAmt + $shippingTax);
100
+ $address->setBaseShippingInclTax($baseShippingAmt + $baseShippingTax);
101
+ $address->setShippingTaxable($shippingTax ? $shippingAmt : 0);
102
+ $address->setBaseShippingTaxable($baseShippingTax ? $baseShippingAmt : 0);
103
+ $address->setIsShippingInclTax(false);
104
+
105
+ $this->_addAmount($shippingTax);
106
+ $this->_addBaseAmount($baseShippingTax);
107
+ }
108
+
109
+ if ($address->getGwPrice() > 0) {
110
+ $gwOrderItem = new Varien_Object();
111
+ $gwOrderItem->setId(Mage::helper('avatax')->getGwOrderSku($store->getId()));
112
+ $gwOrderItem->setProductId(Mage::helper('avatax')->getGwOrderSku($store->getId()));
113
+ $gwOrderItem->setAddress($address);
114
+ $baseGwOrderTax = $calculator->getItemTax($gwOrderItem);
115
+ $gwOrderTax = Mage::app()->getStore()->convertPrice($baseGwOrderTax);
116
+
117
+ $address->setGwBaseTaxAmount($address->getGwBasePrice() + $baseGwOrderTax);
118
+ $address->setGwTaxAmount($address->getGwPrice() + $gwOrderTax);
119
+
120
+ $this->_addAmount($gwOrderTax);
121
+ $this->_addBaseAmount($baseGwOrderTax);
122
+ }
123
+
124
+ if ($address->getGwItemsPrice() > 0) {
125
+ $gwIndividualItem = new Varien_Object();
126
+ $gwIndividualItem->setId(Mage::helper('avatax')->getGwItemsSku($store->getId()));
127
+ $gwIndividualItem->setProductId(Mage::helper('avatax')->getGwItemsSku($store->getId()));
128
+ $gwIndividualItem->setAddress($address);
129
+ $baseGwItemsTax = $calculator->getItemTax($gwIndividualItem);
130
+ $gwItemsTax = Mage::app()->getStore()->convertPrice($baseGwItemsTax);
131
+
132
+ $address->setGwItemsBaseTaxAmount($address->getGwItemsBasePrice() + $baseGwItemsTax);
133
+ $address->setGwItemsTaxAmount($address->getGwItemsPrice() + $gwItemsTax);
134
+
135
+ $this->_addAmount($gwItemsTax);
136
+ $this->_addBaseAmount($baseGwItemsTax);
137
+ }
138
+
139
+ if ($address->getGwAddPrintedCard()) {
140
+ $gwPrintedCardItem = new Varien_Object();
141
+ $gwPrintedCardItem->setId(Mage::helper('avatax')->getGwPrintedCardSku($store->getId()));
142
+ $gwPrintedCardItem->setProductId(Mage::helper('avatax')->getGwPrintedCardSku($store->getId()));
143
+ $gwPrintedCardItem->setAddress($address);
144
+ $baseGwPrintedCardTax = $calculator->getItemTax($gwPrintedCardItem);
145
+ $gwPrintedCardTax = Mage::app()->getStore()->convertPrice($baseGwPrintedCardTax);
146
+
147
+ $address->setGwPrintedCardBaseTaxAmount(
148
+ $address->getGwPrintedCardBasePrice() + $baseGwPrintedCardTax
149
+ );
150
+ $address->setGwPrintedCardTaxAmount($address->getGwPrintedCardPrice() + $gwPrintedCardTax);
151
+
152
+ $this->_addAmount($gwPrintedCardTax);
153
+ $this->_addBaseAmount($baseGwPrintedCardTax);
154
+ }
155
+ }
156
+ }
157
+
158
  return $this;
159
  }
160
 
161
+ /**
162
+ * Check if address actionable to calculate tax
163
+ *
164
+ * @param Mage_Sales_Model_Quote_Address $address
165
+ * @return bool
166
+ */
167
+ protected function _isAddressActionable($address)
168
+ {
169
+ /** @var OnePica_AvaTax_Helper_Data $helper */
170
+ $helper = Mage::helper('avatax');
171
+ $storeId = $address->getQuote()->getStoreId();
172
+ return $helper->isAddressActionable($address, $storeId, OnePica_AvaTax_Model_Config::REGIONFILTER_TAX);
173
+ }
174
+
175
  /**
176
  * Add tax totals information to address object
177
  *
178
  * @param Mage_Sales_Model_Quote_Address $address
179
  * @return Mage_Tax_Model_Sales_Total_Quote
180
  */
181
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
182
+ {
183
  $config = Mage::getSingleton('tax/config');
184
  $quote = $address->getQuote();
185
  $store = $quote->getStore();
192
  $id = 'avatax-' . $key;
193
  $fullInfo[$id] = array(
194
  'rates' => array(array(
195
+ 'code' => $row['name'],
196
+ 'title' => $row['name'],
197
+ 'percent' => $row['rate'],
198
+ 'position' => $key,
199
+ 'priority' => $key,
200
+ 'rule_id' => 0
201
  )),
202
  'percent' => $row['rate'],
203
  'id' => $id,
220
  /**
221
  * Modify subtotal
222
  */
223
+ if (method_exists($config, "displayCartSubtotalBoth") && method_exists($config, "displayCartSubtotalInclTax")
224
+ && ($config->displayCartSubtotalBoth($store) || $config->displayCartSubtotalInclTax($store))) {
225
  $subtotalInclTax = $address->getSubtotal() + $address->getTaxAmount() - $address->getShippingTaxAmount();
226
  $address->setSubtotalInclTax($subtotalInclTax);
227
 
245
  * @var string
246
  */
247
  protected $_code;
248
+
249
+ /**
250
+ * Quote address
251
+ *
252
+ * @var Mage_Sales_Model_Quote_Address|null
253
+ */
254
  protected $_address = null;
255
 
256
  /**
257
  * Add total model amount value to address
258
  *
259
+ * @param float $amount
260
+ * @return Mage_Sales_Model_Quote_Address_Total_Abstract
261
  */
262
+ protected function _addAmount($amount)
263
+ {
264
  $this->_getAddress()->addTotalAmount($this->getCode(), $amount);
265
  return $this;
266
  }
268
  /**
269
  * Add total model base amount value to address
270
  *
271
+ * @param float $baseAmount
272
+ * @return Mage_Sales_Model_Quote_Address_Total_Abstract
273
  */
274
+ protected function _addBaseAmount($baseAmount)
275
+ {
276
  $this->_getAddress()->addBaseTotalAmount($this->getCode(), $baseAmount);
277
  return $this;
278
  }
279
 
280
  /**
281
+ * Set address which can be used inside totals calculation
282
  *
283
  * @param Mage_Sales_Model_Quote_Address $address
284
  * @return Mage_Sales_Model_Quote_Address_Total_Abstract
285
  */
286
+ protected function _setAddress(Mage_Sales_Model_Quote_Address $address)
287
+ {
288
  $this->_address = $address;
289
  return $this;
290
  }
292
  /**
293
  * Get quote address object
294
  *
295
+ * @return Mage_Sales_Model_Quote_Address
296
+ * @throws Mage_Core_Exception
297
  */
298
+ protected function _getAddress()
299
+ {
300
  if ($this->_address === null) {
301
+ throw new Mage_Core_Exception(Mage::helper('sales')->__('Address model is not defined'));
 
 
302
  }
303
  return $this->_address;
304
  }
 
305
  }
app/code/community/OnePica/AvaTax/Model/Session.php CHANGED
@@ -1,27 +1,36 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * The AvaTax Session model.
20
- */
21
- class OnePica_AvaTax_Model_Session extends Mage_Core_Model_Session_Abstract {
22
-
23
- public function __construct($data=array()) {
24
- $this->init('avatax');
25
- }
26
-
27
- }
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * The AvaTax Session model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Session extends Mage_Core_Model_Session_Abstract
26
+ {
27
+ /**
28
+ * Construct
29
+ *
30
+ * @param array $data
31
+ */
32
+ public function __construct($data = array())
33
+ {
34
+ $this->init('avatax');
35
+ }
36
+ }
app/code/community/OnePica/AvaTax/Model/Source/Actions.php CHANGED
@@ -1,43 +1,53 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
 
 
 
 
 
 
 
 
19
  class OnePica_AvaTax_Model_Source_Actions
20
  {
21
  /**
22
- * Gets the list of cache methods for the admin config dropdown
23
- *
24
- * @return array
25
- */
26
  public function toOptionArray()
27
  {
28
  return array(
29
  array(
30
- 'value' => OnePica_AvaTax_Model_Config::ACTION_DISABLE,
31
- 'label' => Mage::helper('avatax')->__('Disable')),
32
- array(
33
- 'value' => OnePica_AvaTax_Model_Config::ACTION_CALC,
34
- 'label' => Mage::helper('avatax')->__('Enable: calculate tax')),
 
 
35
  array(
36
- 'value' => OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT,
37
- 'label' => Mage::helper('avatax')->__('Enable: calculate tax, submit data')),
 
38
  array(
39
- 'value' => OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT_COMMIT,
40
- 'label' => Mage::helper('avatax')->__('Enable: calculate tax, submit data, and commit')),
 
41
  );
42
  }
43
  }
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
 
17
 
18
+ /**
19
+ * Actions source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Model_Source_Actions
26
  {
27
  /**
28
+ * Gets the list of cache methods for the admin config dropdown
29
+ *
30
+ * @return array
31
+ */
32
  public function toOptionArray()
33
  {
34
  return array(
35
  array(
36
+ 'value' => OnePica_AvaTax_Model_Config::ACTION_DISABLE,
37
+ 'label' => Mage::helper('avatax')->__('Disable')
38
+ ),
39
+ array(
40
+ 'value' => OnePica_AvaTax_Model_Config::ACTION_CALC,
41
+ 'label' => Mage::helper('avatax')->__('Enable: calculate tax')
42
+ ),
43
  array(
44
+ 'value' => OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT,
45
+ 'label' => Mage::helper('avatax')->__('Enable: calculate tax, submit data')
46
+ ),
47
  array(
48
+ 'value' => OnePica_AvaTax_Model_Config::ACTION_CALC_SUBMIT_COMMIT,
49
+ 'label' => Mage::helper('avatax')->__('Enable: calculate tax, submit data, and commit')
50
+ )
51
  );
52
  }
53
  }
app/code/community/OnePica/AvaTax/Model/Source/Addressvalidation.php CHANGED
@@ -15,30 +15,50 @@
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
-
 
 
 
 
 
 
19
  class OnePica_AvaTax_Model_Source_Addressvalidation
20
  {
21
- const DISABLED = 0;
22
- const ENABLED_PREVENT_ORDER = 1;
23
- const ENABLED_ALLOW_ORDER = 2;
24
-
25
  /**
26
- * Gets the list of address validation for the admin config dropdown
27
- *
28
- * @return array
29
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  public function toOptionArray()
31
  {
32
  return array(
33
  array(
34
- 'value' => self::DISABLED,
35
- 'label' => Mage::helper('avatax')->__('Disabled')),
36
- array(
37
- 'value' => self::ENABLED_PREVENT_ORDER,
38
- 'label' => Mage::helper('avatax')->__('Enabled + Prevent Order')),
39
- array(
40
- 'value' => self::ENABLED_ALLOW_ORDER,
41
- 'label' => Mage::helper('avatax')->__('Enabled + Allow Order'))
 
 
 
42
  );
43
  }
44
  }
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
+ /**
19
+ * Address validation source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Model_Source_Addressvalidation
26
  {
 
 
 
 
27
  /**
28
+ * Disabled
29
+ */
30
+ const DISABLED = 0;
31
+
32
+ /**
33
+ * Enabled + Prevent order
34
+ */
35
+ const ENABLED_PREVENT_ORDER = 1;
36
+
37
+ /**
38
+ * Enabled + Allow order
39
+ */
40
+ const ENABLED_ALLOW_ORDER = 2;
41
+
42
+ /**
43
+ * Gets the list of address validation for the admin config dropdown
44
+ *
45
+ * @return array
46
+ */
47
  public function toOptionArray()
48
  {
49
  return array(
50
  array(
51
+ 'value' => self::DISABLED,
52
+ 'label' => Mage::helper('avatax')->__('Disabled')
53
+ ),
54
+ array(
55
+ 'value' => self::ENABLED_PREVENT_ORDER,
56
+ 'label' => Mage::helper('avatax')->__('Enabled + Prevent Order')
57
+ ),
58
+ array(
59
+ 'value' => self::ENABLED_ALLOW_ORDER,
60
+ 'label' => Mage::helper('avatax')->__('Enabled + Allow Order')
61
+ )
62
  );
63
  }
64
  }
app/code/community/OnePica/AvaTax/Model/Source/Customercodeformat.php CHANGED
@@ -1,44 +1,64 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Source_Customercodeformat
20
- {
21
- const LEGACY = 0; //depricated, included for stores who are upgrading so the code format doesn't change unexpectedly
22
- const CUST_ID = 1; //recommended
23
- const CUST_EMAIL = 2;
24
-
25
- /**
26
- * Gets the list of cache methods for the admin config dropdown
27
- *
28
- * @return array
29
- */
30
- public function toOptionArray()
31
- {
32
- return array(
33
- array(
34
- 'value' => self::CUST_ID,
35
- 'label' => 'customer_id'),
36
- array(
37
- 'value' => self::CUST_EMAIL,
38
- 'label' => 'customer_email'),
39
- array(
40
- 'value' => self::LEGACY,
41
- 'label' => 'customer_name (customer_id)'),
42
- );
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Customer code format source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Source_Customercodeformat
26
+ {
27
+ /**
28
+ * Legacy format
29
+ */
30
+ const LEGACY = 0; //depricated, included for stores who are upgrading so the code format doesn't change unexpectedly
31
+
32
+ /**
33
+ * Customer id format
34
+ */
35
+ const CUST_ID = 1; //recommended
36
+
37
+ /**
38
+ * Customer email format
39
+ */
40
+ const CUST_EMAIL = 2;
41
+
42
+ /**
43
+ * Gets the list of cache methods for the admin config dropdown
44
+ *
45
+ * @return array
46
+ */
47
+ public function toOptionArray()
48
+ {
49
+ return array(
50
+ array(
51
+ 'value' => self::CUST_ID,
52
+ 'label' => 'customer_id'
53
+ ),
54
+ array(
55
+ 'value' => self::CUST_EMAIL,
56
+ 'label' => 'customer_email'
57
+ ),
58
+ array(
59
+ 'value' => self::LEGACY,
60
+ 'label' => 'customer_name (customer_id)'
61
+ )
62
+ );
63
+ }
64
+ }
app/code/community/OnePica/AvaTax/Model/Source/Error.php CHANGED
@@ -1,37 +1,45 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Source_Error
20
- {
21
- /**
22
- * Gets the list of cache methods for the admin config dropdown
23
- *
24
- * @return array
25
- */
26
- public function toOptionArray()
27
- {
28
- return array(
29
- array(
30
- 'value' => 1,
31
- 'label' => Mage::helper('avatax')->__('Disable checkout & show error message')),
32
- array(
33
- 'value' => 0,
34
- 'label' => Mage::helper('avatax')->__('Allow checkout without charging tax (no error message)')),
35
- );
36
- }
37
- }
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Error mode source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Source_Error
26
+ {
27
+ /**
28
+ * Gets the list of cache methods for the admin config dropdown
29
+ *
30
+ * @return array
31
+ */
32
+ public function toOptionArray()
33
+ {
34
+ return array(
35
+ array(
36
+ 'value' => 1,
37
+ 'label' => Mage::helper('avatax')->__('Disable checkout & show error message')
38
+ ),
39
+ array(
40
+ 'value' => 0,
41
+ 'label' => Mage::helper('avatax')->__('Allow checkout without charging tax (no error message)')
42
+ )
43
+ );
44
+ }
45
+ }
app/code/community/OnePica/AvaTax/Model/Source/Fieldlist.php CHANGED
@@ -15,31 +15,35 @@
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
-
 
 
 
 
 
 
19
  class OnePica_AvaTax_Model_Source_Fieldlist
20
  {
21
  /**
22
- * Gets the list of required fileds for the admin config dropdown
23
- *
24
- * @return array
25
- */
26
  public function toOptionArray()
27
  {
28
- $obj = Mage::getConfig()->getNode('admin/fieldsets/customer_dataflow');
29
-
30
- foreach ($obj as $key => $obj2) {
31
- foreach ($obj2 as $key2 => $obj3) {
32
- if ($obj3->shipping)
33
- {
34
- $arr[] = array(
35
- 'value' => $key2,
36
- 'label' => Mage::helper('avatax')->__($key2),
37
- );
38
- }
39
- }
40
- }
41
-
42
- return $arr;
43
  }
44
  }
45
-
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
+ /**
19
+ * Field list source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Model_Source_Fieldlist
26
  {
27
  /**
28
+ * Gets the list of required fileds for the admin config dropdown
29
+ *
30
+ * @return array
31
+ */
32
  public function toOptionArray()
33
  {
34
+ $obj = Mage::getConfig()->getNode('admin/fieldsets/customer_dataflow');
35
+
36
+ foreach ($obj as $key => $obj2) {
37
+ foreach ($obj2 as $key2 => $obj3) {
38
+ if ($obj3->shipping) {
39
+ $arr[] = array(
40
+ 'value' => $key2,
41
+ 'label' => Mage::helper('avatax')->__($key2),
42
+ );
43
+ }
44
+ }
45
+ }
46
+
47
+ return $arr;
 
48
  }
49
  }
 
app/code/community/OnePica/AvaTax/Model/Source/Logmode.php CHANGED
@@ -1,44 +1,64 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Source_Logmode
20
- {
21
- const ERRORS = 0;
22
- const NORMAL = 1;
23
- const DEBUG = 2;
24
-
25
- /**
26
- * Gets the list of cache methods for the admin config dropdown
27
- *
28
- * @return array
29
- */
30
- public function toOptionArray()
31
- {
32
- return array(
33
- array(
34
- 'value' => self::ERRORS,
35
- 'label' => Mage::helper('avatax')->__('Log only errors')),
36
- array(
37
- 'value' => self::NORMAL,
38
- 'label' => Mage::helper('avatax')->__('Log all actions (recommended)')),
39
- array(
40
- 'value' => self::DEBUG,
41
- 'label' => Mage::helper('avatax')->__('Log all actions with trace (debug mode)'))
42
- );
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Log mode source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Source_Logmode
26
+ {
27
+ /**
28
+ * Only errors mode
29
+ */
30
+ const ERRORS = 0;
31
+
32
+ /**
33
+ * Normal mode
34
+ */
35
+ const NORMAL = 1;
36
+
37
+ /**
38
+ * Debug mode
39
+ */
40
+ const DEBUG = 2;
41
+
42
+ /**
43
+ * Gets the list of cache methods for the admin config dropdown
44
+ *
45
+ * @return array
46
+ */
47
+ public function toOptionArray()
48
+ {
49
+ return array(
50
+ array(
51
+ 'value' => self::ERRORS,
52
+ 'label' => Mage::helper('avatax')->__('Log only errors')
53
+ ),
54
+ array(
55
+ 'value' => self::NORMAL,
56
+ 'label' => Mage::helper('avatax')->__('Log all actions (recommended)')
57
+ ),
58
+ array(
59
+ 'value' => self::DEBUG,
60
+ 'label' => Mage::helper('avatax')->__('Log all actions with trace (debug mode)')
61
+ )
62
+ );
63
+ }
64
+ }
app/code/community/OnePica/AvaTax/Model/Source/Logtype.php CHANGED
@@ -15,40 +15,68 @@
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
-
 
 
 
 
 
 
19
  class OnePica_AvaTax_Model_Source_Logtype
20
  {
21
- const PING = 'Ping';
22
- const GET_TAX = 'GetTax';
23
- const FILTER = 'Filter';
24
- const VALIDATE = 'Validate';
25
- const QUEUE = 'Queue';
26
-
27
  /**
28
- * Gets the list of type for the admin config dropdown
29
- *
30
- * @return array
31
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  public function toOptionArray()
33
  {
34
  return array(
35
  array(
36
- 'value' => self::PING,
37
- 'label' => Mage::helper('avatax')->__('Ping')),
38
- array(
39
- 'value' => self::GET_TAX,
40
- 'label' => Mage::helper('avatax')->__('Get Tax')),
41
- array(
42
- 'value' => self::FILTER,
43
- 'label' => Mage::helper('avatax')->__('Filter')),
44
- array(
45
- 'value' => self::VALIDATE,
46
- 'label' => Mage::helper('avatax')->__('Validate')),
47
- array(
48
- 'value' => self::QUEUE,
49
- 'label' => Mage::helper('avatax')->__('Queue'))
50
-
51
-
 
 
 
52
  );
53
  }
54
  }
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
 
18
+ /**
19
+ * Log type source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Model_Source_Logtype
26
  {
 
 
 
 
 
 
27
  /**
28
+ * Ping type
29
+ */
30
+ const PING = 'Ping';
31
+
32
+ /**
33
+ * Get tax type
34
+ */
35
+ const GET_TAX = 'GetTax';
36
+
37
+ /**
38
+ * Filter type
39
+ */
40
+ const FILTER = 'Filter';
41
+
42
+ /**
43
+ * Validate type
44
+ */
45
+ const VALIDATE = 'Validate';
46
+
47
+ /**
48
+ * Queue type
49
+ */
50
+ const QUEUE = 'Queue';
51
+
52
+ /**
53
+ * Gets the list of type for the admin config dropdown
54
+ *
55
+ * @return array
56
+ */
57
  public function toOptionArray()
58
  {
59
  return array(
60
  array(
61
+ 'value' => self::PING,
62
+ 'label' => Mage::helper('avatax')->__('Ping')
63
+ ),
64
+ array(
65
+ 'value' => self::GET_TAX,
66
+ 'label' => Mage::helper('avatax')->__('Get Tax')
67
+ ),
68
+ array(
69
+ 'value' => self::FILTER,
70
+ 'label' => Mage::helper('avatax')->__('Filter')
71
+ ),
72
+ array(
73
+ 'value' => self::VALIDATE,
74
+ 'label' => Mage::helper('avatax')->__('Validate')
75
+ ),
76
+ array(
77
+ 'value' => self::QUEUE,
78
+ 'label' => Mage::helper('avatax')->__('Queue')
79
+ )
80
  );
81
  }
82
  }
app/code/community/OnePica/AvaTax/Model/Source/Onerrorfrontend.php CHANGED
@@ -1,34 +1,49 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
 
 
 
 
 
 
 
 
19
  class OnePica_AvaTax_Model_Source_Onerrorfrontend
20
  {
21
  /**
22
- * Gets the list of cache methods for the admin config dropdown
23
- *
24
- * @return array
25
- */
26
  public function toOptionArray()
27
  {
28
  return array(
29
- array('value'=>1, 'label'=>Mage::helper('avatax')->__('Always show no tax')),
30
- array('value'=>2, 'label'=>Mage::helper('avatax')->__('Always show no tax and warn user')),
31
- array('value'=>3, 'label'=>Mage::helper('avatax')->__('Stop orders from completing and warn user')),
 
 
 
 
 
 
 
 
 
32
  );
33
  }
34
  }
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
 
17
 
18
+ /**
19
+ * On error frontend action source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
  class OnePica_AvaTax_Model_Source_Onerrorfrontend
26
  {
27
  /**
28
+ * Gets the list of cache methods for the admin config dropdown
29
+ *
30
+ * @return array
31
+ */
32
  public function toOptionArray()
33
  {
34
  return array(
35
+ array(
36
+ 'value' => 1,
37
+ 'label' => Mage::helper('avatax')->__('Always show no tax')
38
+ ),
39
+ array(
40
+ 'value' => 2,
41
+ 'label' => Mage::helper('avatax')->__('Always show no tax and warn user')
42
+ ),
43
+ array(
44
+ 'value' => 3,
45
+ 'label' => Mage::helper('avatax')->__('Stop orders from completing and warn user')
46
+ )
47
  );
48
  }
49
  }
app/code/community/OnePica/AvaTax/Model/Source/Regionfilter/List.php CHANGED
@@ -24,36 +24,52 @@
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
-
 
 
 
 
 
 
28
  class OnePica_AvaTax_Model_Source_Regionfilter_List
29
  {
 
 
 
 
 
30
  protected $_options;
31
 
32
- public function toOptionArray($isMultiselect=false)
 
 
 
 
 
33
  {
34
  if (!$this->_options) {
35
- $countries = array('US', 'CA');
36
- $this->_options = array();
37
-
38
- $this->_options[] = array(
39
- 'label' => '',
40
- 'value' => ''
41
- );
42
-
43
- foreach($countries as $country) {
44
- $regions = Mage::getResourceModel('directory/region_collection')
45
- ->addCountryFilter($country)
46
- ->loadData()
47
- ->toOptionArray();
48
- array_shift($regions);
49
-
50
- $this->_options[] = array(
51
- 'label' => Mage::app()->getLocale()->getCountryTranslation($country),
52
- 'value' => $regions
53
- );
54
- }
55
  }
56
-
57
  return $this->_options;
58
  }
59
  }
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
+ /**
28
+ * Regionfilter source model
29
+ *
30
+ * @category OnePica
31
+ * @package OnePica_AvaTax
32
+ * @author OnePica Codemaster <codemaster@onepica.com>
33
+ */
34
  class OnePica_AvaTax_Model_Source_Regionfilter_List
35
  {
36
+ /**
37
+ * Options
38
+ *
39
+ * @var array
40
+ */
41
  protected $_options;
42
 
43
+ /**
44
+ * Get option array
45
+ *
46
+ * @return array
47
+ */
48
+ public function toOptionArray()
49
  {
50
  if (!$this->_options) {
51
+ $countries = array('US', 'CA');
52
+ $this->_options = array();
53
+
54
+ $this->_options[] = array(
55
+ 'label' => '',
56
+ 'value' => ''
57
+ );
58
+
59
+ foreach ($countries as $country) {
60
+ $regions = Mage::getResourceModel('directory/region_collection')
61
+ ->addCountryFilter($country)
62
+ ->loadData()
63
+ ->toOptionArray();
64
+ array_shift($regions);
65
+
66
+ $this->_options[] = array(
67
+ 'label' => Mage::app()->getLocale()->getCountryTranslation($country),
68
+ 'value' => $regions
69
+ );
70
+ }
71
  }
72
+
73
  return $this->_options;
74
  }
75
  }
app/code/community/OnePica/AvaTax/Model/Source/Regionfilter/Mode.php CHANGED
@@ -1,40 +1,49 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- class OnePica_AvaTax_Model_Source_Regionfilter_Mode
20
- {
21
- /**
22
- * Gets the list of cache methods for the admin config dropdown
23
- *
24
- * @return array
25
- */
26
- public function toOptionArray()
27
- {
28
- return array(
29
- array(
30
- 'value' => OnePica_AvaTax_Model_Config::REGIONFILTER_OFF,
31
- 'label' => Mage::helper('avatax')->__('None')),
32
- array(
33
- 'value' => OnePica_AvaTax_Model_Config::REGIONFILTER_TAX,
34
- 'label' => Mage::helper('avatax')->__('Filter tax calculations')),
35
- array(
36
- 'value' => OnePica_AvaTax_Model_Config::REGIONFILTER_ALL,
37
- 'label' => Mage::helper('avatax')->__('Filter tax calculations & address options')),
38
- );
39
- }
40
- }
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Regionfilter mode source model
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Source_Regionfilter_Mode
26
+ {
27
+ /**
28
+ * Gets the list of cache methods for the admin config dropdown
29
+ *
30
+ * @return array
31
+ */
32
+ public function toOptionArray()
33
+ {
34
+ return array(
35
+ array(
36
+ 'value' => OnePica_AvaTax_Model_Config::REGIONFILTER_OFF,
37
+ 'label' => Mage::helper('avatax')->__('None')
38
+ ),
39
+ array(
40
+ 'value' => OnePica_AvaTax_Model_Config::REGIONFILTER_TAX,
41
+ 'label' => Mage::helper('avatax')->__('Filter tax calculations')
42
+ ),
43
+ array(
44
+ 'value' => OnePica_AvaTax_Model_Config::REGIONFILTER_ALL,
45
+ 'label' => Mage::helper('avatax')->__('Filter tax calculations & address options')
46
+ )
47
+ );
48
+ }
49
+ }
app/code/community/OnePica/AvaTax/Model/Tax/Config.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2015 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Configuration paths storage
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Model_Tax_Config extends Mage_Tax_Model_Config
26
+ {
27
+ /**
28
+ * Get configuration setting "Apply Discount On Prices Including Tax" value
29
+ * Always apply discount first since AvaTax does not support line-level item discount amounts
30
+ *
31
+ * @param null|int $store
32
+ * @return bool
33
+ */
34
+ public function discountTax($store = null)
35
+ {
36
+ if (Mage::helper('avatax')->isAvataxEnabled($store)) {
37
+ return false;
38
+ }
39
+
40
+ return parent::discountTax($store);
41
+ }
42
+ }
app/code/community/OnePica/AvaTax/controllers/.DS_Store DELETED
Binary file
app/code/community/OnePica/AvaTax/controllers/Adminhtml/ExportController.php CHANGED
@@ -1,52 +1,90 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- class OnePica_AvaTax_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action
19
- {
20
- protected function _isAllowed()
21
- {
22
- return Mage::getSingleton('admin/session')->isAllowed('avatax');
23
- }
24
-
25
- public function logAction() {
26
- $fileName = 'avatax-log-' . gmdate('U') . '.sql';
27
- $content = $this->getLayout()->createBlock('avatax/adminhtml_export_log_grid')->getSql();
28
- $this->_sendResponse($fileName, $content);
29
- }
30
-
31
- public function queueAction() {
32
- $fileName = 'avatax-queue-' . gmdate('U') . '.sql';
33
- $content = $this->getLayout()->createBlock('avatax/adminhtml_export_queue_grid')->getSql();
34
- $this->_sendResponse($fileName, $content);
35
- }
36
-
37
- protected function _sendResponse($fileName, $content, $contentType='application/octet-stream') {
38
- $response = $this->getResponse();
39
- $response->setHeader('HTTP/1.1 200 OK','');
40
- $response->setHeader('Pragma', 'public', true);
41
- $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
42
- $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
43
- $response->setHeader('Last-Modified', date('r'));
44
- $response->setHeader('Accept-Ranges', 'bytes');
45
- $response->setHeader('Content-Length', strlen($content));
46
- $response->setHeader('Content-type', $contentType);
47
- $response->setBody($content);
48
- $response->sendResponse();
49
- exit;
50
- }
51
-
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Admin export controller
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action
26
+ {
27
+ /**
28
+ * Check if is allowed
29
+ *
30
+ * @return bool
31
+ */
32
+ protected function _isAllowed()
33
+ {
34
+ return Mage::getSingleton('admin/session')->isAllowed('avatax');
35
+ }
36
+
37
+ /**
38
+ * Log action
39
+ *
40
+ * @return $this
41
+ */
42
+ public function logAction() {
43
+ $fileName = 'avatax-log-' . gmdate('U') . '.sql';
44
+ $content = Mage::getModel('avatax/export')
45
+ ->setAdapter(Mage::getModel('avatax/export_adapter_sql'))
46
+ ->setEntity(Mage::getModel('avatax/export_entity_log'))
47
+ ->getContent();
48
+ $this->_sendResponse($fileName, $content);
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * Queue action
54
+ *
55
+ * @return $this
56
+ */
57
+ public function queueAction()
58
+ {
59
+ $fileName = 'avatax-queue-' . gmdate('U') . '.sql';
60
+ $content = Mage::getModel('avatax/export')
61
+ ->setAdapter(Mage::getModel('avatax/export_adapter_sql'))
62
+ ->setEntity(Mage::getModel('avatax/export_entity_queue'))
63
+ ->getContent();
64
+ $this->_sendResponse($fileName, $content);
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Send response
70
+ *
71
+ * @param string $fileName
72
+ * @param string $content
73
+ * @param string $contentType
74
+ * @return $this
75
+ */
76
+ protected function _sendResponse($fileName, $content, $contentType = 'application/octet-stream')
77
+ {
78
+ $response = $this->getResponse();
79
+ $response->setHeader('HTTP/1.1 200 OK', '');
80
+ $response->setHeader('Pragma', 'public', true);
81
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
82
+ $response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
83
+ $response->setHeader('Last-Modified', date('r'));
84
+ $response->setHeader('Accept-Ranges', 'bytes');
85
+ $response->setHeader('Content-Length', strlen($content));
86
+ $response->setHeader('Content-type', $contentType);
87
+ $response->setBody($content);
88
+ return $this;
89
+ }
90
+ }
app/code/community/OnePica/AvaTax/controllers/Adminhtml/GridController.php CHANGED
@@ -1,93 +1,137 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- class OnePica_AvaTax_Adminhtml_GridController extends Mage_Adminhtml_Controller_Action
19
- {
20
-
21
- /**
22
- * Additional initialization
23
- *
24
- */
25
- protected function _construct() {
26
- $this->setUsedModuleName('OnePica_AvaTax');
27
- }
28
-
29
- public function clearQueueAction() {
30
- Mage::getModel('avatax_records/queue_process')->clear();
31
- $this->_redirect('*/*/queue');
32
- }
33
-
34
-
35
- public function logAction() {
36
- $this->_setTitle($this->__('Sales'))->_setTitle($this->__('Tax'))->_setTitle($this->__('AvaTax Log'));
37
-
38
- $this->loadLayout()
39
- ->_setActiveMenu('sales/tax/avatax_log')
40
- ->_addContent($this->getLayout()->createBlock('avatax/adminhtml_export_log_grid'))
41
- ->renderLayout();
42
- }
43
-
44
- public function logViewAction() {
45
- $this->_setTitle($this->__('Sales'))->_setTitle($this->__('Tax'))->_setTitle($this->__('AvaTax Log'));
46
-
47
- $logId = $this->getRequest()->getParam('id');
48
- $model = Mage::getModel('avatax/records_log')->load($logId);
49
-
50
- if (!$model->getId()) {
51
- $this->_redirect('*/*/');
52
- return;
53
- }
54
-
55
- Mage::register('current_event', $model);
56
-
57
- $this->loadLayout()
58
- ->_setActiveMenu('sales/tax/avatax_log')
59
- ->renderLayout();
60
- }
61
-
62
- public function queueAction() {
63
- $this->_setTitle($this->__('Sales'))->_setTitle($this->__('Tax'))->_setTitle($this->__('AvaTax Queue'));
64
-
65
- $this->loadLayout()
66
- ->_setActiveMenu('sales/tax/avatax_queue')
67
- ->_addContent($this->getLayout()->createBlock('avatax/adminhtml_export_queue_grid'))
68
- ->renderLayout();
69
- }
70
-
71
- public function processQueueAction() {
72
- Mage::getModel('avatax_records/queue_process')->run();
73
- $this->_redirect('*/*/queue');
74
- }
75
-
76
- protected function _isAllowed() {
77
- return Mage::getSingleton('admin/session')->isAllowed('avatax');
78
- }
79
-
80
- /**
81
- * Magento <1.4 does not let the title be set
82
- *
83
- * @param string
84
- * @return self
85
- */
86
- protected function _setTitle($title) {
87
- if(method_exists($this, '_title')) {
88
- $this->_title($title);
89
- }
90
- return $this;
91
- }
92
-
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * Admin grid controller
20
+ *
21
+ * @category OnePica
22
+ * @package OnePica_AvaTax
23
+ * @author OnePica Codemaster <codemaster@onepica.com>
24
+ */
25
+ class OnePica_AvaTax_Adminhtml_GridController extends Mage_Adminhtml_Controller_Action
26
+ {
27
+ /**
28
+ * Additional initialization
29
+ */
30
+ protected function _construct()
31
+ {
32
+ $this->setUsedModuleName('OnePica_AvaTax');
33
+ }
34
+
35
+ /**
36
+ * Clear queue action
37
+ *
38
+ * @return $this
39
+ */
40
+ public function clearQueueAction()
41
+ {
42
+ Mage::getModel('avatax_records/queue_process')->clear();
43
+ $this->_redirect('*/*/queue');
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * Log action
49
+ *
50
+ * @return $this
51
+ */
52
+ public function logAction()
53
+ {
54
+ $this->_setTitle($this->__('Sales'))->_setTitle($this->__('Tax'))->_setTitle($this->__('AvaTax Log'));
55
+
56
+ $this->loadLayout()
57
+ ->_setActiveMenu('sales/tax/avatax_log')
58
+ ->renderLayout();
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Log view action
64
+ *
65
+ * @return $this
66
+ */
67
+ public function logViewAction()
68
+ {
69
+ $this->_setTitle($this->__('Sales'))->_setTitle($this->__('Tax'))->_setTitle($this->__('AvaTax Log'));
70
+
71
+ $logId = $this->getRequest()->getParam('id');
72
+ $model = Mage::getModel('avatax/records_log')->load($logId);
73
+
74
+ if (!$model->getId()) {
75
+ $this->_redirect('*/*/log');
76
+ return $this;
77
+ }
78
+
79
+ Mage::register('current_event', $model);
80
+
81
+ $this->loadLayout()
82
+ ->_setActiveMenu('sales/tax/avatax_log')
83
+ ->renderLayout();
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Queue action
89
+ *
90
+ * @return $this
91
+ */
92
+ public function queueAction()
93
+ {
94
+ $this->_setTitle($this->__('Sales'))->_setTitle($this->__('Tax'))->_setTitle($this->__('AvaTax Queue'));
95
+
96
+ $this->loadLayout()
97
+ ->_setActiveMenu('sales/tax/avatax_queue')
98
+ ->renderLayout();
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * Process queue action
104
+ *
105
+ * @return $this
106
+ */
107
+ public function processQueueAction()
108
+ {
109
+ Mage::getModel('avatax_records/queue_process')->run();
110
+ $this->_redirect('*/*/queue');
111
+ return $this;
112
+ }
113
+
114
+ /**
115
+ * Check if is allowed
116
+ *
117
+ * @return bool
118
+ */
119
+ protected function _isAllowed()
120
+ {
121
+ return Mage::getSingleton('admin/session')->isAllowed('avatax');
122
+ }
123
+
124
+ /**
125
+ * Magento <1.4 does not let the title be set
126
+ *
127
+ * @param string $title
128
+ * @return $this
129
+ */
130
+ protected function _setTitle($title)
131
+ {
132
+ if (method_exists($this, '_title')) {
133
+ $this->_title($title);
134
+ }
135
+ return $this;
136
+ }
137
+ }
app/code/community/OnePica/AvaTax/controllers/CartController.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
- /**
19
- * Shopping cart controller
20
- */
21
-
22
- require_once 'Mage/Checkout/controllers/CartController.php';
23
-
24
- class OnePica_AvaTax_CartController extends Mage_Checkout_CartController
25
- {
26
- /**
27
- * Initialize shipping information
28
- */
29
- public function estimatePostAction()
30
- {
31
- $session = Mage::getSingleton('checkout/session');
32
- $session->setPostType('estimate');
33
- parent::estimatePostAction();
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/OnePica/AvaTax/{controllers/OnepageController.php → data/avatax_records_setup/data-upgrade-2.2.0-2.2.1.php} RENAMED
@@ -14,19 +14,18 @@
14
  * @copyright Copyright (c) 2009 One Pica, Inc.
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
-
18
-
19
- require_once 'Mage/Checkout/controllers/OnepageController.php';
20
-
21
- class OnePica_AvaTax_OnepageController extends Mage_Checkout_OnepageController
22
- {
23
- /**
24
- * Initialize shipping information
25
- */
26
- public function indexAction()
27
- {
28
- $session = Mage::getSingleton('checkout/session');
29
- $session->setPostType('onepage');
30
- parent::indexAction();
31
- }
32
- }
14
  * @copyright Copyright (c) 2009 One Pica, Inc.
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
+ $installer = $this;
18
+ $this->startSetup();
19
+ /* @var $this Mage_Core_Model_Resource_Setup */
20
+ $adapter = $this->getConnection();
21
+ $adapter->update(
22
+ $this->getTable('tax/tax_class'),
23
+ array(
24
+ 'class_name' => 'Shipping (not used by AvaTax)'
25
+ ),
26
+ array(
27
+ 'class_name = ?' => 'Shipping',
28
+ 'class_type = ?' => Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT
29
+ )
30
+ );
31
+ $this->endSetup();
 
app/code/community/OnePica/AvaTax/etc/adminhtml.xml CHANGED
@@ -1,69 +1,68 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * OnePica_AvaTax
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0), a
9
- * copy of which is available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- *
12
- * @category OnePica
13
- * @package OnePica_AvaTax
14
- * @author OnePica Codemaster <codemaster@onepica.com>
15
- * @copyright Copyright (c) 2009 One Pica, Inc.
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
- */
18
- -->
19
-
20
- <config>
21
- <!-- the adminhtml section is repeated in config.xml & adminhtml.xml for backwards compatibility -->
22
- <!-- @see http://www.magentocommerce.com/bug-tracking/issue?issue=8496 -->
23
- <layout>
24
- <updates>
25
- <avatax>
26
- <file>avatax.xml</file>
27
- </avatax>
28
- </updates>
29
- </layout>
30
- <menu>
31
- <sales>
32
- <children>
33
- <tax>
34
- <children>
35
- <rules>
36
- <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
37
- </rules>
38
- <rates>
39
- <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
40
- </rates>
41
- <import_export>
42
- <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
43
- </import_export>
44
- <avatax_queue translate="title" module="avatax">
45
- <title>AvaTax Order Sync Queue</title>
46
- <action>avatax/adminhtml_grid/queue</action>
47
- </avatax_queue>
48
- <avatax_log translate="title" module="avatax">
49
- <title>AvaTax Log</title>
50
- <action>avatax/adminhtml_grid/log</action>
51
- </avatax_log>
52
- </children>
53
- </tax>
54
- </children>
55
- </sales>
56
- </menu>
57
- <acl>
58
- <resources>
59
- <admin>
60
- <children>
61
- <avatax translate="title">
62
- <title>AvaTax Module</title>
63
- <sort_order>100</sort_order>
64
- </avatax>
65
- </children>
66
- </admin>
67
- </resources>
68
- </acl>
69
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * OnePica_AvaTax
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category OnePica
13
+ * @package OnePica_AvaTax
14
+ * @author OnePica Codemaster <codemaster@onepica.com>
15
+ * @copyright Copyright (c) 2009 One Pica, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <!-- the adminhtml section is repeated in config.xml & adminhtml.xml for backwards compatibility -->
21
+ <!-- @see http://www.magentocommerce.com/bug-tracking/issue?issue=8496 -->
22
+ <layout>
23
+ <updates>
24
+ <avatax>
25
+ <file>onepica/avatax.xml</file>
26
+ </avatax>
27
+ </updates>
28
+ </layout>
29
+ <menu>
30
+ <sales>
31
+ <children>
32
+ <tax>
33
+ <children>
34
+ <rules>
35
+ <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
36
+ </rules>
37
+ <rates>
38
+ <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
39
+ </rates>
40
+ <import_export>
41
+ <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
42
+ </import_export>
43
+ <avatax_queue translate="title" module="avatax">
44
+ <title>AvaTax Order Sync Queue</title>
45
+ <action>avatax/adminhtml_grid/queue</action>
46
+ </avatax_queue>
47
+ <avatax_log translate="title" module="avatax">
48
+ <title>AvaTax Log</title>
49
+ <action>avatax/adminhtml_grid/log</action>
50
+ </avatax_log>
51
+ </children>
52
+ </tax>
53
+ </children>
54
+ </sales>
55
+ </menu>
56
+ <acl>
57
+ <resources>
58
+ <admin>
59
+ <children>
60
+ <avatax translate="title">
61
+ <title>AvaTax Module</title>
62
+ <sort_order>100</sort_order>
63
+ </avatax>
64
+ </children>
65
+ </admin>
66
+ </resources>
67
+ </acl>
68
+ </config>
 
app/code/community/OnePica/AvaTax/etc/config.xml CHANGED
@@ -1,324 +1,336 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * OnePica_AvaTax
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0), a
9
- * copy of which is available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- *
12
- * @category OnePica
13
- * @package OnePica_AvaTax
14
- * @author OnePica Codemaster <codemaster@onepica.com>
15
- * @copyright Copyright (c) 2009 One Pica, Inc.
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
- */
18
- -->
19
-
20
- <config>
21
- <modules>
22
- <OnePica_AvaTax>
23
- <version>2.4.3.3</version>
24
- </OnePica_AvaTax>
25
- </modules>
26
- <global>
27
- <models>
28
- <avatax>
29
- <class>OnePica_AvaTax_Model</class>
30
- </avatax>
31
- <avatax_records>
32
- <class>OnePica_AvaTax_Model_Records</class>
33
- <resourceModel>avatax_records_mysql4</resourceModel>
34
- </avatax_records>
35
- <avatax_records_mysql4>
36
- <class>OnePica_AvaTax_Model_Records_Mysql4</class>
37
- <entities>
38
- <log>
39
- <table>op_avatax_log</table>
40
- </log>
41
- <queue>
42
- <table>op_avatax_queue</table>
43
- </queue>
44
- </entities>
45
- </avatax_records_mysql4>
46
- <adminhtml>
47
- <rewrite>
48
- <config>OnePica_AvaTax_Model_Adminhtml_Config</config>
49
- <sales_order_create>OnePica_AvaTax_Model_Adminhtml_Sales_Order_Create</sales_order_create>
50
- </rewrite>
51
- </adminhtml>
52
- <admin>
53
- <rewrite>
54
- <session>OnePica_AvaTax_Model_Admin_Session</session>
55
- </rewrite>
56
- </admin>
57
- <sales>
58
- <rewrite>
59
- <quote_address>OnePica_AvaTax_Model_Sales_Quote_Address</quote_address>
60
- <quote_address_total_grand>OnePica_AvaTax_Model_Sales_Quote_Address_Total_Grand</quote_address_total_grand>
61
- </rewrite>
62
- </sales>
63
- </models>
64
- <helpers>
65
- <avatax>
66
- <class>OnePica_AvaTax_Helper</class>
67
- </avatax>
68
- <tax>
69
- <rewrite>
70
- <data>OnePica_AvaTax_Helper_Tax_Data</data>
71
- </rewrite>
72
- </tax>
73
- </helpers>
74
- <blocks>
75
- <avatax>
76
- <class>OnePica_AvaTax_Block</class>
77
- </avatax>
78
- <adminhtml>
79
- <rewrite>
80
- <tax_class_grid>OnePica_AvaTax_Block_Adminhtml_Tax_Class_Grid</tax_class_grid>
81
- <tax_class_edit_form>OnePica_AvaTax_Block_Adminhtml_Tax_Class_Edit_Form</tax_class_edit_form>
82
- </rewrite>
83
- </adminhtml>
84
- </blocks>
85
- <resources>
86
- <avatax_records_setup>
87
- <setup>
88
- <module>OnePica_AvaTax</module>
89
- </setup>
90
- <connection>
91
- <use>core_setup</use>
92
- </connection>
93
- </avatax_records_setup>
94
- <avatax_records_write>
95
- <connection>
96
- <use>core_write</use>
97
- </connection>
98
- </avatax_records_write>
99
- <avatax_records_read>
100
- <connection>
101
- <use>core_read</use>
102
- </connection>
103
- </avatax_records_read>
104
- </resources>
105
- <events>
106
- <sales_quote_collect_totals_before>
107
- <observers>
108
- <avatax>
109
- <type>singleton</type>
110
- <class>avatax/observer</class>
111
- <method>salesQuoteCollectTotalsBefore</method>
112
- </avatax>
113
- </observers>
114
- </sales_quote_collect_totals_before>
115
- <sales_order_invoice_save_after>
116
- <observers>
117
- <avatax>
118
- <type>singleton</type>
119
- <class>avatax/observer</class>
120
- <method>salesOrderInvoiceSaveAfter</method>
121
- </avatax>
122
- </observers>
123
- </sales_order_invoice_save_after>
124
- <sales_order_creditmemo_save_after>
125
- <observers>
126
- <avatax>
127
- <type>singleton</type>
128
- <class>avatax/observer</class>
129
- <method>salesOrderCreditmemoSaveAfter</method>
130
- </avatax>
131
- </observers>
132
- </sales_order_creditmemo_save_after>
133
- <admin_system_config_changed_section_tax>
134
- <observers>
135
- <avatax>
136
- <type>singleton</type>
137
- <class>avatax/observer</class>
138
- <method>adminSystemConfigChangedSectionTax</method>
139
- </avatax>
140
- </observers>
141
- </admin_system_config_changed_section_tax>
142
- <checkout_type_multishipping_set_shipping_items>
143
- <observers>
144
- <avatax>
145
- <type>singleton</type>
146
- <class>avatax/observer</class>
147
- <method>multishippingSetShippingItems</method>
148
- </avatax>
149
- </observers>
150
- </checkout_type_multishipping_set_shipping_items>
151
- </events>
152
- <!-- set on-the-fly in OnePica_AvaTax_Model_Observer::salesQuoteCollectTotalsBefore
153
- <sales>
154
- <quote>
155
- <totals>
156
- <tax>
157
- <class>avatax/sales_quote_address_total_tax</class>
158
- <after>subtotal,shipping</after>
159
- <before>customerbalance,grand_total</before>
160
- </tax>
161
- </totals>
162
- </quote>
163
- </sales>
164
- -->
165
- </global>
166
- <frontend>
167
- <layout>
168
- <updates>
169
- <avatax>
170
- <file>avatax.xml</file>
171
- </avatax>
172
- </updates>
173
- </layout>
174
- <routers>
175
- <checkout>
176
- <args>
177
- <modules>
178
- <OnePica_AvaTax before="Mage_Checkout">OnePica_AvaTax</OnePica_AvaTax>
179
- </modules>
180
- </args>
181
- </checkout>
182
- </routers>
183
- <translate>
184
- <modules>
185
- <OnePica_AvaTax>
186
- <files>
187
- <default>OnePica_AvaTax.csv</default>
188
- </files>
189
- </OnePica_AvaTax>
190
- </modules>
191
- </translate>
192
- </frontend>
193
- <admin>
194
- <routers>
195
- <avatax>
196
- <use>admin</use>
197
- <args>
198
- <module>OnePica_AvaTax</module>
199
- <frontName>avatax</frontName>
200
- </args>
201
- </avatax>
202
- </routers>
203
- </admin>
204
- <!-- the adminhtml section is repeated in config.xml & adminhtml.xml for backwards compatibility -->
205
- <!-- @see http://www.magentocommerce.com/bug-tracking/issue?issue=8496 -->
206
- <adminhtml>
207
- <layout>
208
- <updates>
209
- <avatax>
210
- <file>avatax.xml</file>
211
- </avatax>
212
- </updates>
213
- </layout>
214
- <translate>
215
- <modules>
216
- <OnePica_AvaTax>
217
- <files>
218
- <default>OnePica_AvaTax.csv</default>
219
- </files>
220
- </OnePica_AvaTax>
221
- </modules>
222
- </translate>
223
- <menu>
224
- <sales>
225
- <children>
226
- <tax>
227
- <children>
228
- <rules>
229
- <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
230
- </rules>
231
- <rates>
232
- <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
233
- </rates>
234
- <import_export>
235
- <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
236
- </import_export>
237
- <avatax_queue translate="title" module="avatax">
238
- <title>AvaTax Order Sync Queue</title>
239
- <action>avatax/adminhtml_grid/queue</action>
240
- </avatax_queue>
241
- <!--
242
- <avatax_log translate="title" module="avatax">
243
- <title>AvaTax Log</title>
244
- <action>avatax/adminhtml_grid/log</action>
245
- </avatax_log>
246
- -->
247
- </children>
248
- </tax>
249
- </children>
250
- </sales>
251
- </menu>
252
- <acl>
253
- <resources>
254
- <admin>
255
- <children>
256
- <avatax translate="title">
257
- <title>AvaTax Module</title>
258
- <sort_order>100</sort_order>
259
- </avatax>
260
- </children>
261
- </admin>
262
- </resources>
263
- </acl>
264
- </adminhtml>
265
- <default>
266
- <tax>
267
- <avatax>
268
- <action>0</action>
269
- <url>https://avatax.avalara.net/</url>
270
- <region_filter_mode>0</region_filter_mode>
271
- <country_filter_list>CA,US</country_filter_list>
272
- <log_status>1</log_status>
273
- <log_lifetime>3</log_lifetime>
274
- <queue_success_lifetime>7</queue_success_lifetime>
275
- <queue_failed_lifetime>60</queue_failed_lifetime>
276
- <log_type_list>Ping,Get Tax,Filter,Validate,Queue</log_type_list>
277
- <cust_code_format>0</cust_code_format>
278
- <shipping_sku>Shipping</shipping_sku>
279
- <gw_order_sku>GwOrder</gw_order_sku>
280
- <gw_items_sku>GwItems</gw_items_sku>
281
- <gw_printed_card_sku>GwPrintedCard</gw_printed_card_sku>
282
- <adjustment_positive_sku>Adjustment</adjustment_positive_sku>
283
- <adjustment_negative_sku>Adjustment</adjustment_negative_sku>
284
- <sales_person_code>Magento</sales_person_code>
285
- <error_full_stop>1</error_full_stop>
286
- <error_frontend_action>2</error_frontend_action>
287
- <error_frontend_message>Unfortunately, we could not calculate tax for your order. Please try again with a different address or contact us to complete your order.</error_frontend_message>
288
- <error_backend_message>There was an error getting tax rates from Avalara. Please see the error log for details.</error_backend_message>
289
- <error_notification_toolbar>1</error_notification_toolbar>
290
- <onepage_normalize_message>Your shipping address has been modified during our validation process. Please confirm the address to the right is accurate.</onepage_normalize_message>
291
- <multiaddress_normalize_message>Your shipping addresses have been modified during our validation process. Please confirm they are still correct.</multiaddress_normalize_message>
292
- <validate_address_message>The address '%s' appears invalid. Please correct it or select another address.</validate_address_message>
293
- </avatax>
294
- <calculation>
295
- <based_on>shipping</based_on>
296
- <price_includes_tax>0</price_includes_tax>
297
- <shipping_includes_tax>0</shipping_includes_tax>
298
- <apply_after_discount>1</apply_after_discount>
299
- <discount_tax>1</discount_tax>
300
- <apply_tax_on>0</apply_tax_on>
301
- </calculation>
302
- <defaults>
303
- <region>0</region>
304
- <postcode>*</postcode>
305
- </defaults>
306
- </tax>
307
- </default>
308
- <crontab>
309
- <jobs>
310
- <avatax_processqueue>
311
- <schedule><cron_expr>0 * * * *</cron_expr></schedule>
312
- <run>
313
- <model>avatax/observer::processQueue</model>
314
- </run>
315
- </avatax_processqueue>
316
- <avatax_cleanlog>
317
- <schedule><cron_expr>0 0 * * *</cron_expr></schedule>
318
- <run>
319
- <model>avatax/observer::cleanLog</model>
320
- </run>
321
- </avatax_cleanlog>
322
- </jobs>
323
- </crontab>
324
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * OnePica_AvaTax
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category OnePica
13
+ * @package OnePica_AvaTax
14
+ * @author OnePica Codemaster <codemaster@onepica.com>
15
+ * @copyright Copyright (c) 2009 One Pica, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <OnePica_AvaTax>
22
+ <version>2.5.0.2</version>
23
+ </OnePica_AvaTax>
24
+ </modules>
25
+ <global>
26
+ <models>
27
+ <avatax>
28
+ <class>OnePica_AvaTax_Model</class>
29
+ </avatax>
30
+ <avatax_records>
31
+ <class>OnePica_AvaTax_Model_Records</class>
32
+ <resourceModel>avatax_records_mysql4</resourceModel>
33
+ </avatax_records>
34
+ <avatax_records_mysql4>
35
+ <class>OnePica_AvaTax_Model_Records_Mysql4</class>
36
+ <entities>
37
+ <log>
38
+ <table>op_avatax_log</table>
39
+ </log>
40
+ <queue>
41
+ <table>op_avatax_queue</table>
42
+ </queue>
43
+ </entities>
44
+ </avatax_records_mysql4>
45
+ <adminhtml>
46
+ <rewrite>
47
+ <config>OnePica_AvaTax_Model_Adminhtml_Config</config>
48
+ <sales_order_create>OnePica_AvaTax_Model_Adminhtml_Sales_Order_Create</sales_order_create>
49
+ </rewrite>
50
+ </adminhtml>
51
+ <admin>
52
+ <rewrite>
53
+ <session>OnePica_AvaTax_Model_Admin_Session</session>
54
+ </rewrite>
55
+ </admin>
56
+ <sales>
57
+ <rewrite>
58
+ <quote_address>OnePica_AvaTax_Model_Sales_Quote_Address</quote_address>
59
+ <quote_address_total_grand>OnePica_AvaTax_Model_Sales_Quote_Address_Total_Grand</quote_address_total_grand>
60
+ </rewrite>
61
+ </sales>
62
+ <tax>
63
+ <rewrite>
64
+ <config>OnePica_AvaTax_Model_Tax_Config</config>
65
+ </rewrite>
66
+ </tax>
67
+ </models>
68
+ <helpers>
69
+ <avatax>
70
+ <class>OnePica_AvaTax_Helper</class>
71
+ </avatax>
72
+ <tax>
73
+ <rewrite>
74
+ <data>OnePica_AvaTax_Helper_Tax_Data</data>
75
+ </rewrite>
76
+ </tax>
77
+ </helpers>
78
+ <blocks>
79
+ <avatax>
80
+ <class>OnePica_AvaTax_Block</class>
81
+ </avatax>
82
+ <adminhtml>
83
+ <rewrite>
84
+ <tax_class_grid>OnePica_AvaTax_Block_Adminhtml_Tax_Class_Grid</tax_class_grid>
85
+ <tax_class_edit_form>OnePica_AvaTax_Block_Adminhtml_Tax_Class_Edit_Form</tax_class_edit_form>
86
+ </rewrite>
87
+ </adminhtml>
88
+ </blocks>
89
+ <resources>
90
+ <avatax_records_setup>
91
+ <setup>
92
+ <module>OnePica_AvaTax</module>
93
+ </setup>
94
+ <connection>
95
+ <use>core_setup</use>
96
+ </connection>
97
+ </avatax_records_setup>
98
+ <avatax_records_write>
99
+ <connection>
100
+ <use>core_write</use>
101
+ </connection>
102
+ </avatax_records_write>
103
+ <avatax_records_read>
104
+ <connection>
105
+ <use>core_read</use>
106
+ </connection>
107
+ </avatax_records_read>
108
+ </resources>
109
+ <events>
110
+ <sales_quote_collect_totals_before>
111
+ <observers>
112
+ <avatax>
113
+ <type>singleton</type>
114
+ <class>avatax/observer</class>
115
+ <method>salesQuoteCollectTotalsBefore</method>
116
+ </avatax>
117
+ </observers>
118
+ </sales_quote_collect_totals_before>
119
+ <sales_order_invoice_save_after>
120
+ <observers>
121
+ <avatax>
122
+ <type>singleton</type>
123
+ <class>avatax/observer</class>
124
+ <method>salesOrderInvoiceSaveAfter</method>
125
+ </avatax>
126
+ </observers>
127
+ </sales_order_invoice_save_after>
128
+ <sales_order_creditmemo_save_after>
129
+ <observers>
130
+ <avatax>
131
+ <type>singleton</type>
132
+ <class>avatax/observer</class>
133
+ <method>salesOrderCreditmemoSaveAfter</method>
134
+ </avatax>
135
+ </observers>
136
+ </sales_order_creditmemo_save_after>
137
+ <admin_system_config_changed_section_tax>
138
+ <observers>
139
+ <avatax>
140
+ <type>singleton</type>
141
+ <class>avatax/observer</class>
142
+ <method>adminSystemConfigChangedSectionTax</method>
143
+ </avatax>
144
+ </observers>
145
+ </admin_system_config_changed_section_tax>
146
+ <checkout_type_multishipping_set_shipping_items>
147
+ <observers>
148
+ <avatax>
149
+ <type>singleton</type>
150
+ <class>avatax/observer</class>
151
+ <method>multishippingSetShippingItems</method>
152
+ </avatax>
153
+ </observers>
154
+ </checkout_type_multishipping_set_shipping_items>
155
+ <controller_front_init_before>
156
+ <observers>
157
+ <avatax>
158
+ <type>singleton</type>
159
+ <class>avatax/observer</class>
160
+ <method>loadAvaTaxExternalLib</method>
161
+ </avatax>
162
+ </observers>
163
+ </controller_front_init_before>
164
+ <default>
165
+ <observers>
166
+ <avatax>
167
+ <type>singleton</type>
168
+ <class>avatax/observer</class>
169
+ <method>loadAvaTaxExternalLib</method>
170
+ </avatax>
171
+ </observers>
172
+ </default>
173
+ <controller_action_predispatch_checkout_cart_estimatePost>
174
+ <observers>
175
+ <avatax>
176
+ <type>singleton</type>
177
+ <class>avatax/observer</class>
178
+ <method>controllerActionPredispatchCheckoutCartEstimatePost</method>
179
+ </avatax>
180
+ </observers>
181
+ </controller_action_predispatch_checkout_cart_estimatePost>
182
+ <controller_action_predispatch_checkout_onepage_index>
183
+ <observers>
184
+ <avatax>
185
+ <type>singleton</type>
186
+ <class>avatax/observer</class>
187
+ <method>controllerActionPredispatchCheckoutOnepageIndex</method>
188
+ </avatax>
189
+ </observers>
190
+ </controller_action_predispatch_checkout_onepage_index>
191
+ </events>
192
+ </global>
193
+ <frontend>
194
+ <layout>
195
+ <updates>
196
+ <avatax>
197
+ <file>onepica/avatax.xml</file>
198
+ </avatax>
199
+ </updates>
200
+ </layout>
201
+ <translate>
202
+ <modules>
203
+ <OnePica_AvaTax>
204
+ <files>
205
+ <default>OnePica_AvaTax.csv</default>
206
+ </files>
207
+ </OnePica_AvaTax>
208
+ </modules>
209
+ </translate>
210
+ </frontend>
211
+ <admin>
212
+ <routers>
213
+ <avatax>
214
+ <use>admin</use>
215
+ <args>
216
+ <module>OnePica_AvaTax</module>
217
+ <frontName>avatax</frontName>
218
+ </args>
219
+ </avatax>
220
+ </routers>
221
+ </admin>
222
+ <!-- the adminhtml section is repeated in config.xml & adminhtml.xml for backwards compatibility -->
223
+ <!-- @see http://www.magentocommerce.com/bug-tracking/issue?issue=8496 -->
224
+ <adminhtml>
225
+ <layout>
226
+ <updates>
227
+ <avatax>
228
+ <file>onepica/avatax.xml</file>
229
+ </avatax>
230
+ </updates>
231
+ </layout>
232
+ <translate>
233
+ <modules>
234
+ <OnePica_AvaTax>
235
+ <files>
236
+ <default>OnePica_AvaTax.csv</default>
237
+ </files>
238
+ </OnePica_AvaTax>
239
+ </modules>
240
+ </translate>
241
+ <menu>
242
+ <sales>
243
+ <children>
244
+ <tax>
245
+ <children>
246
+ <rules>
247
+ <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
248
+ </rules>
249
+ <rates>
250
+ <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
251
+ </rates>
252
+ <import_export>
253
+ <!-- enabled/disabled in OnePica_AvaTax_Model_Admin_Session -->
254
+ </import_export>
255
+ <avatax_queue translate="title" module="avatax">
256
+ <title>AvaTax Order Sync Queue</title>
257
+ <action>avatax/adminhtml_grid/queue</action>
258
+ </avatax_queue>
259
+ </children>
260
+ </tax>
261
+ </children>
262
+ </sales>
263
+ </menu>
264
+ <acl>
265
+ <resources>
266
+ <admin>
267
+ <children>
268
+ <avatax translate="title">
269
+ <title>AvaTax Module</title>
270
+ <sort_order>100</sort_order>
271
+ </avatax>
272
+ </children>
273
+ </admin>
274
+ </resources>
275
+ </acl>
276
+ </adminhtml>
277
+ <default>
278
+ <tax>
279
+ <avatax>
280
+ <action>0</action>
281
+ <url>https://avatax.avalara.net/</url>
282
+ <region_filter_mode>0</region_filter_mode>
283
+ <country_filter_list>CA,US</country_filter_list>
284
+ <log_status>1</log_status>
285
+ <log_lifetime>3</log_lifetime>
286
+ <queue_success_lifetime>7</queue_success_lifetime>
287
+ <queue_failed_lifetime>60</queue_failed_lifetime>
288
+ <log_type_list>Ping,Get Tax,Filter,Validate,Queue</log_type_list>
289
+ <cust_code_format>0</cust_code_format>
290
+ <shipping_sku>Shipping</shipping_sku>
291
+ <gw_order_sku>GwOrder</gw_order_sku>
292
+ <gw_items_sku>GwItems</gw_items_sku>
293
+ <gw_printed_card_sku>GwPrintedCard</gw_printed_card_sku>
294
+ <adjustment_positive_sku>Adjustment</adjustment_positive_sku>
295
+ <adjustment_negative_sku>Adjustment</adjustment_negative_sku>
296
+ <sales_person_code>Magento</sales_person_code>
297
+ <error_full_stop>1</error_full_stop>
298
+ <error_frontend_action>2</error_frontend_action>
299
+ <error_frontend_message>Unfortunately, we could not calculate tax for your order. Please try again with a different address or contact us to complete your order.</error_frontend_message>
300
+ <error_backend_message>There was an error getting tax rates from Avalara. Please see the error log for details.</error_backend_message>
301
+ <error_notification_toolbar>1</error_notification_toolbar>
302
+ <onepage_normalize_message>Your shipping address has been modified during our validation process. Please confirm the address to the right is accurate.</onepage_normalize_message>
303
+ <multiaddress_normalize_message>Your shipping addresses have been modified during our validation process. Please confirm they are still correct.</multiaddress_normalize_message>
304
+ <validate_address_message>The address '%s' appears invalid. Please correct it or select another address.</validate_address_message>
305
+ </avatax>
306
+ <calculation>
307
+ <based_on>shipping</based_on>
308
+ <price_includes_tax>0</price_includes_tax>
309
+ <shipping_includes_tax>0</shipping_includes_tax>
310
+ <apply_after_discount>1</apply_after_discount>
311
+ <discount_tax>0</discount_tax>
312
+ <apply_tax_on>0</apply_tax_on>
313
+ </calculation>
314
+ <defaults>
315
+ <region>0</region>
316
+ <postcode>*</postcode>
317
+ </defaults>
318
+ </tax>
319
+ </default>
320
+ <crontab>
321
+ <jobs>
322
+ <avatax_processqueue>
323
+ <schedule><cron_expr>0 * * * *</cron_expr></schedule>
324
+ <run>
325
+ <model>avatax/observer::processQueue</model>
326
+ </run>
327
+ </avatax_processqueue>
328
+ <avatax_cleanlog>
329
+ <schedule><cron_expr>0 0 * * *</cron_expr></schedule>
330
+ <run>
331
+ <model>avatax/observer::cleanLog</model>
332
+ </run>
333
+ </avatax_cleanlog>
334
+ </jobs>
335
+ </crontab>
336
+ </config>
app/code/community/OnePica/AvaTax/etc/system-disabled.xml CHANGED
@@ -1,91 +1,90 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * OnePica_AvaTax
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0), a
9
- * copy of which is available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- *
12
- * @category OnePica
13
- * @package OnePica_AvaTax
14
- * @author OnePica Codemaster <codemaster@onepica.com>
15
- * @copyright Copyright (c) 2009 One Pica, Inc.
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
- */
18
- -->
19
-
20
- <config>
21
- <sections>
22
- <tax>
23
- <groups>
24
- <classes>
25
- <fields>
26
- <shipping_tax_class>
27
- <show_in_default>1</show_in_default>
28
- <show_in_website>1</show_in_website>
29
- <show_in_store>1</show_in_store>
30
- </shipping_tax_class>
31
- </fields>
32
- </classes>
33
- <calculation>
34
- <fields>
35
- <based_on>
36
- <show_in_default>1</show_in_default>
37
- <show_in_website>1</show_in_website>
38
- <show_in_store>1</show_in_store>
39
- </based_on>
40
- <price_includes_tax>
41
- <show_in_default>1</show_in_default>
42
- <show_in_website>1</show_in_website>
43
- <show_in_store>1</show_in_store>
44
- </price_includes_tax>
45
- <shipping_includes_tax>
46
- <show_in_default>1</show_in_default>
47
- <show_in_website>1</show_in_website>
48
- <show_in_store>1</show_in_store>
49
- </shipping_includes_tax>
50
- <apply_after_discount>
51
- <show_in_default>1</show_in_default>
52
- <show_in_website>1</show_in_website>
53
- <show_in_store>1</show_in_store>
54
- </apply_after_discount>
55
- <discount_tax>
56
- <show_in_default>1</show_in_default>
57
- <show_in_website>1</show_in_website>
58
- <show_in_store>1</show_in_store>
59
- </discount_tax>
60
- <apply_tax_on>
61
- <show_in_default>1</show_in_default>
62
- <show_in_website>1</show_in_website>
63
- <show_in_store>1</show_in_store>
64
- </apply_tax_on>
65
- </fields>
66
- </calculation>
67
- <defaults>
68
- <fields>
69
- <region>
70
- <comment></comment>
71
- </region>
72
- <postcode>
73
- <comment></comment>
74
- </postcode>
75
- </fields>
76
- </defaults>
77
- <sales_display>
78
- <display>
79
- <fields>
80
- <full_summary>
81
- <show_in_default>1</show_in_default>
82
- <show_in_website>1</show_in_website>
83
- <show_in_store>1</show_in_store>
84
- </full_summary>
85
- </fields>
86
- </display>
87
- </sales_display>
88
- </groups>
89
- </tax>
90
- </sections>
91
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * OnePica_AvaTax
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category OnePica
13
+ * @package OnePica_AvaTax
14
+ * @author OnePica Codemaster <codemaster@onepica.com>
15
+ * @copyright Copyright (c) 2009 One Pica, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <sections>
21
+ <tax>
22
+ <groups>
23
+ <classes>
24
+ <fields>
25
+ <shipping_tax_class>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </shipping_tax_class>
30
+ </fields>
31
+ </classes>
32
+ <calculation>
33
+ <fields>
34
+ <based_on>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </based_on>
39
+ <price_includes_tax>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </price_includes_tax>
44
+ <shipping_includes_tax>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </shipping_includes_tax>
49
+ <apply_after_discount>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </apply_after_discount>
54
+ <discount_tax>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </discount_tax>
59
+ <apply_tax_on>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </apply_tax_on>
64
+ </fields>
65
+ </calculation>
66
+ <defaults>
67
+ <fields>
68
+ <region>
69
+ <comment></comment>
70
+ </region>
71
+ <postcode>
72
+ <comment></comment>
73
+ </postcode>
74
+ </fields>
75
+ </defaults>
76
+ <sales_display>
77
+ <display>
78
+ <fields>
79
+ <full_summary>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ </full_summary>
84
+ </fields>
85
+ </display>
86
+ </sales_display>
87
+ </groups>
88
+ </tax>
89
+ </sections>
90
+ </config>
 
app/code/community/OnePica/AvaTax/etc/system.xml CHANGED
@@ -1,523 +1,522 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * OnePica_AvaTax
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0), a
9
- * copy of which is available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- *
12
- * @category OnePica
13
- * @package OnePica_AvaTax
14
- * @author OnePica Codemaster <codemaster@onepica.com>
15
- * @copyright Copyright (c) 2009 One Pica, Inc.
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
- */
18
- -->
19
-
20
- <config>
21
- <sections>
22
- <tax>
23
- <tab>sales</tab>
24
- <groups>
25
- <avatax translate="label comment">
26
- <label>AvaTax</label>
27
- <comment><![CDATA[
28
- <style type="text/css"> #tax_avatax textarea { height:65px; } #tax_avatax .multiselect { height:155px; } </style>
29
- <p class="switcher">For complete and up-to-date documentation, please visit <a href="http://www.onepica.com/magento-extensions/avatax/" target="_blank">http://www.onepica.com/magento-extensions/avatax</a>.</p>
30
- ]]></comment>
31
- <sort_order>0</sort_order>
32
- <show_in_default>1</show_in_default>
33
- <show_in_website>1</show_in_website>
34
- <show_in_store>1</show_in_store>
35
- <fields>
36
- <title_connection_settings translate="label">
37
- <label><![CDATA[<strong>Connection Settings</strong>]]></label>
38
- <frontend_type>label</frontend_type>
39
- <sort_order>0</sort_order>
40
- <show_in_default>1</show_in_default>
41
- <show_in_website>1</show_in_website>
42
- <show_in_store>1</show_in_store>
43
- </title_connection_settings>
44
- <action translate="label">
45
- <label>Action</label>
46
- <frontend_type>select</frontend_type>
47
- <source_model>avatax/source_actions</source_model>
48
- <sort_order>10</sort_order>
49
- <show_in_default>1</show_in_default>
50
- <show_in_website>1</show_in_website>
51
- <show_in_store>1</show_in_store>
52
- </action>
53
- <url translate="label">
54
- <label>URL</label>
55
- <frontend_type>text</frontend_type>
56
- <sort_order>20</sort_order>
57
- <show_in_default>1</show_in_default>
58
- <show_in_website>1</show_in_website>
59
- <show_in_store>1</show_in_store>
60
- </url>
61
- <account translate="label">
62
- <label>Account Number</label>
63
- <frontend_type>text</frontend_type>
64
- <sort_order>30</sort_order>
65
- <show_in_default>1</show_in_default>
66
- <show_in_website>1</show_in_website>
67
- <show_in_store>1</show_in_store>
68
- </account>
69
- <license translate="label">
70
- <label>License Key</label>
71
- <frontend_type>text</frontend_type>
72
- <sort_order>40</sort_order>
73
- <show_in_default>1</show_in_default>
74
- <show_in_website>1</show_in_website>
75
- <show_in_store>1</show_in_store>
76
- </license>
77
- <company_code translate="label comment">
78
- <label>Company Code</label>
79
- <comment>Required. Your company code from the dashboard.</comment>
80
- <frontend_type>text</frontend_type>
81
- <sort_order>50</sort_order>
82
- <show_in_default>1</show_in_default>
83
- <show_in_website>1</show_in_website>
84
- <show_in_store>1</show_in_store>
85
- </company_code>
86
- <region_filter_mode translate="label">
87
- <label>Filter Requests by Region</label>
88
- <frontend_type>select</frontend_type>
89
- <source_model>avatax/source_regionfilter_mode</source_model>
90
- <sort_order>60</sort_order>
91
- <show_in_default>1</show_in_default>
92
- <show_in_website>1</show_in_website>
93
- <show_in_store>1</show_in_store>
94
- </region_filter_mode>
95
- <region_filter_list translate="label comment">
96
- <label></label>
97
- <comment><![CDATA[Select regions to use AvaTax services. Ignored if <em>Filter Requests by Region</em> is set to <em>None</em>.]]></comment>
98
- <frontend_type>multiselect</frontend_type>
99
- <source_model>avatax/source_regionfilter_list</source_model>
100
- <sort_order>70</sort_order>
101
- <show_in_default>1</show_in_default>
102
- <show_in_website>1</show_in_website>
103
- <show_in_store>1</show_in_store>
104
- </region_filter_list>
105
- <country_filter_list>
106
- <frontend_type>multiselect</frontend_type>
107
- <source_model>adminhtml/system_config_source_country</source_model>
108
- <sort_order>80</sort_order>
109
- <show_in_default>0</show_in_default>
110
- <show_in_website>0</show_in_website>
111
- <show_in_store>0</show_in_store>
112
- </country_filter_list>
113
-
114
- <title_debug_settings translate="label">
115
- <label><![CDATA[<strong>Log &amp; Queue Settings</strong>]]></label>
116
- <frontend_type>label</frontend_type>
117
- <sort_order>100</sort_order>
118
- <show_in_default>1</show_in_default>
119
- <show_in_website>1</show_in_website>
120
- <show_in_store>1</show_in_store>
121
- </title_debug_settings>
122
- <log_status translate="label">
123
- <label>Log Mode</label>
124
- <frontend_type>select</frontend_type>
125
- <source_model>avatax/source_logmode</source_model>
126
- <sort_order>110</sort_order>
127
- <show_in_default>1</show_in_default>
128
- <show_in_website>1</show_in_website>
129
- <show_in_store>1</show_in_store>
130
- </log_status>
131
- <log_lifetime translate="label comment">
132
- <label>Log Entry Lifetime</label>
133
- <comment>Required. Days before entries are auto-purged.</comment>
134
- <frontend_type>text</frontend_type>
135
- <sort_order>120</sort_order>
136
- <show_in_default>1</show_in_default>
137
- <show_in_website>0</show_in_website>
138
- <show_in_store>0</show_in_store>
139
- </log_lifetime>
140
- <queue_success_lifetime translate="label comment">
141
- <label>Successful Queue Lifetime</label>
142
- <comment>Required. Days before entries are auto-purged.</comment>
143
- <frontend_type>text</frontend_type>
144
- <sort_order>122</sort_order>
145
- <show_in_default>1</show_in_default>
146
- <show_in_website>0</show_in_website>
147
- <show_in_store>0</show_in_store>
148
- </queue_success_lifetime>
149
- <queue_failed_lifetime translate="label comment">
150
- <label>Failed Queue Lifetime</label>
151
- <comment>Required. Days before entries are auto-purged.</comment>
152
- <frontend_type>text</frontend_type>
153
- <sort_order>124</sort_order>
154
- <show_in_default>1</show_in_default>
155
- <show_in_website>0</show_in_website>
156
- <show_in_store>0</show_in_store>
157
- </queue_failed_lifetime>
158
-
159
- <log_type_list>
160
- <label>Log Type</label>
161
- <frontend_type>multiselect</frontend_type>
162
- <source_model>avatax/source_logtype</source_model>
163
- <sort_order>125</sort_order>
164
- <show_in_default>1</show_in_default>
165
- <show_in_website>0</show_in_website>
166
- <show_in_store>0</show_in_store>
167
- </log_type_list>
168
-
169
- <log_export>
170
- <label></label>
171
- <frontend_model>avatax/adminhtml_system_config_form_field_export</frontend_model>
172
- <sort_order>130</sort_order>
173
- <show_in_default>1</show_in_default>
174
- <show_in_website>0</show_in_website>
175
- <show_in_store>0</show_in_store>
176
- </log_export>
177
-
178
- <title_data_mapping translate="label">
179
- <label><![CDATA[<strong>Data Mapping</strong>]]></label>
180
- <frontend_type>label</frontend_type>
181
- <sort_order>200</sort_order>
182
- <show_in_default>1</show_in_default>
183
- <show_in_website>1</show_in_website>
184
- <show_in_store>1</show_in_store>
185
- </title_data_mapping>
186
- <cust_code_format translate="label comment">
187
- <label>Customer Code Format</label>
188
- <comment><![CDATA[Recommended: <code>customer_id</code>]]></comment>
189
- <frontend_type>select</frontend_type>
190
- <source_model>avatax/source_customercodeformat</source_model>
191
- <sort_order>205</sort_order>
192
- <show_in_default>1</show_in_default>
193
- <show_in_website>1</show_in_website>
194
- <show_in_store>1</show_in_store>
195
- </cust_code_format>
196
- <shipping_sku translate="label comment">
197
- <label>Shipping Sku</label>
198
- <comment>Required. The sku sent to denote shipping costs.</comment>
199
- <frontend_type>text</frontend_type>
200
- <sort_order>210</sort_order>
201
- <show_in_default>1</show_in_default>
202
- <show_in_website>1</show_in_website>
203
- <show_in_store>1</show_in_store>
204
- </shipping_sku>
205
- <gw_order_sku translate="label comment">
206
- <label>Gift Wrap Order Sku</label>
207
- <comment>Required. The sku sent to denote gift wrap order costs.</comment>
208
- <frontend_type>text</frontend_type>
209
- <sort_order>215</sort_order>
210
- <show_in_default>1</show_in_default>
211
- <show_in_website>1</show_in_website>
212
- <show_in_store>1</show_in_store>
213
- </gw_order_sku>
214
- <gw_items_sku translate="label comment">
215
- <label>Gift Wrap Items Sku</label>
216
- <comment>Required. The sku sent to denote gift wrap items costs.</comment>
217
- <frontend_type>text</frontend_type>
218
- <sort_order>216</sort_order>
219
- <show_in_default>1</show_in_default>
220
- <show_in_website>1</show_in_website>
221
- <show_in_store>1</show_in_store>
222
- </gw_items_sku>
223
- <gw_printed_card_sku translate="label comment">
224
- <label>Gift Wrap Printed Card Sku</label>
225
- <comment>Required. The sku sent to denote gift wrap printed card costs.</comment>
226
- <frontend_type>text</frontend_type>
227
- <sort_order>217</sort_order>
228
- <show_in_default>1</show_in_default>
229
- <show_in_website>1</show_in_website>
230
- <show_in_store>1</show_in_store>
231
- </gw_printed_card_sku>
232
- <adjustment_positive_sku translate="label comment">
233
- <label>Adjustment Refund Sku</label>
234
- <comment>Required. The sku sent to denote positive ajustments.</comment>
235
- <frontend_type>text</frontend_type>
236
- <sort_order>220</sort_order>
237
- <show_in_default>1</show_in_default>
238
- <show_in_website>1</show_in_website>
239
- <show_in_store>1</show_in_store>
240
- </adjustment_positive_sku>
241
- <adjustment_negative_sku translate="label comment">
242
- <label>Adjustment Fee Sku</label>
243
- <comment>Required. The sku sent to denote negative ajustments.</comment>
244
- <frontend_type>text</frontend_type>
245
- <sort_order>230</sort_order>
246
- <show_in_default>1</show_in_default>
247
- <show_in_website>1</show_in_website>
248
- <show_in_store>1</show_in_store>
249
- </adjustment_negative_sku>
250
- <sales_person_code translate="label comment">
251
- <label>Sales Person Code</label>
252
- <comment>Optional. The sales person code for orders.</comment>
253
- <frontend_type>text</frontend_type>
254
- <sort_order>240</sort_order>
255
- <show_in_default>1</show_in_default>
256
- <show_in_website>1</show_in_website>
257
- <show_in_store>1</show_in_store>
258
- </sales_person_code>
259
- <location_code translate="label comment">
260
- <label>Location Code</label>
261
- <comment>Optional. The location code for orders.</comment>
262
- <frontend_type>text</frontend_type>
263
- <sort_order>250</sort_order>
264
- <show_in_default>1</show_in_default>
265
- <show_in_website>1</show_in_website>
266
- <show_in_store>1</show_in_store>
267
- </location_code>
268
- <line_ref1_code translate="label">
269
- <label>Reference Code 1</label>
270
- <frontend_type>text</frontend_type>
271
- <sort_order>260</sort_order>
272
- <show_in_default>1</show_in_default>
273
- <show_in_website>1</show_in_website>
274
- <show_in_store>1</show_in_store>
275
- </line_ref1_code>
276
- <line_ref2_code translate="label comment">
277
- <label>Reference Code 2</label>
278
- <comment>Optional. An attribute code to pass with each product. See product attributes in catalog > attributes.</comment>
279
- <frontend_type>text</frontend_type>
280
- <sort_order>270</sort_order>
281
- <show_in_default>1</show_in_default>
282
- <show_in_website>1</show_in_website>
283
- <show_in_store>1</show_in_store>
284
- </line_ref2_code>
285
-
286
- <title_address_validation translate="label">
287
- <label><![CDATA[<strong>Shipping Address Options</strong>]]></label>
288
- <frontend_type>label</frontend_type>
289
- <sort_order>300</sort_order>
290
- <show_in_default>1</show_in_default>
291
- <show_in_website>1</show_in_website>
292
- <show_in_store>1</show_in_store>
293
- </title_address_validation>
294
- <validate_address translate="label comment">
295
- <label>Address Validation</label>
296
- <frontend_type>select</frontend_type>
297
- <source_model>avatax/source_addressvalidation</source_model>
298
- <comment>Require a validated address from AvaTax to checkout</comment>
299
- <sort_order>301</sort_order>
300
- <show_in_default>1</show_in_default>
301
- <show_in_website>1</show_in_website>
302
- <show_in_store>1</show_in_store>
303
- </validate_address>
304
- <validate_address_message translate="label comment">
305
- <label>Multi-Address Address Validation Error</label>
306
- <comment>Only applies if address validation is enabled and shows ONLY for the multi-address checkout</comment>
307
- <frontend_type>textarea</frontend_type>
308
- <sort_order>331</sort_order>
309
- <show_in_default>1</show_in_default>
310
- <show_in_website>1</show_in_website>
311
- <show_in_store>1</show_in_store>
312
- </validate_address_message>
313
- <normalize_address translate="label comment">
314
- <label>Address Normalization</label>
315
- <frontend_type>select</frontend_type>
316
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
317
- <comment>Replace address with well-formed one from AvaTax</comment>
318
- <sort_order>320</sort_order>
319
- <show_in_default>1</show_in_default>
320
- <show_in_website>1</show_in_website>
321
- <show_in_store>1</show_in_store>
322
- </normalize_address>
323
- <onepage_normalize_message translate="label comment">
324
- <label>Onepage Checkout Address Normalized Notice</label>
325
- <comment>Only applies if address normalization is enabled</comment>
326
- <frontend_type>textarea</frontend_type>
327
- <sort_order>330</sort_order>
328
- <show_in_default>1</show_in_default>
329
- <show_in_website>1</show_in_website>
330
- <show_in_store>1</show_in_store>
331
- </onepage_normalize_message>
332
- <multiaddress_normalize_message translate="label comment">
333
- <label>Multi-Address Checkout Address Normalized Notice</label>
334
- <comment>Only applies if address normalization is enabled</comment>
335
- <frontend_type>textarea</frontend_type>
336
- <sort_order>330</sort_order>
337
- <show_in_default>1</show_in_default>
338
- <show_in_website>1</show_in_website>
339
- <show_in_store>1</show_in_store>
340
- </multiaddress_normalize_message>
341
-
342
- <title_request_settings translate="label">
343
- <label><![CDATA[<strong>Request Settings</strong>]]></label>
344
- <frontend_type>label</frontend_type>
345
- <sort_order>340</sort_order>
346
- <show_in_default>1</show_in_default>
347
- <show_in_website>1</show_in_website>
348
- <show_in_store>1</show_in_store>
349
- </title_request_settings>
350
- <field_required_list>
351
- <label>Required Fileds</label>
352
- <frontend_type>multiselect</frontend_type>
353
- <source_model>avatax/source_fieldlist</source_model>
354
- <sort_order>350</sort_order>
355
- <show_in_default>1</show_in_default>
356
- <show_in_website>1</show_in_website>
357
- <show_in_store>1</show_in_store>
358
- </field_required_list>
359
- <field_rule>
360
- <label>Field Rule</label>
361
- <comment>Example: ' ,-,_'</comment>
362
- <frontend_type>text</frontend_type>
363
- <sort_order>360</sort_order>
364
- <show_in_default>1</show_in_default>
365
- <show_in_website>1</show_in_website>
366
- <show_in_store>1</show_in_store>
367
- </field_rule>
368
-
369
- <title_error_handling translate="label">
370
- <label><![CDATA[<strong>Error Handling</strong>]]></label>
371
- <frontend_type>label</frontend_type>
372
- <sort_order>400</sort_order>
373
- <show_in_default>1</show_in_default>
374
- <show_in_website>1</show_in_website>
375
- <show_in_store>1</show_in_store>
376
- </title_error_handling>
377
- <error_full_stop translate="label">
378
- <label>Action on Error</label>
379
- <frontend_type>select</frontend_type>
380
- <source_model>avatax/source_error</source_model>
381
- <sort_order>410</sort_order>
382
- <show_in_default>1</show_in_default>
383
- <show_in_website>1</show_in_website>
384
- <show_in_store>1</show_in_store>
385
- </error_full_stop>
386
- <error_frontend_message translate="label">
387
- <label>Frontend Error Message</label>
388
- <frontend_type>textarea</frontend_type>
389
- <sort_order>420</sort_order>
390
- <show_in_default>1</show_in_default>
391
- <show_in_website>1</show_in_website>
392
- <show_in_store>1</show_in_store>
393
- </error_frontend_message>
394
- <error_backend_message translate="label">
395
- <label>Backend Error Message</label>
396
- <frontend_type>textarea</frontend_type>
397
- <sort_order>430</sort_order>
398
- <show_in_default>1</show_in_default>
399
- <show_in_website>1</show_in_website>
400
- <show_in_store>1</show_in_store>
401
- </error_backend_message>
402
- <error_notification_toolbar translate="label comment">
403
- <label>Notification Toolbar</label>
404
- <frontend_type>select</frontend_type>
405
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
406
- <comment>If there are issues syncing invoice or credit memo data, show warning in admin notification toolbar.</comment>
407
- <sort_order>440</sort_order>
408
- <show_in_default>1</show_in_default>
409
- <show_in_website>0</show_in_website>
410
- <show_in_store>0</show_in_store>
411
- </error_notification_toolbar>
412
- </fields>
413
- </avatax>
414
- <classes>
415
- <fields>
416
- <shipping_tax_class>
417
- <!-- Will always be FR020100. It is hardcoded in OnePica_AvaTax_Helper_Tax_Data. -->
418
- <show_in_default>0</show_in_default>
419
- <show_in_website>0</show_in_website>
420
- <show_in_store>0</show_in_store>
421
- </shipping_tax_class>
422
- </fields>
423
- </classes>
424
- <calculation>
425
- <fields>
426
- <based_on>
427
- <!-- AvaTax always computes tax based on ship from and ship to addresses. -->
428
- <show_in_default>0</show_in_default>
429
- <show_in_website>0</show_in_website>
430
- <show_in_store>0</show_in_store>
431
- </based_on>
432
- <price_includes_tax>
433
- <!-- Items should not include tax so that AvaTax can calculate it. -->
434
- <show_in_default>0</show_in_default>
435
- <show_in_website>0</show_in_website>
436
- <show_in_store>0</show_in_store>
437
- </price_includes_tax>
438
- <shipping_includes_tax>
439
- <!-- Shipping should not include tax so that AvaTax can calculate it. -->
440
- <show_in_default>0</show_in_default>
441
- <show_in_website>0</show_in_website>
442
- <show_in_store>0</show_in_store>
443
- </shipping_includes_tax>
444
- <apply_after_discount>
445
- <!-- Always apply discount first since AvaTax doesn't support line-level item discount amounts -->
446
- <show_in_default>0</show_in_default>
447
- <show_in_website>0</show_in_website>
448
- <show_in_store>0</show_in_store>
449
- </apply_after_discount>
450
- <discount_tax>
451
- <!-- Always apply discount first since AvaTax doesn't support line-level item discount amounts -->
452
- <show_in_default>0</show_in_default>
453
- <show_in_website>0</show_in_website>
454
- <show_in_store>0</show_in_store>
455
- </discount_tax>
456
- <apply_tax_on>
457
- <!-- Always apply tax to custom price if available -->
458
- <show_in_default>0</show_in_default>
459
- <show_in_website>0</show_in_website>
460
- <show_in_store>0</show_in_store>
461
- </apply_tax_on>
462
- <algorithm>
463
- <!-- Always based on row (actually determined by Avalara) -->
464
- <show_in_default>0</show_in_default>
465
- <show_in_website>0</show_in_website>
466
- <show_in_store>0</show_in_store>
467
- </algorithm>
468
- </fields>
469
- </calculation>
470
- <defaults>
471
- <fields>
472
- <region translate="comment">
473
- <comment>Set this to "*" (asterisk) to stop unneeded requests to Avalara and to help speed up page loads</comment>
474
- </region>
475
- <postcode translate="comment">
476
- <comment>Set this to "*" (asterisk) to stop unneeded requests to Avalara and to help speed up page loads</comment>
477
- </postcode>
478
- </fields>
479
- </defaults>
480
- <display>
481
- <fields>
482
- <type>
483
- <show_in_default>0</show_in_default>
484
- <show_in_website>0</show_in_website>
485
- <show_in_store>0</show_in_store>
486
- </type>
487
- <shipping>
488
- <show_in_default>0</show_in_default>
489
- <show_in_website>0</show_in_website>
490
- <show_in_store>0</show_in_store>
491
- </shipping>
492
- </fields>
493
- </display>
494
- <sales_display>
495
- <fields>
496
- <full_summary>
497
- <!-- Jurisdiction data is not kept in Magento at this time after the quote -->
498
- <show_in_default>0</show_in_default>
499
- <show_in_website>0</show_in_website>
500
- <show_in_store>0</show_in_store>
501
- </full_summary>
502
- </fields>
503
- </sales_display>
504
- </groups>
505
- </tax>
506
- <shipping>
507
- <groups>
508
- <origin>
509
- <fields>
510
- <street translate="label">
511
- <label><![CDATA[Number & Street]]></label>
512
- <frontend_type>text</frontend_type>
513
- <sort_order>99</sort_order>
514
- <show_in_default>1</show_in_default>
515
- <show_in_website>1</show_in_website>
516
- <show_in_store>1</show_in_store>
517
- </street>
518
- </fields>
519
- </origin>
520
- </groups>
521
- </shipping>
522
- </sections>
523
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * OnePica_AvaTax
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category OnePica
13
+ * @package OnePica_AvaTax
14
+ * @author OnePica Codemaster <codemaster@onepica.com>
15
+ * @copyright Copyright (c) 2009 One Pica, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <sections>
21
+ <tax>
22
+ <tab>sales</tab>
23
+ <groups>
24
+ <avatax translate="label comment">
25
+ <label>AvaTax</label>
26
+ <comment><![CDATA[
27
+ <style type="text/css"> #tax_avatax textarea { height:65px; } #tax_avatax .multiselect { height:155px; } </style>
28
+ <p class="switcher">For complete and up-to-date documentation, please visit <a href="http://www.onepica.com/magento-extensions/avatax/" target="_blank">http://www.onepica.com/magento-extensions/avatax</a>.</p>
29
+ ]]></comment>
30
+ <sort_order>0</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <fields>
35
+ <title_connection_settings translate="label">
36
+ <label><![CDATA[<strong>Connection Settings</strong>]]></label>
37
+ <frontend_type>label</frontend_type>
38
+ <sort_order>0</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </title_connection_settings>
43
+ <action translate="label">
44
+ <label>Action</label>
45
+ <frontend_type>select</frontend_type>
46
+ <source_model>avatax/source_actions</source_model>
47
+ <sort_order>10</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </action>
52
+ <url translate="label">
53
+ <label>URL</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>20</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ </url>
60
+ <account translate="label">
61
+ <label>Account Number</label>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>30</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </account>
68
+ <license translate="label">
69
+ <label>License Key</label>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>40</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ </license>
76
+ <company_code translate="label comment">
77
+ <label>Company Code</label>
78
+ <comment>Required. Your company code from the dashboard.</comment>
79
+ <frontend_type>text</frontend_type>
80
+ <sort_order>50</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ </company_code>
85
+ <region_filter_mode translate="label">
86
+ <label>Filter Requests by Region</label>
87
+ <frontend_type>select</frontend_type>
88
+ <source_model>avatax/source_regionfilter_mode</source_model>
89
+ <sort_order>60</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ </region_filter_mode>
94
+ <region_filter_list translate="label comment">
95
+ <label></label>
96
+ <comment><![CDATA[Select regions to use AvaTax services. Ignored if <em>Filter Requests by Region</em> is set to <em>None</em>.]]></comment>
97
+ <frontend_type>multiselect</frontend_type>
98
+ <source_model>avatax/source_regionfilter_list</source_model>
99
+ <sort_order>70</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ </region_filter_list>
104
+ <country_filter_list>
105
+ <frontend_type>multiselect</frontend_type>
106
+ <source_model>adminhtml/system_config_source_country</source_model>
107
+ <sort_order>80</sort_order>
108
+ <show_in_default>0</show_in_default>
109
+ <show_in_website>0</show_in_website>
110
+ <show_in_store>0</show_in_store>
111
+ </country_filter_list>
112
+
113
+ <title_debug_settings translate="label">
114
+ <label><![CDATA[<strong>Log &amp; Queue Settings</strong>]]></label>
115
+ <frontend_type>label</frontend_type>
116
+ <sort_order>100</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </title_debug_settings>
121
+ <log_status translate="label">
122
+ <label>Log Mode</label>
123
+ <frontend_type>select</frontend_type>
124
+ <source_model>avatax/source_logmode</source_model>
125
+ <sort_order>110</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ </log_status>
130
+ <log_lifetime translate="label comment">
131
+ <label>Log Entry Lifetime</label>
132
+ <comment>Required. Days before entries are auto-purged.</comment>
133
+ <frontend_type>text</frontend_type>
134
+ <sort_order>120</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>0</show_in_website>
137
+ <show_in_store>0</show_in_store>
138
+ </log_lifetime>
139
+ <queue_success_lifetime translate="label comment">
140
+ <label>Successful Queue Lifetime</label>
141
+ <comment>Required. Days before entries are auto-purged.</comment>
142
+ <frontend_type>text</frontend_type>
143
+ <sort_order>122</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>0</show_in_website>
146
+ <show_in_store>0</show_in_store>
147
+ </queue_success_lifetime>
148
+ <queue_failed_lifetime translate="label comment">
149
+ <label>Failed Queue Lifetime</label>
150
+ <comment>Required. Days before entries are auto-purged.</comment>
151
+ <frontend_type>text</frontend_type>
152
+ <sort_order>124</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>0</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ </queue_failed_lifetime>
157
+
158
+ <log_type_list>
159
+ <label>Log Type</label>
160
+ <frontend_type>multiselect</frontend_type>
161
+ <source_model>avatax/source_logtype</source_model>
162
+ <sort_order>125</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>0</show_in_website>
165
+ <show_in_store>0</show_in_store>
166
+ </log_type_list>
167
+
168
+ <log_export>
169
+ <label></label>
170
+ <frontend_model>avatax/adminhtml_system_config_form_field_export</frontend_model>
171
+ <sort_order>130</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>0</show_in_website>
174
+ <show_in_store>0</show_in_store>
175
+ </log_export>
176
+
177
+ <title_data_mapping translate="label">
178
+ <label><![CDATA[<strong>Data Mapping</strong>]]></label>
179
+ <frontend_type>label</frontend_type>
180
+ <sort_order>200</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ </title_data_mapping>
185
+ <cust_code_format translate="label comment">
186
+ <label>Customer Code Format</label>
187
+ <comment><![CDATA[Recommended: <code>customer_id</code>]]></comment>
188
+ <frontend_type>select</frontend_type>
189
+ <source_model>avatax/source_customercodeformat</source_model>
190
+ <sort_order>205</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>1</show_in_store>
194
+ </cust_code_format>
195
+ <shipping_sku translate="label comment">
196
+ <label>Shipping Sku</label>
197
+ <comment>Required. The sku sent to denote shipping costs.</comment>
198
+ <frontend_type>text</frontend_type>
199
+ <sort_order>210</sort_order>
200
+ <show_in_default>1</show_in_default>
201
+ <show_in_website>1</show_in_website>
202
+ <show_in_store>1</show_in_store>
203
+ </shipping_sku>
204
+ <gw_order_sku translate="label comment">
205
+ <label>Gift Wrap Order Sku</label>
206
+ <comment>Required. The sku sent to denote gift wrap order costs.</comment>
207
+ <frontend_type>text</frontend_type>
208
+ <sort_order>215</sort_order>
209
+ <show_in_default>1</show_in_default>
210
+ <show_in_website>1</show_in_website>
211
+ <show_in_store>1</show_in_store>
212
+ </gw_order_sku>
213
+ <gw_items_sku translate="label comment">
214
+ <label>Gift Wrap Items Sku</label>
215
+ <comment>Required. The sku sent to denote gift wrap items costs.</comment>
216
+ <frontend_type>text</frontend_type>
217
+ <sort_order>216</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>1</show_in_website>
220
+ <show_in_store>1</show_in_store>
221
+ </gw_items_sku>
222
+ <gw_printed_card_sku translate="label comment">
223
+ <label>Gift Wrap Printed Card Sku</label>
224
+ <comment>Required. The sku sent to denote gift wrap printed card costs.</comment>
225
+ <frontend_type>text</frontend_type>
226
+ <sort_order>217</sort_order>
227
+ <show_in_default>1</show_in_default>
228
+ <show_in_website>1</show_in_website>
229
+ <show_in_store>1</show_in_store>
230
+ </gw_printed_card_sku>
231
+ <adjustment_positive_sku translate="label comment">
232
+ <label>Adjustment Refund Sku</label>
233
+ <comment>Required. The sku sent to denote positive ajustments.</comment>
234
+ <frontend_type>text</frontend_type>
235
+ <sort_order>220</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ </adjustment_positive_sku>
240
+ <adjustment_negative_sku translate="label comment">
241
+ <label>Adjustment Fee Sku</label>
242
+ <comment>Required. The sku sent to denote negative ajustments.</comment>
243
+ <frontend_type>text</frontend_type>
244
+ <sort_order>230</sort_order>
245
+ <show_in_default>1</show_in_default>
246
+ <show_in_website>1</show_in_website>
247
+ <show_in_store>1</show_in_store>
248
+ </adjustment_negative_sku>
249
+ <sales_person_code translate="label comment">
250
+ <label>Sales Person Code</label>
251
+ <comment>Optional. The sales person code for orders.</comment>
252
+ <frontend_type>text</frontend_type>
253
+ <sort_order>240</sort_order>
254
+ <show_in_default>1</show_in_default>
255
+ <show_in_website>1</show_in_website>
256
+ <show_in_store>1</show_in_store>
257
+ </sales_person_code>
258
+ <location_code translate="label comment">
259
+ <label>Location Code</label>
260
+ <comment>Optional. The location code for orders.</comment>
261
+ <frontend_type>text</frontend_type>
262
+ <sort_order>250</sort_order>
263
+ <show_in_default>1</show_in_default>
264
+ <show_in_website>1</show_in_website>
265
+ <show_in_store>1</show_in_store>
266
+ </location_code>
267
+ <line_ref1_code translate="label">
268
+ <label>Reference Code 1</label>
269
+ <frontend_type>text</frontend_type>
270
+ <sort_order>260</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>1</show_in_store>
274
+ </line_ref1_code>
275
+ <line_ref2_code translate="label comment">
276
+ <label>Reference Code 2</label>
277
+ <comment>Optional. An attribute code to pass with each product. See product attributes in catalog > attributes.</comment>
278
+ <frontend_type>text</frontend_type>
279
+ <sort_order>270</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>1</show_in_store>
283
+ </line_ref2_code>
284
+
285
+ <title_address_validation translate="label">
286
+ <label><![CDATA[<strong>Shipping Address Options</strong>]]></label>
287
+ <frontend_type>label</frontend_type>
288
+ <sort_order>300</sort_order>
289
+ <show_in_default>1</show_in_default>
290
+ <show_in_website>1</show_in_website>
291
+ <show_in_store>1</show_in_store>
292
+ </title_address_validation>
293
+ <validate_address translate="label comment">
294
+ <label>Address Validation</label>
295
+ <frontend_type>select</frontend_type>
296
+ <source_model>avatax/source_addressvalidation</source_model>
297
+ <comment>Require a validated address from AvaTax to checkout</comment>
298
+ <sort_order>301</sort_order>
299
+ <show_in_default>1</show_in_default>
300
+ <show_in_website>1</show_in_website>
301
+ <show_in_store>1</show_in_store>
302
+ </validate_address>
303
+ <validate_address_message translate="label comment">
304
+ <label>Multi-Address Address Validation Error</label>
305
+ <comment>Only applies if address validation is enabled and shows ONLY for the multi-address checkout</comment>
306
+ <frontend_type>textarea</frontend_type>
307
+ <sort_order>331</sort_order>
308
+ <show_in_default>1</show_in_default>
309
+ <show_in_website>1</show_in_website>
310
+ <show_in_store>1</show_in_store>
311
+ </validate_address_message>
312
+ <normalize_address translate="label comment">
313
+ <label>Address Normalization</label>
314
+ <frontend_type>select</frontend_type>
315
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
316
+ <comment>Replace address with well-formed one from AvaTax</comment>
317
+ <sort_order>320</sort_order>
318
+ <show_in_default>1</show_in_default>
319
+ <show_in_website>1</show_in_website>
320
+ <show_in_store>1</show_in_store>
321
+ </normalize_address>
322
+ <onepage_normalize_message translate="label comment">
323
+ <label>Onepage Checkout Address Normalized Notice</label>
324
+ <comment>Only applies if address normalization is enabled</comment>
325
+ <frontend_type>textarea</frontend_type>
326
+ <sort_order>330</sort_order>
327
+ <show_in_default>1</show_in_default>
328
+ <show_in_website>1</show_in_website>
329
+ <show_in_store>1</show_in_store>
330
+ </onepage_normalize_message>
331
+ <multiaddress_normalize_message translate="label comment">
332
+ <label>Multi-Address Checkout Address Normalized Notice</label>
333
+ <comment>Only applies if address normalization is enabled</comment>
334
+ <frontend_type>textarea</frontend_type>
335
+ <sort_order>330</sort_order>
336
+ <show_in_default>1</show_in_default>
337
+ <show_in_website>1</show_in_website>
338
+ <show_in_store>1</show_in_store>
339
+ </multiaddress_normalize_message>
340
+
341
+ <title_request_settings translate="label">
342
+ <label><![CDATA[<strong>Request Settings</strong>]]></label>
343
+ <frontend_type>label</frontend_type>
344
+ <sort_order>340</sort_order>
345
+ <show_in_default>1</show_in_default>
346
+ <show_in_website>1</show_in_website>
347
+ <show_in_store>1</show_in_store>
348
+ </title_request_settings>
349
+ <field_required_list>
350
+ <label>Required Fileds</label>
351
+ <frontend_type>multiselect</frontend_type>
352
+ <source_model>avatax/source_fieldlist</source_model>
353
+ <sort_order>350</sort_order>
354
+ <show_in_default>1</show_in_default>
355
+ <show_in_website>1</show_in_website>
356
+ <show_in_store>1</show_in_store>
357
+ </field_required_list>
358
+ <field_rule>
359
+ <label>Field Rule</label>
360
+ <comment>Example: ' ,-,_'</comment>
361
+ <frontend_type>text</frontend_type>
362
+ <sort_order>360</sort_order>
363
+ <show_in_default>1</show_in_default>
364
+ <show_in_website>1</show_in_website>
365
+ <show_in_store>1</show_in_store>
366
+ </field_rule>
367
+
368
+ <title_error_handling translate="label">
369
+ <label><![CDATA[<strong>Error Handling</strong>]]></label>
370
+ <frontend_type>label</frontend_type>
371
+ <sort_order>400</sort_order>
372
+ <show_in_default>1</show_in_default>
373
+ <show_in_website>1</show_in_website>
374
+ <show_in_store>1</show_in_store>
375
+ </title_error_handling>
376
+ <error_full_stop translate="label">
377
+ <label>Action on Error</label>
378
+ <frontend_type>select</frontend_type>
379
+ <source_model>avatax/source_error</source_model>
380
+ <sort_order>410</sort_order>
381
+ <show_in_default>1</show_in_default>
382
+ <show_in_website>1</show_in_website>
383
+ <show_in_store>1</show_in_store>
384
+ </error_full_stop>
385
+ <error_frontend_message translate="label">
386
+ <label>Frontend Error Message</label>
387
+ <frontend_type>textarea</frontend_type>
388
+ <sort_order>420</sort_order>
389
+ <show_in_default>1</show_in_default>
390
+ <show_in_website>1</show_in_website>
391
+ <show_in_store>1</show_in_store>
392
+ </error_frontend_message>
393
+ <error_backend_message translate="label">
394
+ <label>Backend Error Message</label>
395
+ <frontend_type>textarea</frontend_type>
396
+ <sort_order>430</sort_order>
397
+ <show_in_default>1</show_in_default>
398
+ <show_in_website>1</show_in_website>
399
+ <show_in_store>1</show_in_store>
400
+ </error_backend_message>
401
+ <error_notification_toolbar translate="label comment">
402
+ <label>Notification Toolbar</label>
403
+ <frontend_type>select</frontend_type>
404
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
405
+ <comment>If there are issues syncing invoice or credit memo data, show warning in admin notification toolbar.</comment>
406
+ <sort_order>440</sort_order>
407
+ <show_in_default>1</show_in_default>
408
+ <show_in_website>0</show_in_website>
409
+ <show_in_store>0</show_in_store>
410
+ </error_notification_toolbar>
411
+ </fields>
412
+ </avatax>
413
+ <classes>
414
+ <fields>
415
+ <shipping_tax_class>
416
+ <!-- Will always be FR020100. It is hardcoded in OnePica_AvaTax_Helper_Tax_Data. -->
417
+ <show_in_default>0</show_in_default>
418
+ <show_in_website>0</show_in_website>
419
+ <show_in_store>0</show_in_store>
420
+ </shipping_tax_class>
421
+ </fields>
422
+ </classes>
423
+ <calculation>
424
+ <fields>
425
+ <based_on>
426
+ <!-- AvaTax always computes tax based on ship from and ship to addresses. -->
427
+ <show_in_default>0</show_in_default>
428
+ <show_in_website>0</show_in_website>
429
+ <show_in_store>0</show_in_store>
430
+ </based_on>
431
+ <price_includes_tax>
432
+ <!-- Items should not include tax so that AvaTax can calculate it. -->
433
+ <show_in_default>0</show_in_default>
434
+ <show_in_website>0</show_in_website>
435
+ <show_in_store>0</show_in_store>
436
+ </price_includes_tax>
437
+ <shipping_includes_tax>
438
+ <!-- Shipping should not include tax so that AvaTax can calculate it. -->
439
+ <show_in_default>0</show_in_default>
440
+ <show_in_website>0</show_in_website>
441
+ <show_in_store>0</show_in_store>
442
+ </shipping_includes_tax>
443
+ <apply_after_discount>
444
+ <!-- Always apply discount first since AvaTax doesn't support line-level item discount amounts -->
445
+ <show_in_default>0</show_in_default>
446
+ <show_in_website>0</show_in_website>
447
+ <show_in_store>0</show_in_store>
448
+ </apply_after_discount>
449
+ <discount_tax>
450
+ <!-- Always apply discount first since AvaTax doesn't support line-level item discount amounts -->
451
+ <show_in_default>0</show_in_default>
452
+ <show_in_website>0</show_in_website>
453
+ <show_in_store>0</show_in_store>
454
+ </discount_tax>
455
+ <apply_tax_on>
456
+ <!-- Always apply tax to custom price if available -->
457
+ <show_in_default>0</show_in_default>
458
+ <show_in_website>0</show_in_website>
459
+ <show_in_store>0</show_in_store>
460
+ </apply_tax_on>
461
+ <algorithm>
462
+ <!-- Always based on row (actually determined by Avalara) -->
463
+ <show_in_default>0</show_in_default>
464
+ <show_in_website>0</show_in_website>
465
+ <show_in_store>0</show_in_store>
466
+ </algorithm>
467
+ </fields>
468
+ </calculation>
469
+ <defaults>
470
+ <fields>
471
+ <region translate="comment">
472
+ <comment>Set this to "*" (asterisk) to stop unneeded requests to Avalara and to help speed up page loads</comment>
473
+ </region>
474
+ <postcode translate="comment">
475
+ <comment>Set this to "*" (asterisk) to stop unneeded requests to Avalara and to help speed up page loads</comment>
476
+ </postcode>
477
+ </fields>
478
+ </defaults>
479
+ <display>
480
+ <fields>
481
+ <type>
482
+ <show_in_default>0</show_in_default>
483
+ <show_in_website>0</show_in_website>
484
+ <show_in_store>0</show_in_store>
485
+ </type>
486
+ <shipping>
487
+ <show_in_default>0</show_in_default>
488
+ <show_in_website>0</show_in_website>
489
+ <show_in_store>0</show_in_store>
490
+ </shipping>
491
+ </fields>
492
+ </display>
493
+ <sales_display>
494
+ <fields>
495
+ <full_summary>
496
+ <!-- Jurisdiction data is not kept in Magento at this time after the quote -->
497
+ <show_in_default>0</show_in_default>
498
+ <show_in_website>0</show_in_website>
499
+ <show_in_store>0</show_in_store>
500
+ </full_summary>
501
+ </fields>
502
+ </sales_display>
503
+ </groups>
504
+ </tax>
505
+ <shipping>
506
+ <groups>
507
+ <origin>
508
+ <fields>
509
+ <street translate="label">
510
+ <label><![CDATA[Number & Street]]></label>
511
+ <frontend_type>text</frontend_type>
512
+ <sort_order>99</sort_order>
513
+ <show_in_default>1</show_in_default>
514
+ <show_in_website>1</show_in_website>
515
+ <show_in_store>1</show_in_store>
516
+ </street>
517
+ </fields>
518
+ </origin>
519
+ </groups>
520
+ </shipping>
521
+ </sections>
522
+ </config>
 
app/code/community/OnePica/AvaTax/lib/AvaTax.php CHANGED
@@ -93,9 +93,4 @@ function getCurrentDate()
93
  {
94
  $dateTime=new DateTime();
95
  return $dateTime->format("Y-m-d");
96
- }
97
-
98
-
99
-
100
-
101
- ?>
93
  {
94
  $dateTime=new DateTime();
95
  return $dateTime->format("Y-m-d");
96
+ }
 
 
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/ATConfig.class.php CHANGED
@@ -65,7 +65,3 @@ new ATConfig('Default', array(
65
  'name' => 'PHPAdapter',
66
  'trace' => true) // change to false for production
67
  );
68
-
69
-
70
-
71
- ?>
65
  'name' => 'PHPAdapter',
66
  'trace' => true) // change to false for production
67
  );
 
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/ATObject.class.php CHANGED
@@ -50,6 +50,4 @@ class ATObject
50
  }
51
  }
52
  public function ivars() { return $this->_ivars; }
53
- }
54
-
55
- ?>
50
  }
51
  }
52
  public function ivars() { return $this->_ivars; }
53
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/AVObject.class.php CHANGED
File without changes
app/code/community/OnePica/AvaTax/lib/classes/Address.class.php CHANGED
@@ -224,6 +224,4 @@ class Address
224
  $this->TaxRegionId === $other->TaxRegionId
225
  );
226
  }
227
- }
228
-
229
- ?>
224
  $this->TaxRegionId === $other->TaxRegionId
225
  );
226
  }
227
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/AddressServiceSoap.class.php CHANGED
@@ -151,7 +151,3 @@ class AddressServiceSoap extends AvalaraSoapClient
151
 
152
 
153
  }
154
-
155
-
156
-
157
- ?>
151
 
152
 
153
  }
 
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/AddressType.class.php CHANGED
@@ -36,5 +36,3 @@ class AddressType extends Enum
36
  // Unfortunate boiler plate due to polymorphism issues on static functions
37
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
38
  }
39
-
40
- ?>
36
  // Unfortunate boiler plate due to polymorphism issues on static functions
37
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
38
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/AdjustTaxRequest.class.php CHANGED
@@ -72,6 +72,4 @@ class AdjustTaxRequest
72
 
73
 
74
 
75
- }
76
-
77
- ?>
72
 
73
 
74
 
75
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/AdjustTaxResult.class.php CHANGED
@@ -258,6 +258,4 @@ class AdjustTaxResult //extends GetTaxResult
258
 
259
 
260
 
261
- }
262
-
263
- ?>
258
 
259
 
260
 
261
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/ApplyPaymentRequest.class.php CHANGED
@@ -74,6 +74,4 @@ class ApplyPaymentRequest
74
  */
75
  public function getPaymentDate(){ return $this->PaymentDate;} //date
76
 
77
- }
78
-
79
- ?>
74
  */
75
  public function getPaymentDate(){ return $this->PaymentDate;} //date
76
 
77
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/ApplyPaymentResult.class.php CHANGED
@@ -10,6 +10,4 @@ class ApplyPaymentResult extends BaseResult
10
 
11
 
12
 
13
- }
14
-
15
- ?>
10
 
11
 
12
 
13
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/AvalaraSoapClient.class.php CHANGED
@@ -30,7 +30,3 @@ class AvalaraSoapClient
30
  public function __getLastResponseHeaders() { return $this->client->__getLastResponseHeaders(); }
31
 
32
  }
33
-
34
-
35
-
36
- ?>
30
  public function __getLastResponseHeaders() { return $this->client->__getLastResponseHeaders(); }
31
 
32
  }
 
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/BaseResult.class.php CHANGED
@@ -34,6 +34,4 @@ class BaseResult
34
  */
35
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
36
 
37
- }
38
-
39
- ?>
34
  */
35
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
36
 
37
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/AuditMessage.class.php CHANGED
@@ -11,5 +11,3 @@ class AuditMessage {
11
  public function getMessage(){return $this->Message;} // string
12
 
13
  }
14
-
15
- ?>
11
  public function getMessage(){return $this->Message;} // string
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/AvaTaxBatchSvc.php CHANGED
@@ -68,7 +68,4 @@ function xml_pretty_printer($xml, $html_output=FALSE)
68
 
69
  $xml = join("n", $new_xml_lines);
70
  return ($html_output) ? '<pre>' . htmlentities($xml) . '</pre>' : $xml;
71
- }
72
-
73
-
74
- ?>
68
 
69
  $xml = join("n", $new_xml_lines);
70
  return ($html_output) ? '<pre>' . htmlentities($xml) . '</pre>' : $xml;
71
+ }
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BaseResult.class.php CHANGED
@@ -18,6 +18,4 @@ class BaseResult {
18
  public function setMessages($value){$this->Messages=$value;} // ArrayOfMessage
19
  public function getMessages(){return $this->Messages;} // ArrayOfMessage
20
 
21
- }
22
-
23
- ?>
18
  public function setMessages($value){$this->Messages=$value;} // ArrayOfMessage
19
  public function getMessages(){return $this->Messages;} // ArrayOfMessage
20
 
21
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/Batch.class.php CHANGED
@@ -84,5 +84,3 @@ class Batch {
84
  public function getCurrentRecord(){return $this->CurrentRecord;} // int
85
 
86
  }
87
-
88
- ?>
84
  public function getCurrentRecord(){return $this->CurrentRecord;} // int
85
 
86
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchDelete.class.php CHANGED
@@ -10,6 +10,4 @@ class BatchDelete {
10
  public function setDeleteRequest($value){$this->DeleteRequest=$value;} // DeleteRequest
11
  public function getDeleteRequest(){return $this->DeleteRequest;} // DeleteRequest
12
 
13
- }
14
-
15
- ?>
10
  public function setDeleteRequest($value){$this->DeleteRequest=$value;} // DeleteRequest
11
  public function getDeleteRequest(){return $this->DeleteRequest;} // DeleteRequest
12
 
13
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchDeleteResponse.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchDeleteResponse {
11
  public function getBatchDeleteResult(){return $this->BatchDeleteResult;} // DeleteResult
12
 
13
  }
14
-
15
- ?>
11
  public function getBatchDeleteResult(){return $this->BatchDeleteResult;} // DeleteResult
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFetch.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchFetch {
11
  public function getFetchRequest(){return $this->FetchRequest;} // FetchRequest
12
 
13
  }
14
-
15
- ?>
11
  public function getFetchRequest(){return $this->FetchRequest;} // FetchRequest
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFetchResponse.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchFetchResponse {
11
  public function getBatchFetchResult(){return $this->BatchFetchResult;} // BatchFetchResult
12
 
13
  }
14
-
15
- ?>
11
  public function getBatchFetchResult(){return $this->BatchFetchResult;} // BatchFetchResult
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFetchResult.class.php CHANGED
@@ -15,5 +15,3 @@ class BatchFetchResult extends BaseResult {
15
  public function getRecordCount(){return $this->RecordCount;} // int
16
 
17
  }
18
-
19
- ?>
15
  public function getRecordCount(){return $this->RecordCount;} // int
16
 
17
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFile.class.php CHANGED
@@ -50,5 +50,3 @@ class BatchFile {
50
  public function getErrorCount(){return $this->ErrorCount;} // int
51
 
52
  }
53
-
54
- ?>
50
  public function getErrorCount(){return $this->ErrorCount;} // int
51
 
52
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileDelete.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchFileDelete {
11
  public function getDeleteRequest(){return $this->DeleteRequest;} // DeleteRequest
12
 
13
  }
14
-
15
- ?>
11
  public function getDeleteRequest(){return $this->DeleteRequest;} // DeleteRequest
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileDeleteResponse.class.php CHANGED
@@ -10,6 +10,4 @@ class BatchFileDeleteResponse {
10
  public function setBatchFileDeleteResult($value){$this->BatchFileDeleteResult=$value;} // DeleteResult
11
  public function getBatchFileDeleteResult(){return $this->BatchFileDeleteResult;} // DeleteResult
12
 
13
- }
14
-
15
- ?>
10
  public function setBatchFileDeleteResult($value){$this->BatchFileDeleteResult=$value;} // DeleteResult
11
  public function getBatchFileDeleteResult(){return $this->BatchFileDeleteResult;} // DeleteResult
12
 
13
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileFetch.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchFileFetch {
11
  public function getFetchRequest(){return $this->FetchRequest;} // FetchRequest
12
 
13
  }
14
-
15
- ?>
11
  public function getFetchRequest(){return $this->FetchRequest;} // FetchRequest
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileFetchResponse.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchFileFetchResponse {
11
  public function getBatchFileFetchResult(){return $this->BatchFileFetchResult;} // BatchFileFetchResult
12
 
13
  }
14
-
15
- ?>
11
  public function getBatchFileFetchResult(){return $this->BatchFileFetchResult;} // BatchFileFetchResult
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileFetchResult.class.php CHANGED
@@ -15,5 +15,3 @@ class BatchFileFetchResult extends BaseResult {
15
  public function getRecordCount(){return $this->RecordCount;} // int
16
 
17
  }
18
-
19
- ?>
15
  public function getRecordCount(){return $this->RecordCount;} // int
16
 
17
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileSave.class.php CHANGED
@@ -10,6 +10,4 @@ class BatchFileSave {
10
  public function setBatchFile($value){$this->BatchFile=$value;} // BatchFile
11
  public function getBatchFile(){return $this->BatchFile;} // BatchFile
12
 
13
- }
14
-
15
- ?>
10
  public function setBatchFile($value){$this->BatchFile=$value;} // BatchFile
11
  public function getBatchFile(){return $this->BatchFile;} // BatchFile
12
 
13
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileSaveResponse.class.php CHANGED
@@ -10,6 +10,4 @@ class BatchFileSaveResponse {
10
  public function setBatchFileSaveResult($value){$this->BatchFileSaveResult=$value;} // BatchFileSaveResult
11
  public function getBatchFileSaveResult(){return $this->BatchFileSaveResult;} // BatchFileSaveResult
12
 
13
- }
14
-
15
- ?>
10
  public function setBatchFileSaveResult($value){$this->BatchFileSaveResult=$value;} // BatchFileSaveResult
11
  public function getBatchFileSaveResult(){return $this->BatchFileSaveResult;} // BatchFileSaveResult
12
 
13
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchFileSaveResult.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchFileSaveResult extends BaseResult {
11
  public function getBatchFileId(){return $this->BatchFileId;} // int
12
 
13
  }
14
-
15
- ?>
11
  public function getBatchFileId(){return $this->BatchFileId;} // int
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchProcess.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchProcess {
11
  public function getBatchProcessRequest(){return $this->BatchProcessRequest;} // BatchProcessRequest
12
 
13
  }
14
-
15
- ?>
11
  public function getBatchProcessRequest(){return $this->BatchProcessRequest;} // BatchProcessRequest
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchProcessRequest.class.php CHANGED
@@ -22,5 +22,3 @@ class BatchProcessRequest //extends FilterRequest
22
  public function getMaxCount(){return $this->MaxCount;} // int
23
 
24
  }
25
-
26
- ?>
22
  public function getMaxCount(){return $this->MaxCount;} // int
23
 
24
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchProcessResponse.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchProcessResponse {
11
  public function getBatchProcessResult(){return $this->BatchProcessResult;} // BatchProcessResult
12
 
13
  }
14
-
15
- ?>
11
  public function getBatchProcessResult(){return $this->BatchProcessResult;} // BatchProcessResult
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchProcessResult.class.php CHANGED
@@ -7,5 +7,3 @@
7
  class BatchProcessResult extends BaseResult {
8
 
9
  }
10
-
11
- ?>
7
  class BatchProcessResult extends BaseResult {
8
 
9
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchSave.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchSave {
11
  public function getBatch(){return $this->Batch;} // Batch
12
 
13
  }
14
-
15
- ?>
11
  public function getBatch(){return $this->Batch;} // Batch
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchSaveResponse.class.php CHANGED
@@ -11,5 +11,3 @@ class BatchSaveResponse {
11
  public function getBatchSaveResult(){return $this->BatchSaveResult;} // BatchSaveResult
12
 
13
  }
14
-
15
- ?>
11
  public function getBatchSaveResult(){return $this->BatchSaveResult;} // BatchSaveResult
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchSaveResult.class.php CHANGED
@@ -15,5 +15,3 @@ class BatchSaveResult extends BaseResult {
15
  public function getEstimatedCompletion(){return $this->EstimatedCompletion;} // dateTime
16
 
17
  }
18
-
19
- ?>
15
  public function getEstimatedCompletion(){return $this->EstimatedCompletion;} // dateTime
16
 
17
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/BatchSvc.class.php CHANGED
@@ -171,5 +171,3 @@ public function IsAuthorized($operations)
171
  }
172
 
173
  }
174
-
175
- ?>
171
  }
172
 
173
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/DeleteRequest.class.php CHANGED
@@ -22,5 +22,3 @@ class DeleteRequest //extends FilterRequest
22
  public function getMaxCount(){return $this->MaxCount;} // int
23
 
24
  }
25
-
26
- ?>
22
  public function getMaxCount(){return $this->MaxCount;} // int
23
 
24
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/DeleteResult.class.php CHANGED
@@ -6,6 +6,4 @@
6
  */
7
  class DeleteResult extends BaseResult {
8
 
9
- }
10
-
11
- ?>
6
  */
7
  class DeleteResult extends BaseResult {
8
 
9
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/FetchRequest.class.php CHANGED
@@ -43,5 +43,3 @@ class FetchRequest {
43
  public function getRecordCount(){return $this->RecordCount;} // int
44
 
45
  }
46
-
47
- ?>
43
  public function getRecordCount(){return $this->RecordCount;} // int
44
 
45
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/FilterRequest.class.php CHANGED
@@ -20,6 +20,4 @@ class FilterRequest {
20
  public function setMaxCount($value){$this->MaxCount=$value;} // int
21
  public function getMaxCount(){return $this->MaxCount;} // int
22
 
23
- }
24
-
25
- ?>
20
  public function setMaxCount($value){$this->MaxCount=$value;} // int
21
  public function getMaxCount(){return $this->MaxCount;} // int
22
 
23
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/FilterResult.class.php CHANGED
@@ -10,6 +10,4 @@ class FilterResult {
10
  public function setCount($value){$this->Count=$value;} // int
11
  public function getCount(){return $this->Count;} // int
12
 
13
- }
14
-
15
- ?>
10
  public function setCount($value){$this->Count=$value;} // int
11
  public function getCount(){return $this->Count;} // int
12
 
13
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/IsAuthorized.class.php CHANGED
@@ -11,5 +11,3 @@ class IsAuthorized {
11
  public function getOperations(){return $this->Operations;} // string
12
 
13
  }
14
-
15
- ?>
11
  public function getOperations(){return $this->Operations;} // string
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/IsAuthorizedResponse.class.php CHANGED
@@ -10,6 +10,4 @@ class IsAuthorizedResponse {
10
  public function setIsAuthorizedResult($value){$this->IsAuthorizedResult=$value;} // IsAuthorizedResult
11
  public function getIsAuthorizedResult(){return $this->IsAuthorizedResult;} // IsAuthorizedResult
12
 
13
- }
14
-
15
- ?>
10
  public function setIsAuthorizedResult($value){$this->IsAuthorizedResult=$value;} // IsAuthorizedResult
11
  public function getIsAuthorizedResult(){return $this->IsAuthorizedResult;} // IsAuthorizedResult
12
 
13
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/IsAuthorizedResult.class.php CHANGED
@@ -15,5 +15,3 @@ class IsAuthorizedResult {
15
  public function getExpires(){return $this->Expires;} // dateTime
16
 
17
  }
18
-
19
- ?>
15
  public function getExpires(){return $this->Expires;} // dateTime
16
 
17
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/Message.class.php CHANGED
@@ -35,5 +35,3 @@ class Message {
35
  public function getName(){return $this->Name;} // string
36
 
37
  }
38
-
39
- ?>
35
  public function getName(){return $this->Name;} // string
36
 
37
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/Ping.class.php CHANGED
@@ -11,5 +11,3 @@ class Ping {
11
  public function getMessage(){return $this->Message;} // string
12
 
13
  }
14
-
15
- ?>
11
  public function getMessage(){return $this->Message;} // string
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/PingResponse.class.php CHANGED
@@ -11,5 +11,3 @@ class PingResponse {
11
  public function getPingResult(){return $this->PingResult;} // PingResult
12
 
13
  }
14
-
15
- ?>
11
  public function getPingResult(){return $this->PingResult;} // PingResult
12
 
13
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/PingResult.class.php CHANGED
@@ -24,5 +24,3 @@ class PingResult extends BaseResult
24
  //public function getMessages() { return EnsureIsArray($this->Messages->Message);}
25
 
26
  }
27
-
28
- ?>
24
  //public function getMessages() { return EnsureIsArray($this->Messages->Message);}
25
 
26
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/Profile.class.php CHANGED
@@ -22,6 +22,4 @@ class Profile {
22
  public function setMachine($value){$this->Machine=$value;} // string
23
  public function getMachine(){return $this->Machine;} // string
24
 
25
- }
26
-
27
- ?>
22
  public function setMachine($value){$this->Machine=$value;} // string
23
  public function getMachine(){return $this->Machine;} // string
24
 
25
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BatchSvc/SeverityLevel.class.php CHANGED
@@ -10,6 +10,4 @@ class SeverityLevel {
10
  const Error = 'Error';
11
  const Exception = 'Exception';
12
 
13
- }
14
-
15
- ?>
10
  const Error = 'Error';
11
  const Exception = 'Exception';
12
 
13
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/BoundaryLevel.class.php CHANGED
@@ -54,7 +54,4 @@ class BoundaryLevel extends Enum
54
 
55
  // Unfortunate boiler plate due to polymorphism issues on static functions
56
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
57
- }
58
-
59
-
60
- ?>
54
 
55
  // Unfortunate boiler plate due to polymorphism issues on static functions
56
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
57
+ }
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/CancelCode.class.php CHANGED
@@ -69,6 +69,4 @@ class CancelCode extends Enum
69
  // Unfortunate boiler plate due to polymorphism issues on static functions
70
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
71
 
72
- }
73
-
74
- ?>
69
  // Unfortunate boiler plate due to polymorphism issues on static functions
70
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
71
 
72
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/CancelTaxRequest.class.php CHANGED
@@ -52,10 +52,4 @@ class CancelTaxRequest extends TaxRequest
52
 
53
  public function setCancelCode($value) { CancelCode::Validate($value); $this->CancelCode = $value; return $this; }
54
 
55
- }
56
-
57
-
58
-
59
-
60
-
61
- ?>
52
 
53
  public function setCancelCode($value) { CancelCode::Validate($value); $this->CancelCode = $value; return $this; }
54
 
55
+ }
 
 
 
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/CancelTaxResult.class.php CHANGED
@@ -53,6 +53,4 @@ class CancelTaxResult // extends BaseResult
53
 
54
 
55
 
56
- }
57
-
58
- ?>
53
 
54
 
55
 
56
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/CommitTaxRequest.class.php CHANGED
@@ -40,7 +40,4 @@ class CommitTaxRequest extends TaxRequest
40
 
41
 
42
 
43
- }
44
-
45
-
46
- ?>
40
 
41
 
42
 
43
+ }
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/CommitTaxResult.class.php CHANGED
@@ -49,6 +49,4 @@ class CommitTaxResult //extends BaseResult
49
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
50
 
51
 
52
- }
53
-
54
- ?>
49
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
50
 
51
 
52
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/DetailLevel.class.php CHANGED
@@ -52,6 +52,4 @@ class DetailLevel extends Enum
52
 
53
  // Unfortunate boiler plate due to polymorphism issues on static functions
54
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
55
- }
56
-
57
- ?>
52
 
53
  // Unfortunate boiler plate due to polymorphism issues on static functions
54
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
55
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/DocStatus.class.php CHANGED
@@ -82,6 +82,4 @@ class DocStatus extends Enum
82
  // Unfortunate boiler plate due to polymorphism issues on static functions
83
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
84
 
85
- }
86
-
87
- ?>
82
  // Unfortunate boiler plate due to polymorphism issues on static functions
83
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
84
 
85
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/DocumentType.class.php CHANGED
@@ -85,6 +85,4 @@ class DocumentType extends Enum
85
 
86
 
87
 
88
- }
89
-
90
- ?>
85
 
86
 
87
 
88
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/DynamicSoapClient.class.php CHANGED
@@ -59,5 +59,3 @@ class DynamicSoapClient extends SoapClient
59
  }
60
 
61
  }
62
-
63
- ?>
59
  }
60
 
61
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/Enum.class.php CHANGED
@@ -27,6 +27,4 @@ class Enum
27
 
28
  throw new Exception('Invalid '.$class.' "'.$value.'" - must be one of "'.implode('"|"',$values).'"');
29
  }
30
- }
31
-
32
- ?>
27
 
28
  throw new Exception('Invalid '.$class.' "'.$value.'" - must be one of "'.implode('"|"',$values).'"');
29
  }
30
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/GetTaxHistoryRequest.class.php CHANGED
@@ -49,6 +49,4 @@ class GetTaxHistoryRequest extends TaxRequest
49
 
50
  public function setDetailLevel($value) { DetailLevel::Validate($value); $this->DetailLevel = $value; return $this; } //Summary or Document or Line or Tax or Diagnostic - enum
51
 
52
- }
53
-
54
- ?>
49
 
50
  public function setDetailLevel($value) { DetailLevel::Validate($value); $this->DetailLevel = $value; return $this; } //Summary or Document or Line or Tax or Diagnostic - enum
51
 
52
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/GetTaxHistoryResult.class.php CHANGED
@@ -67,6 +67,4 @@ class GetTaxHistoryResult //extends BaseResult
67
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
68
 
69
 
70
- }
71
-
72
- ?>
67
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
68
 
69
 
70
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/GetTaxRequest.class.php CHANGED
@@ -258,17 +258,17 @@ class GetTaxRequest
258
  * </p>
259
  * <p>
260
  * The standard values for the CustomerUsageType (A-L).<br/>
261
- A � Federal Government<br/>
262
- B � State/Local Govt.<br/>
263
- C � Tribal Government<br/>
264
- D � Foreign Diplomat<br/>
265
- E � Charitable Organization<br/>
266
- F � Religious/Education<br/>
267
- G � Resale<br/>
268
- H � Agricultural Production<br/>
269
- I � Industrial Prod/Mfg.<br/>
270
- J � Direct Pay Permit<br/>
271
- K � Direct Mail<br/>
272
  L - Other<br/>
273
  * </p>
274
  * @param customerUsageType
@@ -526,6 +526,4 @@ class GetTaxRequest
526
 
527
 
528
 
529
- }
530
-
531
- ?>
258
  * </p>
259
  * <p>
260
  * The standard values for the CustomerUsageType (A-L).<br/>
261
+ A � Federal Government<br/>
262
+ B � State/Local Govt.<br/>
263
+ C � Tribal Government<br/>
264
+ D � Foreign Diplomat<br/>
265
+ E � Charitable Organization<br/>
266
+ F � Religious/Education<br/>
267
+ G � Resale<br/>
268
+ H � Agricultural Production<br/>
269
+ I � Industrial Prod/Mfg.<br/>
270
+ J � Direct Pay Permit<br/>
271
+ K � Direct Mail<br/>
272
  L - Other<br/>
273
  * </p>
274
  * @param customerUsageType
526
 
527
 
528
 
529
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/GetTaxResult.class.php CHANGED
@@ -258,6 +258,4 @@ class GetTaxResult // extends BaseResult
258
 
259
 
260
 
261
- }
262
-
263
- ?>
258
 
259
 
260
 
261
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/IsAuthorizedResult.class.php CHANGED
@@ -76,6 +76,4 @@ class IsAuthorizedResult //extends BaseResult
76
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
77
 
78
 
79
- }
80
-
81
- ?>
76
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
77
 
78
 
79
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/JurisdictionType.class.php CHANGED
@@ -70,6 +70,4 @@ class JurisdictionType
70
 
71
  */
72
 
73
- }
74
-
75
- ?>
70
 
71
  */
72
 
73
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/Line.class.php CHANGED
@@ -122,17 +122,17 @@ class Line
122
  * </p>
123
  * <p>
124
  * The standard values for the CustomerUsageType (A-L).<br/>
125
- A � Federal Government<br/>
126
- B � State/Local Govt.<br/>
127
- C � Tribal Government<br/>
128
- D � Foreign Diplomat<br/>
129
- E � Charitable Organization<br/>
130
- F � Religious/Education<br/>
131
- G � Resale<br/>
132
- H � Agricultural Production<br/>
133
- I � Industrial Prod/Mfg.<br/>
134
- J � Direct Pay Permit<br/>
135
- K � Direct Mail<br/>
136
  L - Other<br/>
137
  * </p>
138
  * @param string $value
@@ -261,7 +261,4 @@ class Line
261
 
262
  /**#@-*/
263
 
264
- }
265
-
266
-
267
- ?>
122
  * </p>
123
  * <p>
124
  * The standard values for the CustomerUsageType (A-L).<br/>
125
+ A � Federal Government<br/>
126
+ B � State/Local Govt.<br/>
127
+ C � Tribal Government<br/>
128
+ D � Foreign Diplomat<br/>
129
+ E � Charitable Organization<br/>
130
+ F � Religious/Education<br/>
131
+ G � Resale<br/>
132
+ H � Agricultural Production<br/>
133
+ I � Industrial Prod/Mfg.<br/>
134
+ J � Direct Pay Permit<br/>
135
+ K � Direct Mail<br/>
136
  L - Other<br/>
137
  * </p>
138
  * @param string $value
261
 
262
  /**#@-*/
263
 
264
+ }
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/Message.class.php CHANGED
@@ -83,6 +83,4 @@ class Message
83
  public function setSource($value) { $this->Source = $value; return $this; }
84
  public function setName($value) { $this->Name = $value; return $this; }
85
 
86
- }
87
-
88
- ?>
83
  public function setSource($value) { $this->Source = $value; return $this; }
84
  public function setName($value) { $this->Name = $value; return $this; }
85
 
86
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/PingResult.class.php CHANGED
@@ -71,6 +71,4 @@ class PingResult //extends BaseResult
71
 
72
 
73
 
74
- }
75
-
76
- ?>
71
 
72
 
73
 
74
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/PostTaxRequest.class.php CHANGED
@@ -76,9 +76,4 @@ class PostTaxRequest extends TaxRequest
76
  */
77
  public function setNewDocCode($value) { $this->NewDocCode = $value; }
78
 
79
- }
80
-
81
-
82
-
83
-
84
- ?>
76
  */
77
  public function setNewDocCode($value) { $this->NewDocCode = $value; }
78
 
79
+ }
 
 
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/PostTaxResult.class.php CHANGED
@@ -49,6 +49,4 @@ class PostTaxResult //extends BaseResult
49
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
50
 
51
 
52
- }
53
-
54
- ?>
49
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
50
 
51
 
52
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/ReconcileTaxHistoryRequest.class.php CHANGED
@@ -86,6 +86,4 @@ class ReconcileTaxHistoryRequest// extends TaxRequest
86
  public function getPageSize(){return $this->PageSize;} // int
87
 
88
 
89
- }
90
-
91
- ?>
86
  public function getPageSize(){return $this->PageSize;} // int
87
 
88
 
89
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/ReconcileTaxHistoryResult.class.php CHANGED
@@ -106,7 +106,5 @@ class ReconcileTaxHistoryResult //extends SearchTaxHistoryResult
106
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
107
 
108
 
109
-
110
- }
111
 
112
- ?>
106
  public function getMessages() { return EnsureIsArray($this->Messages->Message); }
107
 
108
 
 
 
109
 
110
+ }
app/code/community/OnePica/AvaTax/lib/classes/SearchTaxHistoryResult.class.php CHANGED
@@ -97,6 +97,4 @@ class SearchTaxHistoryResult //extends BaseResult
97
 
98
 
99
 
100
- }
101
-
102
- ?>
97
 
98
 
99
 
100
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/ServiceMode.class.php CHANGED
@@ -43,5 +43,4 @@ class ServiceMode extends Enum
43
 
44
  // Unfortunate boiler plate due to polymorphism issues on static functions
45
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
46
- }
47
- ?>
43
 
44
  // Unfortunate boiler plate due to polymorphism issues on static functions
45
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
46
+ }
 
app/code/community/OnePica/AvaTax/lib/classes/SeverityLevel.class.php CHANGED
@@ -35,6 +35,4 @@ class SeverityLevel extends Enum
35
 
36
  // Unfortunate boiler plate due to polymorphism issues on static functions
37
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
38
- }
39
-
40
- ?>
35
 
36
  // Unfortunate boiler plate due to polymorphism issues on static functions
37
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
38
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/TaxDetail.class.php CHANGED
@@ -187,10 +187,4 @@ class TaxDetail
187
  public function getTaxGroup(){ return $this->TaxGroup;}
188
 
189
 
190
- }
191
-
192
-
193
-
194
-
195
-
196
- ?>
187
  public function getTaxGroup(){ return $this->TaxGroup;}
188
 
189
 
190
+ }
 
 
 
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/TaxLine.class.php CHANGED
@@ -130,5 +130,4 @@ class TaxLine
130
 
131
 
132
 
133
- }
134
- ?>
130
 
131
 
132
 
133
+ }
 
app/code/community/OnePica/AvaTax/lib/classes/TaxOverride.class.php CHANGED
@@ -37,6 +37,4 @@ class TaxOverride
37
  public function getReason(){return $this->Reason;} //string
38
 
39
 
40
- }
41
-
42
- ?>
37
  public function getReason(){return $this->Reason;} //string
38
 
39
 
40
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/TaxOverrideType.class.php CHANGED
@@ -11,6 +11,4 @@ class TaxOverrideType
11
  public static $Exemption = "Exemption";
12
  public static $TaxDate = "TaxDate";
13
 
14
- }
15
-
16
- ?>
11
  public static $Exemption = "Exemption";
12
  public static $TaxDate = "TaxDate";
13
 
14
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/TaxRequest.class.php CHANGED
@@ -158,6 +158,4 @@ class TaxRequest
158
 
159
  }
160
 
161
- }
162
-
163
- ?>
158
 
159
  }
160
 
161
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/TaxServiceSoap.class.php CHANGED
@@ -304,5 +304,3 @@ public function __construct($configurationName = 'Default')
304
  }
305
 
306
  }
307
-
308
- ?>
304
  }
305
 
306
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/TaxType.class.php CHANGED
@@ -32,8 +32,4 @@ class TaxType// extends Enum
32
 
33
  */
34
 
35
- }
36
-
37
-
38
-
39
- ?>
32
 
33
  */
34
 
35
+ }
 
 
 
 
app/code/community/OnePica/AvaTax/lib/classes/TextCase.class.php CHANGED
@@ -29,6 +29,4 @@ class TextCase extends Enum
29
 
30
  // Unfortunate boiler plate due to polymorphism issues on static functions
31
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
32
- }
33
-
34
- ?>
29
 
30
  // Unfortunate boiler plate due to polymorphism issues on static functions
31
  public static function Validate($value) { self::__Validate($value,self::Values(),__CLASS__); }
32
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/ValidAddress.class.php CHANGED
@@ -473,6 +473,4 @@ class ValidAddress //extends Address - or it should - SoapClient has issues mapp
473
 
474
 
475
 
476
- }
477
-
478
- ?>
473
 
474
 
475
 
476
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/ValidateRequest.class.php CHANGED
@@ -188,5 +188,3 @@ class ValidateRequest
188
 
189
  public function getCoordinates() { return $this->Coordinates; }
190
  }
191
-
192
- ?>
188
 
189
  public function getCoordinates() { return $this->Coordinates; }
190
  }
 
 
app/code/community/OnePica/AvaTax/lib/classes/ValidateResult.class.php CHANGED
@@ -84,6 +84,4 @@ class ValidateResult// extends BaseResult
84
  return $this->Taxable;
85
  }
86
 
87
- }
88
-
89
- ?>
84
  return $this->Taxable;
85
  }
86
 
87
+ }
 
 
app/code/community/OnePica/AvaTax/lib/classes/wsdl/Address.wsdl CHANGED
File without changes
app/code/community/OnePica/AvaTax/lib/classes/wsdl/BatchSvc.wsdl CHANGED
File without changes
app/code/community/OnePica/AvaTax/lib/classes/wsdl/Tax.wsdl CHANGED
File without changes
app/code/community/OnePica/AvaTax/lib/functions.php CHANGED
File without changes
app/code/community/OnePica/AvaTax/sql/avatax_records_setup/mysql4-install-0.1.0.php CHANGED
@@ -1,33 +1,37 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- $installer = $this;
20
-
21
- $installer->startSetup();
22
-
23
- try {
24
- $installer->run("
25
-
26
- ALTER TABLE `" . $this->getTable('tax/tax_class') . "`
27
- ADD `op_avatax_code` VARCHAR(255) DEFAULT '' NOT NULL COMMENT 'Used by One Pica AvaTax extension'
28
- AFTER `class_name`;
29
-
30
- ");
31
- } catch(Exception $e) { }
32
-
33
- $installer->endSetup();
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ $installer = $this;
18
+ $installer->startSetup();
19
+ /* @var $this Mage_Core_Model_Resource_Setup */
20
+ $adapter = $this->getConnection();
21
+ try {
22
+ $adapter->addColumn(
23
+ $this->getTable('tax/tax_class'),
24
+ 'op_avatax_code',
25
+ array(
26
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
27
+ 'length' => 255,
28
+ 'default' => '',
29
+ 'nullable' => false,
30
+ 'comment' => 'Used by One Pica AvaTax extension',
31
+ 'after' => 'class_name'
32
+ )
33
+ );
34
+ } catch (Exception $e) {
35
+ Mage::logException($e);
36
+ }
37
+ $installer->endSetup();
app/code/community/OnePica/AvaTax/sql/avatax_records_setup/mysql4-upgrade-0.1.4-0.1.5.php CHANGED
@@ -1,34 +1,81 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- $installer = $this;
20
-
21
- $this->startSetup();
22
-
23
- $installer->run("CREATE TABLE IF NOT EXISTS `" . $this->getTable('avatax_records/log') . "` (
24
- `log_id` INT UNSIGNED AUTO_INCREMENT,
25
- `store_id` SMALLINT (5) UNSIGNED,
26
- `level` VARCHAR (50),
27
- `type` VARCHAR (50),
28
- `request` TEXT,
29
- `result` TEXT,
30
- `additional` TEXT,
31
- `created_at` DATETIME,
32
- PRIMARY KEY(`log_id`)) COMMENT = 'Used by One Pica AvaTax extension' ENGINE = InnoDB");
33
-
34
- $this->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ $installer = $this;
19
+ $this->startSetup();
20
+ /* @var $this Mage_Core_Model_Resource_Setup */
21
+ $adapter = $this->getConnection();
22
+ $table = $adapter->newTable($this->getTable('avatax_records/log'))
23
+ ->addColumn('log_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
24
+ 'identity' => true,
25
+ 'nullable' => false,
26
+ 'primary' => true,
27
+ 'unsigned' => true
28
+ ))
29
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
30
+ 'unsigned' => true
31
+ ))
32
+ ->addColumn('level', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50)
33
+ ->addColumn('type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50)
34
+ ->addColumn('request', Varien_Db_Ddl_Table::TYPE_TEXT, null)
35
+ ->addColumn('result', Varien_Db_Ddl_Table::TYPE_TEXT, null)
36
+ ->addColumn('additional', Varien_Db_Ddl_Table::TYPE_TEXT, null)
37
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null)
38
+ ->addForeignKey(
39
+ $this->getFkName(
40
+ $this->getTable('avatax_records/log'),
41
+ 'store_id',
42
+ $this->getTable('core/store'),
43
+ 'store_id'
44
+ ),
45
+ 'store_id',
46
+ $this->getTable('core/store'),
47
+ 'store_id',
48
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
49
+ Varien_Db_Ddl_Table::ACTION_CASCADE
50
+ )
51
+ ->addIndex(
52
+ $this->getIdxName(
53
+ $this->getTable('avatax_records/log'),
54
+ array('level'),
55
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
56
+ ),
57
+ array('level'),
58
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
59
+ )
60
+ ->addIndex(
61
+ $this->getIdxName(
62
+ $this->getTable('avatax_records/log'),
63
+ array('type'),
64
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
65
+ ),
66
+ array('type'),
67
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
68
+ )
69
+ ->addIndex(
70
+ $this->getIdxName(
71
+ $this->getTable('avatax_records/log'),
72
+ array('created_at'),
73
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
74
+ ),
75
+ array('created_at'),
76
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
77
+ )
78
+ ->setComment('Used by One Pica AvaTax extension');
79
+
80
+ $adapter->createTable($table);
81
+ $this->endSetup();
app/code/community/OnePica/AvaTax/sql/avatax_records_setup/mysql4-upgrade-1.0.1-2.0.0.php CHANGED
@@ -1,37 +1,122 @@
1
- <?php
2
- /**
3
- * OnePica_AvaTax
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0), a
8
- * copy of which is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category OnePica
12
- * @package OnePica_AvaTax
13
- * @author OnePica Codemaster <codemaster@onepica.com>
14
- * @copyright Copyright (c) 2009 One Pica, Inc.
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
-
18
-
19
- $installer = $this;
20
-
21
- $this->startSetup();
22
-
23
- $installer->run("CREATE TABLE IF NOT EXISTS `" . $this->getTable('avatax_records/queue') . "` (
24
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
25
- `store_id` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
26
- `entity_id` INT(10) UNSIGNED NOT NULL,
27
- `entity_increment_id` VARCHAR(50) NOT NULL,
28
- `type` ENUM('Invoice','Credit memo') NOT NULL,
29
- `status` ENUM('Pending','Retry pending','Failed','Complete','Unbalanced') NOT NULL DEFAULT 'pending',
30
- `attempt` TINYINT UNSIGNED NOT NULL DEFAULT '0',
31
- `message` VARCHAR (255) NULL DEFAULT NULL,
32
- `created_at` DATETIME NOT NULL,
33
- `updated_at` DATETIME NOT NULL,
34
- PRIMARY KEY (`id`)
35
- ) COMMENT = 'Used by One Pica AvaTax extension' ENGINE = InnoDB");
36
-
37
- $this->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ $installer = $this;
18
+ $this->startSetup();
19
+ /* @var $this Mage_Core_Model_Resource_Setup */
20
+ $adapter = $this->getConnection();
21
+ $table = $adapter->newTable($this->getTable('avatax_records/queue'))
22
+ ->addColumn('queue_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
23
+ 'identity' => true,
24
+ 'nullable' => false,
25
+ 'primary' => true,
26
+ 'unsigned' => true
27
+ ))
28
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
29
+ 'unsigned' => true
30
+ ))
31
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
32
+ 'unsigned' => true
33
+ ))
34
+ ->addColumn('entity_increment_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50)
35
+ ->addColumn('type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50)
36
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50)
37
+ ->addColumn('attempt', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
38
+ 'unsigned' => true,
39
+ 'default' => 0
40
+ ))
41
+ ->addColumn('message', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255)
42
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null)
43
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null)
44
+ ->addForeignKey(
45
+ $this->getFkName(
46
+ $this->getTable('avatax_records/queue'),
47
+ 'store_id',
48
+ $this->getTable('core/store'),
49
+ 'store_id'
50
+ ),
51
+ 'store_id',
52
+ $this->getTable('core/store'),
53
+ 'store_id',
54
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
55
+ Varien_Db_Ddl_Table::ACTION_CASCADE
56
+ )
57
+ ->addIndex(
58
+ $this->getIdxName(
59
+ $this->getTable('avatax_records/queue'),
60
+ array('entity_id'),
61
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
62
+ ),
63
+ array('entity_id'),
64
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
65
+ )
66
+ ->addIndex(
67
+ $this->getIdxName(
68
+ $this->getTable('avatax_records/queue'),
69
+ array('entity_increment_id'),
70
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
71
+ ),
72
+ array('entity_increment_id'),
73
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
74
+ )
75
+ ->addIndex(
76
+ $this->getIdxName(
77
+ $this->getTable('avatax_records/queue'),
78
+ array('type'),
79
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
80
+ ),
81
+ array('type'),
82
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
83
+ )
84
+ ->addIndex(
85
+ $this->getIdxName(
86
+ $this->getTable('avatax_records/queue'),
87
+ array('status'),
88
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
89
+ ),
90
+ array('status'),
91
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
92
+ )
93
+ ->addIndex(
94
+ $this->getIdxName(
95
+ $this->getTable('avatax_records/queue'),
96
+ array('attempt'),
97
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
98
+ ),
99
+ array('attempt'),
100
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
101
+ )
102
+ ->addIndex(
103
+ $this->getIdxName(
104
+ $this->getTable('avatax_records/queue'),
105
+ array('created_at'),
106
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
107
+ ),
108
+ array('created_at'),
109
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
110
+ )
111
+ ->addIndex(
112
+ $this->getIdxName(
113
+ $this->getTable('avatax_records/queue'),
114
+ array('updated_at'),
115
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
116
+ ),
117
+ array('updated_at'),
118
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
119
+ )
120
+ ->setComment('Used by One Pica AvaTax extension');
121
+ $adapter->createTable($table);
122
+ $this->endSetup();
app/code/community/OnePica/AvaTax/sql/avatax_records_setup/mysql4-upgrade-2.5.0.0-2.5.0.1.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ $installer = $this;
18
+ $this->startSetup();
19
+ /* @var $this Mage_Core_Model_Resource_Setup */
20
+ $adapter = $this->getConnection();
21
+
22
+ // check if current process is install from scratch or update from 2.4.3.3-stable
23
+ $queueColumns = array_keys($adapter->describeTable($this->getTable('avatax_records/queue')));
24
+ if (!in_array('queue_id', $queueColumns)) {
25
+ $adapter
26
+ ->modifyColumn(
27
+ $this->getTable('avatax_records/log'),
28
+ 'log_id',
29
+ array(
30
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
31
+ 'identity' => true,
32
+ 'nullable' => false,
33
+ 'primary' => true,
34
+ 'unsigned' => true
35
+ )
36
+ )
37
+ ->modifyColumn(
38
+ $this->getTable('avatax_records/log'),
39
+ 'store_id',
40
+ array(
41
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
42
+ 'unsigned' => true
43
+ )
44
+ )
45
+ ->modifyColumn(
46
+ $this->getTable('avatax_records/log'),
47
+ 'level',
48
+ array(
49
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
50
+ 'length' => 50
51
+ )
52
+ )
53
+ ->modifyColumn(
54
+ $this->getTable('avatax_records/log'),
55
+ 'type',
56
+ array(
57
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
58
+ 'length' => 50
59
+ )
60
+ )
61
+ ->modifyColumn(
62
+ $this->getTable('avatax_records/log'),
63
+ 'request',
64
+ array(
65
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
66
+ )
67
+ )
68
+ ->modifyColumn(
69
+ $this->getTable('avatax_records/log'),
70
+ 'result',
71
+ array(
72
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
73
+ )
74
+ )
75
+ ->modifyColumn(
76
+ $this->getTable('avatax_records/log'),
77
+ 'additional',
78
+ array(
79
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
80
+ )
81
+ )
82
+ ->modifyColumn(
83
+ $this->getTable('avatax_records/log'),
84
+ 'created_at',
85
+ array(
86
+ 'type' => Varien_Db_Ddl_Table::TYPE_DATETIME,
87
+ )
88
+ );
89
+ $adapter
90
+ ->addForeignKey(
91
+ $this->getFkName(
92
+ $this->getTable('avatax_records/log'),
93
+ 'store_id',
94
+ $this->getTable('core/store'),
95
+ 'store_id'
96
+ ),
97
+ $this->getTable('avatax_records/log'),
98
+ 'store_id',
99
+ $this->getTable('core/store'),
100
+ 'store_id',
101
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
102
+ Varien_Db_Ddl_Table::ACTION_CASCADE
103
+ );
104
+ $adapter->addIndex(
105
+ $this->getTable('avatax_records/log'),
106
+ $this->getIdxName(
107
+ $this->getTable('avatax_records/log'),
108
+ array('level'),
109
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
110
+ ),
111
+ array('level'),
112
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
113
+ );
114
+ $adapter->addIndex(
115
+ $this->getTable('avatax_records/log'),
116
+ $this->getIdxName(
117
+ $this->getTable('avatax_records/log'),
118
+ array('type'),
119
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
120
+ ),
121
+ array('type'),
122
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
123
+ );
124
+ $adapter->addIndex(
125
+ $this->getTable('avatax_records/log'),
126
+ $this->getIdxName(
127
+ $this->getTable('avatax_records/log'),
128
+ array('created_at'),
129
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
130
+ ),
131
+ array('created_at'),
132
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
133
+ );
134
+
135
+ $result = $adapter->changeColumn(
136
+ $this->getTable('avatax_records/queue'),
137
+ 'id',
138
+ 'queue_id',
139
+ array(
140
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
141
+ 'identity' => true,
142
+ 'nullable' => false,
143
+ 'primary' => true,
144
+ 'unsigned' => true
145
+ )
146
+ );
147
+
148
+ $adapter
149
+ ->modifyColumn(
150
+ $this->getTable('avatax_records/queue'),
151
+ 'store_id',
152
+ array(
153
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
154
+ 'unsigned' => true
155
+ )
156
+ )
157
+ ->modifyColumn(
158
+ $this->getTable('avatax_records/queue'),
159
+ 'entity_id',
160
+ array(
161
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
162
+ 'unsigned' => true
163
+ )
164
+ )
165
+ ->modifyColumn(
166
+ $this->getTable('avatax_records/queue'),
167
+ 'entity_increment_id',
168
+ array(
169
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
170
+ 'length' => 50
171
+ )
172
+ )
173
+ ->modifyColumn(
174
+ $this->getTable('avatax_records/queue'),
175
+ 'type',
176
+ array(
177
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
178
+ 'length' => 50
179
+ )
180
+ )
181
+ ->modifyColumn(
182
+ $this->getTable('avatax_records/queue'),
183
+ 'status',
184
+ array(
185
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
186
+ 'length' => 50
187
+ )
188
+ )
189
+ ->modifyColumn(
190
+ $this->getTable('avatax_records/queue'),
191
+ 'attempt',
192
+ array(
193
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
194
+ 'unsigned' => true,
195
+ 'default' => 0
196
+ )
197
+ )
198
+ ->modifyColumn(
199
+ $this->getTable('avatax_records/queue'),
200
+ 'message',
201
+ array(
202
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
203
+ 'length' => 255
204
+ )
205
+ )
206
+ ->modifyColumn(
207
+ $this->getTable('avatax_records/queue'),
208
+ 'created_at',
209
+ array(
210
+ 'type' => Varien_Db_Ddl_Table::TYPE_DATETIME,
211
+ )
212
+ )
213
+ ->modifyColumn(
214
+ $this->getTable('avatax_records/queue'),
215
+ 'updated_at',
216
+ array(
217
+ 'type' => Varien_Db_Ddl_Table::TYPE_DATETIME,
218
+ )
219
+ );
220
+ $adapter->addForeignKey(
221
+ $this->getFkName(
222
+ $this->getTable('avatax_records/queue'),
223
+ 'store_id',
224
+ $this->getTable('core/store'),
225
+ 'store_id'
226
+ ),
227
+ $this->getTable('avatax_records/queue'),
228
+ 'store_id',
229
+ $this->getTable('core/store'),
230
+ 'store_id',
231
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
232
+ Varien_Db_Ddl_Table::ACTION_CASCADE
233
+ );
234
+ $adapter->addIndex(
235
+ $this->getTable('avatax_records/queue'),
236
+ $this->getIdxName(
237
+ $this->getTable('avatax_records/queue'),
238
+ array('entity_id'),
239
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
240
+ ),
241
+ array('entity_id'),
242
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
243
+ );
244
+ $adapter->addIndex(
245
+ $this->getTable('avatax_records/queue'),
246
+ $this->getIdxName(
247
+ $this->getTable('avatax_records/queue'),
248
+ array('entity_increment_id'),
249
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
250
+ ),
251
+ array('entity_increment_id'),
252
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
253
+ );
254
+ $adapter->addIndex(
255
+ $this->getTable('avatax_records/queue'),
256
+ $this->getIdxName(
257
+ $this->getTable('avatax_records/queue'),
258
+ array('type'),
259
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
260
+ ),
261
+ array('type'),
262
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
263
+ );
264
+ $adapter->addIndex(
265
+ $this->getTable('avatax_records/queue'),
266
+ $this->getIdxName(
267
+ $this->getTable('avatax_records/queue'),
268
+ array('status'),
269
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
270
+ ),
271
+ array('status'),
272
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
273
+ );
274
+ $adapter->addIndex(
275
+ $this->getTable('avatax_records/queue'),
276
+ $this->getIdxName(
277
+ $this->getTable('avatax_records/queue'),
278
+ array('attempt'),
279
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
280
+ ),
281
+ array('attempt'),
282
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
283
+ );
284
+ $adapter->addIndex(
285
+ $this->getTable('avatax_records/queue'),
286
+ $this->getIdxName(
287
+ $this->getTable('avatax_records/queue'),
288
+ array('created_at'),
289
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
290
+ ),
291
+ array('created_at'),
292
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
293
+ );
294
+ $adapter->addIndex(
295
+ $this->getTable('avatax_records/queue'),
296
+ $this->getIdxName(
297
+ $this->getTable('avatax_records/queue'),
298
+ array('updated_at'),
299
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
300
+ ),
301
+ array('updated_at'),
302
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
303
+ );
304
+ }
305
+
306
+ $this->endSetup();
app/design/adminhtml/default/default/layout/avatax.xml DELETED
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <layout>
3
- <default>
4
- <reference name="notifications">
5
- <block type="avatax/adminhtml_notification_toolbar" name="avatax_notifications"></block>
6
- </reference>
7
- </default>
8
-
9
- <avatax_adminhtml_grid_logview>
10
- <reference name="content">
11
- <block type="avatax/adminhtml_export_log_view" name ="avatax_log_view" template="avatax/log/view.phtml"></block>
12
- </reference>
13
- </avatax_adminhtml_grid_logview>
14
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/onepica/avatax.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * OnePica_AvaTax
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category OnePica
13
+ * @package OnePica_AvaTax
14
+ * @author OnePica Codemaster <codemaster@onepica.com>
15
+ * @copyright Copyright (c) 2009 One Pica, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <layout>
20
+ <default>
21
+ <reference name="notifications">
22
+ <block type="avatax/adminhtml_notification_toolbar" name="avatax.notifications" template="onepica/avatax/notification/toolbar.phtml" />
23
+ </reference>
24
+ </default>
25
+
26
+ <avatax_adminhtml_grid_log>
27
+ <reference name="content">
28
+ <block type="avatax/adminhtml_export_log_grid" name="avatax.log.grid" />
29
+ </reference>
30
+ </avatax_adminhtml_grid_log>
31
+
32
+ <avatax_adminhtml_grid_queue>
33
+ <reference name="content">
34
+ <block type="avatax/adminhtml_export_queue_grid" name="avatax.queue.grid" />
35
+ </reference>
36
+ </avatax_adminhtml_grid_queue>
37
+
38
+ <avatax_adminhtml_grid_logview>
39
+ <reference name="content">
40
+ <block type="avatax/adminhtml_export_log_view" name ="avatax.log.view" template="onepica/avatax/log/view.phtml" />
41
+ </reference>
42
+ </avatax_adminhtml_grid_logview>
43
+ </layout>
app/design/adminhtml/default/default/template/{avatax → onepica/avatax}/log/view.phtml RENAMED
@@ -19,34 +19,32 @@
19
  <div class="content-header">
20
  <table cellspacing="0">
21
  <tr>
22
- <td style="<?php echo $this->getHeaderWidth() ?>"><?php echo $this->getHeaderHtml() ?></td>
23
- <td class="form-buttons"><?php echo $this->getButtonsHtml() ?></td>
24
  </tr>
25
  </table>
26
  </div>
27
 
28
- <?php
29
- $event = $this->getCurrentEvent();
30
- ?>
31
  <div class="entry-edit">
32
  <div class="entry-edit">
33
  <div class="entry-edit-head">
34
  <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Request'); ?></h4>
35
  </div>
36
  <div id="log_details_fieldset" class="log-details">
37
- <textarea readonly style="width:100%; height:300px"><?php echo $this->escapeHtml($event->getRequest()); ?></textarea>
38
  </div>
39
  <div class="entry-edit-head">
40
  <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Response'); ?></h4>
41
  </div>
42
  <div id="log_details_fieldset" class="log-details">
43
- <textarea readonly style="width:100%; height:300px"><?php echo $this->escapeHtml($event->getResult()); ?></textarea>
44
  </div>
45
  <div class="entry-edit-head">
46
  <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Additional'); ?></h4>
47
  </div>
48
  <div id="log_details_fieldset" class="log-details">
49
- <textarea readonly style="width:100%; height:300px"><?php echo $this->escapeHtml($event->getAdditional()); ?></textarea>
50
  </div>
51
  </div>
52
  </div>
19
  <div class="content-header">
20
  <table cellspacing="0">
21
  <tr>
22
+ <td style="<?php echo $this->getHeaderWidth() ?>"><?php echo $this->getHeaderHtml(); ?></td>
23
+ <td class="form-buttons"><?php echo $this->getButtonsHtml(); ?></td>
24
  </tr>
25
  </table>
26
  </div>
27
 
28
+ <?php $event = $this->getCurrentEvent();?>
 
 
29
  <div class="entry-edit">
30
  <div class="entry-edit">
31
  <div class="entry-edit-head">
32
  <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Request'); ?></h4>
33
  </div>
34
  <div id="log_details_fieldset" class="log-details">
35
+ <textarea readonly style="width:100%; height:300px"><?php echo $this->escapeHtml($event->getRequest()); ?></textarea>
36
  </div>
37
  <div class="entry-edit-head">
38
  <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Response'); ?></h4>
39
  </div>
40
  <div id="log_details_fieldset" class="log-details">
41
+ <textarea readonly style="width:100%; height:300px"><?php echo $this->escapeHtml($event->getResult()); ?></textarea>
42
  </div>
43
  <div class="entry-edit-head">
44
  <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Additional'); ?></h4>
45
  </div>
46
  <div id="log_details_fieldset" class="log-details">
47
+ <textarea readonly style="width:100%; height:300px"><?php echo $this->escapeHtml($event->getAdditional()); ?></textarea>
48
  </div>
49
  </div>
50
  </div>
app/design/adminhtml/default/default/template/onepica/avatax/notification/toolbar.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * OnePica_AvaTax
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0), a
8
+ * copy of which is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category OnePica
12
+ * @package OnePica_AvaTax
13
+ * @author OnePica Codemaster <codemaster@onepica.com>
14
+ * @copyright Copyright (c) 2009 One Pica, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ ?>
18
+ <?php /** @var OnePica_AvaTax_Block_Adminhtml_Notification_Toolbar $this */?>
19
+ <?php if ($this->isEnabled()):?>
20
+ <?php $count = $this->getQueuePendingRetryCount();?>
21
+ <?php if ($count):?>
22
+ <div class="notification-global">
23
+ <?php if ($this->isAllowed()):?>
24
+ <span class="f-right"><?php echo $this->__('Go to the <a href="%s">AvaTax Order Sync Queue</a>', $this->getQueueGridUrl());?></span>
25
+ <?php endif;?>
26
+ <strong class="label"><?php echo $this->__('AvaTax:');?></strong>
27
+ <?php if ($count == 1):?>
28
+ <?php echo $this->__('There is <strong>%s</strong> entry in the AvaTax Order Sync Queue that has errored. Syncing is attemped %s times before permanently failing.', $count, $this->getQueueAttemptMaxValue());?>
29
+ <?php else:?>
30
+ <?php echo $this->__('There are <strong>%s</strong> entries in the AvaTax Order Sync Queue that have errored. Syncing is attemped %s times before permanently failing.', $count, $this->getQueueAttemptMaxValue());?>
31
+ <?php endif;?>
32
+ </div>
33
+ <?php endif;?>
34
+ <?php endif;?>
app/design/frontend/base/default/layout/avatax.xml DELETED
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <layout>
3
- <checkout_onepage_index>
4
- <reference name="checkout.onepage.shipping_method">
5
- <block type="avatax/checkout_onepage_shipping_method_available" name="checkout.onepage.shipping_method.availableAvatax" before="-" output="toHtml" />
6
- </reference>
7
- </checkout_onepage_index>
8
-
9
- <checkout_onepage_shippingmethod>
10
- <block type="avatax/checkout_onepage_shipping_method_available" name="checkout.onepage.shipping_method.availableAvatax" before="-" output="toHtml" />
11
- </checkout_onepage_shippingmethod>
12
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/onepica/avatax.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * OnePica_AvaTax
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category OnePica
13
+ * @package OnePica_AvaTax
14
+ * @author OnePica Codemaster <codemaster@onepica.com>
15
+ * @copyright Copyright (c) 2009 One Pica, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <layout>
20
+ <checkout_onepage_index>
21
+ <reference name="checkout.onepage.shipping_method">
22
+ <block type="avatax/checkout_onepage_shipping_method_available" name="checkout.onepage.shipping_method.availableAvatax" before="-" output="toHtml" />
23
+ </reference>
24
+ </checkout_onepage_index>
25
+
26
+ <checkout_onepage_shippingmethod>
27
+ <block type="avatax/checkout_onepage_shipping_method_available" name="checkout.onepage.shipping_method.availableAvatax" before="-" output="toHtml" />
28
+ </checkout_onepage_shippingmethod>
29
+ </layout>
app/etc/modules/OnePica_AvaTax.xml CHANGED
@@ -1,9 +1,26 @@
1
  <?xml version="1.0"?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <config>
3
- <modules>
4
- <OnePica_AvaTax>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </OnePica_AvaTax>
8
- </modules>
9
  </config>
1
  <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * OnePica_AvaTax
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0), a
9
+ * copy of which is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category OnePica
13
+ * @package OnePica_AvaTax
14
+ * @author OnePica Codemaster <codemaster@onepica.com>
15
+ * @copyright Copyright (c) 2009 One Pica, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
  <config>
20
+ <modules>
21
+ <OnePica_AvaTax>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ </OnePica_AvaTax>
25
+ </modules>
26
  </config>
app/locale/de_DE/OnePica_AvaTax.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "firstname", "First Name"
2
+ "middlename", "Middle Name"
3
+ "lastname", "Last Name"
4
+ "street_full", "Full Address"
5
+ "street", "Address"
6
+ "street1", "Address"
7
+ "city", "City"
8
+ "region", "State/Province"
9
+ "country", "Country"
10
+ "postcode", "Zip/Postal Code"
11
+ "telephone", "Telephone"
12
+ "company", "Company"
13
+ "fax", "Fax"
app/locale/en_US/OnePica_AvaTax.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "firstname", "First Name"
2
+ "middlename", "Middle Name"
3
+ "lastname", "Last Name"
4
+ "street_full", "Full Address"
5
+ "street", "Address"
6
+ "street1", "Address"
7
+ "city", "City"
8
+ "region", "State/Province"
9
+ "country", "Country"
10
+ "postcode", "Zip/Postal Code"
11
+ "telephone", "Telephone"
12
+ "company", "Company"
13
+ "fax", "Fax"
app/locale/es_ES/OnePica_AvaTax.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "firstname", "First Name"
2
+ "middlename", "Middle Name"
3
+ "lastname", "Last Name"
4
+ "street_full", "Full Address"
5
+ "street", "Address"
6
+ "street1", "Address"
7
+ "city", "City"
8
+ "region", "State/Province"
9
+ "country", "Country"
10
+ "postcode", "Zip/Postal Code"
11
+ "telephone", "Telephone"
12
+ "company", "Company"
13
+ "fax", "Fax"
app/locale/fr_FR/OnePica_AvaTax.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "firstname", "First Name"
2
+ "middlename", "Middle Name"
3
+ "lastname", "Last Name"
4
+ "street_full", "Full Address"
5
+ "street", "Address"
6
+ "street1", "Address"
7
+ "city", "City"
8
+ "region", "State/Province"
9
+ "country", "Country"
10
+ "postcode", "Zip/Postal Code"
11
+ "telephone", "Telephone"
12
+ "company", "Company"
13
+ "fax", "Fax"
app/locale/nl_NL/OnePica_AvaTax.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "firstname", "First Name"
2
+ "middlename", "Middle Name"
3
+ "lastname", "Last Name"
4
+ "street_full", "Full Address"
5
+ "street", "Address"
6
+ "street1", "Address"
7
+ "city", "City"
8
+ "region", "State/Province"
9
+ "country", "Country"
10
+ "postcode", "Zip/Postal Code"
11
+ "telephone", "Telephone"
12
+ "company", "Company"
13
+ "fax", "Fax"
app/locale/pt_BR/OnePica_AvaTax.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "firstname", "First Name"
2
+ "middlename", "Middle Name"
3
+ "lastname", "Last Name"
4
+ "street_full", "Full Address"
5
+ "street", "Address"
6
+ "street1", "Address"
7
+ "city", "City"
8
+ "region", "State/Province"
9
+ "country", "Country"
10
+ "postcode", "Zip/Postal Code"
11
+ "telephone", "Telephone"
12
+ "company", "Company"
13
+ "fax", "Fax"
app/locale/zh_CN/OnePica_AvaTax.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "firstname", "First Name"
2
+ "middlename", "Middle Name"
3
+ "lastname", "Last Name"
4
+ "street_full", "Full Address"
5
+ "street", "Address"
6
+ "street1", "Address"
7
+ "city", "City"
8
+ "region", "State/Province"
9
+ "country", "Country"
10
+ "postcode", "Zip/Postal Code"
11
+ "telephone", "Telephone"
12
+ "company", "Company"
13
+ "fax", "Fax"
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>OnePica_AvaTax</name>
4
- <version>2.4.3.3</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
@@ -18,20 +18,27 @@ Released as a commercial extension, this software will not work unless you have
18
  &#xD;
19
  &#xD;
20
  At One Pica (www.onepica.com), we strive to build increasingly scalable and flexible enterprise systems for all of our clients, large and small. We want to give back to this community both to promote its success and as a sign of our gratitude. Please feel free to contact us on ways we can improve this extension or extend on this framework.</description>
21
- <notes>Fixed message queue showing multiple notices.&#xD;
22
  &#xD;
23
- Fixed duplicate invoice sending after modification.&#xD;
 
 
 
 
 
 
 
 
 
 
24
  &#xD;
25
- Fixed checkout for invalid addresses.&#xD;
26
  &#xD;
27
- Fixed destination address (missing street lines).&#xD;
28
  &#xD;
29
- Added avoiding shipping address validation logic for virtual orders.&#xD;
30
  </notes>
31
- <authors><author><name>Gregory Segall</name><user>gsegall</user><email>magento@onepica.com</email></author></authors>
32
- <date>2013-12-09</date>
33
- <time>14:07:38</time>
34
- <contents><target name="magecommunity"><dir name="OnePica"><dir name="AvaTax"><dir name="Block"><dir name="Adminhtml"><dir name="Export"><dir name="Abstract"><file name="Grid.php" hash="b5db0baa25adca61990553cdfae054f8"/></dir><dir name="Log"><file name="Grid.php" hash="3d36d791700f8a747bb492732ff86077"/><file name="View.php" hash="99f17c532b545e34fb6ca207c2beeb37"/></dir><dir name="Queue"><file name="Grid.php" hash="52efc8e013002639cc2f0f88010c91ec"/></dir></dir><dir name="Notification"><file name="Toolbar.php" hash="a0cb132e6fb73412879a5b0b7f85871c"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Export.php" hash="a834887971b517d7141cb2c8868d68b1"/></dir></dir></dir></dir><dir name="Tax"><dir name="Class"><dir name="Edit"><file name="Form.php" hash="a34316cf45867eb83de49243f0fdf4c6"/></dir><file name="Grid.php" hash="a7222bf20619ea8104e4d3d0066f27fd"/></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Available.php" hash="32d846b8b509e62206ab5de2ff3680dd"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="c210d52ae758be31baf225f9926029bc"/><dir name="Tax"><file name="Data.php" hash="81edee6048e5e9487f5c0a3e985d1b15"/></dir></dir><dir name="Model"><file name="Abstract.php" hash="96dcb00145bbc1a28859bd5c0f2c380d"/><dir name="Admin"><file name="Session.php" hash="e19ebf06208e3d2edef45683401fe7a8"/></dir><dir name="Adminhtml"><file name="Config.php" hash="518933b279d0bbf7f13651a9b33e2edb"/><dir name="Sales"><dir name="Order"><file name="Create.php" hash="f2202ae68958e359d294a221c95ffde9"/></dir></dir></dir><dir name="Avatax"><file name="Abstract.php" hash="4a3cc074e955055d9ae1ba7e32dac400"/><file name="Address.php" hash="21dadef76f7df29d65da454dfdc262e7"/><file name="Estimate.php" hash="331ee6dd5ec37954ec54aa9f64606d85"/><dir name="Exception"><file name="Address.php" hash="9052a48d9c3b46811c3db4090dc610d4"/><file name="Commitfailure.php" hash="23559a21d37fd14904f088e8c2357992"/><file name="Unbalanced.php" hash="3ee206bb1cfb87cceae006a2c1b6b5e7"/></dir><file name="Invoice.php" hash="08764c536526d8c54e09c9d2a831fae4"/><file name="Ping.php" hash="61fc25b14e144ffbae8629e497cd5305"/></dir><file name="Config.php" hash="7f202ecb12a601971369714f1281d5ba"/><file name="Observer.php" hash="4fa7733a4ca40a99f5d837f2653d24df"/><dir name="Records"><file name="Log.php" hash="14d58227e9c6b96b46b6a00cd7952586"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="14344f43b12f84d745f522589b83e271"/></dir><file name="Log.php" hash="dd367bc03d936fab12d93b5a950ec102"/><dir name="Queue"><file name="Collection.php" hash="faac004ece9a1e413f870dedfc925e38"/></dir><file name="Queue.php" hash="fc68b22eec10cc208ae8d4f8b33c2a46"/></dir><dir name="Queue"><file name="Process.php" hash="8e650e32f1208867441d041716adc098"/></dir><file name="Queue.php" hash="4bd9ba90dbb6a81f9f01acb8ed8e3082"/><file name=".DS_Store" hash="48d5c220a3fad09c37de12b9e5e448f8"/></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Grand.php" hash="ce472ac13ac610db29175afc735c5701"/><file name="Tax.php" hash="065a94e81758d52f8ebfd816f71e4756"/></dir></dir><file name="Address.php" hash="94c10d2fb4e2830ad6faee3c878122bc"/></dir></dir><file name="Session.php" hash="72849341ba81db155cc8d998b7dfef69"/><dir name="Source"><file name="Actions.php" hash="55cde933437761b778ebea15075568ab"/><file name="Addressvalidation.php" hash="50910e35a4413b03e2089b2b7877e98e"/><file name="Customercodeformat.php" hash="1478c6fcba951ae497e7621d6cf808e0"/><file name="Error.php" hash="467b37421490cfe5eba060fc5e1af240"/><file name="Fieldlist.php" hash="78e6a255435b2e48ebe912424108c606"/><file name="Logmode.php" hash="63ab9699d71f2a6031a37d249c816b10"/><file name="Logtype.php" hash="cd46d9baf9ef70d24e1240a891a6b7be"/><file name="Onerrorfrontend.php" hash="9ecd5015d95925adfe1626634d91820e"/><dir name="Regionfilter"><file name="List.php" hash="3b86c8f2a69aeeb9eb0c1988393f10ac"/><file name="Mode.php" hash="1a1bc328674db870d0cf4ef69a05de17"/></dir></dir><file name=".DS_Store" hash="65255944ee79d37cac5700e36e70eaf0"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportController.php" hash="3d770db9c1dbc8199c305e69387b679f"/><file name="GridController.php" hash="d40ba09889406dffd747788e1c244dee"/></dir><file name="CartController.php" hash="1dd07701a719717381b52da7b0e235e2"/><file name="OnepageController.php" hash="491c3547e25aca5632356e678109f105"/><file name=".DS_Store" hash="8b6cbc252371183dd3ee7f9c2a75b282"/></dir><dir name="etc"><file name="adminhtml.xml" hash="65419d8a1aed1cdb2e3bd1af076af732"/><file name="config.xml" hash="546770423cab2123490fb5a9328bcf30"/><file name="system-disabled.xml" hash="851329d6173bca6f2a2f074880c8289a"/><file name="system.xml" hash="b25373b964002d8be9bd9cd671e55ba2"/></dir><dir name="lib"><file name="AvaTax.php" hash="d9d2ac44a3a7a4d5ca34752df3d70afb"/><dir name="classes"><file name="ATConfig.class.php" hash="9ccc6722b520cf4068235ecea5d9cade"/><file name="ATObject.class.php" hash="b9b910adcb86703cff3a59f38665a003"/><file name="AVObject.class.php" hash="b65c5532b01074a57a20703513148301"/><file name="Address.class.php" hash="06f5487c223132005a65d633930f5b72"/><file name="AddressServiceSoap.class.php" hash="776cbf348c32a7dc20cc47f90b2cc806"/><file name="AddressType.class.php" hash="1458d719ab0c4d1ff93244527b8c75cf"/><file name="AdjustTaxRequest.class.php" hash="a67ce5082335bcd553ac7ead85a7a36c"/><file name="AdjustTaxResult.class.php" hash="0fb71e82a0aa38ff792fb45d3b19c664"/><file name="ApplyPaymentRequest.class.php" hash="65fab85ca47b7c9ad84e861d6e2e9a01"/><file name="ApplyPaymentResult.class.php" hash="ddf7a332575f7c972f11f95430179b01"/><file name="AvalaraSoapClient.class.php" hash="e3561a81c82ac293767271195c8cf2e5"/><file name="BaseResult.class.php" hash="8dc91ad90e7b9fb12dbea3d5e3279892"/><dir name="BatchSvc"><file name="AuditMessage.class.php" hash="b2cf0248904656cd10b3d28f3cfa25a1"/><file name="AvaTaxBatchSvc.php" hash="2c6ecf16cec6926ca0438772c08e4f70"/><file name="BaseResult.class.php" hash="911a199f0fd54e00ccab6fad53f89ba3"/><file name="Batch.class.php" hash="ded2b8509c4223732b91608fffea43a5"/><file name="BatchDelete.class.php" hash="27b5510c8199a6e348e7c983a1b68778"/><file name="BatchDeleteResponse.class.php" hash="a181bdf63032b6f292f32a3c2d8dc008"/><file name="BatchFetch.class.php" hash="efeee6d7bcc181c1a4d4a5d165169ca8"/><file name="BatchFetchResponse.class.php" hash="e5c8f28218e1240cf360a61456baeeb5"/><file name="BatchFetchResult.class.php" hash="10549cd50bc803814381bea5e62d951e"/><file name="BatchFile.class.php" hash="0ef50e2a8147f2f57d3072128f6561ee"/><file name="BatchFileDelete.class.php" hash="b937b21facf90fb1db1f1ee70a0fefdd"/><file name="BatchFileDeleteResponse.class.php" hash="8753ed5b4aa5ed2b8f790b5d529698d2"/><file name="BatchFileFetch.class.php" hash="3a374c13d668707e004d779ee6377880"/><file name="BatchFileFetchResponse.class.php" hash="09fe9b8cc3a426b3ab13b4eb9a462914"/><file name="BatchFileFetchResult.class.php" hash="49e84f4dd96483229649539e4bcea9bd"/><file name="BatchFileSave.class.php" hash="72589688feea7a1d6afd1c27794b2585"/><file name="BatchFileSaveResponse.class.php" hash="1850184ea711a501f61ad3cbd7284069"/><file name="BatchFileSaveResult.class.php" hash="1266eefddc041b850b58616935300187"/><file name="BatchProcess.class.php" hash="60912e77dd6e6a0f6629b2e86ce0df09"/><file name="BatchProcessRequest.class.php" hash="a01a7987cc0dc962ee1499f0ab92f346"/><file name="BatchProcessResponse.class.php" hash="db13565dc7b3b1544ef5ada36c32a568"/><file name="BatchProcessResult.class.php" hash="7a4d631658c89539ea07a0236b17cf13"/><file name="BatchSave.class.php" hash="616295413418b16410cd008e3f20b28b"/><file name="BatchSaveResponse.class.php" hash="2cb0ada61c6501877c08da49bbb4a946"/><file name="BatchSaveResult.class.php" hash="bced01bdbfbdd476bca9c9d0176bd785"/><file name="BatchSvc.class.php" hash="a42b48303d7ffa8074821d738ec5b37e"/><file name="DeleteRequest.class.php" hash="259dd71651fbc6307e3ba39ba37b0982"/><file name="DeleteResult.class.php" hash="8c39215b0e317f7834a147869ca7fb17"/><file name="FetchRequest.class.php" hash="3b2cea507374b08bd6b6ea23c9487494"/><file name="FilterRequest.class.php" hash="14d910ba0d03a2179263a03404a85194"/><file name="FilterResult.class.php" hash="0608a53670e6e156628451303d11ace3"/><file name="IsAuthorized.class.php" hash="589c1aff4109cc480312675f2e04aa0e"/><file name="IsAuthorizedResponse.class.php" hash="64db8c37e7946c2902ea9e46ae86cb78"/><file name="IsAuthorizedResult.class.php" hash="5b177cc88d91c63ee998fe5712b44bcc"/><file name="Message.class.php" hash="034c2276b6de0eb234f63d9cb5c1dae0"/><file name="Ping.class.php" hash="119c38ad0e7cd85eb1b550d51a6e2425"/><file name="PingResponse.class.php" hash="f92a631e8c09cfa884acd6b820232e83"/><file name="PingResult.class.php" hash="f818d99e05c0d3c014dbf3e5986ec599"/><file name="Profile.class.php" hash="7fda4e5d8db696d854cd7d1cec25f799"/><file name="SeverityLevel.class.php" hash="043ecef6038f2e95fe282f4c979af425"/></dir><file name="BoundaryLevel.class.php" hash="9a27f3e00bbe8dde729e7e54fb323d62"/><file name="CancelCode.class.php" hash="ef3f56a04d1aade150cb08c3a9134c9b"/><file name="CancelTaxRequest.class.php" hash="19d5af5d81c6e125766c927e76971e4e"/><file name="CancelTaxResult.class.php" hash="07228ddee4ab305bc9b1512b996105f7"/><file name="CommitTaxRequest.class.php" hash="b066a6d15874be72549053f66826c9e1"/><file name="CommitTaxResult.class.php" hash="30372831394d6bdeb705b93af413b71f"/><file name="DetailLevel.class.php" hash="82c39ae81735c84cf42e45f08d2a09a9"/><file name="DocStatus.class.php" hash="bbdb6cc343319bb996f5780d90d3a5a0"/><file name="DocumentType.class.php" hash="d27a4700fefed81cb9f8c701c3939982"/><file name="DynamicSoapClient.class.php" hash="0ab14d845214d6a4c4d1dbe32666bf2f"/><file name="Enum.class.php" hash="0d16eadf4c991e7f52ef41de5cbc92e7"/><file name="GetTaxHistoryRequest.class.php" hash="b598dcee1bcaa13e4c123e558bc5d545"/><file name="GetTaxHistoryResult.class.php" hash="4c85747ef17f770ae4ec94d9e27f681f"/><file name="GetTaxRequest.class.php" hash="9da97ed2bfaa71ae47900ee2c5e2aee2"/><file name="GetTaxResult.class.php" hash="e2cf17e68126a6b0e4f5440a072dc581"/><file name="IsAuthorizedResult.class.php" hash="c570782cd50745810995c787048c8864"/><file name="JurisdictionType.class.php" hash="68b8022228fbc22d60fd74914f2a2749"/><file name="Line.class.php" hash="9afc25c9ce2581b929173d92af8b801d"/><file name="Message.class.php" hash="06a099c0f099e4e6a10c3be887b07b30"/><file name="PingResult.class.php" hash="22d83358dd7c4f8ffe3e720da3c1b565"/><file name="PostTaxRequest.class.php" hash="3301991ededc9fbad1dd45c6aa80dc51"/><file name="PostTaxResult.class.php" hash="36f02467db90d6beb33681e4f1c0a26e"/><file name="ReconcileTaxHistoryRequest.class.php" hash="ce0164310a18a7d464217ce69d7b4fc2"/><file name="ReconcileTaxHistoryResult.class.php" hash="baab8d603255b246731bcb7bca149596"/><file name="SearchTaxHistoryResult.class.php" hash="6a86da07d80fff3518a2be6e74694662"/><file name="ServiceMode.class.php" hash="9a4e633e225d4cdc62b28a041ca4d739"/><file name="SeverityLevel.class.php" hash="72d3fe39e2ced741aa8917b8e8be7c6f"/><file name="TaxDetail.class.php" hash="b6be13edfa217119a5c82c3a291ba340"/><file name="TaxLine.class.php" hash="be67b350e74efc326d1d6dcf5a21978c"/><file name="TaxOverride.class.php" hash="b0f99ad5bfe71e06bfcb60312032fdb3"/><file name="TaxOverrideType.class.php" hash="f5d2434c2a369605f82d2a182ddbea74"/><file name="TaxRequest.class.php" hash="7a6a1dbf317aedb18b225efa7c90da88"/><file name="TaxServiceSoap.class.php" hash="9deec191eb6a90239eaed2537d06ffe1"/><file name="TaxType.class.php" hash="a8a6fe2ed98440606f50190e3f5aa914"/><file name="TextCase.class.php" hash="dd265892e4733ef7f2e6d5cd53daa087"/><file name="ValidAddress.class.php" hash="9aef14ddcda74827f288bce6cf5e18e0"/><file name="ValidateRequest.class.php" hash="df76ee0d0acef422e1640796f627bd4f"/><file name="ValidateResult.class.php" hash="cd7fff7ffa3fbc9d04d3fe15b9d877e9"/><dir name="wsdl"><file name="Address.wsdl" hash="2ca743760c961db0ae03e4c6900667cb"/><file name="BatchSvc.wsdl" hash="eae666b959c1889d586919da4ebccefd"/><file name="Tax.wsdl" hash="da6b3da89c3e4f3f7db6d0ed9d4d33de"/></dir></dir><file name="functions.php" hash="b94adf9f4887ff8f023fdaff5c64d974"/></dir><dir name="sql"><dir name="avatax_records_setup"><file name="mysql4-install-0.1.0.php" hash="cae21cd6e672cb07b606b5ab58fc5fd7"/><file name="mysql4-upgrade-0.1.4-0.1.5.php" hash="3bde3555bafe3f4dbb6b620b75abfa02"/><file name="mysql4-upgrade-1.0.1-2.0.0.php" hash="1b6d23e38621253e76c12a48e5494c64"/><file name="mysql4-upgrade-2.2.0-2.2.1.php" hash="82c4fc41cf9a235072c585028c23fecd"/></dir></dir><file name=".DS_Store" hash="47cfb3e4aa7a816c6eb4f04a99079f50"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="OnePica_AvaTax.xml" hash="9a548b57f519da49acf5fe116d2aeabe"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="avatax.xml" hash="e9ba43333bdc89b3de01845797d74c52"/></dir><dir name="template"><dir name="avatax"><dir name="log"><file name="view.phtml" hash="285bcc5ffb36140d010970e030b141ab"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="avatax.xml" hash="b47bd34f2df8092cdcbc973be8356777"/></dir></dir></dir></dir></target></contents>
35
  <compatible/>
36
- <dependencies><required><php><min>5.2.3</min><max>6.0.0</max></php><extension><name>curl</name><min></min><max></max></extension><extension><name>soap</name><min></min><max></max></extension></required></dependencies>
37
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>OnePica_AvaTax</name>
4
+ <version>2.5.0</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
18
  &#xD;
19
  &#xD;
20
  At One Pica (www.onepica.com), we strive to build increasingly scalable and flexible enterprise systems for all of our clients, large and small. We want to give back to this community both to promote its success and as a sign of our gratitude. Please feel free to contact us on ways we can improve this extension or extend on this framework.</description>
21
+ <notes>Improved performance&#xD;
22
  &#xD;
23
+ Improved logging&#xD;
24
+ &#xD;
25
+ Fixed tax calculation for configurable products&#xD;
26
+ &#xD;
27
+ Fixed tax calculation when coupon is applied&#xD;
28
+ &#xD;
29
+ Fixed tax calculation with gift wrapping&#xD;
30
+ &#xD;
31
+ Fixed filter tax calculation option&#xD;
32
+ &#xD;
33
+ Fixed queue clean up process&#xD;
34
  &#xD;
 
35
  &#xD;
 
36
  &#xD;
 
37
  </notes>
38
+ <authors><author><name>Rostyslav Redko</name><user>marketing</user><email>avalara@onepica.com</email></author></authors>
39
+ <date>2015-07-09</date>
40
+ <time>16:26:17</time>
41
+ <contents><target name="magecommunity"><dir name="OnePica"><dir name="AvaTax"><dir name="Block"><dir name="Adminhtml"><dir name="Export"><dir name="Abstract"><file name="Grid.php" hash="85f9e21148f0bcb16d2bba85379b620c"/></dir><dir name="Log"><file name="Grid.php" hash="9fc68393de0fc3ebdbcd943e39a59a9d"/><file name="View.php" hash="b04fc9f60d4acbb07051f7391b878a92"/></dir><dir name="Queue"><file name="Grid.php" hash="5f32911ee544353d05b093a20c6fac4c"/></dir></dir><dir name="Notification"><file name="Toolbar.php" hash="ce0f6022846b565184147dc50d1792b8"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Export.php" hash="9a34cc10bf2e179725517be980d8ef17"/></dir></dir></dir></dir><dir name="Tax"><dir name="Class"><dir name="Edit"><file name="Form.php" hash="80d7048a100539d0957cc2d1e433d3fa"/></dir><file name="Grid.php" hash="130503c2d1b2e2efe84c0a658aa0f7a8"/></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Available.php" hash="c8ad904b71f344cfd1e01ceea7556dd1"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="3e629ac46ddeefeac5370bcdd6af2476"/><dir name="Tax"><file name="Data.php" hash="2d267503f130a97db1786ea403564016"/></dir></dir><dir name="Model"><file name="Abstract.php" hash="dffa336069582428f490b85567dddb69"/><dir name="Admin"><file name="Session.php" hash="90dd2d8b332f813515889a454ee3c80b"/></dir><dir name="Adminhtml"><file name="Config.php" hash="b0232a66e3deb89a51c870ec9cc815ee"/><dir name="Sales"><dir name="Order"><file name="Create.php" hash="a83d3ac1d0dec5cd70d473dbfba7fc85"/></dir></dir></dir><dir name="Avatax"><file name="Abstract.php" hash="ad54fec335b71a6acc3887a68b347dc7"/><file name="Address.php" hash="365f7ac72aea4296cc5bfdee867a0f08"/><file name="Estimate.php" hash="76da48316e897fe0bdafa5dcc6c00237"/><dir name="Exception"><file name="Address.php" hash="689d9b351489c9101477b8f068bc48cd"/><file name="Commitfailure.php" hash="68e9c96eefed652e54a807bca1019f54"/><file name="Unbalanced.php" hash="778eb77593cb4787d6a00a5da0559ddc"/></dir><file name="Invoice.php" hash="0133aa19a1f4a4aea9d81a7f68d5d9bf"/><file name="Ping.php" hash="57b77948291fda5c6fe15733fd96a3c0"/></dir><file name="Config.php" hash="b4c80dbcd4d476f42f36d2a5dd666c15"/><file name="Exception.php" hash="78b46e431b3d8e1d31a3544c9a037e30"/><dir name="Export"><dir name="Adapter"><file name="Abstract.php" hash="840c8b87acd97646572bba9bb3b8f5ea"/><file name="Sql.php" hash="d4e76c823e5dd575279274debff69e4f"/></dir><dir name="Entity"><file name="Abstract.php" hash="a6e649456073395dc6f0d382e9abded8"/><file name="Log.php" hash="a1dd28eee3e72d1a4ef7bddd865ddbae"/><file name="Queue.php" hash="14a97c283aa74f97982ab71160017aa3"/></dir></dir><file name="Export.php" hash="479265899b15f58c1659c61f31c7470a"/><file name="Observer.php" hash="90932cf4977b4fed97e86746d8850ba7"/><dir name="Records"><file name="Log.php" hash="a15c22cf219e7750a37cde75ba3f22a9"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="29db8163f4dda862ff822ddffd04554d"/></dir><file name="Log.php" hash="f9c213eef54837c95ebef0bb9403d610"/><dir name="Queue"><file name="Collection.php" hash="11bba1561c81f39695f091b94bd81560"/></dir><file name="Queue.php" hash="735132bae49948300cac00658a68cf74"/></dir><dir name="Queue"><file name="Process.php" hash="dda2ef9fa0571db1cb16292b7b93db54"/></dir><file name="Queue.php" hash="17e369325bcac42042676bb61a2248c5"/></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Grand.php" hash="63fb5a808ad3c16d2ed15f1dafad7937"/><file name="Tax.php" hash="e309b0c41e91e714268c02a79d5e8e5f"/></dir></dir><file name="Address.php" hash="3191bbdf4e2227d35cf588dde798731b"/></dir></dir><file name="Session.php" hash="6a858f6395d248178c28160a29530bf1"/><dir name="Source"><file name="Actions.php" hash="879b80f92f735402f57e316546b16984"/><file name="Addressvalidation.php" hash="9f2315018910f7336ad894156d49d9b9"/><file name="Customercodeformat.php" hash="cfcfcbaa27ed29add072324816da0c9d"/><file name="Error.php" hash="7f5495a2f295ded2d0a30f2f7108d009"/><file name="Fieldlist.php" hash="b25835b23df6045777be1c891bd3dd05"/><file name="Logmode.php" hash="24d61da578a3b4adb896fea7d4d4d8ec"/><file name="Logtype.php" hash="4079ebbf7ef44593e631b8cc9f0fc2a5"/><file name="Onerrorfrontend.php" hash="ef4154ae563d8157c1083f20e0adf563"/><dir name="Regionfilter"><file name="List.php" hash="169d0a776823439984fbdf27e631f62e"/><file name="Mode.php" hash="27fdc94c6f162100d55005285b5170df"/></dir></dir><dir name="Tax"><file name="Config.php" hash="6168c0d674a44291b7dbfe358305a04b"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportController.php" hash="306f2f688aaa85e4dbf2bda94bc7d353"/><file name="GridController.php" hash="91f38761378ff91d1f9c396b1cb3c150"/></dir></dir><dir name="data"><dir name="avatax_records_setup"><file name="data-upgrade-2.2.0-2.2.1.php" hash="260d1c57754ebadba00d8ccdbb0ec996"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="92c529d045fa34fd0822b6ccb40bd4ed"/><file name="config.xml" hash="cf523de8daa4d2e4c289f3cafa30826b"/><file name="system-disabled.xml" hash="937460e7271eb45d25f424d7da2baa72"/><file name="system.xml" hash="a1aa4cb07bce94406110cc9c1628460e"/></dir><dir name="lib"><file name="AvaTax.php" hash="ee495f13f7b31af8837839f8fd571102"/><dir name="classes"><file name="ATConfig.class.php" hash="88559205ad296264e9d363e95b7a3e98"/><file name="ATObject.class.php" hash="5447af3f2e2fec7bbf66589539b09e9f"/><file name="AVObject.class.php" hash="b65c5532b01074a57a20703513148301"/><file name="Address.class.php" hash="4f027c9ddbe7449397f1fe6218738ddd"/><file name="AddressServiceSoap.class.php" hash="d61560d0b4f03b6ca2823d2250c9a55e"/><file name="AddressType.class.php" hash="f778cdd8c767edd49e69815e8bd74643"/><file name="AdjustTaxRequest.class.php" hash="868b9eaed8f91ffec23ea2a688d04775"/><file name="AdjustTaxResult.class.php" hash="af37112818b9542e75bded41243a55c8"/><file name="ApplyPaymentRequest.class.php" hash="3b3877a6dc9504b090b6f4feede52b9f"/><file name="ApplyPaymentResult.class.php" hash="a38a544cff1698c59e0da9cd059b8c79"/><file name="AvalaraSoapClient.class.php" hash="1b3209110dbdc4293fbdbc6490ba7fc2"/><file name="BaseResult.class.php" hash="8b85d243d1ad85b6336de60aea38e529"/><dir name="BatchSvc"><file name="AuditMessage.class.php" hash="f3366c62f07ae94366744a18f573a2f1"/><file name="AvaTaxBatchSvc.php" hash="d6d59c824afb9357289e28f5b9ad051e"/><file name="BaseResult.class.php" hash="3d4fb18a13cb2521bdcebbb4828499a5"/><file name="Batch.class.php" hash="345e1566373ff0114fab9faba63b3bb9"/><file name="BatchDelete.class.php" hash="f6c87e688ea9a74b271af1416a5c2d3e"/><file name="BatchDeleteResponse.class.php" hash="281a7f9f48212f37f4a8dd59a8cbef05"/><file name="BatchFetch.class.php" hash="f1bd03669588ce597fb8c9e2ddf1a0c3"/><file name="BatchFetchResponse.class.php" hash="3c348fe3bd7447d1de2b3a7079ef1cb2"/><file name="BatchFetchResult.class.php" hash="8834954a075a890f5408c0fa3f68f359"/><file name="BatchFile.class.php" hash="6c2832889ecfd643bbddd8da92806d17"/><file name="BatchFileDelete.class.php" hash="d026a2536b7062ae435450b53fe81472"/><file name="BatchFileDeleteResponse.class.php" hash="87aa29c139e0f2370d3f32834a3b93d0"/><file name="BatchFileFetch.class.php" hash="8c71726d14294fb18663ba310b76e874"/><file name="BatchFileFetchResponse.class.php" hash="40c3e51f350dd6ce0a84f37e44d0d00c"/><file name="BatchFileFetchResult.class.php" hash="bcf86f8303b40b3304dc8cbf11f9a386"/><file name="BatchFileSave.class.php" hash="e06ef0079955ea1bb79c1e6385761efd"/><file name="BatchFileSaveResponse.class.php" hash="843501f0a13d018d1c48b55750f6e61f"/><file name="BatchFileSaveResult.class.php" hash="620e54c1f0c5d9a461dd9bb7a2de67ce"/><file name="BatchProcess.class.php" hash="5812c04ab18e5c65f598f9fcdfdc428a"/><file name="BatchProcessRequest.class.php" hash="c0b6c76103141b5d07bb62a37a2a7412"/><file name="BatchProcessResponse.class.php" hash="74b46fdcfd39561fed0ba85476d0aafd"/><file name="BatchProcessResult.class.php" hash="274cabe36df7e72f581fa243a2fb8b31"/><file name="BatchSave.class.php" hash="6af9af77f6d3545db34446b1cb25fffd"/><file name="BatchSaveResponse.class.php" hash="98f349e087b1caf602f5f6079a71a146"/><file name="BatchSaveResult.class.php" hash="96b2cfa552d832b75d8561312809216b"/><file name="BatchSvc.class.php" hash="8095b3bba337fe5f83ce6e2ad9ca8623"/><file name="DeleteRequest.class.php" hash="b3f449312c8c302ad919c37282a65857"/><file name="DeleteResult.class.php" hash="6101765b716fb1f3d22d95e5cff59c59"/><file name="FetchRequest.class.php" hash="51f934530a594ecc5b6602e95a90e911"/><file name="FilterRequest.class.php" hash="14fffca5fd500759a41a5072a6731d12"/><file name="FilterResult.class.php" hash="2a2a01693393144a2b9084fc036e7b2c"/><file name="IsAuthorized.class.php" hash="daf2e4fadadfcfc7c1daa5f4083ca4fa"/><file name="IsAuthorizedResponse.class.php" hash="e42a678c7b7f9a31129f87b5aeb1b694"/><file name="IsAuthorizedResult.class.php" hash="55e13f429b08d78b2be811206d4d96a9"/><file name="Message.class.php" hash="21cc40706c1b1bf550f8c84f855960d0"/><file name="Ping.class.php" hash="92358ab5f79862ff0c5e789f64cab8a0"/><file name="PingResponse.class.php" hash="ab87b30bb8204facce97bcf71b589300"/><file name="PingResult.class.php" hash="e22e864065ae905db9c8ef23b69929e7"/><file name="Profile.class.php" hash="655af918d59e879670825e89e43a1fcf"/><file name="SeverityLevel.class.php" hash="2ad4f7c3a19eff71b3459bd261182e50"/></dir><file name="BoundaryLevel.class.php" hash="602a600d04db4d74c7836ee51fafe452"/><file name="CancelCode.class.php" hash="a790b5976535a954f8d6b54e11e305df"/><file name="CancelTaxRequest.class.php" hash="27e2f1313b553ada9af5c6e2c36bbd1d"/><file name="CancelTaxResult.class.php" hash="134c8bc90db0f46a864008c15edf7206"/><file name="CommitTaxRequest.class.php" hash="0ae85335dd2e771760f5cedfeca86f34"/><file name="CommitTaxResult.class.php" hash="f9903f0b8db5a1132e409194147571aa"/><file name="DetailLevel.class.php" hash="b8bbfebb185894572a99a9acd5e53f5d"/><file name="DocStatus.class.php" hash="325c369f1db10b2039d85825a997494f"/><file name="DocumentType.class.php" hash="6ced7e430cf0019d71a83f200de6d086"/><file name="DynamicSoapClient.class.php" hash="3dd165e8cc700b2482a6b5a30568ba7e"/><file name="Enum.class.php" hash="9a131750a6c0bfcef90402721050b27d"/><file name="GetTaxHistoryRequest.class.php" hash="969209d7fc39ed4399d7a0b1fcdd1b60"/><file name="GetTaxHistoryResult.class.php" hash="83b741ace8abca31c0ab6d5c4b8b5c88"/><file name="GetTaxRequest.class.php" hash="2e4a37cb06433880803c679ff0126710"/><file name="GetTaxResult.class.php" hash="d75f0d5fe5b5d351bf92073396c2f951"/><file name="IsAuthorizedResult.class.php" hash="4eb11ff3bdf628cc4e2fc80e35d65de6"/><file name="JurisdictionType.class.php" hash="602d25befdd973b8843bad8202ecfeb7"/><file name="Line.class.php" hash="eacfe73ed6c64325036f9f82c8bca939"/><file name="Message.class.php" hash="07e308557bd2eb7552c15f91e3c85402"/><file name="PingResult.class.php" hash="e3df2dfde0f47ce50c7d95ed61b091da"/><file name="PostTaxRequest.class.php" hash="53acee39c416530b84608660d70ad013"/><file name="PostTaxResult.class.php" hash="a5c918b585ba19331ddfc731d950d9c5"/><file name="ReconcileTaxHistoryRequest.class.php" hash="c5a1d1f0bafa784f33ead69d8adb2bdf"/><file name="ReconcileTaxHistoryResult.class.php" hash="123c536c7f0706139d8f2733d387b4c2"/><file name="SearchTaxHistoryResult.class.php" hash="06175321ad401f59ad2cacd5235c29f2"/><file name="ServiceMode.class.php" hash="f42500790eb598cf28ed0e5a4151ff9c"/><file name="SeverityLevel.class.php" hash="e986ede05ca42f3bb8f1cc41614d9dfc"/><file name="TaxDetail.class.php" hash="c44906a9fd7f2b66050c07b68c9d30b4"/><file name="TaxLine.class.php" hash="481c08a933c0a4530712d405e2ea73b3"/><file name="TaxOverride.class.php" hash="911f2dd4fd707e13e1ce04026cd84b1e"/><file name="TaxOverrideType.class.php" hash="b9b1739cfac7b5523a307a19a705bbb4"/><file name="TaxRequest.class.php" hash="03ba7cc4f0ffa6b4c2fb8eef80b31219"/><file name="TaxServiceSoap.class.php" hash="5f9b9f18e43807cf54f5b0ec915255b4"/><file name="TaxType.class.php" hash="9b51208efe71386135db17fd719160a9"/><file name="TextCase.class.php" hash="9459eeef84909b2a3e7c4fc0855684c9"/><file name="ValidAddress.class.php" hash="0eb72c8763869689f434ac90d568b323"/><file name="ValidateRequest.class.php" hash="444616330d73d1e8bfe4535057a2ce59"/><file name="ValidateResult.class.php" hash="7667161c044dd77f29a0a1863bf2a5f3"/><dir name="wsdl"><file name="Address.wsdl" hash="2ca743760c961db0ae03e4c6900667cb"/><file name="BatchSvc.wsdl" hash="eae666b959c1889d586919da4ebccefd"/><file name="Tax.wsdl" hash="da6b3da89c3e4f3f7db6d0ed9d4d33de"/></dir></dir><file name="functions.php" hash="b94adf9f4887ff8f023fdaff5c64d974"/></dir><dir name="sql"><dir name="avatax_records_setup"><file name="mysql4-install-0.1.0.php" hash="4b83a0755b3d1cfa095649d6d342c9ca"/><file name="mysql4-upgrade-0.1.4-0.1.5.php" hash="75a7ad390a41c2c1f3287ebbf14ab0bd"/><file name="mysql4-upgrade-1.0.1-2.0.0.php" hash="cdd11a55f102b50cf6e522efdb30dadd"/><file name="mysql4-upgrade-2.5.0.0-2.5.0.1.php" hash="5a425755b6aa9f0296ec9aad975653dc"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="OnePica_AvaTax.xml" hash="07fd9423811b4dc084060d6131b889d7"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="onepica"><file name="avatax.xml" hash="a2514046fa0428d24a25f82d17627843"/></dir></dir><dir name="template"><dir name="onepica"><dir name="avatax"><dir name="log"><file name="view.phtml" hash="176cc0e9b7842837be8350de143bc29f"/></dir><dir name="notification"><file name="toolbar.phtml" hash="3fe57e7f43f5995ac69b2c74744bfbd3"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="onepica"><file name="avatax.xml" hash="38c6ce2165f6ccfd6641eb1487faad39"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="OnePica_AvaTax.csv" hash="43d2dee74aee6f15abd471a65b4f407c"/></dir><dir name="en_US"><file name="OnePica_AvaTax.csv" hash="43d2dee74aee6f15abd471a65b4f407c"/></dir><dir name="es_ES"><file name="OnePica_AvaTax.csv" hash="43d2dee74aee6f15abd471a65b4f407c"/></dir><dir name="fr_FR"><file name="OnePica_AvaTax.csv" hash="43d2dee74aee6f15abd471a65b4f407c"/></dir><dir name="nl_NL"><file name="OnePica_AvaTax.csv" hash="43d2dee74aee6f15abd471a65b4f407c"/></dir><dir name="pt_BR"><file name="OnePica_AvaTax.csv" hash="43d2dee74aee6f15abd471a65b4f407c"/></dir><dir name="zh_CN"><file name="OnePica_AvaTax.csv" hash="43d2dee74aee6f15abd471a65b4f407c"/></dir></target></contents>
42
  <compatible/>
43
+ <dependencies><required><php><min>5.2.3</min><max>6.0.0</max></php><extension><name>Core</name><min/><max/></extension><extension><name>curl</name><min/><max/></extension><extension><name>soap</name><min/><max/></extension></required></dependencies>
44
  </package>