Jump to content

EU VAT Module


neweb
 Share

Recommended Posts

Is it possible to create a Module for the EU Market where You can record a customers VAT number?

 

In Europe, if you order a product from another member state and you provide your VAT number (if vat registered) then you don't have to pay the VAT on the order.

 

There are very few, if any, stores that offer this feature.

 

To make this module work you would require a simple box to enter VAT No:

If the person has a vat number then the admin can check that number and if it comes back as valid, then they could change the state on a yes no selection on the customers details.

 

For Example:

** On Registration **

 

Company Name:

VAT Number:

 

** Admin Panel **

Company Name:

VAT Number:

Can charge Tax/VAT: yes / no

 

Once the VAT number is valid the Admin can change the "Can charge Tax/VAT: yes / no" status to NO.

 

 

Another way to do it is, if the VAT field is filled in correctly (example: Ireland is 2 letters 8 digits 1 letter: IE12345678A)

 

TAX/VAT is automaticly deducted from the price

 

 

This is a big requirement in European Ecommerce Sites. The only Ecommerce software I know that can do something remotly like that is CandyPress where they provide a "Can charge TAX: Yes:No" menu

 

Share this post


Link to post
Share on other sites

  • 3 weeks later...
  • 1 year later...

Hello

Any news on this?

I sell business to business with european companies throughout Europe and if they are VAT registered (or that country's equivelant) then they do not pay VAT if they provide their VAT number on registration.

I also use zencart (before i found the wonderful PrestaShop) and this mod exists for that platform and works really well, with the VAT number automatically being checked for validity if required.

Any mod currently available or planned in the near future to work with PrestaShop in the same manner would be well received. I could ask permission of the author of the zencart mod for the code to be available for 'modification' if this helps. Mind you it is a free zen-cart mod so is you want to look:

http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=89

Cheers

RJ

Share this post


Link to post
Share on other sites

This feature has been added to Prestashop v1.3. You can go to Shipping > Countries, edit a country and then change "Need tax identification number?" to "Yes". When you do this, a "Tax identification number" field will be added to the registration page when that country is selected.

Share this post


Link to post
Share on other sites

Hi and thanks for letting me know.

I have enabled it to test for Germany but even though I have inserted a 'real' German VAT number is says 'DNI is Invalid'.

Is there a particular format to enter number in or how is the number checked?

Also where do I go to change the text as this doesn't read right for UK.

Thanks

RJ

Share this post


Link to post
Share on other sites

Hi there.

Thanks again for answering my post.

No, it's not the length of the VAT number as my current site is long time live and working with VAT numbers daily so I know that this particular VAT number, and others I currently have on my system from other European clients are good.

To answer your question specifically though, the VAT number for Germany is just 11 digits long including the DE at the beginning.

DE1XXXXXXX9

I have of course tried many different VAT numbers from several countries but get the same error :(

I have a few questions though:

Is there any documentation around to tell me how this feature should work?
Does it check for validity of VAT number (intracom....)?
Does it automatically not charge VAT if a number is entered (once it is working, lol)?
Does it just do these things for VAT numbers from 'outside' the store's home country?

Many thanks for helping me out here (and with my other post :))

RJ

Share this post


Link to post
Share on other sites

Sorry, but this feature was added in v1.3 and it is so new that I know little about it. Unfortunately, Prestashop provides little documentation, especially for new features they've just written. I usually have to play around with a feature and look at its code to figure out how it works before I can help people use it.

Share this post


Link to post
Share on other sites

That was indeed a fast reply Rocky. :) I had only just picked up my coffee.........

Yes I am a little disappointed wit hthe lack of documentation generally but especially with a new feature. You would think that things like this would be shouted from the rooftops.....

Anybody else know anything more about this new feature? PrestaShop coders perhaps???

Thanks again

RJ

BTW - I am heading over to your site to buy that categories mod today.... looks great.

RJ

Share this post


Link to post
Share on other sites

I still don't know how it works, what features it offers or anything about it at all.

It's alright bringing out a new feature (something I am extremely grateful for) but without a hint of instructions or feature list it is completely useless to me.

I have found out where to 'activate' for each country thanks to the kind response in this thread but it doesn't seem to work at all and even if it did I cannot see what it does.

1. If a customer enters their VAT number does it NOT charge VAT, This is how I assume it should function.

2. Does it recognise and treat differently a customer from outside the home country of the store (for example in the UK we would charge VAT even if a UK customer enters their VAT number) but if the customer is from outside the UK (but still in Europe) the VAT would not be charged. Is this how this feature works?

3. Does it check that the VAT number is legitimate using any official checking system?

