arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
502 stars 211 forks source link

Make it Compability with Adding e-CF #135

Closed jeffryjdelarosa closed 5 years ago

jeffryjdelarosa commented 5 years ago

e-CF is the new way of DGII document, is the same as NCF, but the difference one to another, is that e-CF has 13 digit and is electronic invoice, with this change it will validate the correct NCF and e-CF.

arthurdejong commented 5 years ago

Hi @jeffryjdelarosa,

Thanks for the PR. Do you have some references or pointers to documentation to this new variation of the NCF? Are the old NCF numbers expected to remain in use or is this a new format? The question is basically whether it would be better to create a new stdnum.do.ecf module alongside stdnum.do.ncf?

jeffryjdelarosa commented 5 years ago

Thanks, @arthurdejong this the documentation Norma 05-19, the e-CF and NCF have the same functions, the variation is that on the invoice the e-CF will have a Digital Certificate and 13 digits, so it's not necessary to create other module, because DGII uses the current API to validate the NCF or e-CF with the RNC, I mean the function check_dgii with the url = 'https://www.dgii.gov.do/app/WebApps/ConsultasWeb/consultas/ncf.aspx'

arthurdejong commented 5 years ago

Thanks for providing the improvement. I've merged it as 5d0f288 which restructures things a bit, adds a few more tests and clarify the documentation.

Thanks!

jeffryjdelarosa commented 5 years ago

@arthurdejong thanks, great such, you're the expert :D

rpol commented 4 years ago

Hello @jeffryjdelarosa ,

I'm a little bit confused, Shouldn't the sequence type be validated as below? I see that it's been validated as a normal NCF sequence, that is: 01, 02, 03 and so on. Am I missing something?

Thanks in advance.

Tipos de Comprobantes Fiscales Electrónicos (e-CF)

Factura de Crédito Fiscal Electrónico (Tipo 31) Factura de Consumo Electrónica (Tipo 32) Nota de Débito Electrónica (Tipo 33) Nota de Crédito Electrónica (Tipo 34) Compras Electrónico (Tipo 41) Gastos Menores Electrónico (Tipo 43) Regímenes Especiales Electrónico (Tipo 44) Gubernamental Electrónico (Tipo 45)

jeffryjdelarosa commented 4 years ago

@rpol in Dominincan Republic there are two type of Legal Bill Number NCF and the new one e-CF, both make the same process I mean the little different is the e-CF uses digitl sign like a QR Code , 13 Digits the DGII have to validate the e-CF and then give them to the customer.

rpol commented 4 years ago

@jeffryjdelarosa Today my company received a bill from Claro, it had an e-CF like 'E310000000012' , the numbers after the E are '31', in theory it won't pass the stdnum NCF Validation and yet is a valid e-CF: https://dgii.gov.do/publicacionesOficiales/bibliotecaVirtual/contribuyentes/facturacion/Facturacin/Comprobantes%20Fiscales%20Electr%C3%B3nicos/Guia%20Comprobantes%20Electr%C3%B3nicos%20-WEB.pdf That's why i'm i little bit confused.

jeffryjdelarosa commented 4 years ago

@rpol what version of stdnum do you have? we use stdnum in Odoo ERP Application, and this work like a charm, so the code evaluate if have 13 digit, look at validate method

Look the source here

def validate(number): """Check if the number provided is a valid NCF.""" number = compact(number) if len(number) == 13: if number[0] != 'E' or not isdigits(number[1:]): raise InvalidFormat() if number[1:3] not in _ecf_document_types: raise InvalidComponent() elif len(number) == 11: if number[0] != 'B' or not isdigits(number[1:]): raise InvalidFormat() if number[1:3] not in _ncf_document_types: raise InvalidComponent() elif len(number) == 19: if number[0] not in 'AP' or not isdigits(number[1:]): raise InvalidFormat() if number[9:11] not in _ncf_document_types: raise InvalidComponent() else: raise InvalidLength() return number

rpol commented 4 years ago

@jeffryjdelarosa Excellent my friend, mine is not updated, will do! thanks!