Ë
    Ã?Æi’  ã                  ó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
)aˆ  ESR, ISR, QR-reference (reference number on Swiss payment slips).

The ESR (Eizahlungsschein mit Referenznummer), ISR (In-payment Slip with
Reference Number) or QR-reference refers to the orange payment slip in
Switzerland with which money can be transferred to an account. The slip
contains a machine-readable part that contains a participant number and
reference number. The participant number ensures the crediting to the
corresponding account. The reference number enables the creditor to identify
the invoice recipient. In this way, the payment process can be handled
entirely electronically.

The number consists of 26 numerical characters followed by a Modulo 10
recursive check digit. It is printed in blocks of 5 characters (beginning
with 2 characters, then 5x5-character groups). Leading zeros digits can be
omitted.

More information:

* https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf

>>> validate('21 00000 00003 13947 14300 09017')
'210000000003139471430009017'
>>> validate('210000000003139471430009016')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('18 78583')
'00 00000 00000 00000 00018 78583'
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                ó8   — t        | d«      j                  d«      S )zhConvert the number to the minimal representation. This strips
    surrounding whitespace and separators.ú Ú0)r   Úlstrip©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/ch/esr.pyÚcompactr   :   s   € ô �˜Ó×$Ñ$ SÓ)Ð)ó    c                ót   — d}d}t        | «      D ]  }|t        |«      |z   dz     }Œ t        d|z
  dz  «      S )zeCalculate the check digit for number. The number passed should
    not have the check digit included.)
r   é	   é   é   é   é   é   é   é   é   r   é
   )r   ÚintÚstr)r   Ú_digitsÚcÚns       r   Úcalc_check_digitr    @   sK   € ð -€GØ	€AÜ�V‹_ò 'ˆØ”S˜“V˜a‘Z 2Ñ%Ñ&‰ð'ä��Q‘˜"‰}ÓÐr   c                ó²   — t        | «      } t        | «      dkD  r
t        «       ‚t        | «      s
t	        «       ‚| d   t        | dd «      k7  r
t        «       ‚| S )z[Check if the number is a valid ESR. This checks the length, formatting
    and check digit.é   éÿÿÿÿN)r   ÚlenÚInvalidLengthr   ÚInvalidFormatr    ÚInvalidChecksumr   s    r   Úvalidater(   J   sW   € ô �V‹_€FÜ
ˆ6ƒ{�RÒÜ‹oÐÜ�FÔÜ‹oÐØˆb�zÔ% f¨S¨b kÓ2Ò2ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z#Check if the number is a valid ESR.F)Úboolr(   ÚValidationErrorr   s    r   Úis_validr,   W   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c           
     ó¦   ‡ — t        ‰ «      j                  d«      Š ‰ dd dz   dj                  ˆ fd„t        dt	        ‰ «      d«      D «       «      z   S )z8Reformat the number to the standard presentation format.r"   Nr   r   c              3  ó.   •K  — | ]  }‰||d z    –— Œ y­w)r   N© )Ú.0Úir   s     €r   ú	<genexpr>zformat.<locals>.<genexpr>b   s    øè ø€ ò ';Øˆˆq��Q‘Œñ';ùs   ƒr   )r   ÚzfillÚjoinÚranger$   r   s   `r   Úformatr6   _   sT   ø€ ä�V‹_×"Ñ" 2Ó&€FØ�"�1ˆ:˜Ñ˜cŸh™hó ';Ü!& q¬#¨f«+°qÓ!9ô';ó ;ñ ;ð ;r   N)r   r   Úreturnr   )r   r   r7   r*   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r    r(   r,   r6   r/   r   r   ú<module>r<      s.   ðñ,õ< #ä ß 'ó*óó
óô;r   