stdnum.pe.ruc

RUC (Registro Único de Contribuyentes, Peruvian company tax number).

The RUC (Registro Único de Contribuyentes) is the tax number of Peru assigned to legal and natural persons. The number consists of 11 digits, the first two indicate the kind of number, for personal numbers it is followed by the DNI and a check digit.

More information:

>>> validate('20512333797')
'20512333797'
>>> validate('20512333798')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> to_dni('10054148289')
'05414828'
stdnum.pe.ruc.calc_check_digit(number)

Calculate the check digit.

stdnum.pe.ruc.compact(number)

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

stdnum.pe.ruc.is_valid(number)

Check if the number provided is a valid RUC. This checks the length, formatting and check digit.

stdnum.pe.ruc.to_dni(number)

Return the DNI (CUI) part of the number for natural persons.

stdnum.pe.ruc.validate(number)

Check if the number provided is a valid RUC. This checks the length, formatting and check digit.