Ë
    Ã?ÆiÄ  ã                  óZ   — d Z ddlmZ ddl­ ddlmZmZ dZdd„Zdd„Z	dd„Z
dd	„Zdd
„Zy)u�  USCC (Unified Social Credit Code, ç»Ÿä¸€ç¤¾ä¼šä¿¡ç”¨ä»£ç �, China tax number).

This number consists of 18 digits or uppercase English letters (excluding the
letters I, O, Z, S, V). The number is comprised of several parts:

* Digit 1 represents the registering authority,
* Digit 2 represents the registered entity type,
* Digits 3 through 8 represent the registering region code,
* Digits 9 through 17 represent the organisation code,
* Digit 18 is a check digit (either a number or letter).

The registering authority digit most often is a 9, which represents the State
Administration for Industry and Commerce (SAIC) as the registering authority.

The registered entity type indicates the type of business (or entity). The
most common entity types in China are:

* Wholly Foreign-Owned Enterprises (WFOE): å¤–å•†ç‹¬èµ„ä¼�ä¸š
* Joint Ventures (JV): å�ˆèµ„
* Representative Office: ä»£è¡¨å¤„
* State-Owned Enterprise (SOE): å›½æœ‰ä¼�ä¸š
* Private Enterprise: æ°‘è�¥ä¼�ä¸š
* Individually-Owned: ä¸ªä½“æˆ·

The registering region code, sometimes referred to as the "administrative
division code", is a string of six numbers that indicates where the company
is registered. It roughly follows the organisation of the official Chinese
regions.

The organisation code comes directly from the China Organization Code
certificate, an alternative document to the China Business License. It can
contain letters or digits.

More information:

* https://zh.wikipedia.org/wiki/ç»Ÿä¸€ç¤¾ä¼šä¿¡ç”¨ä»£ç �
* https://zh.wikipedia.org/wiki/æ ¡éªŒç �
* https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/China-TIN.pdf

>>> validate('91110000600037341L')
'91110000600037341L'
>>> validate('A1110000600037341L')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('12345')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> format('9 1 110000 600037341L')
'91110000600037341L'
é    )Úannotations)Ú*)ÚcleanÚisdigitsÚ0123456789ABCDEFGHJKLMNPQRTUWXYc                óR   — t        | d«      j                  «       j                  «       S )z’Convert the number to the minimal representation.

    This strips the number of any valid separators and removes surrounding
    whitespace.
    z -)r   ÚupperÚstrip©Únumbers    úU/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/cn/uscc.pyÚcompactr   S   s#   € ô �˜Ó×$Ñ$Ó&×,Ñ,Ó.Ð.ó    c                ór   — d}t        | «      } t        d„ t        | |«      D «       «      }t        d|z
  dz     S )z)Calculate the check digit for the number.)é   é   é	   é   é   é   é   é   é   é   é   é   é   é   é
   é   é   c              3  óR   K  — | ]  \  }}t         j                  |«      |z  –— Œ! y ­w©N)Ú	_alphabetÚindex)Ú.0ÚnÚws      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>`   s"   è ø€ ÒH©4¨1¨a”	—‘ Ó" QÕ&ÑHùs   ‚%'é   )r   ÚsumÚzipr$   )r   ÚweightsÚtotals      r   Úcalc_check_digitr/   \   s;   € àN€GÜ�V‹_€FÜÑH´3°v¸wÓ3GÔHÓH€EÜ�b˜5‘j BÑ&Ñ'Ð'r   c                óð   — t        | «      } t        | «      dk7  r
t        «       ‚t        | dd «      s
t	        «       ‚t        d„ | dd D «       «      r
t	        «       ‚| d   t        | «      k7  r
t        «       ‚| S )zbCheck if the number is a valid USCC.

    This checks the length, formatting and check digit.
    é   Nr   c              3  ó,   K  — | ]  }|t         v–— Œ y ­wr#   )r$   )r&   Úcs     r   r)   zvalidate.<locals>.<genexpr>n   s   è ø€ Ò
2 !ˆ1”IÔÑ
2ùs   ‚éÿÿÿÿ)r   ÚlenÚInvalidLengthr   ÚInvalidFormatÚanyr/   ÚInvalidChecksumr   s    r   Úvalidater:   d   ss   € ô
 �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�F˜2˜A�JÔÜ‹oÐÜ
Ñ
2 v¨a¨b zÔ
2Ô2Ü‹oÐØˆb�zÔ% fÓ-Ò-ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z$Check if the number is a valid USCC.F)Úboolr:   ÚValidationErrorr   s    r   Úis_validr>   u   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ó   — t        | «      S )z8Reformat the number to the standard presentation format.)r   r   s    r   Úformatr@   }   s   € ä�6‹?Ðr   N)r   ÚstrÚreturnrA   )r   rA   rB   r<   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r$   r   r/   r:   r>   r@   © r   r   ú<module>rH      s6   ðñ*3õj #ä ß 'ð .€	ó/ó(óó"ôr   