Community Add-Ons
TVA Intracommunautaire v2.0
for osCommerce Online Merchant v2.2
Contribution based on an initial work of Gyakutsuki.
Install.txt in French.
Usefull for the new European reglementation about intracom VAT and the necessity of having this "Intracom VAT number" written on the invoices inside the CEE.
Version 5.1: pour les utilisateurs de PHP5, il pouvait y avoir un conflit entre les noms de la classe "soapclient" si la library SOAP de PHP 5 était installée.
Le pb a été réglé en modifiant le nom de cette classe (de "soapclient" en "soapclient_nusoap") dans les fichiers concernés (nusoap.php x2 et validations.php x2 dans l'admin et le catalog).
Egalement, ajout des 2 nouveaux pays entrant dans l'UE (Roumanie et Bulgarie) dans le tableau des correspondance de la fonction tep_get_tva_intracom_array() (fichiers validations.php x2 dans admin et catalog - merci à Madenio).
FULL PACKAGE
Pour les utilisateur de la version 5 de la contrib, seulement remplacer les fichiers classes/nusoap.php et functions/validations.php dans les 2 section admin et catalog.
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.
for users how like to run this on a php version below 4
//u could use the workaround instead of this
function:
//for PHP < 4.x
if(function_exists('file_get_contents')) {
$monfd = file_get_contents('http://www.europa.eu.int/comm/taxation_customs/vies/cgi-bin/viesquer?MS=' . $prefix . '&Lang=FR&VAT=' . $tva, r);
}else{
$monfd = implode('',file('http://www.europa.eu.int/comm/taxation_customs/vies/cgi-bin/viesquer?MS=' . $prefix . '&Lang=FR&VAT=' . $tva, r));
}
Added 10 countries to the zones_to_geo_zones file. Might be handy since you won't have to edit file yourselves.
No credits for the contribution otherwise. Didn't touch a thing. This upload contains the above file only.
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....
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 //-->
Nouvelle fonctionnalité dans cette MAJ:
cette version vérifie si le n° TVA indiqué par le client correspond à son pays.
Pour ceux qui ont déjà une version antérieure d'installée, il y a un fichier "update.txt" qui explique la démarche pour la MAJ.
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...
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.
pour les francophones, voir ce post:
http://www.oscommerce-fr.info/forum/index.php?showtopic=9507
Modification des fichiers .sql : bug dans l'orthographe des mots clés 'true' et 'false' écrits avec une majuscule dans le précédent fichier.
D'ou un pb sur les serveurs unix (case sensitive).
Bug corrigé dans le fichier anglais .sql dans la précédente version...
Cette version corrige un bug dans le fichier .sql de la version précédente...
This 3.3 version fixes some bugs appeared in previous version.
PLUS:
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 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 number 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
Update for MS2: January, 30th 2004 ENGLISH IS NOW AVAILABLE:
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 (13 in main cases) can be set in:
admin/Configuration//VAT_INTRACOM !
VAT INTRACOM number of your shop has to be filled in admin/Configuration/My
shop/VATIntracom of my shop
Fix a bug in the 3.0 version:
Now, if the Company Name field is not empty, it is not required to put a intracom VAT number (for the company not in EEC)
Update for MS2 version.
Mise à jour pour la version MS2.
Contribution based on an initial work of Gyakutsuki.
Install.txt in French.
Usefull for the new European reglementation about intracom VAT and the necessity of having this "Intracom VAT number" written on the invoices inside the CEE.
