Ë
    Ã?Æi=  ã                  óf   — d Z ddlmZ ddlmZ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  VAT (Ð˜Ð´ÐµÐ½Ñ‚Ð¸Ñ„Ð¸ÐºÐ°Ñ†Ð¸Ð¾Ð½ÐµÐ½ Ð½Ð¾Ð¼ÐµÑ€ Ð¿Ð¾ Ð”Ð”Ð¡, Bulgarian VAT number).

The Bulgarian VAT (Ð”Ð°Ð½ÑŠÐº Ð²ÑŠÑ€Ñ…Ñƒ Ð´Ð¾Ð±Ð°Ð²ÐµÐ½Ð°Ñ‚Ð° Ñ�Ñ‚Ð¾Ð¹Ð½Ð¾Ñ�Ñ‚) number is either 9
(for legal entities) or 10 digits (for physical persons, foreigners and
others) long. Each type of number has its own check digit algorithm.

>>> compact('BG 175 074 752')
'175074752'
>>> validate('175074752')
'175074752'
>>> validate('175074751')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
é    )Úannotations)ÚegnÚpnf)Ú*)ÚcleanÚisdigitsc                ó‚   — t        | d«      j                  «       j                  «       } | j                  d«      r| dd } | S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.z -.ÚBGé   N)r   ÚupperÚstripÚ
startswith©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/bg/vat.pyÚcompactr   ,   s@   € ô �6˜5Ó!×'Ñ'Ó)×/Ñ/Ó1€FØ×Ñ˜ÔØ˜˜�ˆØ€Mó    c                ó    — t        d„ t        | «      D «       «      dz  }|dk(  rt        d„ t        | «      D «       «      dz  }t        |dz  «      S )zmCalculate the check digit for legal entities. The number passed
    should not have the check digit included.c              3  óD   K  — | ]  \  }}|d z   t        |«      z  –— Œ y­w)é   N©Úint©Ú.0ÚiÚns      r   ú	<genexpr>z)calc_check_digit_legal.<locals>.<genexpr>8   s!   è ø€ Ò?¡T Q¨��Q‘œ#˜a›&Õ Ñ?ùó   ‚ é   é
   c              3  óD   K  — | ]  \  }}|d z   t        |«      z  –— Œ y­w)é   Nr   r   s      r   r   z)calc_check_digit_legal.<locals>.<genexpr>:   s!   è ø€ ÒC©¨¨A�Q˜‘Uœc !›fÕ$ÑCùr   )ÚsumÚ	enumerateÚstr)r   Úchecks     r   Úcalc_check_digit_legalr'   5   sM   € ô Ñ?¬Y°vÓ->Ô?Ó?À"ÑD€EØ�‚{ÜÑC´¸6Ó1BÔCÓCÀbÑHˆÜˆu�r‰z‹?Ðr   c           
     ó\   — d}t        dt        d„ t        || «      D «       «      z
  dz  «      S )zeCalculate the check digit for others. The number passed should not
    have the check digit included.)	é   r"   r   é   é   é   r)   r"   r   r   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w)Nr   )r   Úwr   s      r   r   z)calc_check_digit_other.<locals>.<genexpr>B   s   è ø€ ÒE©¨¨1˜œS ›V�ÑEùs   ‚)r%   r#   Úzip)r   Úweightss     r   Úcalc_check_digit_otherr1   >   s0   € ð *€GÜ�”SÑE´°G¸VÓ0DÔEÓEÑEÈÑKÓLÐLr   c                ób  — t        | «      } t        | «      s
t        «       ‚t        | «      dk(  r | d   t	        | dd «      k7  r
t        «       ‚| S t        | «      dk(  rJt        j                  | «      s3t        j                  | «      s| d   t        | dd «      k7  r
t        «       ‚| S t        «       ‚)zbCheck if the number is a valid VAT number. This checks the length,
    formatting and check digit.é	   éÿÿÿÿNr    )r   r   ÚInvalidFormatÚlenr'   ÚInvalidChecksumr   Úis_validr   r1   ÚInvalidLengthr   s    r   Úvalidater:   E   s¨   € ô �V‹_€FÜ�FÔÜ‹oÐÜ
ˆ6ƒ{�aÒà�"‰:Ô/°°s¸°Ó<Ò<Ü!Ó#Ð#ð €Mô 
ˆV‹˜Ò	ä�|‰|˜FÔ#¬C¯L©L¸Ô,@Ø�r‘
Ô4°V¸C¸R°[ÓAÒAÜ!Ó#Ð#ð €Mô ‹oÐr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z*Check if the number is a valid VAT number.F)Úboolr:   ÚValidationErrorr   s    r   r8   r8   Y   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"N)r   r%   Úreturnr%   )r   r%   r>   r<   )Ú__doc__Ú
__future__r   Ú	stdnum.bgr   r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r'   r1   r:   r8   © r   r   ú<module>rE      s2   ðñ*õ  #ç Ü ß 'óóóMóô(r   