Ë
    Ã?Æi#  ã                  óV   — d Z ddlmZ ddl­ ddlmZmZ dd„Zdd„Zdd„Z	dd„Z
dd	„Zy
)u?  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'
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                ó‚   — t        | d«      j                  «       j                  «       } | j                  d«      r| dd S | S )z’Convert the number to the minimal representation.

    This strips the number of any valid separators and removes surrounding
    whitespace.
    z -ÚUYé   N)r   ÚupperÚstripÚ
startswith©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/uy/rut.pyÚcompactr   ?   sA   € ô �6˜4Ó ×&Ñ&Ó(×.Ñ.Ó0€FØ×Ñ˜ÔØ�a�bˆzÐØ€Mó    c                ó\   — d}t        d„ t        || «      D «       «      }t        | dz  «      S )zCalculate the check digit.)é   é   r	   é	   é   é   é   é   r   r   r	   c              3  ó>   K  — | ]  \  }}t        |«      |z  –— Œ y ­w)N)Úint)Ú.0ÚwÚns      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>N   s   è ø€ Ò<™t˜q !”�A“˜•
Ñ<ùs   ‚é   )ÚsumÚzipÚstr)r   ÚweightsÚtotals      r   Úcalc_check_digitr&   K   s/   € à/€GÜÑ<¤s¨7°FÓ';Ô<Ó<€EÜ�ˆv˜‰{ÓÐr   c                ó(  — t        | «      } t        | «      dk7  r
t        «       ‚t        | «      s
t	        «       ‚| dd dk  s| dd dkD  r
t        «       ‚| dd dk(  r
t        «       ‚| dd d	k7  r
t        «       ‚| d
   t        | «      k7  r
t        «       ‚| S )zpCheck if the number is a valid Uruguay RUT number.

    This checks the length, formatting and check digit.
    é   Nr	   Ú01Ú22r   Ú000000r    Ú001éÿÿÿÿ)r   ÚlenÚInvalidLengthr   ÚInvalidFormatÚInvalidComponentr&   ÚInvalidChecksumr   s    r   Úvalidater3   R   s£   € ô
 �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�FÔÜ‹oÐØˆbˆq€z�DÒ˜F 2 A˜J¨Ò-ÜÓ Ð Øˆa�€{�hÒÜÓ Ð Øˆa�€|�uÒÜÓ Ð Øˆb�zÔ% fÓ-Ò-ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z2Check if the number is a valid Uruguay RUT number.F)Úboolr3   ÚValidationErrorr   s    r   Úis_validr7   g   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                óZ   — t        | «      } dj                  | dd | dd | dd | d   g«      S )z8Reformat the number to the standard presentation format.ú-Nr	   éüÿÿÿr-   )r   Újoinr   s    r   Úformatr<   o   s9   € ä�V‹_€FØ�8‰8�V˜B˜Q�Z ¨¨" ¨v°b¸¨}¸fÀR¹jÐIÓJÐJr   N)r   r#   Úreturnr#   )r   r#   r=   r5   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r&   r3   r7   r<   © r   r   ú<module>rC      s/   ðñ*õ< #ä ß 'ó	óóó*ôKr   