# stdnum.do.rnc

RNC (Registro Nacional del Contribuyente, Dominican Republic tax number).

The RNC is the Dominican Republic taxpayer registration number for institutions. The number consists of 9 digits.

    >>> validate('1-01-85004-3')
    '101850043'
    >>> validate('1018A0043')
    Traceback (most recent call last):
        ...
    InvalidFormat: ...
    >>> validate('101850042')
    Traceback (most recent call last):
        ...
    InvalidChecksum: ...
    >>> format('131246796')
    '1-31-24679-6'

`stdnum.do.rnc.``calc_check_digit`(number)

  Calculate the check digit.

`stdnum.do.rnc.``check_dgii`(number, timeout=30)

  Lookup the number 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 lookup registration information for the number. The timeout is in seconds.

  Returns a dict with the following structure:

      {
          'rnc': '123456789',     # The requested number
          'name': 'The registered name',
          'commercial_name': 'An additional commercial name',
          'status': '2',          # 1: inactive, 2: active
          'category': '0',        # always 0?
          'payment_regime': '2',  # 1: N/D, 2: NORMAL, 3: PST
      }

  Will return None if the number is invalid or unknown.

`stdnum.do.rnc.``compact`(number)

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

`stdnum.do.rnc.``dgii_wsdl` = 'https://www.dgii.gov.do/wsMovilDGII/WSMovilDGII.asmx?WSDL'

  The WSDL URL of DGII validation service.

`stdnum.do.rnc.``format`(number)

  Reformat the number to the standard presentation format.

`stdnum.do.rnc.``is_valid`(number)

  Check if the number provided is a valid RNC.

`stdnum.do.rnc.``search_dgii`(keyword, end_at=10, start_at=1, timeout=30)

  Search the DGII online web service using the keyword.

  This uses the validation service run by the the Dirección General de Impuestos Internos, the Dominican Republic tax department to search the registration information using the keyword.

  The number of entries returned can be tuned with the end_at and start_at arguments. The timeout is in seconds.

  Returns a list of dicts with the following structure:

      [
          {
              'rnc': '123456789',     # The found number
              'name': 'The registered name',
              'commercial_name': 'An additional commercial name',
              'status': '2',          # 1: inactive, 2: active
              'category': '0',        # always 0?
              'payment_regime': '2',  # 1: N/D, 2: NORMAL, 3: PST
              'result_number': '1',   # index of the result
          },
          ...
      ]

  Will return an empty list if the number is invalid or unknown.

`stdnum.do.rnc.``validate`(number)

  Check if the number provided is a valid RNC.