python-stdnum branch master updated. 1.19-6-g1e412ee
[Date Prev][
Date Next]
[Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.19-6-g1e412ee
- 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.19-6-g1e412ee
- Date: Sat, 3 Feb 2024 16:40:51 +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 1e412ee066afaa0861b4885604aa6106a3c4c879 (commit)
from 2535bbf01258e92f7c33aa8b01c880237114cd33 (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=1e412ee066afaa0861b4885604aa6106a3c4c879
commit 1e412ee066afaa0861b4885604aa6106a3c4c879
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Sat Feb 3 16:34:32 2024 +0100
Fix vatin number compacting for "EU" VAT numbers
Thanks Davide Walder for finding this.
Closes https://github.com/arthurdejong/python-stdnum/issues/427
diff --git a/stdnum/vatin.py b/stdnum/vatin.py
index a8553d2..f7ee12b 100644
--- a/stdnum/vatin.py
+++ b/stdnum/vatin.py
@@ -1,7 +1,7 @@
# vatin.py - function to validate any given VATIN.
#
# Copyright (C) 2020 Leandro Regueiro
-# Copyright (C) 2021 Arthur de Jong
+# Copyright (C) 2021-2024 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
@@ -74,7 +74,10 @@ def compact(number):
"""Convert the number to the minimal representation."""
number = clean(number).strip()
module = _get_cc_module(number[:2])
- return number[:2] + module.compact(number[2:])
+ try:
+ return number[:2].upper() + module.compact(number[2:])
+ except ValidationError:
+ return module.compact(number)
def validate(number):
diff --git a/tests/test_vatin.doctest b/tests/test_vatin.doctest
index 44dc38d..c46c238 100644
--- a/tests/test_vatin.doctest
+++ b/tests/test_vatin.doctest
@@ -1,7 +1,7 @@
test_vatin.doctest - more detailed doctests for stdnum.vatin module
Copyright (C) 2020 Leandro Regueiro
-Copyright (C) 2021 Arthur de Jong
+Copyright (C) 2021-2024 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
@@ -96,3 +96,11 @@ False
False
>>> vatin.is_valid('US')
False
+
+
+Check for VAT numbers that cannot be compacted without EU prefix:
+
+>>> vatin.is_valid('EU191849184')
+True
+>>> vatin.compact('EU191849184')
+'EU191849184'
-----------------------------------------------------------------------
Summary of changes:
stdnum/vatin.py | 7 +++++--
tests/test_vatin.doctest | 10 +++++++++-
2 files changed, 14 insertions(+), 3 deletions(-)
hooks/post-receive
--
python-stdnum
- python-stdnum branch master updated. 1.19-6-g1e412ee,
Commits of the python-stdnum project