python-stdnum branch master updated. 1.14-8-gc74e322
[Date Prev][
Date Next]
[Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.14-8-gc74e322
- From: Commits of the python-stdnum project <python-stdnum-commits [at] lists.arthurdejong.org>
- To: python-stdnum-commits [at] lists.arthurdejong.org
- Reply-to: python-stdnum-users [at] lists.arthurdejong.org, python-stdnum-commits [at] lists.arthurdejong.org
- Subject: python-stdnum branch master updated. 1.14-8-gc74e322
- Date: Sat, 2 Jan 2021 13:31:21 +0100 (CET)
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 c74e3220e96b152d6f54d21e3c0b07a7977b9e36 (commit)
from 5082af48c037e51d51c1d920a1a8d1f0bbf7becb (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 -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=c74e3220e96b152d6f54d21e3c0b07a7977b9e36
commit c74e3220e96b152d6f54d21e3c0b07a7977b9e36
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Sat Jan 2 13:29:12 2021 +0100
Support VAT numbers that are only valid with country prefix
The Swish VAT number has the CH prefix embedded as a required part of
the number. This ensures that the international VAT number module also
supports that.
Closes https://github.com/arthurdejong/python-stdnum/issues/245
Fixes ff188bd
diff --git a/stdnum/vatin.py b/stdnum/vatin.py
index 50f587c..76df143 100644
--- a/stdnum/vatin.py
+++ b/stdnum/vatin.py
@@ -1,6 +1,7 @@
# vatin.py - function to validate any given VATIN.
#
# Copyright (C) 2020 Leandro Regueiro
+# Copyright (C) 2021 Arthur de Jong
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -83,7 +84,10 @@ def validate(number):
"""
number = clean(number, '').strip()
module = _get_cc_module(number[:2])
- return number[:2].upper() + module.validate(number[2:])
+ try:
+ return number[:2].upper() + module.validate(number[2:])
+ except ValidationError:
+ return module.validate(number)
def is_valid(number):
diff --git a/tests/test_vatin.doctest b/tests/test_vatin.doctest
index f0c5f92..bb86785 100644
--- a/tests/test_vatin.doctest
+++ b/tests/test_vatin.doctest
@@ -1,6 +1,7 @@
test_vatin.doctest - more detailed doctests for stdnum.vatin module
Copyright (C) 2020 Leandro Regueiro
+Copyright (C) 2021 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -35,6 +36,8 @@ Check valid VAT numbers for several countries with existing
validation:
'BR16727230000197'
>>> vatin.validate('el-082857563')
'EL082857563'
+>>> vatin.validate('CHE-109.298.651 TVA')
+'CHE109298651TVA'
Try validating invalid VAT numbers for country with validation:
-----------------------------------------------------------------------
Summary of changes:
stdnum/vatin.py | 6 +++++-
tests/test_vatin.doctest | 3 +++
2 files changed, 8 insertions(+), 1 deletion(-)
hooks/post-receive
--
python-stdnum
- python-stdnum branch master updated. 1.14-8-gc74e322,
Commits of the python-stdnum project