stdnum.do.ncf

NCF (Números de Comprobante Fiscal, Dominican Republic receipt number).

The NCF is used to number invoices and other documents for the purpose of tax filing. The e-CF (Comprobante Fiscal Electrónico) is used together with a digital certificate for the same purpose. The number is either 19, 11 or 13 (e-CF) digits long.

The 19 digit number starts with a letter (A or P) to indicate that the number was assigned by the taxpayer or the DGII, followed a 2-digit business unit number, a 3-digit location number, a 3-digit mechanism identifier, a 2-digit document type and a 8-digit serial number.

The 11 digit number always starts with a B followed a 2-digit document type and a 7-digit serial number.

The 13 digit e-CF starts with an E followed a 2-digit document type and an 8-digit serial number.

More information:

>>> validate('E310000000005')  # format since 2019-04-08
'E310000000005'
>>> validate('B0100000005')  # format since 2018-05-01
'B0100000005'
>>> validate('A020010210100000005')  # format before 2018-05-01
'A020010210100000005'
>>> validate('Z0100000005')
Traceback (most recent call last):
    ...
InvalidFormat: ...
stdnum.do.ncf.check_dgii(rnc, ncf, buyer_rnc=None, security_code=None, timeout=30)

Validate the RNC, NCF combination on using the DGII online web service.

This uses the validation service run by the the Dirección General de Impuestos Internos, the Dominican Republic tax department to check whether the combination of RNC and NCF is valid. The timeout is in seconds.

Returns a dict with the following structure for a NCF:

{
    'name': 'The registered name',
    'status': 'VIGENTE',
    'type': 'FACTURAS DE CREDITO FISCAL',
    'rnc': '123456789',
    'ncf': 'A020010210100000005',
    'validation_message': 'El NCF digitado es válido.',
}

For an ECNF:

{
    'status': 'Aceptado',
    'issuing_rnc': '1234567890123',
    'buyer_rnc': '123456789',
    'ncf': 'E300000000000',
    'security_code': '1+2kP3',
    'issuing_date': '2020-03-25',
    'signature_date': '2020-03-22',
    'total': '2203.50',
    'total_itbis': '305.10',
    'validation_message': 'Aceptado',
}

Will return None if the number is invalid or unknown.

stdnum.do.ncf.compact(number)

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.do.ncf.is_valid(number)

Check if the number provided is a valid NCF.

stdnum.do.ncf.validate(number)

Check if the number provided is a valid NCF.