Ë
    Ã?Æi·  ã                  óf   — d Z ddlmZ ddl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dd„Zy)uõ  PVN (PievienotÄ�s vÄ“rtÄ«bas nodokÄ¼a, Latvian VAT number).

The PVN is a 11-digit number that can either be a reference to a legal
entity (in which case the first digit > 3) or a natural person (in which
case it should be the same as the personal code (personas kods)). Personal
codes start "32". Older personal codes start with 6 digits to denote the birth
date in the form ddmmyy.

More information:

* https://en.wikipedia.org/wiki/National_identification_number#Latvia

>>> validate('LV 4000 3521 600')
'40003521600'
>>> validate('40003521601')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('161175-19997')  # personal code, old format
'16117519997'
>>> validate('161375-19997')  # invalid date
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('328673-00679')  # personal code, new format
'32867300679'
>>> validate('328673-00677')  # personal code, new format
Traceback (most recent call last):
    ...
InvalidChecksum: ...
é    )ÚannotationsN)Ú*)Ú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 -ÚLVé   N)r   ÚupperÚstripÚ
startswith©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/lv/pvn.pyÚcompactr   B   s@   € ô �6˜4Ó ×&Ñ&Ó(×.Ñ.Ó0€FØ×Ñ˜ÔØ˜˜�ˆØ€Mó    c                óD   — d}t        d„ t        || «      D «       «      dz  S )z*Calculate the checksum for legal entities.)é	   é   é   é   é   é
   r	   é   é   é   r   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w©N©Úint©Ú.0ÚwÚns      r   ú	<genexpr>zchecksum.<locals>.<genexpr>N   s   è ø€ Ò;™d˜a ˆq”3�q“6�zÑ;ùó   ‚é   )ÚsumÚzip)r   Úweightss     r   Úchecksumr*   K   s$   € à0€GÜÑ;¤c¨'°6Ó&:Ô;Ó;¸bÑ@Ð@r   c                óf   — d}dt        d„ t        || «      D «       «      z   }t        |dz  dz  «      S )zmCalculate the check digit for personal codes. 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r   r   r    s      r   r$   z(calc_check_digit_pers.<locals>.<genexpr>V   s   è ø€ Ò@¡4 1 a�Aœ˜A›•JÑ@ùr%   r&   r   )r'   r(   Ústr)r   r)   Úchecks      r   Úcalc_check_digit_persr/   Q   s8   € ð .€GØ”Ñ@¬3¨w¸Ó+?Ô@Ó@Ñ@€EÜˆu�r‰z˜B‰ÓÐr   c                óø   — t        | «      } t        | dd «      }t        | dd «      }t        | dd «      }|dt        | d   «      dz  z   z  }	 t        j                  |||«      S # t        $ r t        «       ‚w xY w)z?Split the date parts from the number and return the birth date.r   r	   r   r   i  éd   )r   r   ÚdatetimeÚdateÚ
ValueErrorÚInvalidComponent)r   ÚdayÚmonthÚyears       r   Úget_birth_dater9   Z   s‡   € ä�V‹_€FÜ
ˆf�Q�qˆkÓ
€CÜ��q˜�Ó€EÜˆv�a˜ˆ{Ó€DØˆD”3�v˜a‘y“> CÑ'Ñ'Ñ'€Dð!Ü�}‰}˜T 5¨#Ó.Ð.øÜò !ÜÓ Ð ð!ús   ÁA% Á%A9c                ón  — t        | «      } t        | «      s
t        «       ‚t        | «      dk7  r
t	        «       ‚| d   dkD  rt        | «      dk7  r
t        «       ‚| S | j                  d«      r t        | dd «      | d   k7  r
t        «       ‚| S t        | «       t        | dd «      | d   k7  r
t        «       ‚| S )zbCheck if the number is a valid VAT number. This checks the length,
    formatting and check digit.r&   r   Ú3r   Ú32Néÿÿÿÿ)
r   r   ÚInvalidFormatÚlenÚInvalidLengthr*   ÚInvalidChecksumr   r/   r9   r   s    r   ÚvalidaterB   g   s¿   € ô �V‹_€FÜ�FÔÜ‹oÐÜ
ˆ6ƒ{�bÒÜ‹oÐØˆa�y�3‚ä�FÓ˜qÒ Ü!Ó#Ð#ð €Mð 
×	Ñ	˜4Ô	 ä  ¨¨ Ó-°¸±Ò;Ü!Ó#Ð#ð €Mô	 	�vÔä  ¨¨ Ó-°¸±Ò;Ü!Ó#Ð#Ø€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z*Check if the number is a valid VAT number.F)ÚboolrB   ÚValidationErrorr   s    r   Úis_validrF   €   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡")r   r-   Úreturnr-   )r   r-   rG   r   )r   r-   rG   zdatetime.date)r   r-   rG   rD   )Ú__doc__Ú
__future__r   r2   Ústdnum.exceptionsÚstdnum.utilr   r   r   r*   r/   r9   rB   rF   © r   r   ú<module>rM      s8   ðñ*õ@ #ã ä ß 'óóAó ó
!óô2r   