# stdnum.uy.rut

RUT (Registro Único Tributario, Uruguay tax number).

The Registro Único Tributario (RUT) is an identifier of legal entities for tax purposes.

This number consists of 12 digits, the first two indicate the registration number, followed by a 6 digit sequence number, followed by 001 and a check digit.

More information:

- https://www.agesic.gub.uy/innovaportal/file/1634/1/modelo_de_datos.pdf (page 71)

- https://servicios.dgi.gub.uy/ServiciosEnLinea/dgi–servicios-en-linea–consulta-de-certifcado-unico

    >>> validate('21-100342-001-7')
    '211003420017'
    >>> validate('UY 21 140634 001 1')
    '211406340011'
    >>> validate('210303670014')
    Traceback (most recent call last):
        ...
    InvalidChecksum: ...
    >>> validate('12345678')
    Traceback (most recent call last):
        ...
    InvalidLength: ...
    >>> format('211003420017')
    '21-100342-001-7'

stdnum.uy.rut.calc_check_digit(number)

  Calculate the check digit.

stdnum.uy.rut.compact(number)

  Convert the number to the minimal representation.

  This strips the number of any valid separators and removes surrounding whitespace.

stdnum.uy.rut.format(number)

  Reformat the number to the standard presentation format.

stdnum.uy.rut.is_valid(number)

  Check if the number is a valid Uruguay RUT number.

stdnum.uy.rut.validate(number)

  Check if the number is a valid Uruguay RUT number.

  This checks the length, formatting and check digit.