Ë
    Ã?Æiy  ã                  óV   — d Z ddl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
)u0  MST (MÃ£ sá»‘ thuáº¿, Vietnam tax number).

This number consists of 10 digits. Branches have a 13 digit number,
where the first ten digits are the same as the parent company's.

The first two digits is the province code where the business was
established. If an enterprise relocates its head office from one
province to another, the MST will remain unchanged.

The following seven digits are a sequential number from 0000001 to
9999999.

The tenth digit is the check digit for the first nine digits, which is
used to verify the number was correctly typed.

The last optional three digits are a sequence from 001 to 999
indicating branches of the enterprise. These digits are usually
separated from the first ten digits using a dash (-)

More information:

* https://vi.wikipedia.org/wiki/Thuáº¿_Viá»‡t_Nam#MÃ£_sá»‘_thuáº¿_(MST)_cá»§a_doanh_nghiá»‡p
* https://easyinvoice.vn/ma-so-thue/
* https://ub.com.vn/threads/huong-dan-tra-cuu-ma-so-thue-doanh-nghiep-moi-nhat.261393/

>>> validate('0100233488')
'0100233488'
>>> validate('0314409058-002')
'0314409058002'
>>> validate('12345')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> validate('0100233480')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('01.00.112.437')
'0100112437'
>>> format('0312 68 78 78 - 001')
'0312687878-001'
é    )Úannotations)Ú*)Ú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    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/vn/mst.pyÚcompactr   F   s   € ô �˜Ó×%Ñ%Ó'Ð'ó    c                ó`   — d}t        d„ t        || «      D «       «      }t        d|dz  z
  «      S )zCalculate the check digit.)	é   é   é   é   é   é   é   é   é   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w)N)Úint)Ú.0ÚwÚns      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>R   s   è ø€ Ò<™t˜q !�”C˜“F•
Ñ<ùs   ‚é
   é   )ÚsumÚzipÚstr)r
   ÚweightsÚtotals      r   Úcalc_check_digitr%   O   s2   € à/€GÜÑ<¤s¨7°FÓ';Ô<Ó<€EÜˆr�U˜R‘ZÑ Ó!Ð!r   c                ó  — t        | «      } t        | «      dvr
t        «       ‚t        | «      s
t	        «       ‚| dd dk(  r
t        «       ‚t        | «      dk(  r| dd dk(  r
t        «       ‚| d   t        | «      k7  r
t        «       ‚| S )	zpCheck if the number is a valid Vietnam MST number.

    This checks the length, formatting and check digit.
    )r   r   é   é	   Ú0000000r   éýÿÿÿNÚ000)r   ÚlenÚInvalidLengthr   ÚInvalidFormatÚInvalidComponentr%   ÚInvalidChecksumr	   s    r   Úvalidater1   V   sŠ   € ô
 �V‹_€FÜ
ˆ6ƒ{˜(Ñ"Ü‹oÐÜ�FÔÜ‹oÐØˆa�€{�iÒÜÓ Ð Ü
ˆ6ƒ{�bÒ˜V B C˜[¨EÒ1ÜÓ Ð Øˆa�yÔ$ VÓ,Ò,ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z2Check if the number is a valid Vietnam MST number.F)Úboolr1   ÚValidationErrorr	   s    r   Úis_validr5   i   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ój   — t        | «      } t        | «      dk(  r| S dj                  | dd | dd g«      S )z8Reformat the number to the standard presentation format.r   ú-N)r   r,   Újoinr	   s    r   Úformatr9   q   s;   € ä�V‹_€FÜ˜“[ BÒ&ˆ6ÐP¨C¯H©H°f¸S¸b°kÀ6È"È#À;Ð5OÓ,PÐPr   N)r
   r"   Úreturnr"   )r
   r"   r:   r3   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r%   r1   r5   r9   © r   r   ú<module>r@      s0   ðñ*)õV #ä ß 'ó(ó"óó&ôQr   