python-stdnum branch master updated. 1.8.1-20-g8204ac6
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.8.1-20-g8204ac6
- 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
- Subject: python-stdnum branch master updated. 1.8.1-20-g8204ac6
- Date: Mon, 9 Apr 2018 23:38:39 +0200 (CEST)
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 8204ac6327259972962cdc926a24f47ff7285ab5 (commit)
from 918d4832748ad6203cfbc4d0f58d8a9755e2c344 (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=8204ac6327259972962cdc926a24f47ff7285ab5
commit 8204ac6327259972962cdc926a24f47ff7285ab5
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Mon Apr 9 23:34:47 2018 +0200
Support new style of NCF numbers
This adds support for validating Dominican Republic invoice numbers that
should be used since from 2018-05-01.
http://www.dgii.gov.do/contribuyentes/personasFisicas/inicioOperaciones/ComprobantesFiscales/Paginas/SecuenciaDeNCF.aspx
Closes https://github.com/arthurdejong/python-stdnum/issues/69
diff --git a/stdnum/do/ncf.py b/stdnum/do/ncf.py
index 51b360d..5258026 100644
--- a/stdnum/do/ncf.py
+++ b/stdnum/do/ncf.py
@@ -1,7 +1,7 @@
# ncf.py - functions for handling Dominican Republic invoice numbers
# coding: utf-8
#
-# Copyright (C) 2018 Arthur de Jong
+# Copyright (C) 2017-2018 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
@@ -30,11 +30,13 @@ identifier, a 2-digit document type and a 8-digit serial
number.
More information:
- *
https://www.dgii.gov.do/et/nivelContribuyentes/Presentaciones%20contribuyentes/Número%20de%20Comprobantes%20Fiscales%20(NCF).pdf
+ * https://www.dgii.gov.do/
->>> validate('A020010210100000005')
+>>> validate('B0100000005') # format since 2018-05-01
+'B0100000005'
+>>> validate('A020010210100000005') # format before 2018-05-01
'A020010210100000005'
->>> validate('Z020010210100000005')
+>>> validate('Z0100000005')
Traceback (most recent call last):
...
InvalidFormat: ...
@@ -66,11 +68,15 @@ def compact(number):
def validate(number):
"""Check if the number provided is a valid NCF."""
number = compact(number)
- if len(number) != 19:
+ if len(number) == 11:
+ if number[0] != 'B' or not number[1:].isdigit():
+ raise InvalidFormat()
+ elif len(number) == 19:
+ if number[0] not in 'AP' or not number[1:].isdigit():
+ raise InvalidFormat()
+ else:
raise InvalidLength()
- if number[0] not in 'AP' or not number[1:].isdigit():
- raise InvalidFormat()
- if number[9:11] not in (
+ if number[-10:-8] not in (
'01', '02', '03', '04', '11', '12', '13', '14', '15'):
raise InvalidComponent()
return number
-----------------------------------------------------------------------
Summary of changes:
stdnum/do/ncf.py | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
hooks/post-receive
--
python-stdnum
--
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/python-stdnum-commits/
- python-stdnum branch master updated. 1.8.1-20-g8204ac6,
Commits of the python-stdnum project