Closed adwil13 closed 2 years ago
Helo @adwil13,
The purpose of the validator VatNumberValidator
is to check the VIES database, if the database is not accessible then only the format is checked.
From an accounting point of view, if the VAT number is not valid then you have to consider the sale has a B2C one.
That's why I don't understand your issue, do you have some examples of real VAT numbers failing the VAT check ?
@Prometee For some reason I didn't get any notification about your reply :/ The problem bounced back at me, so I'm back :)
VIES database is holding VAT numbers for registered EU taxpayers. When you set up a company (at least in Poland) you don't have to register for EU VAT number if you don't plan to do business abroad. In this case you're getting perfectly valid NIP (polish VAT number) to use only in Poland. The only difference between EU VAT and NIP is that NIP doesn't have country code (PL in this example) in front of the number. Format is identical. I think that Poland is not the only country that does that this way.
So for example: NIP: 4462773388 - perfectly valid VAT number in Poland, but not available in VIES database, so you can't use it for B2B purchases in other EU countries. After additional registration for EU VAT it becomes: EU VAT ID: PL4462773388 - and is registered in VIES DB and you can use it for B2B purchases across EU
The perfect functionality would be to add some configuration which adds option to skip VIES db check if Client's billing country === Shop/Channel country, but still keep format validation.
I hope that this explanation is better than the last one :)
@adwil13 I understand it now, to achieve it the Prometee\VIESClientBundle\Constraints\VatNumber
constraint have to be replaced or enhanced by a new class constraint checking the Adress country code against the channel base country code.
Are you able to propose a PR about this ?
But this means that the final order will have a value which may not be a VAT number, is there a webservice or an public API to check this VAT number in Poland ?
@Prometee I'll probably do something about it in the next month, it's not a critical issue, because right now we're just showing different input when billing country === channel country to avoid the problem, but that's half assed solution ;)
There's an api for checking Polish VAT status: https://wl-api.mf.gov.pl/api/search/nip/XXXXXXXXXX?date=2022-03-17
To ensure active VAT status in response: $response['result']['subject']['statusVat'] === 'Czynny'
I have to check with our accountant how different statuses affect VAT on the invoices. Probably all statuses, but "Zwolniony" (exempt) should include taxes on invoices, but in Poland you have to be some kind of freaking accounting wizard to understand all the nuances.
VAT number validation in VIES db should be disabled when customer country is same as shop country. For example in Poland you don't have to apply for EU VAT ID if you're not buying anything from abroad, but in this case validation will always fail despite the fact that VAT ID is correct.