lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.1-2-g8fe44f9

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.1-2-g8fe44f9



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  8fe44f98a0d8709912ddf7fc383c14d72472d819 (commit)
       via  8925ae2731e2122d3ebc746243f08042ba65cb62 (commit)
      from  58775d96a5fc9783fc5dc3fa22fa0a0361419e78 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://arthurdejong.org/git/python-stdnum/commit/?id=8fe44f98a0d8709912ddf7fc383c14d72472d819

commit 8fe44f98a0d8709912ddf7fc383c14d72472d819
Author: Lionel Elie Mamane <lmamane@debian.org>
Date:   Tue Apr 28 15:44:16 2015 +0200

    Implement alternate VIES check
    
    Add a 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.

diff --git a/stdnum/eu/vat.py b/stdnum/eu/vat.py
index 30a13c3..a0ff0b9 100644
--- a/stdnum/eu/vat.py
+++ b/stdnum/eu/vat.py
@@ -1,7 +1,8 @@
 # vat.py - functions for handling European VAT numbers
 # coding: utf-8
 #
-# Copyright (C) 2012, 2013 Arthur de Jong
+# Copyright (C) 2012-2015 Arthur de Jong
+# Copyright (C) 2015 Lionel Elie Mamane
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -44,8 +45,8 @@ from stdnum.util import clean
 
 country_codes = set([
     'at', 'be', 'bg', 'cy', 'cz', 'de', 'dk', 'ee', 'es', 'fi', 'fr', 'gb',
-    'gr', 'hr', 'hu', 'ie', 'it', 'lt', 'lu', 'lv', 'mt', 'nl', 'pl', 'pt', 
'ro',
-    'se', 'si', 'sk'
+    'gr', 'hr', 'hu', 'ie', 'it', 'lt', 'lu', 'lv', 'mt', 'nl', 'pl', 'pt',
+    'ro', 'se', 'si', 'sk',
 ])
 """The collection of country codes that are queried. Greece is listed with
 a country code of gr while for VAT purposes el is used instead."""
@@ -114,14 +115,10 @@ 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 _get_client():  # pragma: no cover (no tests for this function)
+    """Get a SOAP client for performing VIES requests."""
+    # this function isn't automatically tested because the functions using
+    # it are not automatically tested
     global _vies_client
     if not _vies_client:
         from suds.client import Client
@@ -130,4 +127,30 @@ def check_vies(number):  # pragma: no cover (no tests for 
this function)
         except ImportError:
             from urllib.request import getproxies
         _vies_client = Client(vies_wsdl, proxy=getproxies())
-    return _vies_client.service.checkVat(number[:2], number[2:])
+    return _vies_client
+
+
+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)
+    return _get_client().service.checkVat(number[:2], number[2:])
+
+
+def check_vies_approx(number, requester):  # pragma: no cover
+    """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
+    number = compact(number)
+    requester = compact(requester)
+    return _get_client.service.checkVatApprox(
+        countryCode=number[:2], vatNumber=number[2:],
+        requesterCountryCode=requester[:2], requesterVatNumber=requester[2:])

http://arthurdejong.org/git/python-stdnum/commit/?id=8925ae2731e2122d3ebc746243f08042ba65cb62

commit 8925ae2731e2122d3ebc746243f08042ba65cb62
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Mon Apr 27 20:34:19 2015 +0200

    Fix copyright header

diff --git a/tests/test_iso6346.doctest b/tests/test_iso6346.doctest
index 11bd81f..32b67ea 100644
--- a/tests/test_iso6346.doctest
+++ b/tests/test_iso6346.doctest
@@ -1,6 +1,6 @@
 test_doctest - more detailed doctests for the stdnum.iso6346 package
 
-Copyright (C) 2014 Openlabs Technologies & consulting (P) Limited
+Copyright (C) 2014 Openlabs Technologies & Consulting (P) Limited
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public

-----------------------------------------------------------------------

Summary of changes:
 stdnum/eu/vat.py           |   47 +++++++++++++++++++++++++++++++++-----------
 tests/test_iso6346.doctest |    2 +-
 2 files changed, 36 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
python-stdnum
-- 
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/python-stdnum-commits/