Ë
    Ã?Æi_  ã                  óŽ   — d Z ddlm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dd„Zdd„Zdd„Zdd„Zdd„Zy)aÀ  UEN (Singapore's Unique Entity Number).

The Unique Entity Number (UEN) is a 9 or 10 digit identification issued by
the government of Singapore to businesses that operate within Singapore.


Accounting and Corporate Regulatory Authority (ACRA)

There are three different formats:

* Business (ROB): It consists of 8 digits followed by a check letter.
* Local Company (ROC): It consists of 9 digits (the 4 leftmost digits
  represent the year of issuance) followed by a check letter.
* Others: Consists of 10 characters, begins with either the R letter, or the
  S letter or the T letter followed by 2 digits representing the last two
  digits of the issuance year, followed by two letters representing the
  entity type, 4 digits and finally a check letter.

More information:

* https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Singapore-TIN.pdf
* https://www.uen.gov.sg/ueninternet/faces/pages/admin/aboutUEN.jspx

>>> validate('00192200M')
'00192200M'
>>> validate('197401143C')
'197401143C'
>>> validate('S16FC0121D')
'S16FC0121D'
>>> validate('T01FC6132D')
'T01FC6132D'
>>> validate('123456')
Traceback (most recent call last):
    ...
InvalidLength: ...
é    )Úannotations)Údatetime)Ú*)ÚcleanÚisdigits)&ÚCCÚCDÚCHÚCLÚCMÚCPÚCSÚCXÚDPÚFBÚFCÚFMÚFNÚGAÚGBÚGSÚHSÚLLÚLPÚMBÚMCÚMDÚMHÚMMÚMQÚNBÚNRÚPAÚPBÚPFÚRFÚRPÚSMÚSSÚTCÚTUÚVHÚXLc                óP   — t        | «      j                  «       j                  «       S )zÌConvert the number to the minimal representation.

    This converts to uppercase and removes surrounding whitespace. It
    also replaces the whitespace in UEN for foreign companies with
    zeroes.
    )r   ÚupperÚstrip©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/sg/uen.pyÚcompactr4   O   s    € ô �‹=×ÑÓ ×&Ñ&Ó(Ð(ó    c                ó`   — t        | «      } d}dt        d„ t        | |«      D «       «      dz     S )z8Calculate the check digit for the Business (ROB) number.)é
   é   é	   é   é   é   é   é   ÚXMKECAWLJDBc              3  ó>   K  — | ]  \  }}t        |«      |z  –— Œ y ­w©N©Úint©Ú.0ÚnÚws      r3   ú	<genexpr>z,calc_business_check_digit.<locals>.<genexpr>]   ó   è ø€ ÒI©D¨A¨qœS ›V a�ZÑIùó   ‚é   ©r4   ÚsumÚzip©r2   Úweightss     r3   Úcalc_business_check_digitrQ   Y   s2   € ä�V‹_€FØ'€GØœÑI´C¸ÀÓ4HÔIÓIÈBÑNÑOÐOr5   c                ó¦   — t        | dd «      s
t        «       ‚| d   j                  «       s
t        «       ‚| d   t        | «      k7  r
t	        «       ‚| S )z3Perform validation on UEN - Business (ROB) numbers.Néÿÿÿÿ)r   ÚInvalidFormatÚisalpharQ   ÚInvalidChecksumr1   s    r3   Ú_validate_businessrW   `   sP   € ä�F˜3˜B�KÔ Ü‹oÐØ�"‰:×ÑÔÜ‹oÐØˆb�zÔ.¨vÓ6Ò6ÜÓÐØ€Mr5   c                ó`   — t        | «      } d}dt        d„ t        | |«      D «       «      dz     S )z=Calculate the check digit for the Local Company (ROC) number.)	r7   r;   é   r8   r9   r=   é   r:   r>   ÚZKCMDNERGWHc              3  ó>   K  — | ]  \  }}t        |«      |z  –— Œ y ­wrA   rB   rD   s      r3   rH   z1calc_local_company_check_digit.<locals>.<genexpr>o   rI   rJ   rK   rL   rO   s     r3   Úcalc_local_company_check_digitr]   k   s2   € ä�V‹_€FØ*€GØœÑI´C¸ÀÓ4HÔIÓIÈBÑNÑOÐOr5   c                óÞ   — t        | dd «      s
t        «       ‚t        t        j                  «       j
                  «      }| dd |kD  r
t        «       ‚| d   t        | «      k7  r
t        «       ‚| S )z8Perform validation on UEN - Local Company (ROC) numbers.NrS   r8   )	r   rT   Ústrr   ÚnowÚyearÚInvalidComponentr]   rV   ©r2   Úcurrent_years     r3   Ú_validate_local_companyre   r   se   € ä�F˜3˜B�KÔ Ü‹oÐÜ”x—|‘|“~×*Ñ*Ó+€LØˆbˆq€z�LÒ ÜÓ Ð Øˆb�zÔ3°FÓ;Ò;ÜÓÐØ€Mr5   c                óp   ‡— t        | «      } dŠd}‰t        ˆfd„t        | |«      D «       «      dz
  dz     S )z8Calculate the check digit for the other entities number.Ú ABCDEFGHJKLMNPQRSTUVWX0123456789)	r8   r:   rZ   r:   r7   r<   r<   rZ   r=   c              3  óL   •K  — | ]  \  }}‰j                  |«      |z  –— Œ y ­wrA   )Úindex)rE   rF   rG   Úalphabets      €r3   rH   z)calc_other_check_digit.<locals>.<genexpr>ƒ   s#   øè ø€ ÒP±4°1°a˜Ÿ™¨Ó*¨QÕ.ÑPùs   ƒ!$rZ   rK   rL   )r2   rP   rj   s     @r3   Úcalc_other_check_digitrk   ~   s?   ø€ ä�V‹_€FØ1€HØ*€GØ”SÓP¼3¸vÀwÓ;OÔPÓPÐSTÑTÐXZÑZÑ[Ð[r5   c                óp  — | d   dvr
