dolibarr-tasktrack
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dolibarr-tasktrack] [Task #204] Manage canadian, spain and other countr


From: Doliforge
Subject: [Dolibarr-tasktrack] [Task #204] Manage canadian, spain and other country double VAT with a generic system
Date: Sat, 10 Aug 2013 03:35:16 +0200

Doliforge
Is this email not displaying correctly?
update email preferences.

Manage canadian, spain and other country double VAT with a generic system

Latest modifications

2013-08-10 03:35 (Europe/Paris)
Changes:
  • Status: 
OpenClosed

Answer now

Snapshot

 Details
Submitted by:  Laurent Destailleur (eldy) Last Modified On:  2013-07-03 23:43
Submitted on:  2011-09-17 00:00 
Summary:  Manage canadian, spain and other country double VAT with a generic system
Description:  Manage canadian and other country double VAT with a generic system
Priority:  9 - Highest Open to Any Developer:  No
Subproject:  Module Invoice customer Assigned to (multiple):  Christophe Battarel (cbattarel),Laurent Destailleur (eldy)
 Status
Start Date:  - End Date:  -
Completion (0-100%):  100 Status:  Closed

Comments

Laurent Destailleur 2013-07-03 23:43
I removed code using MAIN_USE_LOCALTAX_TYPE_7 into dev branch (for 3.5). This code was replaced by "revenuestamp".
Management of canadian tax should work with 3.4 so i set task to 100%
HENRY Florian 2013-02-12 21:37
Laurent if you read this, what do you think of this part of code conerning MAIN_USE_LOCALTAX_TYPE_7 in update_price function, should you we remove it, to clean the code ? At least in dev branch ? I know that remove part code that seems old and not used can be dangerous, because in some special case it can be mandatory but this time I really don't understand, and I'm not he only one.
Juanjo Menent 2013-02-12 16:24
Christophe, I i think the manage localtaxes on supplier orders and invoices is ready...
Christophe Battarel 2013-02-12 13:47
dont worry it's not a loss of time; your questions are pertinent.
for the setup of localtaxes in vat dictionnary, it was there before i ran into the project (made for spain).
for MAIN_USE_LOCALTAX_TYPE_7 in update_price function, i am not the author of this (or i'm loosing memory) and i dont understand the test, neither the comment above...
HENRY Florian 2013-02-12 12:47
By the way thank you to tell me this screen is the main way to administrate taxe... and sorry to make you loose your time.
HENRY Florian 2013-02-12 12:46
Arg, I'm just the greater idiot (this word is weak in this case) of this tread....
I've notice a long time ago this screen about TVA administration, but I never take time to look inside... And I as I read TVA, for me, it was just about TVA not global taxe that can apply on product/service with rules describe in tooltips.
The help tool tips do not talk about type 7. I'll add it in 3.3 translation.
The MAIN_USE_LOCALTAX_TYPE_7 is in commonobject.class.php method update_price.
I'll check if we can implement DEEE with this system.
Christophe Battarel 2013-02-12 12:16
The "user" who administrate dolibarr should define local taxes rates in the tva dictionnary the same way as vat rates.

I've just made a global search in the dev branch for "LOCALTAX_7" and did not find anything; can you tell me where you saw this ?
(there are seven types of localtaxes in the configuration and the seventh is for global fixed amount tax - not a rate - for instance in Tunisia, there is a fixed 0.4 dinar tax on invoices)
HENRY Florian 2013-02-12 11:51
When I talking about documentation, for exemple if I set my compny in tunisie, I can see the two added local taxe but as simple user I don"t know how to affect values on this local taxe. As developper I understand that I have to set global variable LOCALTAXE and so one.
HENRY Florian 2013-02-12 11:47
Ok, I understand well the point, I have a big thread on the french forum to discuss about this topic.
I was trying to organize a DevCamp on Dolibarr in April in Montpellier (information will be send as soon as we have book the place), and I think one of the goal of this devcamp will to review all way how Dolibarr calculated price base on tax.
The work you've done is great, and give more flexibility and lisiliby on the subject, but I still do not understand why in the core (in dev or 3.3 branch) there is LOCALTAX_7 variable call.
I understand very well that for 800€ you'll not rewrite all the code of this part of dolibarr.
Christophe Battarel 2013-02-12 11:28
Hello Florian,

We tried to develop localtax system based on what was done for Spain without breaking all stuff in the core.

Note also that this project was financed by a only one customer and that it could not be charged a lot (in this case it was 800 euros !).

Indeed, what we have done is working for Spain, Tunisia, and may work for lots of other countries, but not to all i admit.

For example, taxes in Brasil are very difficult to implement without a system of complicated customized rules because it depends on lots of parameters and can not be done in an easy way.

The documentation of the module is attached to this task (at the end of the page since september) and all the technical discussions between Laurent and me are also on this page and on the github pullrequests.


HENRY Florian 2013-02-09 11:01
Hello Christophe, I am realy interest on this thread.
But I think the way how it done actually in Dolibarr do not allow all customization for all international/local taxe (may be it's not the goal in dolibarr).
For me a good model is to link tax to customer (acccording country) and product and pass to the calcutad price method the "order_id", customer_id, and product_id, gather all inforamtion in the class and determine the price from these input. I can open another task to deal with that in another dev branch to avoid conflict. What do you think about this way to do ?
An another hand, I would like to help with the current task, but I didn't found documentation around LOCALTAX_ dolibarr global variable. May be video conf between all contritor on this subject will be great. For exemple I see $special_code and other part of code that I don't know if they are use or not. As I can update the basic PDF model of proposal(quote), order, invoice to include those special country taxe, I just want to be sure what can be use and what should not.
In all case this will not be in 3.3 because this branch is freeze.
Christophe Battarel 2013-02-09 10:12
i reactivate this thread...
i have integrated the 2 latest points (display of localtaxes on screen and in pdf) in end of november 2012.
now i think it's time to manage localtaxes on supplier orders and invoices.
Juanjo Menent 2012-11-26 17:47
Ok, I will make this week
Christophe Battarel 2012-11-26 15:28
imho, there are still 2 things to implement :
1) display of localtaxes in propales, orders, invoices
2) update of pdf model reports to show taxes
Laurent Destailleur 2012-11-26 15:13
This is a summary of what is done:
There is now a generic system that can support 2 local taxes, each of them can be one of the predefined 7 types.
However, type 1 to 6 are calculation done using the rate, price with or without tax, the type of product (service or product) and if the seller is using local tax or not. This is ready and work is complete I think for this.

However, there is still a problem for spain: Spain need also to use if "buyer" (and not seller" is using localtax or not (it does not depends on seller but buyer). To avoid to have too many changes done and because for other countries it is ready to test, I asked juanjo to keep some code "if spain" into the functions:
- "get_localtax"
- "get_default_localtax"
We must have here specific code to manage "Localtax1 (Spanish RE): applicable if buyer is subject. Is related to VAT Rate (ex: if VAT 21, RE = 5.2)".


So for me, only spain is not finished (but there is only 2 functions to edit, I let juanjo modify them), and this is only for spain and it should not
change code for other countries.

Juanjo, are you ready to add the 2 tests into the 2 functions (and if possible with the PHPunit test case) ?

So Christophe, if i dont miss anything, you start to test current implementation for the use cases you know (change of juanjo should not change your cases). Are you able to test this and make a feedback ?


PS: May be in a next version, we will add more types to manage spain case (but we already factorized a lot of code and removed a lot of code specific to spain so I think we can accept for the moment this short exception "if spain" into the 2 functions get_*tax).
Juanjo Menent 2012-11-26 12:47
Christophe: you can make a generic work. The only problem is: In Spain the suppliers may have diferent localtax2 rate by supplier. I can make this after you end your work.
HENRY Florian 2012-11-26 11:51
I know I'm late on this subject, but I start to dev a multi tax projet a years ago.
The projet is available on Doliforge https://doliforge.org/projects/MultiTax/
This project was ok for 3.2, there is only administration tax screen according country, product, customer, set up by fix rate or % of amount.
The last hard part of use this setting in calculation, this part is not implemented, I think this is the last step to do but once it will be done, the flexibility of the taxe management provide by this module will be great.
I don't really have time to finnish this part, I let you check if the module can be use. But for the next release (3.4) i will try to include it if it not done in 3.3.
Christophe Battarel 2012-11-26 10:51
@Juanjo : is it possible to make generic work with configuration ? we started this work to be generic for all countries and also remove spcific ES country portions of code in dolibarr.

@Laurent : i'm a little lost in this project; what are the remaining steps ? i'd like to finish it before 3.3 release.
Juanjo Menent 2012-11-19 19:01
After talking with tax advisor, I summarize localtaxes operating in Spain:

Localtax1 (Spanish RE): applicable if buyer is subject. Is related to VAT Rate (ex: if VAT 21, RE = 5.2)
Localtax2 (Spanish IRPF): applicable if seller is subject. Is related to seller (21%, 9% for the first 3 years of seller activity).

I'm going to start work on adaptation (only if country of global mysoc is Spain):
hidden localtax2 subject into customers card (all are subject if we are subject)
hidden localtax1 subject into suppliers card (mysoc indicate if we are subject)
add rate localtax2 into suppliers card...
Christophe Battarel 2012-11-04 18:00
great ! i was still looking for time to advance on this project... thanks for the job.
Laurent Destailleur 2012-11-03 21:05
I commited today changes to try to finish management of the 4 fields:
localtax1, localtax2, localtax1_type, localtax2_type.

To avoid to retrieve everywhere the 4 fields, only vat rate + seller is provided. This allows to retrieve into function calculate_total_price(), all the 4 information.

Everything seems to work, but it needs tests.
Laurent Destailleur 2012-10-08 11:56
Yes, create a function named "dol_get_localtaxes" and set get_localtax to deprecated by adding the @deprecated tag into comment.
Christophe Battarel 2012-10-07 12:41
that's why i asked if you have a better idea.
maybe the best way to avoid temporary unstability is to write another function named get_localtaxes then replace get_localtax calls one by one. it will ensure stability, and will give me time to push get_localtax replaces one by one.
Laurent Destailleur 2012-10-06 20:54
Are you ready to modify the around 40 call to get_localtax ?
If yes, you can go to push your new function that return an array.
Christophe Battarel 2012-10-03 10:47
How do we go on ? my code modify the get_localtax function to return an array with localtax rate and type; this needs to modify also every get_localtax function calls in dolibarr. are you ok with it or do you have a better way to achieve the localtax retrieval ?
Laurent Destailleur 2012-09-20 00:52
Manage canadian and other country double VAT with a generic system
Christophe Battarel 2012-09-07 11:22
first pull request done (database modif) : https://github.com/Dolibarr/dolibarr/pull/373
Laurent Destailleur 2012-09-06 22:01
Great.
I'am waiting the push...
Christophe Battarel 2012-09-06 16:39
my work is already in use by several customers in Tunisia; it seems to fit their needs.

for Spain, my code works but you have to define localtax2 as a negative rate, since i prefer adding all taxes to be generic (and logic).

for Canada, it seems to fit (http://fr.wikipedia.org/wiki/Taxe_sur_les_produits_et_services and http://fr.wikipedia.org/wiki/Taxe_de_vente_du_Qu%C3%A9bec)

i know from several discussions with Saxa that my work wont fit in Brazil since they have many taxes with many cases of application and many ways of calculation !

i'm ok to begin push on develop branch the way you asked, asap...
Laurent Destailleur 2012-09-06 16:24
The first thing to do is to start to write a documentation on how things should works.
A page was started:
http://wiki.dolibarr.org/index.php/Draft:VAT_calculation_and_rounding

We can see that spain has two more vat rates. But code is not specific. It is generic and can be used for other countries.
What is specific is the rule:
The localtax1 is a second vat added to each line
The localtax2 is a second vat substracted from each line.

But i don't know if canada vat works like this. So first thing is to write how it works into the wiki into the chapter canada.

Your work seems to be enough advanced to be the one used for standard version.
Can you answer this questions :
- Do you know if canada tax system can works with yours (your dev seems generic but i don't know canadian system to tell if it's ok) ?
- Do you use the field localtax1 and localtax2 already existing for spain. It seems yes. You added field localtax1_type. So i think your dev address spain question.
- Are you ready to push to github dolibarr dev brnahc your changes. But not at once. This is how i see thing:
* First push add into database and migrate scripts
* Then push update into vat calculation functions (price.lib.php, functions.lib.php, commonobject.class.php) and vat table data. This are new functions that take care of localtax but if we use zero we can check everything is still compatible.

We should be able to do the rest (pdf, screen) into a next step after, won't we ?


Christophe Battarel 2012-09-06 14:48
how do you plan to do that ?
there is already some specific code for Spain in dolibarr and there are two active projects on generic local taxes management (one by Florian Henry and one from me)...
maybe we should put everything in common ?
i've already send my code to Florian and Regis but without any answer for the moment;
it manages two local taxes but without the test on country code ES (it was done for tunisian customers on 3.1.1).
many files are impacted (propales, orders, invoices for customers and suppliers).
i will try to attach a zip file here (remember it was written for 3.1.1 - so it's very old isnt it ? it was written in june and july 2012 !)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]