Ë
    Ã?Æib  ã                  óx   — d Z ddlmZ ddlmZ ddl­ ddlmZ ddlm	Z	m
Z
 dd„Zdd„Zdd	„Zdd
„Zdd„Zddd„Zy)u  SIRET (a French company establishment identification number).

The SIRET (SystÃ¨me d'Identification du RÃ©pertoire des ETablissements)
is a 14 digit number used to identify French companies' establishments
and facilities. The Luhn checksum is used to validate the numbers (except
for La Poste).

More information:

* https://fr.wikipedia.org/wiki/SystÃ¨me_d'identification_du_rÃ©pertoire_des_Ã©tablissements

>>> validate('73282932000074')
'73282932000074'
>>> validate('73282932000079')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> to_siren('732 829 320 00074')
'732 829 320'
>>> to_siren('73282932000074')
'732829320'
>>> to_tva('732 829 320 00074')
'44 732 829 320'
>>> to_tva('73282932000074')
'44732829320'
>>> format('73282932000074')
'732 829 320 00074'
é    )Úannotations)Úluhn)Ú*)Úsiren)Ú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.z .)r   Ústrip©Únumbers    úV/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/fr/siret.pyÚcompactr   :   s   € ô �˜Ó×$Ñ$Ó&Ð&ó    c                óN  — t        | «      } t        | «      s
t        «       ‚t        | «      dk7  r
t	        «       ‚| j                  d«      r.| dk7  r)t        t        t        | «      «      dz  dk7  rt        «       ‚t        j                  | «       t        j                  | dd «       | S )z]Check if the number is a valid SIRET. This checks the length,
    formatting and check digit.é   Ú	356000000Ú35600000000048é   r   Né	   )r   r   ÚInvalidFormatÚlenÚInvalidLengthÚ
startswithÚsumÚmapÚintÚInvalidChecksumr   Úvalidater   r   s    r   r   r   @   sŽ   € ô �V‹_€FÜ�FÔÜ‹oÐÜ
ˆ6ƒ{�bÒÜ‹oÐð ×Ñ˜Ô%¨&Ð4DÒ*DÜŒs”3˜ÓÓ  1Ñ$¨Ò)Ü!Ó#Ð#ä�‰�fÔÜ	‡N�N�6˜"˜1�:ÔØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z%Check if the number is a valid SIRET.F)Úboolr   ÚValidationErrorr   s    r   Úis_validr"   S   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                óŠ   — g }d}| D ]*  }|dk  sŒ	|j                  |«       t        |«      sŒ&|dz  }Œ, dj                  |«      S )zqConvert the SIRET number to a SIREN number.

    The SIREN number is the 9 first digits of the SIRET number.
    r   r   é   Ú )Úappendr   Újoin)r   Ú_sirenÚdigit_countÚchars       r   Úto_sirenr+   [   sQ   € ð
 €FØ€KØò !ˆØ˜‹?Ø�M‰M˜$ÔÜ˜�~Ø˜qÑ ‘ð	!ð
 �7‰7�6‹?Ðr   c                ó>   — t        j                  t        | «      «      S )z”Convert the SIRET number to a TVA number.

    The TVA number is built from the SIREN number, prepended by two extra
    error checking digits.
    )r   Úto_tvar+   r   s    r   r-   r-   j   s   € ô �<‰<œ Ó(Ó)Ð)r   c                óZ   — t        | «      } |j                  | dd | dd | dd | dd f«      S )z8Reformat the number to the standard presentation format.r   é   é   r   N)r   r'   )r   Ú	separators     r   Úformatr2   s   s;   € ä�V‹_€FØ�>‰>˜6 ! A˜;¨¨q°¨°V¸A¸a°[À&ÈÈÀ*ÐMÓNÐNr   N)r   ÚstrÚreturnr3   )r   r3   r4   r    )ú )r   r3   r1   r3   r4   r3   )Ú__doc__Ú
__future__r   Ústdnumr   Ústdnum.exceptionsÚ	stdnum.frr   Ústdnum.utilr   r   r   r   r"   r+   r-   r2   © r   r   ú<module>r=      s:   ðñ*õ: #å Ü Ý ß 'ó'óó&óó*õOr   