Community Add-Ons
E.U. VAT Intracom Number
for osCommerce Online Merchant v2.2
European Union VAT INTRACOM Number V3.3 - JeanLuc - Under GPL
Update for MS2: February, 5th 2004
## This 3.3 version fixes some bugs appeared in previous version.
New separated VAT number menu in the admin configuration menu.
New checking function of the VAT number with the europa.eu.int server (enable/disable in the admin menu).
Bugs fixed for checking input in catalog/admin/customers.php
Modification of function managing the display of addresses (tep_address_format) has been integrated with this new version of VAT_INTRACOM.
ATTENTION !!!:
VAT_INTRACOM field is placed when you enter data in company's field (ACCOUNT_COMPANY == true) to be set in admin/Configuration/customers details/company
The figure of the VAT number (10 minimum) can be set in: admin/Configuration/VAT_INTRACOM/VAT Intracom minimum
VAT INTRACOM number of your shop has to be filled in admin/Configuration/VAT Intracom/VAT Intracom of my shop
For info, the structure of the VAT numbers must be as following:
Germany DE + 9 numeric characters
Austria AT + 9 numeric and alphanumeric characters
Belgium BE + 9 numeric characters
Denmark DK + 8 numeric characters
Spain ES + 9 characters
Finland FI + 8 numeric characters
France FR + 2 figures (informatic key) + N° SIREN (9 figures)
United-Kingdom GB + 9 numeric characters
Greece EL + 9 numeric characters
Irlande IE + 8 numeric and alphabetic characters
Italy IT + 11 numeric characters
Luxembourg LU + 8 numeric characters
Netherlands NL + 12 alphanumeric characters, one of them a letter
Portugal PT + 9 numeric characters
Sweden SE + 12 numeric characters
there was a missing "_entry" in the
catalog/admin/customers.php changes
this ..
// End update for TVA_INTRACOM_v3.9
$result_tva = tep_verif_tva(strtoupper(rtrim($tva_intracom)));
should be like this
// End update for TVA_INTRACOM_v3.9
$result_tva = tep_verif_tva(strtoupper(rtrim($entry_tva_intracom)));
anyway I updated the instructions and am adding that file here...
update v. 5.1: fix a bug for php5 users: this built-in SOAP extension used same soapclient() class name as Nusoap. I just change the class name in sopclient_nusoap() in the files nusoap.php and validations.php both in admin and catalog.
Have a look to http://fr2.php.net/manual/en/ref.soap.php for more infos.
Also add 2 more countries (Bulgaria and Romania) in the EU countries array (thanks to Madenio).
FULL PACKAGE
For version 5 users, just replace classes/nusoap.php and functions/validations.php files in both admin and catalog sections
Little fix for users, who are not able to use the new SOAP version for VAT validation.
Just 2 changed files added. Refer to readme inside the .zip file. Enjoy!
This update use now the new webservice (SOAP) proposed by the europa site (http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl) for checking the VAT number type by customers when they create their count in the shop.
Previous versions only checked the VAT number using the HTML page in the europa site (http://ec.europa.eu/taxation_customs/vies/fr/vieshome.htm).
Now, the verification use SOAP protocol via nusoap.php class file (Dietrich Ayala) included in this package.
It is more secure and "clean".
For those who have already installed this contribution, the only changes are:
2 new files added:
catalog/admin/includes/classes/nusoap.php
and
catalog/includes/classes/nusoap.php
and the tep_verif_tva() functions updated in
catalog/admin/includes/functions/validations.php
and
catalog/includes/functions/validations.php
Complete package.
Bugfix with this version:
When customer choose "France métropolitaine" or "Greece" as his country, the contribution refused the VAT number.
To fix that:
In catalog/create_account.php, catalog/address_book_process.php, catalog/checkout_payment_address.php, catalog/checkout_shipping_address.php,
find this line added by the contribution:
if ( (array_search($country_code['countries_iso_code_2'], array_keys(tep_get_tva_intracom_array())) === false) || ($country_code['countries_iso_code_2'] != substr(strtoupper(trim($tva_intracom)),0,2)) ) {
and replace it by:
$tva_intracom_array = tep_get_tva_intracom_array();
if ( (array_search($country_code['countries_iso_code_2'], array_keys($tva_intracom_array) ) === false) || ($tva_intracom_array[$country_code['countries_iso_code_2']] != substr(strtoupper(trim($tva_intracom)),0,2)) ) {
That's it...
Anyway, this version is a complete package...
Fixing 2 queries in the install_English.txt file (inappropriate quotes)
Thanks to Berkedam in the french forum of osCommerce.
UPDATE_from_every_previous_version :
Since the beginning of this contribution (version 1.0...), I notice an error in the install.txt file :
The modification in the catalog/includes/classes/order.php file is not explained....but it should have been done...
If not, the VAT number is not displayed in the checkout_confirmation page and not saved in the orders table in the database.
The file was correctly modified and placed in the package but the modifications was not mentioned in the install.txt file.
If you installed the contribution with the install.txt file, please do the following:
===================================
In catalog/includes/classes/order.php
After those lines (around 34):
function query($order_id) {
global $languages_id;
$order_id = tep_db_prepare_input($order_id);
Add database field "billing_tva_intracom" in the following request:
//Add for TVA_intracom : "billing_tva_intracom"
$order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_tva_intracom, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
---------------------------------
After these lines (around 93):
$this->billing = array('name' => $order['billing_name'],
'company' => $order['billing_company'],
Add:
//BOF for VAT INTRACOM
'tva_intracom' => $order['billing_tva_intracom'],
// EOF for TVA_INTRACOM
---------------------------------
After those lines (around 141):
function cart() {
global $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment;
$this->content_type = $cart->get_content_type();
Add database field "ab.entry_tva_intracom" in the following request:
//Add for TVA_intracom : "ab.entry_tva_intracom"
$customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_tva_intracom, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id");
---------------------------------
After this line (around 146):
$shipping_address = tep_db_fetch_array($shipping_address_query);
Add database field "ab.entry_tva_intracom" in the following request:
$billing_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_tva_intracom, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$billto . "'");
---------------------------------
After those lines (around 212):
$this->billing = array('firstname' => $billing_address['entry_firstname'],
'lastname' => $billing_address['entry_lastname'],
'company' => $billing_address['entry_company'],
Add:
//BOF for VAT INTRACOM
'tva_intracom' => $billing_address['entry_tva_intracom'],
// EOF for TVA_INTRACOM
=================================
I'm sorry about this oversight ....
I was always testing the contribution in my correct installation where the modification is done....
UPDATE_from_every_previous_version :
Since the beginning of this contribution (version 1.0...), I notice an error in the install.txt file :
The modification in the catalog/includes/classes/order.php file is not explained....but it should have been done...
If not, the VAT number is not displayed in the checkout_confirmation page and not saved in the orders table in the database.
The file was correctly modified and placed in the package but the modifications was not mentioned in the install.txt file.
If you installed the contribution with the install.txt file, please do the following:
===================================
In catalog/includes/classes/order.php
After those lines (around 34):
function query($order_id) {
global $languages_id;
$order_id = tep_db_prepare_input($order_id);
Add database field "billing_tva_intracom" in the following request:
//Add for TVA_intracom : "billing_tva_intracom"
$order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_tva_intracom, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
---------------------------------
After these lines (around 93):
$this->billing = array('name' => $order['billing_name'],
'company' => $order['billing_company'],
Add:
//BOF for VAT INTRACOM
'tva_intracom' => $order['billing_tva_intracom'],
// EOF for TVA_INTRACOM
---------------------------------
After those lines (around 141):
function cart() {
global $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment;
$this->content_type = $cart->get_content_type();
Add database field "ab.entry_tva_intracom" in the following request:
//Add for TVA_intracom : "ab.entry_tva_intracom"
$customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_tva_intracom, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id");
---------------------------------
After this line (around 146):
$shipping_address = tep_db_fetch_array($shipping_address_query);
Add database field "ab.entry_tva_intracom" in the following request:
$billing_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_tva_intracom, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$billto . "'");
---------------------------------
After those lines (around 212):
$this->billing = array('firstname' => $billing_address['entry_firstname'],
'lastname' => $billing_address['entry_lastname'],
'company' => $billing_address['entry_company'],
Add:
//BOF for VAT INTRACOM
'tva_intracom' => $billing_address['entry_tva_intracom'],
// EOF for TVA_INTRACOM
=================================
I'm sorry about this oversight ....
I was always testing the contribution in my correct installation where the modification is done....
Fix of a bug when you wanted to change the VAT number in the admin section (customers.php), the verification was false everytime....
This version fixes the bug in the install.txt file and in the .php files
See the post in the forum for more info:
http://forums.oscommerce.com/index.php?showtopic=76315&st=110&#entry433280
Because of the changes in the europa.eu.int site (where the check of the VAT number is done) we have to modify the tep_verif_tva() function.
For this new update, in your php.ini file, be sure 'allow_url_fopen' is enabled : " allow_url_fopen = On "
In this package, there is always the complete contribution with install.txt file in english and in french.
Also, an update.txt file for those who have already installed the contribution version 3.3 or upper.
Because of a change in the cgi-bin (or something else...) in the europa.eu.int site (the checking site of the VAT n°), the automatic checking of the VAT number is not available anymore....
That circumstance was not planned...
To solve the problem for the moment, we have to change the condition of display of the error message in both catalog/includes/functions/validations.php and catalog/admin/includes/functions/validations.php, change these lines (in tep_verif_tva function):
if (is_string($verif)) {
$str = str_replace("n", "", $verif);
preg_match('/</form> *(Oui|Non)/i', $str, $a);
if ($a[1] == 'Oui') {
return 'true';
} else {
return 'false';
}
} else {
return 'no_verif'; // no check available
}
with these lines :
if (is_string($verif)) {
$str = str_replace("n", "", $verif);
preg_match('/</form> *(Oui|Non)/i', $str, $a);
if ($a[1] == 'Oui') {
return 'true';
} elseif ($a[1] == 'Non'){
return 'false';
} else {
return 'no_verif'; // no check available
}
} else {
return 'no_verif'; // no check available
}[/
With those changes, we have an error message displayed even the answer of the europa site is not "Oui" or "Non".
Fix a bug in admin/customers.php:
in admin menu, if "Check the Intracom VAT number" was on "false", the VAT field in admin/customers.php was hidden.
This update fixes it...
Fix a bug In catalog/includes/form_check.js.php
After this line (around 88)
} else if (password_new != password_confirmation) {
error_message = error_message + "* " + message_3 + "n";
error = true;
}
}
}
Replace (added in the previous version):
<!--BOF for VAT INTRACOM_v3.3 //-->
function check_company(field_name, field_size, message) {
if ( form.elements[company].value != '' && form.elements[field_name].value < field_size ) {
error = true;
error_message = error_message + "* " + message + "n";
}
}
<!-- EOF for TVA_INTRACOM_v3.3 //-->
BY this code I changed "company" by "field_name":
<!--BOF for VAT INTRACOM_v3.3 //-->
function check_company(field_name, field_size, message) {
if ( form.elements[field_name].value != '' && form.elements[field_name].value < field_size ) {
error = true;
error_message = error_message + "* " + message + "n";
}
}
<!-- EOF for TVA_INTRACOM_v3.3 //-->
New functionality for this update:
this version check if the vat number entered by the customer correspond to his country.
For those who had already intalled previous version, there is an "update.txt" file which explain the steps of the modifications.
Fix a bug in the 3.81 version (bad name of a variable)
I found a pb when the customer enters the VAT number in lower case (especially the first letters...), the ckecking returns false.
If you don't want that, replace in:
admin/customers.php
catalog/create_account.php
catalog/address_book_process.php
catalog/checkout_shipping_address.php
catalog/checkout_payment_address.php
catalog/account_edit.php
the folowing line:
$result_tva = tep_verif_tva(rtrim($tva_intracom));
by this one:
$result_tva = tep_verif_tva(strtoupper(rtrim($tva_intracom)));
Anyway, the .zip file contains all files and install advices for a complete updated contribution.
enjoy...
I found a pb when the customer enters the VAT number in lower case (especially the first letters...), the ckecking returns false.
If you don't want that, replace in:
admin/customers.php
catalog/create_account.php
catalog/address_book_process.php
catalog/checkout_shipping_address.php
catalog/checkout_payment_address.php
catalog/account_edit.php
the folowing line:
CODE
$result_tva = tep_verif_tva(rtrim($tva_intracom));
by this one:
CODE
$result_tva = tep_verif_tva(strtoupper(rtrim($tva_intracom)));
Anyway, the .zip file contains all files and install advices for a complete updated contribution.
enjoy...
I found a pb when the customer enters the VAT number in lower case (especially the first letters...), the ckecking returns false.
If you don't want that, replace in:
admin/customers.php
catalog/create_account.php
catalog/address_book_process.php
catalog/checkout_shipping_address.php
catalog/checkout_payment_address.php
catalog/account_edit.php
the folowing line:
CODE
$result_tva = tep_verif_tva(rtrim($tva_intracom));
by this one:
CODE
$result_tva = tep_verif_tva(strtoupper(rtrim($tva_intracom)));
enjoy...
Because of the 10 new brand states members in European Union, just an update of the languages files for the error messages:
The VAT number must be structured like this:
Germany DE + 9 numeric characters
Austria AT + 9 numeric and alphanumeric characters
Belgium BE + 9 numeric characters
Denmark DK + 8 numeric characters
Spain ES + 9 characters
Finland FI + 8 numeric characters
France FR + 2 figures (informatic key) + N° SIREN (9 figures)
United-Kingdom GB + 9 numeric characters
Greece EL + 9 numeric characters
Irlande IE + 8 numeric and alphabetic characters
Italy IT + 11 numeric characters
Luxembourg LU + 8 numeric characters
Netherlands NL + 12 alphanumeric characters, one of them a letter
Portugal PT + 9 numeric characters
Sweden SE + 12 numeric characters
Cyprus CY + 8 numeric characters + 1 alphabetic character
Estonia EE + 9 numeric characters
Hungary HU + 8 numeric characters
Latvia LV + 11 numeric characterss
Lithuania LT + 9 ou 12 numeric characters
Malta MT + 8 numeric characters
Poland PL + 10 numeric characters
Slovakia SK + 9 ou 10 numeric characters
Czech Republic CZ + 8 ou 9 ou 10 numeric characters
Slovenia SI + 8 numeric characters
Add of a "missing" define in an admin language file.
In the install.txt file, add a link to this forum topic:
http://forums.oscommerce.com/index.php?showtopic=76315
where you can pick up 2 files if you don't want taxes automatically.
Fix a bug in the precedent .sql files where the key words 'true' and 'false' was written with a high case (so pb in a Unix server).
Fix a bug in the enhlish .sql file in the previous version
This version fixe a bug in the .sql file of the previous version.
European Union VAT INTRACOM Number V3.3 - JeanLuc - Under GPL
Update for MS2: February, 5th 2004
## This 3.3 version fixes some bugs appeared in previous version.
New separated VAT number menu in the admin configuration menu.
New checking function of the VAT number with the europa.eu.int server (enable/disable in the admin menu).
Bugs fixed for checking input in catalog/admin/customers.php
Modification of function managing the display of addresses (tep_address_format) has been integrated with this new version of VAT_INTRACOM.
ATTENTION !!!:
VAT_INTRACOM field is placed when you enter data in company's field (ACCOUNT_COMPANY == true) to be set in admin/Configuration/customers details/company
The figure of the VAT number (10 minimum) can be set in: admin/Configuration/VAT_INTRACOM/VAT Intracom minimum
VAT INTRACOM number of your shop has to be filled in admin/Configuration/VAT Intracom/VAT Intracom of my shop
For info, the structure of the VAT numbers must be as following:
Germany DE + 9 numeric characters
Austria AT + 9 numeric and alphanumeric characters
Belgium BE + 9 numeric characters
Denmark DK + 8 numeric characters
Spain ES + 9 characters
Finland FI + 8 numeric characters
France FR + 2 figures (informatic key) + N° SIREN (9 figures)
United-Kingdom GB + 9 numeric characters
Greece EL + 9 numeric characters
Irlande IE + 8 numeric and alphabetic characters
Italy IT + 11 numeric characters
Luxembourg LU + 8 numeric characters
Netherlands NL + 12 alphanumeric characters, one of them a letter
Portugal PT + 9 numeric characters
Sweden SE + 12 numeric characters
