Package: django-verify-vat-number
Django Verify VAT registration numberTheDjango Verify VAT registration numbermodule is an extension of theVerify VAT registration numberproject for theDjangoframework. It is used for verificationVAT registration numberin EU andVAT identification numberin Czechia. This module is used in theDjangoCMS Verify VAT registration numbermodule.VIESVIES VAT number validation for European union. It is an electronic mean of validating VAT-identification numbers of economic operators registered in the European Union for cross border transactions on goods or services. Supported countries see README in projectVerify VAT - VIES.ARESARES- Access to Registers of Economic Subjects / Entities is an information system allowing a retrieval of information on economic entities registered in the Czech Republic. This system intermediates a display of data from particular registers of the state administration (called source registers) in which the data concerned is kept.InstallationThis library is available on PyPI, it's recommended to install it usingpip:pipinstalldjango-verify-vat-numberAppend into Django apps and urlsInsert into sitesettings.py:INSTALLED_APPS=[...'django_verify_vat_number',]Insert into siteurls.py:fromdjango.urlsimportpath,includeurlpatterns=[....path('verify-vat/',include('django_verify_vat_number.urls')),]UsageFollow instructionsWriting your first Django appto launch the site.
Then you can make verification:curl http://127.0.0.1:8000/verify-vat/verify-vat-id-number/?number=67985726

{"status": "OK", "message": null, "company": {
    "company_name": "CZ.NIC, z.s.p.o.",
    "address": "Mile\u0161ovsk\u00e1 1136/5\n13000 Praha 3",
    "street_and_num": "Mile\u0161ovsk\u00e1 1136/5",
    "city": "Praha 3",
    "postal_code": "13000",
    "district": "Praha 3 - Vinohrady",
    "country_code": "CZ"
}, "country": "Czechia"}

curl http://127.0.0.1:8000/verify-vat/verify-vat-reg-number/?number=CZ67985726

{"status": "OK", "message": null, "company": {
    "company_name": "CZ.NIC, z.s.p.o.",
    "address": "Mile\u0161ovsk\u00e1 1136/5\nPRAHA 3 - VINOHRADY\n130 00  PRAHA 3",
    "street_and_num": "Mile\u0161ovsk\u00e1 1136/5",
    "city": "PRAHA 3",
    "postal_code": "130 00",
    "district": "PRAHA 3 - VINOHRADY",
    "country_code": "CZ"
}, "country": "Czechia"}Country name in current site languageThe country name is translated into the current site language.Define languages insettings.py:LANGUAGES=[('en','English'),('cs','Česky'),('fr','Francais'),]MIDDLEWARE=[...'django.middleware.locale.LocaleMiddleware',]Enable language prefix inurl.py:urlpatterns+=i18n_patterns(path('verify-vat/',include('django_verify_vat_number.urls')),)Get translated country name:curl http://127.0.0.1:8000/cs/verify-vat/verify-vat-id-number/?number=67985726

{"status": "OK", "message": null, "company": {"company_name": ... "country_code": "CZ"},
 "country": "\u010cesko"}

curl http://127.0.0.1:8000/fr/verify-vat/verify-vat-id-number/?number=67985726
{"status": "OK", "message": null, "company": {"company_name": ... "country_code": "CZ"},
 "country": "Tch\u00e9quie"}CacheThe data downloaded from the server is cached. At the next query, they are no longer downloaded
from the verification service. The default cache value is one day.
The duration of the data in the cache can be reset in the settings by the constantVERIFY_VAT_KEEP_IN_CACHE.LoggingTemporary unavailability of the resource is logged in theINFOlevel.
An unexpected error is logged in theERRORlevel, including the source response.Example of a temporarily unavailable service:2022-06-16 14:49:33,806 INFO     ares:get_xml_content:27 https://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico=67985726
2022-06-16 14:49:33,815 INFO     fetchers:fetch_from_ares:47 Service is temporarily unavailable. Please, try later.Example of a unexpected service failure:022-06-16 14:55:10,039 INFO     ares:get_xml_content:27 https://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico=67985726
2022-06-16 14:55:10,042 ERROR    fetchers:fetch_from_ares:49 not well-formed (invalid token): line 1, column 11
2022-06-16 14:55:10,042 ERROR    fetchers:fetch_from_ares:50 <are:Error><dtt:Error_kod> ...If you want to debug complete communication, you can set it in loggersdjango_verify_vat_number.fetchersandverify_vat_number.ares,verify_vat_number.vies.Insettings.py:LOGGING={...'loggers':{'verify_vat_number.ares':{'handlers':['console'],'level':'DEBUG'},'verify_vat_number.vies':{'handlers':['console'],'level':'DEBUG'},'django_verify_vat_number.fetchers':{'handlers':['console'],'level':'DEBUG'},}}2022-06-16 15:03:04,078 INFO     ares:get_xml_content:27 https://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico=67985726
2022-06-16 15:03:04,078 INFO     ares:get_xml_content:27 https://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico=67985726
2022-06-16 15:03:05,401 DEBUG    ares:get_xml_content:38 <?xml version="1.0" encoding="UTF-8"?><are:Ares_odpovedi
    ...
<are:Odpoved>
<are:Pocet_zaznamu>1</are:Pocet_zaznamu>
    ...
</are:Odpoved>
</are:Ares_odpovedi>
2022-06-16 15:10:39,020 INFO     fetchers:fetch_from_ares:30 Cached data: VerifiedCompanyResponse(status=<StatusCode.OK: 'OK'>, message=None, company=VerifiedCompany(company_name='CZ.NIC, z.s.p.o.', address='Milešovská 1136/5\n13000 Praha 3', street_and_num='Milešovská 1136/5', city='Praha 3', postal_code='13000', district='Praha 3 - Vinohrady', country_code='CZ'), country='Česko')LicenseGPLv3+