Ë
    Ã?Æ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
)uw  NIT (NÃºmero de IdentificaciÃ³n Tributaria, Guatemala tax number).

The NÃºmero de IdentificaciÃ³n Tributaria (NIT) is an identifier of legal
entities for tax purposes in Guatemala.

The number consists of 2 to 12 characters, where the last one is the check
digit (a digit or the letter K) and the rest are digits. Leading zeroes are
usually omitted. Digits and check digit are usually separated with a hyphen.

More information:

* https://portal.sat.gob.gt/portal/descarga/6524/factura-electronica-fel/25542/fel-reglas-y-validaciones.pdf (page 58)
* https://portal.sat.gob.gt/portal/consulta-cui-nit/

>>> validate('576937-K')
'576937K'
>>> validate('7108-0')
'71080'
>>> validate('8977112-0')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('1234567890123')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> format('39525503')
'3952550-3'
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                óp   — t        | d«      j                  «       j                  «       j                  d«      S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.z -Ú0)r   ÚupperÚstripÚlstrip©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/gt/nit.pyÚcompactr   9   s.   € ô �˜Ó×$Ñ$Ó&×,Ñ,Ó.×5Ñ5°cÓ:Ð:ó    c                óx   — t        d„ t        t        | «      d«      D «       «       dz  }|dk(  rdS t        |«      S )zZCalculate the check digit. The number passed should not have the
    check digit included.c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w)N)Úint)Ú.0ÚiÚns      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>B   s   è ø€ ÒC™D˜A˜qˆQ”�Q“�ZÑCùs   ‚é   é   é
   ÚK)ÚsumÚ	enumerateÚreversedÚstr)r   Úcs     r   Úcalc_check_digitr!   ?   s=   € ô 
ÑC¤I¬h°vÓ.>ÀÓ$BÔCÓ	CÐCÀbÑH€AØ�r’'ˆ3Ð%œs 1›vÐ%r   c                ó  — t        | «      } t        | «      dk  st        | «      dkD  r
t        «       ‚t        | dd «      s
t	        «       ‚| d   dk7  rt        | d   «      s
t	        «       ‚| d   t        | dd «      k7  r
t        «       ‚| S )zrCheck if the number is a valid Guatemala NIT number.

    This checks the length, formatting and check digit.
    r   é   Néÿÿÿÿr   )r   ÚlenÚInvalidLengthr   ÚInvalidFormatr!   ÚInvalidChecksumr   s    r   Úvalidater)   F   s†   € ô
 �V‹_€FÜ
ˆ6ƒ{�Q‚œ#˜f›+¨Ò*Ü‹oÐÜ�F˜3˜B�KÔ Ü‹oÐØˆb�z�SÒ¤¨&°©*Ô!5Ü‹oÐØˆb�zÔ% f¨S¨b kÓ2Ò2ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z4Check if the number is a valid Guatemala NIT number.F)Úboolr)   ÚValidationErrorr   s    r   Úis_validr-   W   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                óJ   — t        | «      } dj                  | dd | d   g«      S )z8Reformat the number to the standard presentation format.ú-Nr$   )r   Újoinr   s    r   Úformatr1   _   s)   € ä�V‹_€FØ�8‰8�V˜C˜R�[ &¨¡*Ð-Ó.Ð.r   N)r   r   Úreturnr   )r   r   r2   r+   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r!   r)   r-   r1   © r   r   ú<module>r8      s.   ðñ*õ< #ä ß 'ó;ó&óó"ô/r   