Ë
    Ã?Æid  ã                  ó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
)u…  UBN (Unified Business Number, çµ±ä¸€ç·¨è™Ÿ, Taiwanese tax number).

The Unified Business Number (UBN, çµ±ä¸€ç·¨è™Ÿ) is the number assigned to businesses
within Taiwan for tax (VAT) purposes. The number consists of 8 digits, the
last being a check digit.

More information:

* https://zh.wikipedia.org/wiki/çµ±ä¸€ç·¨è™Ÿ
* https://findbiz.nat.gov.tw/fts/query/QueryBar/queryInit.do?request_locale=en

>>> validate('00501503')
'00501503'
>>> validate('00501502')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('12345')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> format(' 0050150 3 ')
'00501503'
é    )Ú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/tw/ubn.pyÚcompactr   4   s   € ô �˜Ó×$Ñ$Ó&Ð&ó    c                ót   — d}dj                  d„ t        || «      D «       «      } t        d„ | D «       «      dz  S )z'Calculate the checksum over the number.)é   é   r   r   r   r   é   r   Ú c              3  óP   K  — | ]  \  }}t        |t        |«      z  «      –— Œ  y ­w©N)ÚstrÚint)Ú.0ÚwÚns      r   ú	<genexpr>z calc_checksum.<locals>.<genexpr>A   s    è ø€ ÒF©¨¨A”S˜œS ›V™—_ÑFùs   ‚$&c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr   )r   )r   r   s     r   r   z calc_checksum.<locals>.<genexpr>B   s   è ø€ Ò&˜!Œs�1�vÑ&ùs   ‚é
   )ÚjoinÚzipÚsum)r
   Úweightss     r   Úcalc_checksumr!   =   s:   € ð '€GØ�W‰WÑF´°W¸fÓ1EÔFÓF€FÜÑ&˜vÔ&Ó&¨Ñ+Ð+r   c                óÄ   — t        | «      } t        | «      dk7  r
t        «       ‚t        | «      s
t	        «       ‚t        | «      }|dk(  s|dk(  r| d   dk(  s
t        «       ‚| S )zoCheck if the number is a valid Taiwan UBN number.

    This checks the length, formatting and check digit.
    é   r   é	   é   Ú7)r   ÚlenÚInvalidLengthr   ÚInvalidFormatr!   ÚInvalidChecksum)r
   Úchecksums     r   Úvalidater,   E   sa   € ô
 �V‹_€FÜ
ˆ6ƒ{�aÒÜ‹oÐÜ�FÔÜ‹oÐÜ˜VÓ$€HØ˜ŠM˜h¨!šm°°q±	¸SÒ0@ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z1Check if the number is a valid Taiwan UBN number.F)Úboolr,   ÚValidationErrorr	   s    r   Úis_validr0   U   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ó   — t        | «      S )z8Reformat the number to the standard presentation format.)r   r	   s    r   Úformatr2   ]   s   € ä�6‹?Ðr   N)r
   r   Úreturnr   )r
   r   r3   r   )r
   r   r3   r.   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r!   r,   r0   r2   © r   r   ú<module>r9      s.   ðñ*õ2 #ä ß 'ó'ó,óó ôr   