Skip to content

Commit

Permalink
New release 0.24: add support for swiss VAT numbers
Browse files Browse the repository at this point in the history
Update stdnum from 0.12 to 0.14
  • Loading branch information
alexis-via committed Dec 30, 2020
1 parent 2ecd6f9 commit 7c05c39
Show file tree
Hide file tree
Showing 82 changed files with 4,608 additions and 967 deletions.
2 changes: 1 addition & 1 deletion extension/description.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:d="http://openoffice.org/extensions/description/2006">

<identifier value="com.akretion.factur-x" />
<version value="0.23" />
<version value="0.24" />
<platform value="all" />
<display-name>
<name lang="en">Factur-X Invoice Generator</name>
Expand Down
12 changes: 10 additions & 2 deletions extension/package/libreoffice_facturx_macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
from datetime import datetime, timedelta
import xml.etree.ElementTree as ET
from stdnum.eu.vat import is_valid
from stdnum.ch.vat import is_valid as ch_is_valid
# When the following bug will be solved
# https://github.com/arthurdejong/python-stdnum/issues/245
# We should be able to have a single import for VAT numbers
from stdnum.fr.siret import validate, InvalidChecksum, InvalidComponent, InvalidFormat, InvalidLength
from PyPDF4 import PdfFileWriter, PdfFileReader
from PyPDF4.generic import DictionaryObject, DecodedStreamObject,\
Expand Down Expand Up @@ -364,8 +368,12 @@ def get_and_check_data(doc, data_sheet):
return msg_box(doc, msg_start + str(e))
if field.endswith('_vat_number'):
data[field] = data[field].replace(' ', '').upper()
if not is_valid(data[field]):
return msg_box(doc, msg_start + _("this VAT number is invalid."))
if data[field].startswith('CHE'):
if not ch_is_valid(data[field]):
return msg_box(doc, msg_start + _("this VAT number is invalid."))
else:
if not is_valid(data[field]):
return msg_box(doc, msg_start + _("this VAT number is invalid."))
if field == 'invoice_currency': # required field
if len(data[field]) != 3 or not data[field].isalpha():
return msg_box(doc, msg_start + _("currency codes must have 3 letters."))
Expand Down
4 changes: 2 additions & 2 deletions extension/package/pythonpath/stdnum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# __init__.py - main module
# coding: utf-8
#
# Copyright (C) 2010-2019 Arthur de Jong
# Copyright (C) 2010-2020 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
Expand Down Expand Up @@ -43,4 +43,4 @@
__all__ = ('get_cc_module', '__version__')

# the version number of the library
__version__ = '1.12'
__version__ = '1.14'
24 changes: 15 additions & 9 deletions extension/package/pythonpath/stdnum/ar/cuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@
The CUIT is a taxpayer identification number used for VAT (IVA, Impuesto al
Valor Agregado) and other taxes.
>>> validate('200-5536168-2')
More information:
* https://es.wikipedia.org/wiki/Clave_Única_de_Identificación_Tributaria
>>> validate('20-05536168-2')
'20055361682'
>>> validate('2026756539')
Traceback (most recent call last):
...
InvalidLength: ...
>>> validate('2026756A393')
Traceback (most recent call last):
...
InvalidFormat: ...
>>> validate('20267565392')
Traceback (most recent call last):
...
Expand All @@ -62,13 +58,23 @@ def calc_check_digit(number):
return '012345678990'[11 - check]


# The different types of CUIT that are known
_cuit_tpes = (
'20', '23', '24', '27', # individuals
'30', '33', '34', # companies
'50', '51', '55', # international purposes
)


