TVA/VAT (NPR) feature not implemented properly

Hello,

I have enabled the following entry from the VAT table so that I could use it when defining a product price:

FR - France(country) 8.5(rate) Oui(NPR)
VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur

The problem is that dolibarr does not actually keep track of the NPR variable.

get_default_npr() from lib/functions.lib.php has not been inplemented yet.

the vatrate() function is being called without the “info_bits” parameter (which actually is supposed to hold the NPR value).

Furthermore, the value of NPR is not being saved anywhere in the database.

I created a module to fix this issue in v2.8.1 in the hope that this would be fixed in 2.9. But this issue has not been addressed yet.

I hope the problem description is clear enough to at least understand what is going on.

Maybe I wasn’t explicit enough.

here’s the definition of llx_c_tva:

You can see that recuperableonly is there. For some reason it has a type of int(11) although it’s supposed to be a boolean value.
But that’s not the issue.

Now let’s move on to table llx_product_price:

you can see that the VAT data is there (tva_tx, localtax1_tx, localtax2_tx) however recuperableonly is missing.

now consider the function calcul_price_total defined in htdocs/lib/price.lib.php

in the parameter list, you can see the definition of the $info_bits param

Actually one of the bits of info_bits stores the NPR value.

which is then used in the calcul_price_total function:

however, throughout the code, info_bits is never passed as a param but is instead defaulted to 0. The reason why these functions ( the ones that process data depending on info_bits ) are called without the info_bits param is because NPR is not stored anywhere in the DB (as shown above)

conclusion, the NPR variable is useless as of now.

I made change to allow to declare default price on product with NPR vat.
Can you try and tell if this is enough or i missed something else ?

These files need to be changed as well:

htdocs/comm/propal.php
htdocs/commande/fiche.php
htdocs/compta/facture.php
htdocs/contrat/fiche.php
htdocs/product.class.php
htdocs/product/fiche.php
htdocs/product/price.php

for example, htdocs/compta/facture.php at line #603 calls the “addline()” method of the facture object with a hardcoded value of 0 for $info_bits :

$result=$object->addline($facid,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);

Most of these files do not handle the $info_bits variable correctly.
Let me know if you need more info.

Would it help if I wrote a patch for it or do you have it figured out already?

I think some help in this project is always appreciated, let us see what Eldy thinks…

Yes, this will save me times. if patch is done on cvs version, i can applied it quickly and it zill be very welcome…
Thanks for your help…

Hello,
I see that this TVA NPR change has been implemented in the new version of dolibarr. However, there is a problem with the implementation.
This is how the 8.5 tva npr works:

TVA NPR = 8,5e
HT = 100e
TVA = 0e
TTC = 100e

The calculation needs to appear on the bill without being applied on the final price.

Also When creating a new product with a tva_npr value, an error occurs ( this is due to the fact that the “*” character is being sent through the SQL request.