arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
499 stars 208 forks source link

Incorrect validation case for swiss #336

Open harryparmar opened 1 year ago

harryparmar commented 1 year ago

for example with stdnum both CHE394021985MWST and CHE394021985 MWST are valid. But from Swiss govt office API CHE394021985MWST returns data validation error while CHE394021985 MWST works. So Space is expected.

arthurdejong commented 1 year ago

Hi @harryparmar, Thanks for pointing this out. If you're talking about the search at https://www.uid.admin.ch/ it seems to do weird things with spaces in general. It most likely also expects only handles the UID and not the VAT number.

For example: searching for CHE394021985 XXXXX also returns a result. Even more interesting is the search result for CHE 394021985 which returns results for a different number instead. The value CHE-394021985 returns reasonable results again while CHE-394.021.985MWST returns information for a different number again (but no error like is returned for CHE394021985MWST).

It might be an option to provide a to_uid() function in the stdnum.ch.vat module to help dealing with this search.

If it is a different API, please let ne know.

harryparmar commented 1 year ago

Hi @arthurdejong I am talking about their soap service https://www.uid-wse.admin.ch/V5.0/PublicServices.svc?wsdl ValidateVatNumber method.its possible this is bug on their end as rather than giving boolean false it causes data validation error exception.

arthurdejong commented 1 year ago

According to the documentation in https://dam-api.bfs.admin.ch/hub/api/dam/assets/11007266/master the SOAP interface expects the vatNumber parameter to be without the "MWST" suffix.

There might be some confusion between the difference of a UID and a proper VAT number. When the module was added to python-stdnum it was expected that the "MWST" suffix was what differentiated the UID from the VAT number. If you have any clarifications in this area I'd be happy to update the implementation.

Btw, since researching this got me 90% to the way of implementing support for checking the SOAP service I've added a check_uid() function to the stdnum.ch.uid module in a218032.