Ë
    ÜNªj	  ã                   óx   — d Z ddlmZmZmZ ddlmZ  ed«      Z ed«      Zd„ Z	 G d„ dej                  «      Z
y	)
zJInitialise les couts valorises des achats deja presents, sans effet stock.é    )ÚDecimalÚ
ROUND_DOWNÚROUND_HALF_UP)Ú
migrationsz0.01z0.000000000001c           	      ó0  — | j                  dd«      }| j                  dd«      }|j                  j                  }|j                  j	                  |«      j                  «       j                  «       D �]œ  }t        |j                  j	                  |«      j                  |j                  ¬«      j                  d«      «      }t        d„ |D «       t        d«      «      }t        t        t        |j                  xs d«      «      |«      j!                  t"        «      }|D �	ci c]  }	|	j                  t        d	«      “Œ }
}	|dkD  rÙ|dkD  rÔg }t        d	«      }|D ]u  }	|t        t        |	j$                  «      «      z  |z  }|j!                  t"        t&        ¬
«      }||
|	j                  <   ||z  }|j)                  ||z
  |	j                  f«       Œw t+        ||z
  t"        z  j-                  «       «      }t/        |d„ ¬«      d | D ]  \  }}|
|xx   t"        z  cc<   Œ |D ]ë  }	t        t        |	j$                  xs d«      «      |
|	j                     z
  j!                  t"        «      }t        t        |	j0                  xs d«      «      }|dkD  r||z  n
t        d«      j!                  t2        t4        ¬
«      }|j                  j	                  |«      j                  |	j                  ¬«      j7                  |
|	j                     ||¬«       Œí �ŒŸ y c c}	w )NÚachatsÚAchatÚ
LigneAchat)Úachat_idÚpkc              3   ó`   K  — | ]&  }t        t        |j                  xs d «      «      –— Œ( y­w)r   N)r   ÚstrÚmontant_net)Ú.0Úls     úQ/var/www/faccontrol_acokin/achats/migrations/0003_backfill_valorisation_lignes.pyú	<genexpr>z(backfill_valorisation.<locals>.<genexpr>   s#   è ø€ ÒMÀœG¤C¨¯©Ò(:¸Ó$;×<ÑMùs   ‚,.Ú0r   z0.00)Úroundingc                 ó   — | d    | d   fS )Nr   é   © )Úitems    r   ú<lambda>z'backfill_valorisation.<locals>.<lambda>   s   € È4ÐPQÉ7È(ÐTXÐYZÑT[ÐI\€ ó    )Úkey)r   )Úremise_globale_alloueeÚmontant_net_valoriseÚcout_unite_base_valorise)Ú	get_modelÚ
connectionÚaliasÚobjectsÚusingÚallÚiteratorÚlistÚfilterr   Úorder_byÚsumr   Úminr   Úremise_globaleÚquantizeÚ
MONEY_STEPr   r   ÚappendÚintÚto_integral_valueÚsortedÚquantite_physiqueÚ	COST_STEPr   Úupdate)ÚappsÚschema_editorr	   r
   r"   ÚachatÚlignesÚtotal_lignesÚremiseÚligneÚallocationsÚ	fractionsÚ	allocatedÚexactÚbaseÚcentsÚ	_fractionÚline_pkÚvaloriseÚphysiqueÚcouts                        r   Úbackfill_valorisationrH      s¾  € Ø�N‰N˜8 WÓ-€EØ—‘ ¨,Ó7€JØ×$Ñ$×*Ñ*€EØ—‘×$Ñ$ UÓ+×/Ñ/Ó1×:Ñ:Ó<ó ˆÜ�j×(Ñ(×.Ñ.¨uÓ5×<Ñ<ÀeÇhÁhÐ<ÓO×XÑXÐY]Ó^Ó_ˆÜÑMÀfÔMÌwÐWZË|Ó\ˆÜ”WœS ×!5Ñ!5Ò!:¸Ó;Ó<¸lÓK×TÑTÔU_Ó`ˆØ>DÖE°U�u—x‘x¤¨£Ñ0ÐEˆÐEØ˜!Ò ¨¢
ØˆIÜ ›ˆIØò ;�Ø¤¬¨U×->Ñ->Ó)?Ó!@Ñ@À<ÑO�Ø—~‘~¤j¼:�~ÓF�Ø(,�˜EŸH™HÑ%Ø˜TÑ!�	Ø× Ñ  %¨$¡,°·±Ð!9Õ:ð;ô ˜& 9Ñ,´
Ñ:×MÑMÓOÓPˆEÜ&,¨YÑ<\Ô&]Ð^dÐ_dÐ&eò 3Ñ"�	˜7Ø˜GÓ$¬
Ñ2Ô$ð3àò 	ˆEÜ¤ E×$5Ñ$5Ò$:¸Ó ;Ó<¸{È5Ï8É8Ñ?TÑT×^Ñ^Ô_iÓjˆHÜœs 5×#:Ñ#:Ò#?¸aÓ@ÓAˆHØ+3°aª<�H˜xÒ'¼WÀS»\×SÑSÜÜ&ð Tó ˆDð ×Ñ×$Ñ$ UÓ+×2Ñ2°e·h±hÐ2Ó?×FÑFØ'2°5·8±8Ñ'<Ø%-Ø)-ð Gõ ò	ñ#ùò Fs   Ä"Lc                   ób   — e Zd ZdgZ ej
                  eej
                  j                  «      gZy)Ú	Migration)r   Ú$0002_compteurreceptionachat_and_moreN)	Ú__name__Ú
__module__Ú__qualname__Údependenciesr   Ú	RunPythonrH   ÚnoopÚ
operationsr   r   r   rJ   rJ   /   s.   „ ØFÐG€Là&�*×&Ñ&Ð'<¸j×>RÑ>R×>WÑ>WÓXÐY�Jr   rJ   N)Ú__doc__Údecimalr   r   r   Ú	django.dbr   r.   r4   rH   rJ   r   r   r   ú<module>rV      sA   ðÙ Pç 6Ñ 6å  ñ �V‹_€
ÙÐ$Ó%€	ò ôFZ�
×$Ñ$õ Zr   