
    |i)                     F   d dl mZ d dlmZmZ  G d dej
                        Z G d dej
                        Z G d dej
                        Z G d	 d
ej
                        Z	 G d dej                        Z G d dej                        Z G d dej                        Zy)    )serializers)ServicePriceServicec                        e Zd Z G d d      Zy)MinimumServicePriceSerializerc                       e Zd ZeZdgZy)"MinimumServicePriceSerializer.Meta
base_priceN__name__
__module____qualname__r   modelfields     \/var/www/html/dp2/backend_v2.1/server/apps/companies/serializers/service_price_serializer.pyMetar	      s    
r   r   N)r   r   r   r   r   r   r   r   r      s    
 
r   r   c                       e Zd Z ej                  d      Z ej                  d      Z ej                  ddd      Z	 ej                  dd	      Z
 G d
 d      Zy)ServicePriceSerializerNdefaultT	read_only
      )
max_digitsdecimal_placesr   r   r   r   c                       e Zd ZeZg dZy)ServicePriceSerializer.Meta)idservicecompanyr
   labor_rate_per_hourestimated_hourscurrencyeffective_fromeffective_to	is_activestarting_attotal_priceNr   r   r   r   r   r!      s    
r   r   )r   r   r   r   HiddenFieldr$   BooleanFieldr*   DecimalFieldr,   r&   r   r   r   r   r   r      sc    %k%%d3G(((48I*+**a4K /k..O

 
r   r   c                       e Zd Z ej                         Z ej                         Z ej                         Z G d d      Zd Z	d Z
d Zy)ServiceListSerializerc                       e Zd ZeZg dZy)ServiceListSerializer.Meta)r"   namedescriptionr*   service_pricer%   r&   Nr   r   r   r   r   r   r   r   r   r   r3   .       
r   r   c                     | j                   d   j                  j                  }|j                  j	                  |d      j                  d      j                         }|r|j                  S d S NrequestT)r$   r*   z-effective_from)contextuseractive_companypricesfilterorder_byfirstr
   selfobjr$   prices       r   get_service_pricez'ServiceListSerializer.get_service_price:   sf    ,,y)..==

!! " 
 ($
%eeg 	
 $)u2d2r   c                     | j                   d   j                  j                  }|j                  j	                  |d      j                  d      j                         }|r|j                  r|j                  S d S r:   )r<   r=   r>   r?   r@   rA   rB   r%   rC   s       r   get_labor_rate_per_hourz-ServiceListSerializer.get_labor_rate_per_hourD   so    ,,y)..==

!! " 
 ($
%eeg 	
 -2e6O6Ou((YUYYr   c                    | j                   d   j                  j                  }|j                  j	                  |d      j                  d      j                         }|r!|j                  rt        |j                        S d S r:   )	r<   r=   r>   r?   r@   rA   rB   r&   intrC   s       r   get_estimated_hoursz)ServiceListSerializer.get_estimated_hoursN   st    ,,y)..==

!! " 
 ($
%eeg 	
 .3u7L7Ls5(()VRVVr   N)r   r   r   r   SerializerMethodFieldr6   r%   r&   r   rG   rI   rL   r   r   r   r1   r1   )   sN    5K557M;+;;=7k779O

 

3ZWr   r1   c                       e Zd Z ej                  d      Z ej                  d      Z ej                         Z	 G d d      Z
d Zy)ServiceSerializerTr   Nr   c                       e Zd ZeZg dZy)ServiceSerializer.Meta)r"   r4   coder5   r*   r$   current_priceNr7   r   r   r   r   rQ   ]   r8   r   r   c                     | j                   d   j                  j                  }|j                  j	                  |d      j                  d      j                         }|rt        |      j                  S d S r:   )	r<   r=   r>   r?   r@   rA   rB   r   datarC   s       r   get_current_pricez#ServiceSerializer.get_current_pricei   sl    ,,y)..==

!! " 
 ($
%eeg 	
 6;%e,11DDr   )r   r   r   r   	CharFieldrR   r-   r$   rM   rS   r   rV   r   r   r   rO   rO   X   sF     ;  40D%k%%d3G5K557M

 

Er   rO   c                   (   e Zd Z ej                  dd      Z ej                  dddd      Z ej                  dddd      Z ej                  d	      Z	 ej                  d	      Z ej                  dd
      Z ej                  dd
      Zy)ServicePriceInputSerializerr   r   r   FT)r   r   required
allow_null   USDr   )rZ   r[   N)r   r   r   r   r/   r
   r%   r&   rW   r'   r.   r+   	DateFieldr(   r)   r   r   r   rY   rY   s   s    )))RJJ2+22	 /k..	O %{$$U3H*+**59K*[**EdKN(;((%DILr   rY   c                   t    e Zd Z ej                  d      Z ej                  ddd      Z ed      Zd Z	y)	ServiceWithPriceSerializerd   )
max_lengthFTrZ   allow_blankr[   rZ   c                     |S )Nr   )rD   validated_datas     r   createz!ServiceWithPriceSerializer.create   s    r   N)
r   r   r   r   rW   r4   r5   rY   rF   rh   r   r   r   r`   r`      s@     ;  C0D'+''K
 (6Er   r`   c                       e Zd Z ej                  dd      Z ej                  ddd      Z ej                  d      Z e	d      Z
y) ServiceWithPriceUpdateSerializerra   F)rb   rZ   Trc   re   N)r   r   r   r   rW   r4   r5   r.   r*   rY   rF   r   r   r   rj   rj      sO     ;  C%@D'+''K
 )((%8I'6Er   rj   N)rest_frameworkr   apps.companies.modelsr   r   ModelSerializerr   r   r1   rO   
SerializerrY   r`   rj   r   r   r   <module>ro      s    & 7
K$?$? 

[88 
8-WK77 -W^E33 E6J+"8"8 J&
!7!7 
7{'='= 7r   