def validate(number):
"""Check if the number is a valid CUIT."""
number = compact(number)
if len(number) != 11:
raise InvalidLength()
if not isdigits(number):
raise InvalidFormat()
if number[:2] not in _cuit_tpes:
raise InvalidComponent()
if calc_check_digit(number[:-1]) != number[-1]:
raise InvalidChecksum()
return number
Expand Down
2 changes: 1 addition & 1 deletion extension/package/pythonpath/stdnum/at/postleitzahl.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# generated from PLZ_Verzeichnis_OKT19.xls downloaded from
# generated from PLZ_Verzeichnis_JAN20.xls downloaded from
# https://www.post.at/en/business_advertise_products_and_services_addresses_postcodes.php
1010 location="Wien" region="Wien"
1020 location="Wien" region="Wien"
Expand Down
17 changes: 9 additions & 8 deletions extension/package/pythonpath/stdnum/be/banks.dat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated from current_codes.xls downloaded from
# https://www.nbb.be/doc/be/be/protocol/current_codes.xls
# version 02/09/2019
# version 24/07/2020
000-000 bic="BPOTBEB1" bank="bpost bank"
001-049 bic="GEBABEBB" bank="BNP Paribas Fortis"
050-099 bic="GKCCBEBB" bank="BELFIUS BANK"
Expand Down Expand Up @@ -42,10 +42,9 @@
509-509 bic="ABNABE2AIPC" bank="ABN AMRO Bank N.V."
510-510 bic="VAPEBE22" bank="VAN DE PUT & CO Privaatbankiers"
512-512 bic="DNIBBE21" bank="NIBC BANK"
513-513 bic="SGPBBE99" bank="ABN AMRO Bank N.V."
513-513 bic="ABNABE2AIPC" bank="ABN AMRO Bank N.V."
514-514 bic="PUILBEBB" bank="Puilaetco Dewaay Private Bankers"
515-515 bic="IRVTBEBB" bank="The Bank of New York Mellon NV/SA"
519-519 bic="BNYMBEBB" bank="The Bank of New York Mellon"
521-521 bic="FVLBBE22" bank="F. van Lanschot Bankiers"
522-522 bic="UTWBBEBB" bank="United Taiwan Bank"
523-523 bic="TRIOBEBB" bank="Triodos Bank"
Expand Down Expand Up @@ -77,23 +76,24 @@
630-631 bic="BBRUBEBB" bank="ING België"
634-636 bic="BNAGBEBB" bank="Bank Nagelmackers"
638-638 bic="GKCCBEBB" bank="BELFIUS BANK"
639-639 bic="ABNABE2AMYO" bank="ABN AMRO Bank N.V."
640-640 bic="ADIABE22" bank="KBC Bank N.V. Business Center Diamant"
642-642 bic="BBVABEBB" bank="Banco Bilbao Vizcaya Argentaria"
643-643 bic="BMPBBEBB" bank="Banca Monte Paschi Belgio"
643-643 bic="BMPBBEBB" bank="Aion"
644-644 bank="FCA Bank S.p.A."
645-645 bic="JVBABE22" bank="Bank J. Van Breda & C°"
646-647 bic="BNAGBEBB" bank="Bank Nagelmackers"
648-648 bic="BMPBBEBBVOD" bank="Banca Monte Paschi Belgio"
648-648 bic="BMPBBEBBVOD" bank="Aion"
649-649 bank="Caisse d'Epargne et de Prévoyance Hauts de France"
651-651 bic="KEYTBEBB" bank="Arkéa Direct Bank (nom commercial / commerciële naam: Keytrade Bank)"
652-652 bic="BBRUBEBB" bank="ING België"
653-653 bank="Barclays Bank Ireland Plc Brussels Branch"
654-654 bank="Crédit foncier et communal d'Alsace et de Lorraine - Banque"
657-657 bic="GKCCBEBB" bank="BELFIUS BANK"
658-658 bic="HABBBEBB" bank="Habib Bank"
663-663 bic="BMEUBEB1" bank="BMCE Euro Services"
664-664 bic="BCDMBEBB" bank="Banque Chaabi du Maroc"
666-666 bank="WORLDLINE NV"
667-667 bic="CMCIBEB1CIC" bank="Crédit Industriel et Commercial - Succursale de Bruxelles"
668-668 bic="SBINBE2X" bank="State Bank of India"
669-669 bank="WORLDLINE NV"
670-670 bank="CNH Industrial Capital EUROPE"
Expand Down Expand Up @@ -151,8 +151,8 @@
883-884 bic="BBRUBEBB" bank="ING België"
887-888 bic="BBRUBEBB" bank="ING België"
890-899 bic="VDSPBE91" bank="vdk bank"
906-906 bic="CEKVBE81" bank="Centrale Kredietverlening (C.K.V.)"
908-908 bic="CEKVBE81" bank="Centrale Kredietverlening (C.K.V.)"
906-906 bic="CEKVBE88" bank="Centrale Kredietverlening (C.K.V.)"
908-908 bic="CEKVBE88" bank="Centrale Kredietverlening (C.K.V.)"
910-910 bic="BBRUBEBB" bank="ING België"
911-911 bic="TUNZBEB1" bank="Ingenico Financial Solutions"
912-912 bank="Hi - Media Porte Monnaie Electronique"
Expand Down Expand Up @@ -183,6 +183,7 @@
960-960 bic="ABNABE2AIPC" bank="ABN AMRO Bank N.V."
961-961 bic="BBRUBEBB" bank="ING België"
963-963 bic="AXABBE22" bank="AXA Bank Belgium"
966-966 bic="NEECBEB2" bank="NewB"
967-967 bic="TRWIBEB1" bank="TransferWise"
968-968 bic="ENIBBEBB" bank="Banque Eni"
969-969 bic="PUILBEBB" bank="Puilaetco Dewaay Private Bankers"
Expand Down
5 changes: 3 additions & 2 deletions extension/package/pythonpath/stdnum/br/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# __init__.py - collection of Brazillian numbers
# __init__.py - collection of Brazilian numbers
# coding: utf-8
#
# Copyright (C) 2012 Arthur de Jong
Expand All @@ -18,4 +18,5 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

"""Collection of Brazillian numbers."""
"""Collection of Brazilian numbers."""
from stdnum.br import cnpj as vat # noqa: F401
2 changes: 1 addition & 1 deletion extension/package/pythonpath/stdnum/br/cnpj.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

"""CNPJ (Cadastro Nacional da Pessoa Jurídica, Brazillian company identifier).
"""CNPJ (Cadastro Nacional da Pessoa Jurídica, Brazilian company identifier).
Numbers from the national register of legal entities have 14 digits. The
first 8 digits identify the company, the following 4 digits identify a
Expand Down
2 changes: 1 addition & 1 deletion extension/package/pythonpath/stdnum/br/cpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

"""CPF (Cadastro de Pessoas Físicas, Brazillian national identifier).
"""CPF (Cadastro de Pessoas Físicas, Brazilian national identifier).
The Cadastro de Pessoas Físicas is the Brazilian identification number
assigned to individuals for tax purposes. The number consists of 11 digits
Expand Down
24 changes: 24 additions & 0 deletions extension/package/pythonpath/stdnum/by/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# __init__.py - collection of Belarusian numbers
# coding: utf-8
#
# Copyright (C) 2020 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
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

"""Collection of Belarusian numbers."""

# provide aliases
from stdnum.by import unp as vat # noqa: F401
47 changes: 47 additions & 0 deletions extension/package/pythonpath/stdnum/by/portal.nalog.gov.by.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-----BEGIN CERTIFICATE-----
MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow
SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT
GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF
q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8
SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0
Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA
a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj
/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T
AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG
CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9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