
    %xEi                        d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d dej                        Z
 G d d	ej                        Zy
)zInvestment and reward models.    )annotations)Decimal)MinValueValidator)modelsc            	         e Zd ZdZdZdZdZedfedfedfgZg dZ e	j                  d	e	j                  d
      Z e	j                  dd e ed            g      Z e	j"                  e      Z e	j                  dd      Z e	j"                         Z e	j*                  dee      Z e	j.                         Z e	j.                         Z e	j                  dd ed      d      Z e	j                  dd ed      d      Z e	j.                  d      Z e	j.                  d      Z G d d       Zd$d!Ze d%d"       Z!y#)&
Investmentz4Tracks a user's investment and its reward lifecycle.pendingactive	completedPendingActive	Completed))   u   Tier 1: ≤ $100)   u   Tier 2: ≤ $500)   u   Tier 3: ≤ $1,000)   u   Tier 4: ≤ $2,000)   u   Tier 5: ≤ $5,000)   zTier 6: > $5,000z
users.Userinvestments	on_deleterelated_name      z10.00000000)
max_digitsdecimal_places
validators)choicesr   r   r   r   )
max_lengthr   defaultz
0.00000000z:Accumulated total ROI amount generated for this investment)r   r   r!   	help_text
   r   z0.0000zDAccumulated total ROI percentage ((roi_total_amount / amount) * 100)Tauto_now_add)auto_nowc                  d    e Zd ZdZ ej
                  ddg       ej
                  ddg      gZy)Investment.Metar   userstatusfieldsend_dateN)__name__
__module____qualname__db_tabler   Indexindexes     H/home/cursorai/projects/telegram-earn/backend/apps/investments/models.pyMetar(   G   s4     FLL 23FLL: 67
r5   r7   c                h    d| j                    d| j                  j                   d| j                   S )NzInvestment #z - z - $)idr)   
first_nameamountselfs    r6   __str__zInvestment.__str__N   s.    dggYc$))*>*>)?tDKK=QQr5   c                j   t        t        |             }|t        d      k  rdt        d      ddS |t        d      k  rdt        d      d	dS |t        d
      k  rdt        d      ddS |t        d      k  rdt        d      ddS |t        d      k  rdt        d      ddS dt        d      ddS )z3Determine tier metadata based on investment amount.100r   z1.00x   )tierrateduration500r   z1.50   1000r   z2.00   2000r   z2.50   5000r   z3.00   r   z3.50   )r   str)r;   
normalizeds     r6   get_tier_infozInvestment.get_tier_infoQ   s     S[)
'wvCHH'wvCHH(wvCHH(wvCHH(wvCHH76?DDr5   NreturnrN   )r;   zDecimal | float | intrR   zdict[str, Decimal | int])"r.   r/   r0   __doc__STATUS_PENDINGSTATUS_ACTIVESTATUS_COMPLETEDSTATUS_CHOICESTIER_CHOICESr   
ForeignKeyCASCADEr)   DecimalFieldr   r   r;   IntegerFieldrB   daily_reward_rateduration_days	CharFieldr*   DateTimeField
start_dater-   roi_total_amountroi_total_percent
created_at
updated_atr7   r>   staticmethodrP   r4   r5   r6   r   r      s   >NM"	#	!	;'NL 6.."D
 !V  %gm&<=>F
 6|4D+++qK'F'')MVF
 &%%'J#v##%H +v**%N	 ,++!X	 &%%48J%%%t4J
 
R E Er5   r   c                     e Zd ZdZ ej
                  eej                  d      Z ej                  dd      Z
 ej                         Z ej                  d      Z ej                  dd	      Z G d
 d      ZddZy)Rewardz)Daily reward entries tied to investments.rewardsr   r   r   r   Tr$   )nullblankc                  l    e Zd ZdZddgZ ej                  ddg       ej                  ddg      gZy)Reward.Metari   
investmentreward_dater+   distributed_atN)r.   r/   r0   r1   unique_togetherr   r2   r3   r4   r5   r6   r7   rm   o   s?    '7FLL} =>FLL0@ AB
r5   r7   c                :    d| j                    d| j                   S )NzReward z for investment )ro   investment_idr<   s    r6   r>   zReward.__str__w   s$    ))**:4;M;M:NOOr5   NrQ   )r.   r/   r0   rS   r   rY   r   rZ   rn   r[   r;   	DateFieldro   r`   calculated_atrp   r7   r>   r4   r5   r6   rh   rh   b   s    3"""..J
 !V  BqAF"&""$K(F((d;M)V))t4@N
 
Pr5   rh   N)rS   
__future__r   decimalr   django.core.validatorsr   	django.dbr   Modelr   rh   r4   r5   r6   <module>r{      s;    # "  4 TE TEnPV\\ Pr5   