Ë
    Ã?ÆiW  ã                  óˆ   — d Z ddlmZ ddlZddlZddl­ ddlmZ  eg d¢«      Z	dZ
dd„Zdd	„Zdd
„Zddd„Zddd„Zddd„Zy)aæ  RFC (Registro Federal de Contribuyentes, Mexican tax number).

This number is used to identify individuals and companies for tax purposes.

The company number is 12 digits where the first 3 letters or digits are
derived from the name of the company, the following 6 contain the date of
incorporation, followed by 3 check digits.

Personal numbers consist of 13 digits where the first 4 characters from the
person's name, followed by their birth date and 3 check digits.

The first two check digits are calculated based on the person's or company's
full name. The last check digit is calculated over all the preceding digits
in the number. However, it seems a lot of numbers (estimated at around 1.5%
of all numbers) are in use with invalid check digits so this test is disabled
by default.

More information:

* https://www.infomex.org.mx/jspsi/documentos/2005/seguimiento/06101/0610100162005_065.doc
* https://es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico)

An online validation service is available at:

* https://portalsat.plataforma.sat.gob.mx/ConsultaRFC/

>>> validate('GODE 561231 GR8')  # personal number
'GODE561231GR8'
>>> validate('MAB-930714-8T4')  # company number
'MAB9307148T4'
>>> validate('COMG-600703')  # personal number without serial
'COMG600703'
>>> validate('VACE-460910-SX6')
'VACE460910SX6'
>>> validate('VACE-460910-SX6', validate_check_digits=True)
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('GODE561231GR8')
'GODE 561231 GR8'
é    )ÚannotationsN)Ú*)Úclean))ÚBUEIÚBUEYÚCACAÚCACOÚCAGAÚCAGOÚCAKAÚCAKOÚCOGEÚCOJAÚCOJEÚCOJIÚCOJOÚCULOÚFETOÚGUEYÚJOTOÚKACAÚKACOÚKAGAÚKAGOÚKAKAÚKOGEÚKOJOÚKULOÚMAMEÚMAMOÚMEARÚMEASÚMEONÚMIONÚMOCOÚMULAÚPEDAÚPEDOÚPENEÚPUTAÚPUTOÚQULOÚRATAÚRUINu(   0123456789ABCDEFGHIJKLMN&OPQRSTUVWXYZ Ã‘c                óR   — t        | d«      j                  «       j                  «       S )zmConvert the number to the minimal representation. This strips
    surrounding whitespace and separation dash.z-_ )r   ÚupperÚstrip)Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/mx/rfc.pyÚcompactr4   V   s#   € ô �˜Ó×%Ñ%Ó'×-Ñ-Ó/Ð/ó    c                óº   — t        | dd «      }t        | dd «      }t        | dd «      }	 t        j                  |dz   ||«      S # t        $ r t	        «       ‚w xY w)zrConvert the part of the number that represents a date into a
    datetime. Note that the century may be incorrect.r   é   é   é   iÐ  )ÚintÚdatetimeÚdateÚ
ValueErrorÚInvalidComponent)r2   ÚyearÚmonthÚdays       r3   Ú	_get_daterB   \   sh   € ô ˆv�a˜ˆ{Ó€DÜ��q˜�Ó€EÜ
ˆf�Q�qˆkÓ
€Cð!Ü�}‰}˜T D™[¨%°Ó5Ð5øÜò !ÜÓ Ð ð!ús   ¬A ÁAc                óf   — d| z   dd } t        d„ t        | «      D «       «      }t        d|z
  dz     S )zZCalculate the check digit. The number passed should not have the
    check digit included.z   iôÿÿÿNc              3  óX   K  — | ]"  \  }}t         j                  |«      d |z
  z  –— Œ$ y­w)é   N)Ú	_alphabetÚindex)Ú.0ÚiÚns      r3   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>l   s&   è ø€ ÒL±$°!°Q”	—‘ Ó" b¨1¡fÕ-ÑLùs   ‚(*é   )ÚsumÚ	enumeraterF   )r2   Úchecks     r3   Úcalc_check_digitrP   h   s=   € ð �f‰n˜c˜dÐ#€FÜÑL¼)ÀFÓ:KÔLÓL€EÜ�b˜5‘j BÑ&Ñ'Ð'r5   c                óî  — t        | «      } t        | «      dv rDt        j                  d| «      s
t	        «       ‚| dd t
        v r
t        «       ‚t        | dd «       nGt        | «      dk(  r/t        j                  d| «      s
t	        «       ‚t        | dd	 «       n
t        «       ‚|rOt        | «      dk\  rAt        j                  d
| dd «      s
t        «       ‚| d   t        | dd «      k7  r
t        «       ‚| S )z#Check if the number is a valid RFC.)é
   rE   u"   ^[A-Z&Ã‘]{4}[0-9]{6}[0-9A-Z]{0,3}$Nr8   rR   é   u    ^[A-Z&Ã‘]{3}[0-9]{6}[0-9A-Z]{3}$é   é	   z^[1-9A-V][1-9A-Z][0-9A]$éýÿÿÿéÿÿÿÿ)r4   ÚlenÚreÚmatchÚInvalidFormatÚ_name_blacklistr>   rB   ÚInvalidLengthrP   ÚInvalidChecksum©r2   Úvalidate_check_digitss     r3   Úvalidatera   p   sÞ   € ä�V‹_€FÜ
ˆ6ƒ{�hÑä�x‰xÐ<¸fÔEÜ“/Ð!Ø�"�1ˆ:œÑ(Ü"Ó$Ð$Ü�&˜˜2�,ÕÜ	ˆV‹˜Ò	ä�x‰xÐ:¸FÔCÜ“/Ð!Ü�&˜˜1�+Õä‹oÐÙ¤ V£°Ò!2Ü�x‰xÐ2°F¸2¸3°KÔ@Ü"Ó$Ð$Ø�"‰:Ô)¨&°°"¨+Ó6Ò6Ü!Ó#Ð#Ø€Mr5   c                óL   — 	 t        t        | |«      «      S # t        $ r Y yw xY w)z,Check if the number provided is a valid RFC.F)Úboolra   ÚValidationErrorr_   s     r3   Úis_validre   ‰   s,   € ðÜ”H˜VÐ%:Ó;Ó<Ð<øÜò Ùðús   ‚ —	#¢#c                óä   — t        | «      } t        | «      dk(  r,|j                  | dd | dd | dd f«      j                  |«      S |j                  | dd | dd | dd f«      j                  |«      S )z8Reformat the number to the standard presentation format.rS   NrT   rU   r8   rR   )r4   rX   Újoinr1   )r2   Ú	separators     r3   Úformatri   ‘   s‹   € ä�V‹_€FÜ
ˆ6ƒ{�bÒØ�~‰~Ø�2�AˆJ˜˜q ˜ V¨A¨B Zð1ó 2ß27±%¸	Ó2Bð	Cà�>‰>Øˆr�ˆ
�F˜1˜R�L &¨¨ +ð/ó 0ß05±°iÓ0@ðAr5   )r2   ÚstrÚreturnrj   )r2   rj   rk   zdatetime.date)F)r2   rj   r`   rc   rk   rj   )r2   rj   r`   rc   rk   rc   )ú )r2   rj   rh   rj   rk   rj   )Ú__doc__Ú
__future__r   r;   rY   Ústdnum.exceptionsÚstdnum.utilr   Úsetr\   rF   r4   rB   rP   ra   re   ri   © r5   r3   ú<module>rs      sS   ðñ*(õT #ã Û 	ä Ý ñ ò ó €ð 7€	ó0ó	!ó(ôô2õAr5   