Version Notes
Added Validation of Countrycode
Download this release
Release Info
Developer | Roman Hutterer |
Extension | Multibyte_VATFix |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
app/code/community/Multibyte/VATFix/Helper/Countries.php
ADDED
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Multibyte_VATFix_Helper_Countries extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
public function getCountries() {
|
6 |
+
return array(
|
7 |
+
"AF" => "Afghanistan",
|
8 |
+
"AX" => "\xc3\x85land Islands",
|
9 |
+
"AL" => "Albania",
|
10 |
+
"DZ" => "Algeria",
|
11 |
+
"AS" => "American Samoa",
|
12 |
+
"AD" => "Andorra",
|
13 |
+
"AO" => "Angola",
|
14 |
+
"AI" => "Anguilla",
|
15 |
+
"AQ" => "Antarctica",
|
16 |
+
"AG" => "Antigua and Barbuda",
|
17 |
+
"AR" => "Argentina",
|
18 |
+
"AM" => "Armenia",
|
19 |
+
"AW" => "Aruba",
|
20 |
+
"AU" => "Australia",
|
21 |
+
"AT" => "Austria",
|
22 |
+
"AZ" => "Azerbaijan",
|
23 |
+
"BS" => "Bahamas",
|
24 |
+
"BH" => "Bahrain",
|
25 |
+
"BD" => "Bangladesh",
|
26 |
+
"BB" => "Barbados",
|
27 |
+
"BY" => "Belarus",
|
28 |
+
"BE" => "Belgium",
|
29 |
+
"BZ" => "Belize",
|
30 |
+
"BJ" => "Benin",
|
31 |
+
"BM" => "Bermuda",
|
32 |
+
"BT" => "Bhutan",
|
33 |
+
"BO" => "Bolivia, Plurinational State of",
|
34 |
+
"BQ" => "Bonaire, Sint Eustatius and Saba",
|
35 |
+
"BA" => "Bosnia and Herzegovina",
|
36 |
+
"BW" => "Botswana",
|
37 |
+
"BV" => "Bouvet Island",
|
38 |
+
"BR" => "Brazil",
|
39 |
+
"IO" => "British Indian Ocean Territory",
|
40 |
+
"BN" => "Brunei Darussalam",
|
41 |
+
"BG" => "Bulgaria",
|
42 |
+
"BF" => "Burkina Faso",
|
43 |
+
"BI" => "Burundi",
|
44 |
+
"KH" => "Cambodia",
|
45 |
+
"CM" => "Cameroon",
|
46 |
+
"CA" => "Canada",
|
47 |
+
"CV" => "Cape Verde",
|
48 |
+
"KY" => "Cayman Islands",
|
49 |
+
"CF" => "Central African Republic",
|
50 |
+
"TD" => "Chad",
|
51 |
+
"CL" => "Chile",
|
52 |
+
"CN" => "China",
|
53 |
+
"CX" => "Christmas Island",
|
54 |
+
"CC" => "Cocos (Keeling) Islands",
|
55 |
+
"CO" => "Colombia",
|
56 |
+
"KM" => "Comoros",
|
57 |
+
"CG" => "Congo",
|
58 |
+
"CD" => "Congo, The Democratic Republic of the",
|
59 |
+
"CK" => "Cook Islands",
|
60 |
+
"CR" => "Costa Rica",
|
61 |
+
"CI" => "C\xc3\xb4te d'Ivoire",
|
62 |
+
"HR" => "Croatia",
|
63 |
+
"CU" => "Cuba",
|
64 |
+
"CW" => "Cura\xc3\xa7ao",
|
65 |
+
"CY" => "Cyprus",
|
66 |
+
"CZ" => "Czech Republic",
|
67 |
+
"DK" => "Denmark",
|
68 |
+
"DJ" => "Djibouti",
|
69 |
+
"DM" => "Dominica",
|
70 |
+
"DO" => "Dominican Republic",
|
71 |
+
"EC" => "Ecuador",
|
72 |
+
"EG" => "Egypt",
|
73 |
+
"SV" => "El Salvador",
|
74 |
+
"GQ" => "Equatorial Guinea",
|
75 |
+
"ER" => "Eritrea",
|
76 |
+
"EE" => "Estonia",
|
77 |
+
"ET" => "Ethiopia",
|
78 |
+
"FK" => "Falkland Islands (Malvinas)",
|
79 |
+
"FO" => "Faroe Islands",
|
80 |
+
"FJ" => "Fiji",
|
81 |
+
"FI" => "Finland",
|
82 |
+
"FR" => "France",
|
83 |
+
"GF" => "French Guiana",
|
84 |
+
"PF" => "French Polynesia",
|
85 |
+
"TF" => "French Southern Territories",
|
86 |
+
"GA" => "Gabon",
|
87 |
+
"GM" => "Gambia",
|
88 |
+
"GE" => "Georgia",
|
89 |
+
"DE" => "Germany",
|
90 |
+
"GH" => "Ghana",
|
91 |
+
"GI" => "Gibraltar",
|
92 |
+
"EL" => "Greece",
|
93 |
+
"GL" => "Greenland",
|
94 |
+
"GD" => "Grenada",
|
95 |
+
"GP" => "Guadeloupe",
|
96 |
+
"GU" => "Guam",
|
97 |
+
"GT" => "Guatemala",
|
98 |
+
"GG" => "Guernsey",
|
99 |
+
"GN" => "Guinea",
|
100 |
+
"GW" => "Guinea-Bissau",
|
101 |
+
"GY" => "Guyana",
|
102 |
+
"HT" => "Haiti",
|
103 |
+
"HM" => "Heard Island and McDonald Islands",
|
104 |
+
"VA" => "Holy See (Vatican City State)",
|
105 |
+
"HN" => "Honduras",
|
106 |
+
"HK" => "Hong Kong",
|
107 |
+
"HU" => "Hungary",
|
108 |
+
"IS" => "Iceland",
|
109 |
+
"IN" => "India",
|
110 |
+
"ID" => "Indonesia",
|
111 |
+
"IR" => "Iran, Islamic Republic of",
|
112 |
+
"IQ" => "Iraq",
|
113 |
+
"IE" => "Ireland",
|
114 |
+
"IM" => "Isle of Man",
|
115 |
+
"IL" => "Israel",
|
116 |
+
"IT" => "Italy",
|
117 |
+
"JM" => "Jamaica",
|
118 |
+
"JP" => "Japan",
|
119 |
+
"JE" => "Jersey",
|
120 |
+
"JO" => "Jordan",
|
121 |
+
"KZ" => "Kazakhstan",
|
122 |
+
"KE" => "Kenya",
|
123 |
+
"KI" => "Kiribati",
|
124 |
+
"KP" => "Korea, Democratic People's Republic of",
|
125 |
+
"KR" => "Korea, Republic of",
|
126 |
+
"KW" => "Kuwait",
|
127 |
+
"KG" => "Kyrgyzstan",
|
128 |
+
"LA" => "Lao People's Democratic Republic",
|
129 |
+
"LV" => "Latvia",
|
130 |
+
"LB" => "Lebanon",
|
131 |
+
"LS" => "Lesotho",
|
132 |
+
"LR" => "Liberia",
|
133 |
+
"LY" => "Libya",
|
134 |
+
"LI" => "Liechtenstein",
|
135 |
+
"LT" => "Lithuania",
|
136 |
+
"LU" => "Luxembourg",
|
137 |
+
"MO" => "Macao",
|
138 |
+
"MK" => "Macedonia, The Former Yugoslav Republic of",
|
139 |
+
"MG" => "Madagascar",
|
140 |
+
"MW" => "Malawi",
|
141 |
+
"MY" => "Malaysia",
|
142 |
+
"MV" => "Maldives",
|
143 |
+
"ML" => "Mali",
|
144 |
+
"MT" => "Malta",
|
145 |
+
"MH" => "Marshall Islands",
|
146 |
+
"MQ" => "Martinique",
|
147 |
+
"MR" => "Mauritania",
|
148 |
+
"MU" => "Mauritius",
|
149 |
+
"YT" => "Mayotte",
|
150 |
+
"MX" => "Mexico",
|
151 |
+
"FM" => "Micronesia, Federated States of",
|
152 |
+
"MD" => "Moldova, Republic of",
|
153 |
+
"MC" => "Monaco",
|
154 |
+
"MN" => "Mongolia",
|
155 |
+
"ME" => "Montenegro",
|
156 |
+
"MS" => "Montserrat",
|
157 |
+
"MA" => "Morocco",
|
158 |
+
"MZ" => "Mozambique",
|
159 |
+
"MM" => "Myanmar",
|
160 |
+
"NA" => "Namibia",
|
161 |
+
"NR" => "Nauru",
|
162 |
+
"NP" => "Nepal",
|
163 |
+
"NL" => "Netherlands",
|
164 |
+
"NC" => "New Caledonia",
|
165 |
+
"NZ" => "New Zealand",
|
166 |
+
"NI" => "Nicaragua",
|
167 |
+
"NE" => "Niger",
|
168 |
+
"NG" => "Nigeria",
|
169 |
+
"NU" => "Niue",
|
170 |
+
"NF" => "Norfolk Island",
|
171 |
+
"MP" => "Northern Mariana Islands",
|
172 |
+
"NO" => "Norway",
|
173 |
+
"OM" => "Oman",
|
174 |
+
"PK" => "Pakistan",
|
175 |
+
"PW" => "Palau",
|
176 |
+
"PS" => "Palestine, State of",
|
177 |
+
"PA" => "Panama",
|
178 |
+
"PG" => "Papua New Guinea",
|
179 |
+
"PY" => "Paraguay",
|
180 |
+
"PE" => "Peru",
|
181 |
+
"PH" => "Philippines",
|
182 |
+
"PN" => "Pitcairn",
|
183 |
+
"PL" => "Poland",
|
184 |
+
"PT" => "Portugal",
|
185 |
+
"PR" => "Puerto Rico",
|
186 |
+
"QA" => "Qatar",
|
187 |
+
"RE" => "R\xc3\xa9union",
|
188 |
+
"RO" => "Romania",
|
189 |
+
"RU" => "Russian Federation",
|
190 |
+
"RW" => "Rwanda",
|
191 |
+
"BL" => "Saint Barth\xc3\xa9lemy",
|
192 |
+
"SH" => "Saint Helena, Ascension and Tristan Da Cunha",
|
193 |
+
"KN" => "Saint Kitts and Nevis",
|
194 |
+
"LC" => "Saint Lucia",
|
195 |
+
"MF" => "Saint Martin (French part)",
|
196 |
+
"PM" => "Saint Pierre and Miquelon",
|
197 |
+
"VC" => "Saint Vincent and the Grenadines",
|
198 |
+
"WS" => "Samoa",
|
199 |
+
"SM" => "San Marino",
|
200 |
+
"ST" => "Sao Tome and Principe",
|
201 |
+
"SA" => "Saudi Arabia",
|
202 |
+
"SN" => "Senegal",
|
203 |
+
"RS" => "Serbia",
|
204 |
+
"SC" => "Seychelles",
|
205 |
+
"SL" => "Sierra Leone",
|
206 |
+
"SG" => "Singapore",
|
207 |
+
"SX" => "Sint Maarten (Dutch part)",
|
208 |
+
"SK" => "Slovakia",
|
209 |
+
"SI" => "Slovenia",
|
210 |
+
"SB" => "Solomon Islands",
|
211 |
+
"SO" => "Somalia",
|
212 |
+
"ZA" => "South Africa",
|
213 |
+
"GS" => "South Georgia and the South Sandwich Islands",
|
214 |
+
"SS" => "South Sudan",
|
215 |
+
"ES" => "Spain",
|
216 |
+
"LK" => "Sri Lanka",
|
217 |
+
"SD" => "Sudan",
|
218 |
+
"SR" => "Suriname",
|
219 |
+
"SJ" => "Svalbard and Jan Mayen",
|
220 |
+
"SZ" => "Swaziland",
|
221 |
+
"SE" => "Sweden",
|
222 |
+
"CH" => "Switzerland",
|
223 |
+
"SY" => "Syrian Arab Republic",
|
224 |
+
"TW" => "Taiwan, Province of China",
|
225 |
+
"TJ" => "Tajikistan",
|
226 |
+
"TZ" => "Tanzania, United Republic of",
|
227 |
+
"TH" => "Thailand",
|
228 |
+
"TL" => "Timor-Leste",
|
229 |
+
"TG" => "Togo",
|
230 |
+
"TK" => "Tokelau",
|
231 |
+
"TO" => "Tonga",
|
232 |
+
"TT" => "Trinidad and Tobago",
|
233 |
+
"TN" => "Tunisia",
|
234 |
+
"TR" => "Turkey",
|
235 |
+
"TM" => "Turkmenistan",
|
236 |
+
"TC" => "Turks and Caicos Islands",
|
237 |
+
"TV" => "Tuvalu",
|
238 |
+
"UG" => "Uganda",
|
239 |
+
"UA" => "Ukraine",
|
240 |
+
"AE" => "United Arab Emirates",
|
241 |
+
"GB" => "United Kingdom",
|
242 |
+
"US" => "United States",
|
243 |
+
"UM" => "United States Minor Outlying Islands",
|
244 |
+
"UY" => "Uruguay",
|
245 |
+
"UZ" => "Uzbekistan",
|
246 |
+
"VU" => "Vanuatu",
|
247 |
+
"VE" => "Venezuela, Bolivarian Republic of",
|
248 |
+
"VN" => "Viet Nam",
|
249 |
+
"VG" => "Virgin Islands, British",
|
250 |
+
"VI" => "Virgin Islands, U.S.",
|
251 |
+
"WF" => "Wallis and Futuna",
|
252 |
+
"EH" => "Western Sahara",
|
253 |
+
"YE" => "Yemen",
|
254 |
+
"ZM" => "Zambia",
|
255 |
+
"ZW" => "Zimbabwe"
|
256 |
+
);
|
257 |
+
}
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
?>
|
app/code/{local → community}/Multibyte/VATFix/Helper/Data.php
RENAMED
@@ -18,9 +18,10 @@ class Multibyte_VATFix_Helper_Data extends Mage_Customer_Helper_Data {
|
|
18 |
* @return boolean
|
19 |
*/
|
20 |
public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode = '', $requesterVatNumber = '') {
|
21 |
-
//@RHU take the VAT without the first two signs (which are the countrycode
|
22 |
-
|
23 |
-
|
|
|
24 |
return parent::checkVatNumber($countryCode, $vatNumber, $requesterCountryCode, $requesterVatNumber);
|
25 |
}
|
26 |
|
@@ -34,4 +35,17 @@ class Multibyte_VATFix_Helper_Data extends Mage_Customer_Helper_Data {
|
|
34 |
return new SoapClient(self::VAT_VALIDATION_WSDL_URL, array('trace' => $trace));
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
18 |
* @return boolean
|
19 |
*/
|
20 |
public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode = '', $requesterVatNumber = '') {
|
21 |
+
//@RHU take the VAT without the first two signs (which are the countrycode)
|
22 |
+
if ($this->includesCountryCode($vatNumber)) {
|
23 |
+
$vatNumber = substr(str_replace(' ', '', trim($vatNumber)), 2);
|
24 |
+
}
|
25 |
return parent::checkVatNumber($countryCode, $vatNumber, $requesterCountryCode, $requesterVatNumber);
|
26 |
}
|
27 |
|
35 |
return new SoapClient(self::VAT_VALIDATION_WSDL_URL, array('trace' => $trace));
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
+
* parse the VAT if it includes the countrycode
|
40 |
+
* @param string $vatNumber
|
41 |
+
* @return boolean
|
42 |
+
*/
|
43 |
+
public function includesCountryCode($vatNumber) {
|
44 |
+
$countryCode = substr(str_replace(' ', '', trim($vatNumber)), 0, 2);
|
45 |
+
if (array_key_exists(strtoupper($countryCode), Mage::helper('multibyte_vatfix/countries')->getCountries())) {
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
|
51 |
}
|
app/code/{local → community}/Multibyte/VATFix/etc/config.xml
RENAMED
@@ -12,6 +12,9 @@
|
|
12 |
<data>Multibyte_VATFix_Helper_Data</data>
|
13 |
</rewrite>
|
14 |
</customer>
|
|
|
|
|
|
|
15 |
</helpers>
|
16 |
</global>
|
17 |
</config>
|
12 |
<data>Multibyte_VATFix_Helper_Data</data>
|
13 |
</rewrite>
|
14 |
</customer>
|
15 |
+
<multibyte_vatfix>
|
16 |
+
<class>Multibyte_VATFix_Helper</class>
|
17 |
+
</multibyte_vatfix>
|
18 |
</helpers>
|
19 |
</global>
|
20 |
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Multibyte_VATFix</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
@@ -11,11 +11,11 @@
|
|
11 |
<description>The VatFix extension for magento fixes the broken VAT check in Magento for European Companies which want to use the built-in feature of Customergroups based on valid VAT-number in Magento.
|
12 |

|
13 |
With this extension the ability to change a Customers Usergroup bases on a valid VAT number is possible.</description>
|
14 |
-
<notes>
|
15 |
<authors><author><name>Roman Hutterer</name><user>roman204</user><email>info@multibyte.at</email></author></authors>
|
16 |
-
<date>2013-07-
|
17 |
-
<time>
|
18 |
-
<contents><target name="
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>5.1.0</min><max>5.4.0</max></php></required></dependencies>
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Multibyte_VATFix</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
11 |
<description>The VatFix extension for magento fixes the broken VAT check in Magento for European Companies which want to use the built-in feature of Customergroups based on valid VAT-number in Magento.
|
12 |

|
13 |
With this extension the ability to change a Customers Usergroup bases on a valid VAT number is possible.</description>
|
14 |
+
<notes>Added Validation of Countrycode</notes>
|
15 |
<authors><author><name>Roman Hutterer</name><user>roman204</user><email>info@multibyte.at</email></author></authors>
|
16 |
+
<date>2013-07-25</date>
|
17 |
+
<time>17:57:57</time>
|
18 |
+
<contents><target name="magecommunity"><dir name="Multibyte"><dir name="VATFix"><dir name="Helper"><file name="Countries.php" hash="3dcb13f1bdeb978d3be3edd875231228"/><file name="Data.php" hash="b53b47865a9eb00cb4250364269a0aee"/></dir><dir name="etc"><file name="config.xml" hash="be3a4af513e7fc31f526f9638c8fed4e"/></dir></dir></dir></target></contents>
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>5.1.0</min><max>5.4.0</max></php></required></dependencies>
|
21 |
</package>
|