Ë
    Ã?Æiç  ã                  ób   — d Z ddlmZ ddlZddl­ ddlmZmZ dZdZ	dZ
dd	„Zdd
„Zdd„Zdd„Zy)uŽ  MF (Matricule Fiscal, Tunisia tax number).

The MF consists of 4 parts: the "identifiant fiscal", the "code TVA", the "code
catÃ©gorie" and the "numÃ©ro d'etablissement secondaire".

The "identifiant fiscal" consists of 2 parts: the "identifiant unique" and the
"clef de contrÃ´le". The "identifiant unique" is composed of 7 digits. The "clef
de contrÃ´le" is a letter, excluding "I", "O" and "U" because of their
similarity to "1", "0" and "4".

The "code TVA" is a letter that tells which VAT regime is being used. The valid
values are "A", "P", "B", "D" and "N".

The "code catÃ©gorie" is a letter that tells the category the contributor
belongs to. The valid values are "M", "P", "C", "N" and "E".

The "numÃ©ro d'etablissement secondaire" consists of 3 digits. It is usually
"000", but it can be "001", "002"... depending on the branches. If it is not
"000" then "code catÃ©gorie" must be "E".

More information:

* https://futurexpert.tn/2019/10/22/structure-et-utilite-du-matricule-fiscal/
* https://www.registre-entreprises.tn/

>>> validate('1234567/M/A/E/001')
'1234567MAE001'
>>> validate('1282182 W')
'1282182W'
>>> validate('121J')
'0000121J'
>>> validate('1219773U')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('1234567/M/A/X/000')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> format('121J')
'0000121/J'
>>> format('1496298 T P N 000')
'1496298/T/P/N/000'
é    )ÚannotationsN)Ú*)ÚcleanÚisdigits)ÚAÚBÚCÚDÚEÚFÚGÚHÚJÚKÚLÚMÚNÚPÚQÚRÚSÚTÚVÚWÚXÚYÚZ)r   r   r   r
   r   )r   r   r	   r   r   c                óÎ   — t        | d«      j                  «       } t        j                  d| «      }|r2|j	                  d«      j                  d«      |j	                  d«      z   } | S )z�Convert the number to the minimal representation.

    This strips the number of any valid separators, removes surrounding
    whitespace.
    z /.-z ^(?P<serial>[0-9]+)(?P<rest>.*)$Úserialé   Úrest)r   ÚupperÚreÚmatchÚgroupÚzfill)Únumberr$   s     úS/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/tn/mf.pyÚcompactr)   Q   sY   € ô �6˜6Ó"×(Ñ(Ó*€Fä�H‰HÐ8¸&ÓA€EÙØ—‘˜XÓ&×,Ñ,¨QÓ/°%·+±+¸fÓ2EÑEˆØ€Mó    c                ó|  — t        | «      } t        | «      dvr
t        «       ‚t        | dd «      s
t	        «       ‚| d   t
        vr
t	        «       ‚t        | «      dk(  r| S | d   t        vr
t	        «       ‚| d   t        vr
t	        «       ‚t        | dd «      s
t	        «       ‚| dd dk7  r| d   dk7  r
t	        «       ‚| S )	zbCheck if the number is a valid Tunisia MF number.

    This checks the length and formatting.
    )é   é   Nr    r,   é	   é
   Ú000r   )r)   ÚlenÚInvalidLengthr   ÚInvalidFormatÚ_VALID_CONTROL_KEYSÚ_VALID_TVA_CODESÚ_VALID_CATEGORY_CODES©r'   s    r(   Úvalidater8   _   sÃ   € ô
 �V‹_€FÜ
ˆ6ƒ{˜'Ñ!Ü‹oÐÜ�F˜2˜A�JÔÜ‹oÐØˆa�yÔ+Ñ+Ü‹oÐÜ
ˆ6ƒ{�aÒØˆØˆa�yÔ(Ñ(Ü‹oÐØˆa�yÔ-Ñ-Ü‹oÐÜ�F˜2˜3�KÔ Ü‹oÐØˆbˆc€{�eÒ  q¡	¨SÒ 0Ü‹oÐØ€Mr*   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z1Check if the number is a valid Tunisia MF number.F)Úboolr8   ÚValidationErrorr7   s    r(   Úis_validr<   x   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c           	     ó°   — t        | «      }t        |«      dk(  rdj                  |dd |d   g«      S dj                  |dd |d   |d   |d   |dd g«      S )z8Reformat the number to the standard presentation format.r,   ú/Nr    r.   r/   )r)   r1   Újoin)r'   Úresults     r(   ÚformatrA   €   sg   € ä�V‹_€FÜ
ˆ6ƒ{�aÒØ�x‰x˜  ˜ V¨A¡YÐ/Ó0Ð0Ø�8‰8�V˜B˜Q�Z ¨¡¨F°1©I°v¸a±yÀ&ÈÈÀ+ÐNÓOÐOr*   )r'   ÚstrÚreturnrB   )r'   rB   rC   r:   )Ú__doc__Ú
__future__r   r#   Ústdnum.exceptionsÚstdnum.utilr   r   r4   r5   r6   r)   r8   r<   rA   © r*   r(   ú<module>rI      sD   ðñ*+õZ #ã 	ä ß 'ðÐ ð -Ð Ø1Ð óóó2ôPr*   