Author Topic: [ SOLVED ] How to not add VAT on customers with VAT ID...? Please help!  (Read 17420 times)

SnakeDragon

  • Jr. Member
  • **
  • Posts: 61
Hello,

I wonder, how do I not add VAT on customers with a VAT ID?

My store is in Sweden. All customers buying from my store have to pay Swedish VAT (moms), which is 25%. However, companies in the EU with a valid VAT ID do not have to pay Swedish VAT when buying from my store. How do I manage this?

I have added the field "EU VAT ID" in the "Manage User Fields" in Virtuemart. When entering a VAT ID, it does check if the information is valid and moves customer with valid VAT ID to a new customer group. But, when the customer with the valid VAT ID buy things in my shop, 25% VAT is still added. How do I choose to not add the VAT for customers with valid VAT ID?

I am very grateful for any answer. ;)

With kind regards,
SnakeDragon

newtonthecat

  • Beginner
  • *
  • Posts: 5
Re: How to not add VAT on customers with VAT ID...? Please help!
« Reply #1 on: October 02, 2008, 09:43:33 am »
I too really would like to be able to do this. I've just started my first project using Virtuemart - tried several others (Cubecart, Zen, OSCommerce etc.) but decided to have a go with the ultimate Joomla based shopping cart!

I know PHP but completely new to Joomla & Virtuemart. The logic is simple and looking at the modular structure of all this it's got to be possible. Even if initially it's just a hack of an existing PHP file with the basic logic of:

IF "a valid EU VAT id is entered" AND "my country is not the same as store country"
THEN "set tax amount to zero".

(Alternatively, a facility to make a Virtuemart Customer Group tax exempt - then upon validating an EU VAT id, the user is moved to the tax exempt group)

This surely is one of the reasons for having a facility to check for a valid EU VAT number.

I see 3 reasons for the feature of checking a valid EU VAT number:

1. In order to put the VAT number on the invoice
2. For internal accounting purposes (book keeping)
3. In order to deduct VAT if the customer is VAT registered in an EU country other than the country where the store is based.

I do hope that the person (Steve Endredy/soeren/jep?) who wrote the VAT ID code can help with option 3

Mark.

newtonthecat

  • Beginner
  • *
  • Posts: 5
HACK: Deduct VAT for EU VAT registered customers in other EU countries
« Reply #2 on: October 02, 2008, 11:30:05 am »
Until something better comes along, I think I've hacked Virtuemart to add this feature (I think!).

HACK Summary: If a shoppper is in a group with "Show Prices including tax" set to off, then the Tax/VAT is set to ZERO at the checkout (if in another EU country) and all prices are shown Excluding Tax/VAT.
You create a Shopper group, called something like "VAT Registered" and set the "Show Prices including tax" for that group to OFF. When the EU VAT ID is validated, use the "move to shopper group" option to put the shopper in this group.

When the customer is viewing the website all prices are shown excluding tax with the text "Exc. VAT" after the price. When they go to the checkout, and IF they are in an country different to the store country, TAX/VAT is shown but it's set to 0.00.

To do: Work out how to **ONLY** deduct the VAT if the shopper is in an EU country other than the country the shop is in! DONE!

