Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.31k stars 2.75k forks source link

TVA Account by country is not used #31159

Open comaiteseb opened 5 days ago

comaiteseb commented 5 days ago

Bug

When you are in the mode SERVICE_ARE_ECOMMERCE_200238EC activated, you must vetiled TVA on account spécified here : /admin/dict.php?id=10&from=accountancy&search_country_id=1&mainmenu=accountancy&leftmenu=accountancy_admin

But it doesn't work and return the seller country account.

I think we need to add condition on the SERVICE_ARE_ECOMMERCE_200238EC in the getTaxedFromId function in core/lib/functions.lib.php line 6597. And use $buyer->country_code rather than seller->country_code

And when this function is called line 227 in accountancy/journal/sellsjournal.php, change :
$vatdata = getTaxesFromId($tax_id, $mysoc, $mysoc, 0); by

$vatdata = getTaxesFromId($tax_id, $mysoc, $thirdparty, 0);

we need to create a $thirdparty object just before.

In fact if we want to respect UE legacy, we need to use delivery country address linked into the invoice contact and if not, use the thirdparty country.

see : https://www.impots.gouv.fr/professionnel/achatvente-de-biens

Dolibarr Version

19.3

Environment PHP

No response

Environment Database

No response

Steps to reproduce the behavior and expected behavior

No response

Attached files

No response

eldy commented 2 days ago

I think so. Can you check if this patch is ok for you: 61e83828696823219c636d756ef1178a60df1699

comaiteseb commented 2 days ago

Hi @eldy , It seems to be ok.

Thank's

comaiteseb commented 1 day ago

Hi, @eldy Can you make a MR on 19.0 branch please ? (version where I create this issue) Thank's