Package: python-stdnum
Version: 1.0-1.0
Severity: wishlist
Tags: patch

Please add a new function to stdnum.eu.vat so that when one does a
VIES VAT number check, one gets a proof (certificate) that one did the
check, as defence against the VAT administration later putting this in
doubt. This certificate is provided by the VIES service, if one provides
one's own VAT number.

Compare:

>>> stdnum.eu.vat.check_vies('BEXXXXXXXXXX')
(reply){
   countryCode = "BE"
   vatNumber = "XXXXXXX"
   requestDate = 2015-04-28
   valid = True
   name = "SPRL FAFA"
   address = "RUE DE FAFA 18
6000 NAMUR"
 }

and

>>> stdnum.eu.vat.check_vies_certificate('BEXXXXXXX', 'LUXXXXXX')
(reply){
   countryCode = "BE"
   vatNumber = "XXXXXXXX"
   requestDate = 2015-04-28
   valid = True
   traderName = "SPRL FAFA"
   traderCompanyType = "---"
   traderAddress = "RUE DE FAFA 18
6000 NAMUR"
   requestIdentifier = "WAPIAAAAU0A9f1Hu"
 }


The "requestIdentifier" is the proof certificate.


Patch attached.

Thanks,

Lionel

-- System Information:
Debian Release: 8.0
  APT prefers testing-updates
  APT policy: (600, 'testing-updates'), (600, 'testing'), (300, 'unstable'), 
(1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=fr_LU.utf8, LC_CTYPE=fr_LU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python-stdnum depends on:
ii  python                2.7.9-1
ii  python-pkg-resources  5.5.1-1

python-stdnum recommends no packages.

Versions of packages python-stdnum suggests:
ii  python-suds-jurko [python-suds]  0.6-1

-- no debconf information
diff -Nru python-stdnum-1.0/debian/changelog python-stdnum-1.0/debian/changelog
--- python-stdnum-1.0/debian/changelog	2014-10-19 23:46:28.000000000 +0200
+++ python-stdnum-1.0/debian/changelog	2015-04-28 15:44:16.000000000 +0200
@@ -1,3 +1,10 @@
+python-stdnum (1.0-1.0) unstable; urgency=medium
+
+  * Local fork (call it NMU to keep lintian happy)
+    - New feature: add stdnum.eu.vat.check_vies_certificate
+
+ -- Lionel Elie Mamane <lmam...@debian.org>  Tue, 28 Apr 2015 15:44:16 +0200
+
 python-stdnum (1.0-1) unstable; urgency=medium
 
   * New upstream release:
diff -Nru python-stdnum-1.0/debian/patches/eu.var.check_vies_certificate python-stdnum-1.0/debian/patches/eu.var.check_vies_certificate
--- python-stdnum-1.0/debian/patches/eu.var.check_vies_certificate	1970-01-01 01:00:00.000000000 +0100
+++ python-stdnum-1.0/debian/patches/eu.var.check_vies_certificate	2015-04-28 19:01:35.000000000 +0200
@@ -0,0 +1,50 @@
+Index: python-stdnum-1.0/stdnum/eu/vat.py
+===================================================================
+--- python-stdnum-1.0.orig/stdnum/eu/vat.py
++++ python-stdnum-1.0/stdnum/eu/vat.py
+@@ -114,14 +114,7 @@ def guess_country(number):
+             if _get_cc_module(cc).is_valid(number)]
+ 
+ 
+-def check_vies(number):  # pragma: no cover (no tests for this function)
+-    """Queries the online European Commission VAT Information Exchange
+-    System (VIES) for validity of the provided number. Note that the
+-    service has usage limitations (see the VIES website for details).
+-    This returns a dict-like object."""
+-    # this function isn't automatically tested because it would require
+-    # network access for the tests and unnecessarily load the VIES website
+-    number = compact(number)
++def _check_vies_common():
+     global _vies_client
+     if not _vies_client:
+         from suds.client import Client
+@@ -130,4 +123,29 @@ def check_vies(number):  # pragma: no co
+         except ImportError:
+             from urllib.request import getproxies
+         _vies_client = Client(vies_wsdl, proxy=getproxies())
++
++def check_vies(number):  # pragma: no cover (no tests for this function)
++    """Queries the online European Commission VAT Information Exchange
++    System (VIES) for validity of the provided number. Note that the
++    service has usage limitations (see the VIES website for details).
++    This returns a dict-like object."""
++    # this function isn't automatically tested because it would require
++    # network access for the tests and unnecessarily load the VIES website
++    _check_vies_common()
++    number = compact(number)
+     return _vies_client.service.checkVat(number[:2], number[2:])
++
++def check_vies_certificate(number, requester):  # pragma: no cover (no tests for this function)
++    """Queries the online European Commission VAT Information Exchange
++    System (VIES) for validity of the provided number, providing a
++    validity certificate as proof. You will need to give your own VAT
++    number for this to work. Note that the service has usage limitations
++    (see the VIES website for details). This returns a dict-like object."""
++    # this function isn't automatically tested because it would require
++    # network access for the tests and unnecessarily load the VIES website
++    _check_vies_common()
++    number = compact(number)
++    requester = compact(requester)
++    return _vies_client.service.checkVatApprox(countryCode=number[:2], vatNumber=number[2:],
++                                               requesterCountryCode=requester[:2], requesterVatNumber=requester[2:])
++
diff -Nru python-stdnum-1.0/debian/patches/series python-stdnum-1.0/debian/patches/series
--- python-stdnum-1.0/debian/patches/series	1970-01-01 01:00:00.000000000 +0100
+++ python-stdnum-1.0/debian/patches/series	2015-04-28 15:35:09.000000000 +0200
@@ -0,0 +1 @@
+eu.var.check_vies_certificate

Reply via email to