NOTE: Shipping costs. This does no zero the tax on shipping costs - but that is not an issue because you just set the VAT ID in the shipping rates for all countries in EU outside your country to 0 - none. Sorted!
To apply the hack so far modify the following files (line numbers based on version 1.1.2 distribution:

ps_checkout.php
(administration/components/com_virtuemart/classes/ps_checkout.php)
Line 1457 change:
Code: [Select]
global $order_tax_details, $discount_factor;to:
Code: [Select]
global $order_tax_details, $discount_factor, $vendor_country;Line 1519 change:
Code: [Select]
$tax_rate = $ps_product->get_product_taxrate($cart[$i]["product_id"]);to
Code: [Select]
if(($auth["show_price_including_tax"] != 1) && ($vendor_country !=$auth['country'])) $tax_rate = 0.0;
else $tax_rate = $ps_product->get_product_taxrate($cart[$i]["product_id"]);
ps_product.php
(administration/components/com_virtuemart/classes/ps_product.php)
Lines 2130-2138 change:
Code: [Select]
if (!empty($my_taxrate)) {
$tax = $my_taxrate * 100;
// only show "including x % tax" when it shall
// not be hidden
if( !$hide_tax && $auth["show_price_including_tax"] == 1 && VM_PRICE_SHOW_INCLUDINGTAX) {
$text_including_tax = $VM_LANG->_('PHPSHOP_INCLUDING_TAX');
eval ("\$text_including_tax = \"$text_including_tax\";");
}
}
To: (added extra line after the above piece of code)
Code: [Select]
if (!empty($my_taxrate)) {
$tax = $my_taxrate * 100;
// only show "including x % tax" when it shall
// not be hidden
if( !$hide_tax && $auth["show_price_including_tax"] == 1 && VM_PRICE_SHOW_INCLUDINGTAX) {
$text_including_tax = $VM_LANG->_('PHPSHOP_INCLUDING_TAX');
eval ("\$text_including_tax = \"$text_including_tax\";");
}
}
// Display excluding vat after price
if($auth["show_price_including_tax"] != 1) $text_including_tax = "(Exc. VAT)";

My first Virtuemart installation was <b>only yesterday</b>(!) - never used it before so this hack is really quick and dirty. But it satisfies one of the "must have" features for my first Virtuemart client project.

A better option would be to simply have an "EU VAT company" field in a shopper group so we don't have to use the "Show Prices including tax" field.
Hope others find this useful while we wait for an official "feature update"!

Mark.

IT2BE

  • Beginner
  • *
  • Posts: 3
Re: How to not add VAT on customers with VAT ID...? Please help!
« Reply #3 on: October 02, 2008, 15:45:34 pm »
Thank you for this hack. I have implemented it and it works.

However, I do not know how to do this:
>When the EU VAT ID is validated, use the "move to shopper group" option to put the shopper in this group

What I have been thinking of, instead of the above, is to check the country code against a list of eu countries before applying vat or not.
What do you think? And do you know how to implement that?

newtonthecat

  • Beginner
  • *
  • Posts: 5
Re: How to not add VAT on customers with VAT ID...? Please help!
« Reply #4 on: October 02, 2008, 16:18:10 pm »
Hey, I did something that works! :D

Quote
When the EU VAT ID is validated, use the "move to shopper group" option to put the shopper in this group

This is the basic functionality I based this hack on. When you add the EU VAT ID User Field (see documentation) you specify a group to place the customer in upon successful validation of the VAT number. I use this just to force the customer into a group which has the "Show prices including tax" set to OFF. It's a bit inflexible, but it was quick to do. Considering my total lack of experience with Virtuemart it's about as far as I can go with this. I would always avoid "hacks" because they have to be re-added when the core gets an upgrade so I see this as a temporary workaround.

Problem: At the moment the validation script for validating EU VAT numbers does not display an error if the validation fails - only a basic javascript validation to check the format of the number you entered is correct). Also, if a customer does not enter a VAT no. on registration and later adds this by editing their details the validate EU VAT number script does NOT execute. and they are NOT moved into the new Customer Group. I have reported this as a bug. So you will have to ask your customers who add or change their VAT number AFTER registration to let you know so you can manually move them into the special Shopper Group you created.

Quote
What I have been thinking of, instead of the above, is to check the country code against a list of eu countries before applying vat or not.
What do you think? And do you know how to implement that?

If you want to not add VAT for non EU countries, just make sure you have set the Tax mode to EU Mode (in administration->configuration) and then make sure you do not have any Tax rates set up for countries outside the EU. (Don't forget to add a tax rate for all EU countries though for when your customers are not VAT registered).

SnakeDragon

  • Jr. Member
  • **
  • Posts: 61
Re: How to not add VAT on customers with VAT ID...? Please help!
« Reply #5 on: October 02, 2008, 19:01:55 pm »
Thank you so much for the hack! It works perfectly! Very nice job! :D


A thing that also would be nice, is if it would be possible to create a very simple module which only shows if the prices are including or excluding VAT. This module could, for example, be placed in the left/top/right column in the webshop.

I think this is a smoother solution than adding the text "inc./exc. VAT" after each price.

I have created a new thread regarding this at: http://forum.virtuemart.net/index.php?topic=46409.0

Thanks again! :D

iefow

  • Beginner
  • *
  • Posts: 27
Re: [ SOLVED ] How to not add VAT on customers with VAT ID...? Please help!
« Reply #6 on: December 02, 2008, 15:39:31 pm »
Hey, I did something that works! :D
Problem: At the moment the validation script for validating EU VAT numbers does not display an error if the validation fails - only a basic javascript validation to check the format of the number you entered is correct). Also, if a customer does not enter a VAT no. on registration and later adds this by editing their details the validate EU VAT number script does NOT execute. and they are NOT moved into the new Customer Group. I have reported this as a bug. So you will have to ask your customers who add or change their VAT number AFTER registration to let you know so you can manually move them into the special Shopper Group you created.