t        «       ‚t        | dd «      s
t        «       ‚t        t	        j
                  «       j                  «      }| d   dk(  r| dd |dd kD  r
t        «       ‚| dd t        vr
t        «       ‚t        | dd	 «      s
t        «       ‚| d	   t        | «      k7  r
t        «       ‚| S )
z(Perform validation on other UEN numbers.r   )ÚRÚSÚTr>   r:   ro   r<   NrZ   rS   )
rb   r   rT   r_   r   r`   ra   ÚOTHER_UEN_ENTITY_TYPESrk   rV   rc   s     r3   Ú_validate_otherrq   †   sº   € àˆa�y˜Ñ'ÜÓ Ð Ü�F˜1˜Q�KÔ Ü‹oÐÜ”x—|‘|“~×*Ñ*Ó+€LØˆa�y�CÒ˜F 1 Q˜K¨,°q°rÐ*:Ò:ÜÓ Ð Øˆa�€{Ô0Ñ0ÜÓ Ð Ü�F˜1˜R�LÔ!Ü‹oÐØˆb�zÔ+¨FÓ3Ò3ÜÓÐØ€Mr5   c                óÀ   — t        | «      } t        | «      dvr
t        «       ‚t        | «      dk(  rt        | «      S t	        | d   «      rt        | «      S t        | «      S )ú4Check if the number is a valid Singapore UEN number.)r9   r7   r9   r   )r4   ÚlenÚInvalidLengthrW   r   re   rq   r1   s    r3   Úvalidaterv   ˜   sX   € ä�V‹_€FÜ
ˆ6ƒ{˜'Ñ!Ü‹oÐÜ
ˆ6ƒ{�aÒÜ! &Ó)Ð)Ü��q‘	ÔÜ& vÓ.Ð.Ü˜6Ó"Ð"r5   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)rs   F)Úboolrv   ÚValidationErrorr1   s    r3   Úis_validrz   ¤   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ó   — t        | «      S )z8Reformat the number to the standard presentation format.)r4   r1   s    r3   Úformatr|   ¬   s   € ä�6‹?Ðr5   N)r2   r_   Úreturnr_   )r2   r_   r}   rx   )Ú__doc__Ú
__future__r   r   Ústdnum.exceptionsÚstdnum.utilr   r   rp   r4   rQ   rW   r]   re   rk   rq   rv   rz   r|   © r5   r3   ú<module>rƒ      sV   ðñ,#õR #å ä ß 'ðÐ ó)óPóóPó	ó\óó$	#óôr5   