VAT for non-EU e-commerce companies

First of all I would like to say I really like Dolibarr, it fits almost all my needs, except the following:

I’ve been looking for some time for a open source ERP that has this feature but until now I didn´t find a single one.

Situation:
An non-EU e-commerce company sells hosting services to EU-end-users (B2C) and EU companies (B2:sunglasses:, by the VAT legislation this company has to register for VAT and charge VAT to EU-end-users (B2C), the difference here is that the VAT percentage is calculated depending of the country location of the end-user (ex: if the end-user billing location is France the Vat should be 19,5%, but if his billing location is Spain the VAT should be 18%)

The VAT has to be calculated not based on the seller’s country VAT percentage but on the customer’s country VAT percentage.

On Dolibarr I think this can be done, but I´m not a programmer.

I think this could really make Dolibarr to be a step ahead from all other open source ERPs, because on all the others I´ve tested none has it and this would make Dolibarr being more used by non-EU-companies

Thank you
LD

It’s the first time I hear a vat calculated on buyer status and not on seller status.

For the moment the rule is calculated like this:

If the seller is subjected to VAT, then VAT by default=0. End of rule.
If the (selling country= buying country), then the VAT by default=VAT of the product in the selling country. End of rule.
If seller and buyer are in the European Community and goods are transport products (car, ship, plane), the default VAT=0 ( The VAT should be paid by the buyer at the custom-office of his country and not at the seller). End of rule.
If seller and buyer in the European Community and buyer is not a company, then the VAT by default=VAT of product sold. End of rule.
If seller and buyer in the European Community and buyer is a company, then the VAT by default=0. End of rule.
Else the proposed default VAT=0. End of rule.

Now, do you know how to include your rule inside these one ?

Feature you ask is possible. Because this rule is coded only once in one function, change is easy to do if we can include your condition into the current one. Does what you need work if i add your test just before the last line of current rule ?

For my information: What is your country ?
Do you know about documentation that speaks about the rule you explained ?

Hi thanks for the reply.

Regarding your questions:

> Does what you need work if i add your test just before the last line of current rule ? I think so.
The condition I need is this:
“If seller NOT in the European Community
AND Buyer IN the European Community
AND buyer not a company (end user/person)
THEN VAT percentage calculated as in the buyer´s country”

this rule should only be available if selling services (only e-services to be exact)

> For my information: What is your country ?
I’m from Portugal but I do work for non-EU companies

> Do you know about documentation that speaks about the rule you explained ?
This regards the EU Council Directive 2002/38/EC
And you can find a FAQ here:
http://ec.europa.eu/taxation_customs/taxation/vat/traders/e-commerce/article_1610_en.htm

OK, thanks for FAQ.
So it should be implemented quickly.

However, Dolibarr can know a product is a service, but how detect it is an eService and not a simple service ?

I can add a hidden option SERVICE_ISECOMMERCE_200238EC=“value” to help Dolibarr know that service is an ecommerce service if service is inside a category called “value”.
But this works only if categories are used and product is a predefined product.

Other solution: Add hidden option to have all services processed as “eservice” so rule will be processed everytime (if no other condition is true before).

I like the second option better, it assumes it by default if no other condition before is true.

Can you please inform me when it will implemented so I can test it?

Thanks!

I think i will add the feature on monday 9, into the CVS version.
You will be able to test it the 10th by downloading the snapshot.

I added a new option into CVS version:
SERVICE_ARE_ECOMMERCE_200238EC

If you add it into setup->other to 1, vat will be on buyer country for BtoC sells.

Thank you!

I’m going to test it.

Where can I download the cvs version? The one I found on the website it´s dated from June.

Date is not modified but file is good and updated every day.
http://dolibarr.org/downloads/doc_details/1-dolibarr-last-cvs-snapshot-tgz-format

I’ve installed the snapshot version and added the line
SERVICE_ARE_ECOMMERCE_200238EC = 1
in Other Setup

I’ve added a non-EU (US) company in Company/Fundation
tried with both options for VAT management (with and without VAT)

I’ve added in the Dictionary/VAT a new line for US where VAT is 0%
and the VAT standard rate for PT

I’ve created a Private/Individual EU customer (PT)

but the VAT on the proposals, orders and contracts always shows 0% and not the VAT rate at the customer´s country.

Just another thing:

Where is the validate button to validate a draft order?

I only have a clone and delete button available.

Problem is that CVS version is on work for other change and this was a broken feature because of a change on the way…
I fixes this. You should be able to test but may experience problem elsewhere.

Ok now I get it.

But as I’ve said 3 posts back the VAT is not showing as expected, I always get VAT 0% and not the VAT from the buyer´s country.

What am I doing wrong?

Hi eldy,

Any news on how can I test the changes you’ve made on the snapshot?

I still can’t put it to work.

Can you give me information on test you do:

What is your country
What is your Intravat number

What is country of customer
What is intravatnumber of customer
What is type of customer “small company, large…”

Did you add the constant MAIN_SERVICES_ARE_ECOMMERCE_200238EC to 1
(MAIN_SERVICES_ARE_ECOMMERCE_200238EC and not SERVICE_ARE_ECOMMERCE_200238EC) ?

The vat number in this cases start with EUxxxxxxxxx
The non-Eu company chooses one of the EU member countries to register for VAT, where every 3 months has to fill a online form where basically has to report the total VAT amount received from each EU country’s private customers.

The EUxxxxxxxxx can’t be verified online by the VIES VAT number validation. I’ve asked directly to the VAT services on the EC and I was informed this VAT number is issued by the member state the non-EU company chooses to register and until now none of the member states provide this information to be available on the VIES VAT number validation service.

I’ve installed the snapshot version and added the line
MAIN_SERVICE_ARE_ECOMMERCE_200238EC = 1
in Other Setup

I’ve added a non-EU (US) company in Company/Fundation
tried with both options for VAT management (with and without VAT)

I’ve added in the Dictionary/VAT a new line for US where VAT is 0%
and the VAT standard rate for PT

I’ve created a Private/Individual EU customer (PT)

but the VAT on the proposals, orders and contracts always shows 0% and not the VAT rate at the customer´s country.

Right. I made new changes to fix this in CVS.
Constant is
“SERVICE_ARE_ECOMMERCE_200238EC”
and not MAIN_SER… as i said previously.

Hi,

I’ve tested it with the last snapshot but it doesn’t seem to work yet.
Now the pdf of the invoice cames out without any products.

regards

What do you mean ?
Does the vat rate on invoice edit screen is ok ?
PDF has nothing to deal with this feature. Which PDF template do you use ?

I was able to create a Module that will do what I need. I don’t know if it’s the best way but it works.

I’ve setup a new module and used the run_triggers function to overwrite the default procedure when you add a new line (in this example I’ve used the proposals).

So if the module is active, the customer is in EU country and the customer’s entity type is private (B2C) then the trigger is activated, here’s what I have:

function run_trigger($action,$object,$user,$langs,$conf)
    {

        $euCountries = array('BE','BG','CZ','DK','DE','EE','EL','ES','FR','IE','IT','CY','LV','LT','LU','HU','MT','NL','AT','PL','PT','RO','SI','SK','FI','SE','UK'); 
        
        if ($action == 'LINEPROPAL_INSERT')
        {
     
          $propal = $object->fk_propal;
          $info = $this->db->query("SELECT fk_typent, fk_pays, code FROM llx_propal, llx_societe, llx_c_pays WHERE llx_propal.rowid='".$propal."' AND llx_propal.fk_soc=llx_societe.rowid AND llx_c_pays.rowid=llx_societe.fk_pays");            
          $client = $this->db->fetch_object($info);     

          if(in_array($client->code,$euCountries)){  
            if($client->fk_typent == 8){
              
              $tax = $this->db->query("SELECT taux FROM llx_c_tva WHERE fk_pays='".$client->fk_pays."' AND note LIKE '%standard%'");
              $vat = $this->db->fetch_object($tax);
              
              $qty       = $object->qty;
              $tva_tx    = $vat->taux;
              $price     = $object->subprice;
              $qty_price = $qty * $price;
              $disc_percent = $object->remise_percent;
              
              $total_disc = ($qty_price * $disc_percent) / 100;
              $final_price = $qty_price - $total_disc;
              $total_tva = ($final_price * $tva_tx) / 100; 
              $total_ttc = ($qty_price - $total_disc) + $total_tva;
                           
              $rowid = $object->rowid;
              $this->db->query("UPDATE llx_propaldet SET remise='".$total_disc."', tva_tx='".$tva_tx."', total_tva='".$total_tva."', total_ttc='".$total_ttc."' WHERE rowid='".$rowid."'");
              
            }
          }
          
        }


		return 0;
    }

This needs to be added also to orders, interventions, etc and so on…

The problem is that I don’t find a LINEPROPAL_UPDATE trigger and if I edit a previous inserted line the changes reverse to the default procedure.
This is the way I found without changing things or adding new tables or columns, it only updates the info I need, the way I need it in this cases.
How can I add a LINEPROPAL_UPDATE trigger?