Ë
    Ã?Æ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
)uc  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:

* https://www.sunat.gob.pe/legislacion/ruc/
* https://consultarelruc.pe/

>>> validate('20512333797')
'20512333797'
>>> validate('20512333798')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> to_dni('10054148289')
'05414828'
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                ó6   — t        | d«      j                  «       S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.ú )r   Ústrip©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/pe/ruc.pyÚcompactr   1   s   € ô �˜Ó×#Ñ#Ó%Ð%ó    c           
     ób   — d}t        dt        d„ t        || «      D «       «      dz  z
  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>:   s   è ø€ ÒE©¨¨1˜œS ›V�ÑEùs   ‚é
   )ÚstrÚsumÚzip)r   Úweightss     r   Úcalc_check_digitr"   7   s3   € à,€GÜ�”SÑE´°G¸VÓ0DÔEÓEÈÑJÑJÈbÑPÓQÐQr   c                óX   — t        | «      } | j                  d«      s
t        «       ‚| dd S )z<Return the DNI (CUI) part of the number for natural persons.Ú10r   r   )ÚvalidateÚ
startswithÚInvalidComponentr
   s    r   Úto_dnir(   =   s/   € ä�fÓ€FØ×Ñ˜TÔ"ÜÓ Ð Ø�!�Bˆ<Ðr   c                óà   — t        | «      } t        | «      dk7  r
t        «       ‚t        | «      s
t	        «       ‚| dd dvr
t        «       ‚| j                  t        | «      «      s
t        «       ‚| S )údCheck if the number provided is a valid RUC. This checks the length,
    formatting and check digit.r   Nr   )r$   Ú15Ú17Ú20)	r   ÚlenÚInvalidLengthr   ÚInvalidFormatr'   Úendswithr"   ÚInvalidChecksumr
   s    r   r%   r%   E   si   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�FÔÜ‹oÐØˆbˆq€zÐ1Ñ1ÜÓ Ð Ø�?‰?Ô+¨FÓ3Ô4ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)r*   F)Úboolr%   ÚValidationErrorr
   s    r   Úis_validr6   T   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"N)r   r   Úreturnr   )r   r   r7   r4   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r"   r(   r%   r6   © r   r   ú<module>r=      s/   ðñ*õ, #ä ß 'ó&óRóóôr   