4. Why is that that no matter what VAT number I enter as a new customer, I get an error saying number is incorrect? Does this mean that it is not working or does it meant that I need to set something up in admin - if so what and where?

Please any help from PrestaShop or any other person would be so very helpful.

Cheers

Rob

Share this post


Link to post
Share on other sites

As far as I can tell, it appears that it is just a tax file number that is kept on record for accounting purposes. I don't think it does any of the things you want. Hopefully, the Prestashop team will expand on this feature in the future.

Share this post


Link to post
Share on other sites

Hi Rocky

I could live with that as I manually authorise all my trade customers anyway. However the problem that I still have is that no matter what VAT number is entered into this box on registration I get the error saying:

1. DNI isn't valid

So I guess some validation is going on somewhere! Even if it is not working right.

RJ

Share this post


Link to post
Share on other sites

I noticed that the text field says DNI / NIF / NIE after it, so I did some research. It appears these are Spanish tax file numbers. Here is what I found:

DNI (Documento Nacional de Identidad): This is the ID number for Spanish citizens. The same number is used for one’s driver’s license.

NIF (Número de Identificación Fiscal): This is the tax ID number for all individuals. For Spaniards, it’s the DNI plus one letter; for foreigners, it’s the same number as your NIE. Once you have an NIE, you do not need to re-apply for an NIF; if and when you have to pay taxes, use your NIE number. If you’re a nonresident who has to pay taxes in Spain, you may get an NIF issued to you without having an NIE. This, of course, does not mean you get automatic residency in Spain, nor will it make it any easier to get residency.

CIF (Certificado de Identificación Fiscal): This is the the same as the NIF, but for companies.

I'll try to find the code that does the validation of these. Perhaps we can modify the validation so it works with other countries.

Share this post


Link to post
Share on other sites

I found it. It is the isDni function in classes/Validate.php that does the validation. The first allowed format is 1 letter, then 7 numbers, then one alphanumeric. The second allowed format is the letter T, then 8 alphanumerics. The last allowed format is 8 numbers then 1 letter. The code then checks whether another customer has entered the same tax identification number and returns an error if true. It then does some calculations to determine whether the entered tax identification number is actually valid.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Rocky

So from what you are sayingit is not intended to function with VAT numbers then as all VAT numbers start with two letters (GB, DE, FR, etc,) and I am pretty sure that all of them have more than 8 digits.

Any way to edit the validation to bodge it up for us VAT users?

RJ

Share this post


Link to post
Share on other sites

I think I misread the formats above. Reading regular expressions is difficult. Anyway, this is the line you'll need to edit on line 772 of Validation.php (in Prestashop v1.3 beta 1):

