Ë
    Ã?Æ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[  IRD number (New Zealand Inland Revenue Department (Te Tari TÄ�ke) number).

The IRD number is used by the New Zealand Inland Revenue Department (Te Tari
TÄ�ke in MÄ�ori) to identify businesses and individuals for tax purposes. The
number consists of 8 or 9 digits where the last digit is a check digit.

More information:

* https://www.ird.govt.nz/
* https://www.ird.govt.nz/-/media/Project/IR/PDF/2020RWTNRWTSpecificationDocumentv10.pdf
* https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/New%20Zealand-TIN.pdf

>>> validate('4909185-0')
'49091850'
>>> validate('NZ 49-098-576')
'49098576'
>>> validate('136410133')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('9125568')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> format('49098576')
'49-098-576'
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                ó‚   — t        | d«      j                  «       j                  «       } | j                  d«      r| dd S | S )z1Convert the number to the minimal representation.z -ÚNZé   N)r   ÚupperÚstripÚ
startswith©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/nz/ird.pyÚcompactr   7   s?   € ä�6˜4Ó ×&Ñ&Ó(×.Ñ.Ó0€FØ×Ñ˜ÔØ�a�bˆzÐØ€Mó    c                óâ   — d}d}| j                  d«      } t        d„ t        || «      D «       «       dz  }|dk7  rt        |«      S t        d„ t        || «      D «       «       dz  }t        |«      S )z`Calculate the check digit.

    The number passed should not have the check digit included.
    )é   r	   é   é   é   é   r   r	   )r   r   r   r	   r   r	   r   r   é   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w©N©Úint©Ú.0ÚwÚns      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>H   s   è ø€ ÒA™D˜A˜qˆQ”�Q“�ZÑAùó   ‚é   é
   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­wr   r   r   s      r   r!   z#calc_check_digit.<locals>.<genexpr>K   s   è ø€ ÒC™D˜A˜qˆQ”�Q“�ZÑCùr"   )ÚzfillÚsumÚzipÚstr)r   Úprimary_weightsÚsecondary_weightsÚss       r   Úcalc_check_digitr-   ?   st   € ð
 /€OØ0Ðà�\‰\˜!‹_€FÜ	ÑA¤C¨¸Ó$@ÔAÓ	AÐAÀBÑF€AØˆB‚wÜ�1‹vˆÜ	ÑC¤CÐ(9¸6Ó$BÔCÓ	CÐCÀbÑH€AÜˆq‹6€Mr   c                ó  — t        | «      } t        | «      dvr
t        «       ‚t        | «      s
t	        «       ‚dt        | «      cxk  rdk  st        «       ‚ t        «       ‚| d   t        | dd «      k7  r
t        «       ‚| S )ú*Check if the number is a valid IRD number.)r   é	   i€–˜ i€ÑðéÿÿÿÿN)	r   ÚlenÚInvalidLengthr   ÚInvalidFormatr   ÚInvalidComponentr-   ÚInvalidChecksumr   s    r   Úvalidater7   O   s}   € ä�V‹_€FÜ
ˆ6ƒ{˜&Ñ Ü‹oÐÜ�FÔÜ‹oÐØ”c˜&“kÔ- IÒ-ÜÓ Ð ð .ÜÓ Ð Øˆb�zÔ% f¨S¨b kÓ2Ò2ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)r/   F)Úboolr7   ÚValidationErrorr   s    r   Úis_validr;   ]   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                óR   — t        | «      } dj                  | dd | dd | dd g«      S )z8Reformat the number to the standard presentation format.ú-Niúÿÿÿéýÿÿÿ)r   Újoinr   s    r   Úformatr@   e   s3   € ä�V‹_€FØ�8‰8�V˜C˜R�[ &¨¨B -°¸¸°Ð=Ó>Ð>r   N)r   r)   Úreturnr)   )r   r)   rA   r9   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r-   r7   r;   r@   © r   r   ú<module>rG      s.   ðñ*õ8 #ä ß 'óóó óô?r   