How about you set this part to " READ ONLY ". That way the customer can not change the VAT number, in case he wants to change it he has to ask the admin. This is the trigger for the admin to check the VAT number and to move him manually. It's not a pretty solution, but it will prevent a lot of possible problems.

Quote
What I have been thinking of, instead of the above, is to check the country code against a list of eu countries before applying vat or not.
What do you think? And do you know how to implement that?

This is a good thing to do, did somebody put this together already?

RolandD

  • Full Member
  • ***
  • Posts: 780
    • Home of CSVI
Re: [ SOLVED ] How to not add VAT on customers with VAT ID...? Please help!
« Reply #7 on: December 02, 2008, 21:08:51 pm »
Quote
This is a good thing to do, did somebody put this together already?
I built a VAT check that checks the VAT number in the VIES database. This is the European database of VAT numbers. This check is already included in VirtueMart but only on submission of the registration form. This can of course be extended to other areas of VirtueMart.
Regards,

RolandD

CSVI
http://www.csvimproved.com/

poly

  • Beginner
  • *
  • Posts: 5
Just thought I would add that I have made this modification - and it seems to work well.  Couldn't find the code around line 2300 but it seemed to just add "Ex Vat" which wasn't critical for me.

Would be good to see this added as a feature rather than a hack.

NEIL

poly

  • Beginner
  • *
  • Posts: 5
Just another little update - this modification seems to work within the VirtueCart PayPal Pro UK payment module from Ecom solutions (commercial product).  It replaces the ps_checkout.php file - so you need to modify their file not the original one.

Piszi

  • Jr. Member
  • **
  • Posts: 58
Re: [ SOLVED ] How to not add VAT on customers with VAT ID...? Please help!
« Reply #10 on: February 13, 2012, 21:12:52 pm »
Actually I think there is a little easier or faster hack.


UPDATE:
SORRY I SCREWED UP SO I DELETED THE WRONG CODE AND CHANGED IT TO THE CORRECT!!!

open standard_shipping.php
around line 220 find this
Code: [Select]
$q = "SELECT tax_rate FROM #__{vm}_shipping_rate,#__{vm}_tax_rate WHERE shipping_rate_id='$shipping_rate_id' AND shipping_rate_vat_id=tax_rate_id";
than add the following lines before that
Code: [Select]
    $select_user = $auth['user_id'];
    //new query for avoiding shipping tax on Valid EU VAT No. Co. Shipping
    $mq = "SELECT `shopper_group_id` FROM `jos_vm_shopper_vendor_xref` WHERE `jos_vm_shopper_vendor_xref`.`user_id` ='$select_user' ";
    $db->query($mq);
    $db->next_record();
    $shopper_group_in_eu = $db->f("shopper_group_id");
 

Than edit this (a few lines below the query)
Code: [Select]
if( $db->f( 'tax_rate' ) )To this
Code: [Select]
if( $db->f( 'tax_rate' ) && $shopper_group_in_eu <> 9 )
With this mod you can set the necessary tax rate for shipping rates in the EU Countries ( for example in my csase it is 5% ) for Individuals and for Companies without valid EU VAT ID
And If you configured the EU VAT USER field to move user to the specified user group like 'EU Company with VAT' or whatever you named it than this will Set Shipping tax to ZERO
The number 9 in the condition is the SHOPPER_GROUP_ID for my EU Companies yours may differ from this.
And of course you can put $auth['user_id'] directly into the query, that's just my habbit to collect data into custom variables.