Bug or Feature or Error with taxes and country groups ?

236 views
Skip to first unread message

Nicolas Micoud

unread,
Apr 15, 2015, 8:54:13 AM4/15/15
to idem...@googlegroups.com
Hi,

I've played with country groups and i find something strange. Here's the steps to reproduce :

Create a country group "European Union" and put 4 countries inside : France, Spain, Italy and Germany.

Then create 2 tax rates (nb: set Parent tax to null)

#1 : Name : France 20% ; From Country France To Country France (see screenshot 1)
#2 : Name : France -> EU ; From Country France to Country Group "European Union" (see screenshot 2)

Add an organization based in France
Add a business partner with a location in France

(all these steps have been done on test.idempiere.org)


Then, when creating a new invoice line (from org Paris (located in France) to customer Nicolas (also located in France), i expect iDempiere to retrieve the tax rate "France 20%".
Instead i get "France -> EU".

Did i miss something ?

Thanks,

Nicolas
scr1_TaxRateFranceToEU.png
scr1_TaxRateFranceToFrance.png

Marco Longo

unread,
Apr 15, 2015, 11:11:34 AM4/15/15
to idem...@googlegroups.com
Hello Nicolas,
you need to have  different Tax Category  
Tax category 20%   for 20% 
Tax category france->eU  for Europe
Marco

Marco Longo

unread,
Apr 15, 2015, 11:23:03 AM4/15/15
to idem...@googlegroups.com
sorry Nicolas i though a different case.
...Invoice Customer. ok.

I think the problem is that France should not be inside the EU group.


Marco

Nicolas Micoud

unread,
Apr 15, 2015, 2:48:03 PM4/15/15
to idem...@googlegroups.com
Hi Marco,

I made same conclusion : if i exclude France from EU, it's ok.
But imagine i got also organization on France, Italy, etc (mean in different countries of EU), i would need to have several country groups.

Perhaps the algorithm is false ? I mean, Country should be prefered as Country group.
Even if France is part of a country group, we should first consider the field Country (before the group which contains the country)

WDYT ?

Carlos Antonio Ruiz Gomez

unread,
Apr 15, 2015, 4:34:17 PM4/15/15
to idem...@googlegroups.com
Nicolas, Marco, I just opened a ticket based on this thread:
https://idempiere.atlassian.net/browse/IDEMPIERE-2580

Can you please help me to test the attached patch?
The configuration must be changed to define the country group plus the country.

Regards,

Carlos Ruiz

Nicolas Micoud

unread,
Apr 16, 2015, 7:55:36 AM4/16/15
to idem...@googlegroups.com
Hello,

Not sure if the best place to discuss is here or on the jira ticket, but i've tested your patch and i still got issues.
But perhaps i miss something on the tax configuration ?
Could you apply your sql migration to test.idempiere.org and update the c_tax records (by direct sql) - then you won't need to deploy the modified MTax class.

Otherwise, wouldn't be MTax.getAll / Tax.get methods which should be modified ?

I mean, instead of taking the first tax which satisfy all criteria, it could be better to search for a tax that will :
 - have good tax category
 - have same from country
 - have same to country
 
If no tax is corresponding, then test tax that
 - have good tax category
 - have same from country or country group
 - have same to country or country group
 
 [...] until we found the good tax.
   
Or perhaps (just an idea), add a 'Applicability case' table
There we can define all use case. Eg:
Tax Category 1 ; FromCountry=France ; ToCountry=France => C_Tax_ID = 1000002
Tax Category 1 ; FromCountry=France ; ToCountryGroup=EU => C_Tax_ID = 1000003
Tax Category 1 ; FromCountry=France ; ToCountry=Colombia => C_Tax_ID = 1000004

Then, when searching for the C_Tax_ID, we "just" need to look into that table to find the correct tax rate.


wdyt ?


Thanks,

Nicolas

Carlos Antonio Ruiz Gomez

unread,
Apr 16, 2015, 9:19:05 AM4/16/15
to idem...@googlegroups.com
Ready Nicolas, updated test.idempiere.org:
- added France to EU
- assigned country group+country in your two tax rates (via SQL)

Regards,

Carlos Ruiz


El 16/04/15 a las 06:55, Nicolas Micoud escribió:

Nicolas Micoud

unread,
Apr 16, 2015, 12:04:56 PM4/16/15
to idem...@googlegroups.com
Thanks Carlos... but i made a mistake...
tax rates were on the tax category 20%. I wanted to change that and put them in the Standard.
Then i saved... and the modifications you done via SQL were erased :(

But using the AD_Changelog, i was able to see the 'correct' setup and reproduce it locally.
So for the sales invoices, my test were ok

But for the purchase invoices, it was not.
I create a tax "EU -> France", only for purchase.
Country Group = EU ; Country = 0 / To CountryGroup = EU ; CountryTo=France.

When creating a purchase invoice for an organization located in France and an italian vendor, the tax retrieved was the "France 20%".

Am I still doing something wrong ?

Thanks,

Nicolas

Marco Longo

unread,
Apr 17, 2015, 3:38:43 AM4/17/15
to idem...@googlegroups.com
for purchase order you have to use "reverse charge"  
You save the VAT in credit and Debit (both) so the result is zero .
You need to have a parent tax with 2 child.
I'm out of the office now... i write you back the correct configuration

Marco

--
You received this message because you are subscribed to a topic in the Google Groups "iDempiere" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/idempiere/_Xp1VF8xrpU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/fac3a179-9d66-4569-9a72-f36cfdef9d6b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Carlos Antonio Ruiz Gómez

unread,
Apr 22, 2015, 3:37:01 PM4/22/15
to idem...@googlegroups.com
Nicolas, just tested a purchase order with my patch and it selected correctly EU to France.

On Thursday, 16 April 2015 11:04:56 UTC-5, Nicolas Micoud wrote:
Thanks Carlos... 
... 

Nicolas Micoud

unread,
Apr 28, 2015, 4:38:14 AM4/28/15
to idem...@googlegroups.com
Hello Carlos

Tested your patch locally and it works with the following setup :

Country Group "EU" contains 3 countries : Spain, Deutschland, Italy. (note that France is not included in this group)

Tax "France -> France" (from Country "France" to Country "France" ; other fields are empty)
Tax  "UE -> France purchase" (from Country Group "EU" to Country "France" ; other fields are empty)
Tax  "France -> EU sales" (from Country "France" to Country Group "EU" ; other fields are empty)

Now, good taxes are retrieved in following cases :

InvoiceCustomer :
From Org in France to customer in France : "France -> France"
From Org in France to customer in Italy : "France -> EU sales"

InvoiceVendor
From Org in France to vendorin France : "France -> France"
From Org in France to vendor in Italy : "UE -> France purchase"


So i think your patch is ok.
But what is weird is to exclude France (or the 'main' country of the tenant) from the country group.

WDYT ?

Thanks,

Nicolas

Carlos Antonio Ruiz Gomez

unread,
Apr 28, 2015, 10:27:11 AM4/28/15
to idem...@googlegroups.com
> But what is weird is to exclude France (or the 'main' country of the tenant) from the country group.

That's not a valid configuration - and if you have organizations in different EU countries then it won't work.

In my tests it worked, but I'm not sure if my tests were correct.
I was reviewing my old notes about bugs and found this one:
"
MTax.getAll doesn't work right, the order by is wrong
there must be an order by for sales and other for purchases
as it's on cache maybe there can be a getAllSO and another getAllPO each one with his array in memory
"

Maybe we can use the experimental branch/server to setup this?

Regards,

Carlos Ruiz

Nicolas Micoud

unread,
Apr 28, 2015, 10:36:54 AM4/28/15
to idem...@googlegroups.com
I agree that it is not a valid configuration, so, let's try something on the experimental server.

But instead of "just" changing the order by (having one for SO and another one for PO as you suggest), what about suggestions on message of 04/16 (new table or changes in Tax.get)
(https://groups.google.com/d/msg/idempiere/_Xp1VF8xrpU/Sq697HyaQDMJ)

Nicolas
Reply all
Reply to author
Forward
0 new messages