if (!preg_match('/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $dni)) 



Unfortunately, I'm out of practice with regular expressions. I did a search on Google and found a regular expression for UK VAT format. Using that, you could change the line above to the following:

if (!preg_match('^([GB])*(([1-9]\d{8})|([1-9]\d{11}))$', $dni))



This code will only validate UK VAT numbers and will not validate any of the Spanish number like the original code. What we need to do is find a regular expression (or write one) that handles all EU VAT, rather than just UK.

Share this post


Link to post
Share on other sites

Hi Rocky

What would be the best solution for me right now is for the field to be totally unvalidated. As long as I have the VAT number captured I can authorise manually without any worries.

Is there a way of removing validation completely?

RJ

Share this post


Link to post
Share on other sites

That's easy. Just change line 50 of authentication.php (in Prestashop v1.3 beta 1) from:

$validateDni = Validate::isDni(Tools::getValue('dni'));



to:

$validateDni = 1;



This will make it so the tax identification number is always accepted, even if it is empty.

Share this post


Link to post
Share on other sites

Thanks for your reply too bambi.

Looks useful and is similar to the one I currently use.

Unless regular and frequent other country VAT registered companies are registering all day long then this is a great tool.

RJ

Share this post


Link to post
Share on other sites

  • 2 months later...
  • 4 weeks later...
Sorry, my mistake. I guess the validation is performed in other places. Instead, modify classes/Validate.php and comment out line 768:

if (!$dni)



I don't realy understand, what i have to to with this Validate.php, I deleted the entry of dni but then i get an 500 error on the webpage...

Please help

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hi,

Sorry if this post is in the wrong place but I have searched the forum and can't seem to find a more appropriate thread.

I wonder if it is yet possible to allow European customers to optionally provide an EU VAT registration number and then be exempt from paying VAT on an order when they are in a different EU country to the seller. I've upgraded to PS version 1.3.1.1 but still can't see anything.

For instance, I and my store are in the UK. If I supply to a French business that is VAT registered in France then they should be able to enter their VAT ID number when ordering/opening their account and the VAT should not be applied to their order(s). However, if a customer in France is an individual and not VAT registered and they leave the VAT ID field empty then VAT should be applied at the UK's rate of 17.5%.

So, would need:

Customers in store's home country tax band: no possibility to enter a VAT ID number and must always pay VAT.
Customers in EU countries other than store's home country: option to enter a VAT ID number with VAT not being charged, otherwise if left empty VAT is charged at store's home country VAT rate.
Customers outside EU: no possibility to enter a VAT ID and VAT never charged.

This could be done within tax bands (i.e. tax bands for store's home country, other EU countries and non-EU countries). I thought that the "Need tax identification number?" option within Back Office > Shipping > Countries would do this, but instead it seems to insist on a VAT ID being entered by customer and doesn't seem to have any effect on whether VAT is charged or not.

At the moment, EU businesses are contacting me and asking how they enter their VAT ID number to avoid paying VAT. My only option seems to be to ask them to pay the full amount including VAT, then credit back to them the VAT in PayPal and manually type an invoice outside Prestashop. Whilst this is not a huge inconvenience there may be other customers who don't bother asking and just go elsewhere to order.

I don't need any automatic validation of the VAT ID number as for the few such orders of this type I get can happily check manually using Europa VAT website before shipping, although it would be nice if the format of text entered in the VAT ID field could be roughly checked. In the past I used the Actinic store and this seems to be what it did, which worked well and wasn't abused by customers entering fake VAT IDs.

Is this possible (and I am just looking in the wrong place)? Or is there a workaround to accomplish it? Or is it planned for the future? It must affect a lot of Prestashop users that sell to other countries. Any news would be very welcome. And sorry for such a long-winded post!

Share this post


Link to post
Share on other sites

Well If you want that I could work on that, my tax system is almost done just need to add 2 radio buttons to choose "consumer" or "business" and only require it with a vat country since right now it the flag has not been set but a demo will be set up in 30 min I will post a username and password for you guys to test out this module!

greetings,
Dutchcoding

Share this post


Link to post
Share on other sites

Wow Dutchcoding, that was a fast reply! Thanks, that sounds good.

As mentioned, this must be something that would benefit many EU users. I've searched this forum and found other mentions of the problem, but not solutions.

Yes, if it would be possible to:

Allow customers in EU countries other than the store's country (i.e. EU tax zone) to select this "business" option and then when they've entered their VAT registration number have them charged a total amount without VAT. But ensure VAT is charged when customers in this tax zone select "consumer"/do not enter a VAT ID.

Ensure that customers in the store's country (i.e. UK tax zone in my case) do not get presented with this "business/consumer" option as they must always pay VAT.

And ensure that customers outside the EU (worldwide or other tax zones) do not get presented with this "business/consumer" option as they never pay VAT.

As mentioned, although validation of the VAT ID may be desired by some users it may not be necessary for many users as they can simply manually check it and query with customer or reject the order if a false ID is input by a customer.

Then it sounds ideal.

Share this post


Link to post
Share on other sites

@ DutchCoding

I'm intrested as well... Are you planning to combine this with the Wholesale pricing module elswhere on the forum (3 more different price levels, pricelevel can be set to customer group.)

Groet,

Marco

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hi Rocky & others out there,

I have implimented Rocky's changes and now any number entered in the Tax identification (DNI / NIF / NIE) is accepted. GREAT.

How can I assign a customer at registration, that enters an EU VAT number or any number for that matter (I will varify manually...) to a group that gets VAT exemption?

ThanX in advance

Dan

Share this post


Link to post
Share on other sites

Try changing line 73 of authentication.php (in PrestaShop v1.3.1) from:

$customer = new Customer();



to:

$customer = new Customer();
if (Tools::getValue('dni') != '')
  $customer->addGroups(array(2));



This should automatically put the customer in group 2 if they provided a VAT number. You can then set customer group 1 to be "Tax included" and customer group 2 to be "Tax excluded".

Share this post


Link to post
Share on other sites

Hi Rocky,

Thank you so so so much for taking the time to answer me and many others here in the forum.

I am using 1.3.1 and a change has been made to classes/validate.php line 768 /* if (!$dni) */ to avoid validation.

Created group 2 with %VAT reduction

Made the changes you suggested. Changed line 77 (in my case) $customer = new Customer();

Changed to: $customer = new Customer();if (Tools::getValue('dni') != '') $customer->addGroups(array(2));
On registration customer was assigned to group 1.

Hope you can further help

Cheers


Dan

Share this post


Link to post
Share on other sites

I just tested my code and it looks like I put it in the wrong place. Instead, change lines 105-108 of authentication.php from:

else
{
   $address->id_customer = intval($customer->id);



to:

else
{
   if (Tools::getValue('dni') != '')
       $customer->addGroups(array(2));

   $address->id_customer = intval($customer->id);

Share this post


Link to post
Share on other sites

Hi Rocky and thanX again,

I have made the changes you suggested and on registration the screen goes white



/* else
{
$address->id_customer = intval($customer->id); */
else
{
if (Tools::getValue('dni') != '')
$customer->addGroups(array(2));
$address->id_customer = intval($customer->id);

$address->alias = "dlv-".$address->alias;

any tips?

Dan

Share this post


Link to post
Share on other sites

I have no idea. It's working fine on my test site. When a customer enters a tax identification number when signing up, they are automatically put in group 2 as well as group 1. If they don't specify any tax identification number, then they are put in group 1 only. I've attached my authentication.php in case in helps you figure out why yours isn't working.

authentication.php.zip

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hi,

I have tried to change the setting for mandatory VAT for my country at shipping>countries, but no id field shows when i go to the registration page. I have tried different zones, and countries. I have also tried using, IE, FF and opera, still no change. Anybody experiensing the same problem? A solution or just a reply is greatly appreciated.

Thanks!

UPDATE:

I found out that it was a problem with my theme. So after copy-pasting the little codeblock from the original theme to my customized theme for authentication.tpl, it did the trick. Now i'm trying to make it evaluate the VAT id automatically. I might go for dutchcode's solution, if i give up, since it looks pretty good.

btw thx to rocky for providing the automatic group adding tip!

Share this post


Link to post
Share on other sites

I have an extention for Rockys code, which I have to use in order to make the prices show ex. VAT. The reason is that the default group is still the standard group (incl. VAT), and therefore this setting overrulls that we put the customer in the Business group (ex. VAT).



                   if (Tools::getValue('dni') != '')
                   {
                       $customer->cleanGroups();
                       $customer->addGroups(array(2));
                       $customer->id_default_group = 2;
                       $row = array('id_default_group' => intval($customer->id_default_group));
                       Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer', $row, 'UPDATE', "email='".$customer->email."'", 1);
                   }




It also clears every other group for this customer. To omit this; comment out the first line:

// $customer->cleanGroups();

Share this post


Link to post
Share on other sites

Hi merico

ThanX for your extention, I did not try it yes.

I found out that in any case I need to validate the VAT number and make sure the address the customer registered with coresponds with the addres in the EU VAT web service or http://ec.europa.eu/taxation_customs/vies/

If I don't check the addresses someone can use a valid VAT number that is not his / hers and order without paying VAT.

Cheers

Dan

Share this post


Link to post
Share on other sites

Yes that is another issue i haven't really toughed about yet.. But this will require a more extensive change i believe. Not only will it have evaluate it, it will also have to make the adress unchangeable to the customer afterwards. And he is not allowed to use other shipping addresses aswell, since then he could still just find a random company, and add another adress and just ship to that one. The only safe solution is to activate the account manually, or make the registered address the only address for shipping. But maybe the issue isn't that big? The risk of being court in such an act is quite large, since we have the information about the payment and the address of shipping, so we could hand this over to the authorities. I don't know about the laws on this point, but is it our responsibility to make sure that he is from the company he says he is? How can one ever be sure on that when selling online?

Share this post


Link to post
Share on other sites

I have made the validate.php so it checks if the DNI is of the format "LLNNNNNNNN" Where L is letter, and N is number. After this, it resolves: http://ec.europa.eu/taxation_customs/vies/, in order to validate if the DIN exist. The file is attached. Backup your old classes/validate.php, and cpy this into the folder to active validation.

I could make it check for adress or company-name aswell, but i will need a way to make sure the customer can't change the adress later or add a new one.

Validate.php

Share this post


Link to post
Share on other sites

  • 2 months later...
I have an extention for Rockys code, which I have to use in order to make the prices show ex. VAT. The reason is that the default group is still the standard group (incl. VAT), and therefore this setting overrulls that we put the customer in the Business group (ex. VAT).



                   if (Tools::getValue('dni') != '')
                   {
                       $customer->cleanGroups();
                       $customer->addGroups(array(2));
                       $customer->id_default_group = 2;
                       $row = array('id_default_group' => intval($customer->id_default_group));
                       Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer', $row, 'UPDATE', "email='".$customer->email."'", 1);
                   }




It also clears every other group for this customer. To omit this; comment out the first line:

// $customer->cleanGroups();





Hi Merico

Could you please explain where and how to placew this code.

I need to separte customers that have a VAT number and asign zero VAT to these customers.

Hope you can help.


Cheers

Dan

Share this post


Link to post
Share on other sites

I have an extention for Rockys code, which I have to use in order to make the prices show ex. VAT. The reason is that the default group is still the standard group (incl. VAT), and therefore this setting overrulls that we put the customer in the Business group (ex. VAT).



                   if (Tools::getValue('dni') != '')
                   {
                       $customer->cleanGroups();
                       $customer->addGroups(array(2));
                       $customer->id_default_group = 2;
                       $row = array('id_default_group' => intval($customer->id_default_group));
                       Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer', $row, 'UPDATE', "email='".$customer->email."'", 1);
                   }




It also clears every other group for this customer. To omit this; comment out the first line:

// $customer->cleanGroups();





Hi Merico

Could you please explain where and how to placew this code.

I need to separte customers that have a VAT number and asign zero VAT to these customers.

Hope you can help.


Cheers

Dan


Hi Dan,

The code merely just put the user into the second group in your list of user-groups, if the user has typed a dni/vat number. The user group defines whether to show prices with or without VAT, not whether to charge VAT or not.

Also you would have to set the flag for "Demand VAT number" under shipping->countries->(all countries where you would like to ask for VAT number on registration"

I have made a piece of code to validate the entered VAT code on account creation, but it is only capable of handling Danish companies.

I have attached the authentication.php. Here you can see the exact way to implement the code piece. If you want to see it in action - check out my shop where i sell led light bulbs. You can see it here:
diodepaere.dk

According to EU laws the following rules apply to customer billing (as far as i know) please correct me if i'm wrong:

1: Customer is a private person
-Charge VAT and show prices incl. VAT. According to your own countries rules. (25% for Denmark).

2: Customer is a buisness from your own memberstate:
-Charge VAT but show prices ex. VAT.

3: Customer is a buisness from another memberstate:
-Don't charge VAT and show prices ex. VAT.

My code is able to comply with 1 and 2 but not 3, as it will still charge VAT.

I hoped it helped you! And if someone reads this and is able to help me with #3 or if there is any correction of my understanding of the laws, please let my know. :)

/Thomas

authentication.php

Share this post


Link to post
Share on other sites

Hi (hej) Thomas,

Thank you for your detailed reply.

My understandding of EU VAT laws are similar to yours.

We sell only B2B (business to business) so we don't need to deal with your option #1

In any case I need to varify "Manually Online" each EU VAT number. We send ONLY to the address that the company is registered under.

Option #2 is our defalt option

It is option #3 that I too would like to implement. If ANY number is punched as the EU VAT, the customer will not be charged VAT and it will show ZERO in cart summary and invoice.

Hope some angles or heros can help

Cheers


Dan

Share this post


Link to post
Share on other sites

  • 5 months later...

Thanks for this ;)

Sorry, my mistake. I guess the validation is performed in other places. Instead, modify classes/Validate.php and comment out line 768:

if (!$dni)

Share this post


Link to post
Share on other sites

  • 1 month later...
I have no idea. It's working fine on my test site. When a customer enters a tax identification number when signing up, they are automatically put in group 2 as well as group 1. If they don't specify any tax identification number, then they are put in group 1 only. I've attached my authentication.php in case in helps you figure out why yours isn't working.


Hi Rocky,

could you please, provide a code that works with 1.4+ version as well?

Share this post


Link to post
Share on other sites

  • 5 months later...

Sorry, my mistake. I guess the validation is performed in other places. Instead, modify classes/Validate.php and comment out line 768:

if (!$dni)

 

That doesn't work for me :(

 

If I leave dni field empty, I always get this error - Identification number is incorrect or has already been used.

 

I use PS 1.4.2.5. What is wrong? How to fix it?

 

Tnx, Housy

Share this post


Link to post
Share on other sites

 

That doesn't work for me :(

 

If I leave dni field empty, I always get this error - Identification number is incorrect or has already been used.

 

I use PS 1.4.2.5. What is wrong? How to fix it?

 

Tnx, Housy

 

 

 

I have found a solution. It might not be the best, but it works.

 

Open this file - /controllers/AuthController.php

 

 

Now change this code:

if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
elseif (!Country::isNeedDniByCountryId($address->id_country))
$address->dni = NULL;

 

To this one:

if(Country::isNeedDniByCountryId($address->id_country) AND Tools::getValue('dni') == "")
   $address->dni = "";
else {
if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))
 $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
elseif (!Country::isNeedDniByCountryId($address->id_country))
 $address->dni = NULL;
}

 

Cheers ;)

Share this post


Link to post
Share on other sites

  • 2 years later...
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More