Ë
    Ã?Æi7  ã                  ó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ò  NIT (NÃºmero de IdentificaciÃ³n Tributaria, El Salvador tax number).

This number consists of 14 digits, usually separated into four groups
using hyphens to make it easier to read, like XXXX-XXXXXX-XXX-X.

The first four digits indicate the code for the municipality of birth
for natural persons or the municipality of stablishment for juridical
persons. NIT for El Salvador nationals begins with either 0 or 1, and
for foreigners it begins with 9.

The following six digits indicate the date of birth for the natural
person, or the stablishment date for the juridical person, using the
format DDMMYY, where DD is the day, MM is the month, and YY is the
year. For example XXXX-051180-XXX-X is (November 5 1980)

The next 3 digits are a sequential number.

The last digit is the check digit, which is used to verify the number
was correctly typed.

More information:

* https://es.wikipedia.org/wiki/Identificaci%C3%B3n_tributaria
* https://www.listasal.info/articulos/nit-el-salvador.shtml
* https://tramitesyrequisitos.com/el-salvador/nit/#Estructura_del_NIT
* https://www.svcommunity.org/forum/programacioacuten/como-calcular-digito-verificador-del-dui-y-nit/msg951882/#msg951882

>>> validate('0614-050707-104-8')
'06140507071048'
>>> validate('SV 0614-050707-104-8')
'06140507071048'
>>> validate('0614-050707-104-0')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('12345678')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> format('06140507071048')
'0614-050707-104-8'
é    )Ú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 -ÚSVé   N)r   ÚupperÚstripÚ
startswith©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/sv/nit.pyÚcompactr   F   sA   € ô �6˜4Ó ×&Ñ&Ó(×.Ñ.Ó0€FØ×Ñ˜ÔØ�a�bˆzÐØ€Mó    c                óÐ   — | dd dk  r/d}t        d„ t        | |«      D «       «      }t        |dz  dz  «      S d}t        d„ t        | |«      D «       «      }t        | dz  dz  «      S )	zCalculate the check digit.é
   é   Ú100)é   r   é   é   r   é	   é   é   é   é   é   é   r	   c              3  ó>   K  — | ]  \  }}t        |«      |z  –— Œ y ­w©N©Úint©Ú.0ÚnÚws      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>W   s   è ø€ Ò@¡4 1 a”C˜“F˜Q•JÑ@ùó   ‚r   )r	   r   r   r   r   r   r	   r   r   r   r   r   r	   c              3  ó>   K  — | ]  \  }}t        |«      |z  –— Œ y ­wr!   r"   r$   s      r   r(   z#calc_check_digit.<locals>.<genexpr>[   s   è ø€ Ò<™t˜q !”�A“˜•
Ñ<ùr)   )ÚsumÚzipÚstr)r   ÚweightsÚtotals      r   Úcalc_check_digitr0   R   st   € ð ˆb�€}˜ÒØ>ˆÜÑ@¬3¨v°wÓ+?Ô@Ó@ˆÜ�E˜B‘J "Ñ$Ó%Ð%à5€GÜÑ<¤s¨6°7Ó';Ô<Ó<€EÜ��˜‘˜rÑ!Ó"Ð"r   c                óÎ   — t        | «      } t        | «      dk7  r
t        «       ‚t        | «      s
t	        «       ‚| d   dvr
t        «       ‚| d   t        | «      k7  r
t        «       ‚| S )ztCheck if the number is a valid El Salvador NIT number.

    This checks the length, formatting and check digit.
    r   r   )Ú0Ú1Ú9éÿÿÿÿ)r   ÚlenÚInvalidLengthr   ÚInvalidFormatÚInvalidComponentr0   ÚInvalidChecksumr   s    r   Úvalidater;   _   sf   € ô
 �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�FÔÜ‹oÐØˆa�y˜Ñ'ÜÓ Ð Øˆb�zÔ% fÓ-Ò-ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z6Check if the number is a valid El Salvador NIT number.F)Úboolr;   ÚValidationErrorr   s    r   Úis_validr?   p   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   éüÿÿÿr5   )r   Újoinr   s    r   ÚformatrD   x   s9   € ä�V‹_€FØ�8‰8�V˜B˜Q�Z ¨¨" ¨v°b¸¨}¸fÀR¹jÐIÓJÐJr   N)r   r-   Úreturnr-   )r   r-   rE   r=   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r0   r;   r?   rD   © r   r   ú<module>rK      s0   ðñ*)õV #ä ß 'ó	ó
#óó"ôKr   