I was reading and didnt find possible solution to our situation and need.
In Bulgaria numbering of the invoices is 10 digit format like 0000000001 etc… which is ok and can be done in dolibarr.
But:
Also the numbering of this new document INVOICE must have separate numbering for each country from which the customer is. This is to be linked with clients country and predefined.
For example for invoices sold locally (in Bulgaria) numbering is like 0000000001 (we will resume from the last number we reached at the moment of start using it).
For invoices to clients in Country 1 (Romania) invoices should start with 1, like 1000000001….
For invoice to clients in Country 2 (Greece) invoices should start with 2, like 2000000001…
For invoices to clients in country 3 (Cypress) invoices should start with 3, like 3000000001
Etc when adding new country.
This is not for all coutnries in EU, but only for those in which we sell via own eshop and B2C. This is apply the EU one stop shop VAT rules for ecommerce.
Any insights how it can be done?
I found the solution with a third party change, but maybe this will enter in conflict (because we need to specify the third party type) with the variable MAIN_SERVICES_ARE_ECOMMERCE_200238EC
This is a common requirement for EU e-commerce with OSS VAT compliance. Dolibarr doesn’t have this country-based invoice numbering out of the box, but there are a couple of approaches you can take.
The cleanest solution is to modify the invoice numbering model. You’d need to create a custom numbering module or modify an existing one in htdocs/core/modules/facture/mod_facture_xxx.php. In the getNextValue() method, you can check the customer’s country from the thirdparty table and apply the appropriate prefix.
You could also use different invoice templates per country, but that gets messy quickly when you have multiple countries.
Another approach is using extrafields on invoices to store a country-specific sequence, then customize the PDF template to display this number instead of the standard one.
The variables you mentioned (MAIN_SERVICES_ARE_ECOMMERCE_200238EC and MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL) are for VAT calculation logic, not numbering, so they shouldn’t conflict with your numbering customization.
I think the custom numbering module approach is your best bet. You’ll want to check the customer’s country code in llx_societe.fk_pays and apply the prefix accordingly. Worth checking if there are any existing modules on DoliStore that handle multi-sequence numbering too.
hi @Dolicraft . Thank you for the detailed info. Yes, either i modify the pdf template or i buy a ready made module for numberring. I think i found one module that will handle this.
As for the 2nd topic, it seems it is bug and dolibarr do not properly manage the VAT in EU for OSS. I think i sow somewhere they will fix this in the V23.01.
thank you for you time.