Ë
    Ã?Æi)  ã                  óŽ   — d Z ddlmZ ddl­ ddlmZmZmZ dZerddl	m
Z
 dd„Zdd„Zdd	„Zdd
„Zdd„ZdZ	 	 d	 	 	 	 	 	 	 dd„Zy)aN  UID (Unternehmens-Identifikationsnummer, Swiss business identifier).

The Swiss UID is used to uniquely identify businesses for taxation purposes.
The number consists of a fixed "CHE" prefix, followed by 9 digits that are
protected with a simple checksum.

This module only supports the "new" format that was introduced in 2011 which
completely replaced the "old" 6-digit format in 2014.
Stripped numbers without the CHE prefix are allowed and validated,
but are returned with the prefix prepended.

More information:

* https://www.uid.admin.ch/
* https://de.wikipedia.org/wiki/Unternehmens-Identifikationsnummer

>>> validate('CHE-100.155.212')
'CHE100155212'
>>> validate('100.155.212')
'CHE100155212'
>>> validate('CHE-100.155.213')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('CHE100155212')
'CHE-100.155.212'
é    )Úannotations)Ú*)ÚcleanÚget_soap_clientÚisdigitsF)ÚAnyc                ó’   — t        | d«      j                  «       j                  «       } t        | «      dk(  rt	        | «      rd| z   } | S )zhConvert the number to the minimal representation. This strips
    surrounding whitespace and separators.z -.é	   ÚCHE)r   ÚstripÚupperÚlenr   ©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/ch/uid.pyÚcompactr   <   sC   € ô �6˜5Ó!×'Ñ'Ó)×/Ñ/Ó1€FÜ
ˆ6ƒ{�aÒœH VÔ,Ø˜‘ˆØ€Mó    c                ó`   — d}t        d„ t        || «      D «       «      }t        d|z
  dz  «      S )zlCalculate the check digit for organisations. The number passed should
    not have the check digit included.)é   é   é   é   é   é   r   r   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w)N)Úint)Ú.0ÚwÚns      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>I   s   è ø€ Ò8™4˜1˜aˆA”�A“�JÑ8ùs   ‚é   )ÚsumÚzipÚstr)r   ÚweightsÚss      r   Úcalc_check_digitr'   E   s3   € ð '€GÜÑ8¤3 w°Ó#7Ô8Ó8€AÜ��Q‘˜"‰}ÓÐr   c                óî   — t        | «      } t        | «      dk7  r
t        «       ‚| j                  d«      s
t	        «       ‚t        | dd «      s
t        «       ‚| d   t        | dd «      k7  r
t        «       ‚| S )z[Check if the number is a valid UID. This checks the length, formatting
    and check digit.é   r   r   Néÿÿÿÿ)	r   r   ÚInvalidLengthÚ
startswithÚInvalidComponentr   ÚInvalidFormatr'   ÚInvalidChecksumr   s    r   Úvalidater0   M   st   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐØ×Ñ˜UÔ#ÜÓ Ð Ü�F˜1˜2�JÔÜ‹oÐØˆb�zÔ% f¨Q¨r lÓ3Ò3ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z#Check if the number is a valid UID.F)Úboolr0   ÚValidationErrorr   s    r   Úis_validr4   \   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c           
     óˆ   ‡ — t        ‰ «      Š ‰ dd dz   dj                  ˆ fd„t        dt        ‰ «      d«      D «       «      z   S )z8Reformat the number to the standard presentation format.Nr   ú-ú.c              3  ó.   •K  — | ]  }‰||d z    –— Œ y­w)r   N© )r   Úir   s     €r   r    zformat.<locals>.<genexpr>g   s    øè ø€ ò ';Øˆˆq��Q‘Œñ';ùs   ƒ)r   ÚjoinÚranger   r   s   `r   Úformatr=   d   sI   ø€ ä�V‹_€FØ�"�1ˆ:˜Ñ˜cŸh™hó ';Ü!& q¬#¨f«+°qÓ!9ô';ó ;ñ ;ð ;r   z9https://www.uid-wse.admin.ch/V5.0/PublicServices.svc?wsdlc                ó˜   — t        | «      } t        t        ||¬«      }	 |j                  | dd | dd dœ¬«      d   S # t        $ r Y yw xY w)u†  Look up information via the Swiss Federal Statistical Office web service.

    This uses the UID registry web service run by the the Swiss Federal
    Statistical Office to provide more details on the provided number.

    The `timeout` argument specifies the network timeout in seconds.

    The `verify` argument is either a boolean that determines whether the
    server's certificate is validate or a string which must be a path the CA
    certificate bundle to use for verification.

    Returns a dict-like object for valid numbers with the following structure::

        {
            'organisation': {
                'organisationIdentification': {
                    'uid': {'uidOrganisationIdCategorie': 'CHE', 'uidOrganisationId': 113690319},
                    'OtherOrganisationId': [
                        {'organisationIdCategory': 'CH.ESTVID', 'organisationId': '052.0111.1006'},
                    ],
                    'organisationName': 'Staatssekretariat fÃ¼r Migration SEM Vermietung von ParkplÃ¤tzen',
                    'legalForm': '0220',
                },
                'address': [
                    {
                        'addressCategory': 'LEGAL',
                        'street': 'Quellenweg',
                        'houseNumber': '6',
                        'town': 'Wabern',
                        'countryIdISO2': 'CH',
                    },
                ],
            },
            'uidregInformation': {
                'uidregStatusEnterpriseDetail': '3',
                ...
            },
            'vatRegisterInformation': {
                'vatStatus': '2',
                'vatEntryStatus': '1',
                ...
            },
        }

    See the following document for more details on the GetByUID return value
    https://www.bfs.admin.ch/bfs/en/home/registers/enterprise-register/enterprise-identification/uid-register/uid-interfaces.html
    )ÚtimeoutÚverifyNr   )ÚuidOrganisationIdCategorieÚuidOrganisationId)Úuidr   )r   r   Úuid_wsdlÚGetByUIDÚ	Exception)r   r?   r@   Úclients       r   Ú	check_uidrH   n   sm   € ôl �V‹_€FÜœX¨w¸vÔF€FðØ�‰Ø/5°b°q¨zÐPVÐWXÐWYÐPZÑ[ð ó 
à
ñð 	øô ò ñ ðús   Ÿ= ½	A	ÁA	N)r   r$   Úreturnr$   )r   r$   rI   r2   )é   T)r   r$   r?   Úfloatr@   z
bool | strrI   zdict[str, Any] | None)Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   ÚTYPE_CHECKINGÚtypingr   r   r'   r0   r4   r=   rD   rH   r9   r   r   ú<module>rR      sw   ðñ*õ8 #ä ß 8Ñ 8ð €ÙÝóóóóó;ð G€ð
 Øð?Øð?àð?ð ð?ð ô	?r   