
    $iI                     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                  ddddd      Z ej                  ddddd      Z ej                  ddd      Z G d	 d
      Z	 fdZ
 xZS )ServiceListSerializer_service_pricer   r   T)sourcer   r   r   
allow_null_labor_rate_estimated_hours)r3   r   r4   c                       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   r8   ?       
r   r   c                     t         |   |      }|j                  d      t        |d         |d<   |j                  d      t        |d         |d<   |S )Nr;   r%   )superto_representationgetfloat)selfinstanceret	__class__s      r   r@   z'ServiceListSerializer.to_representationK   s`    g'177?#/#(_)=#>C 77()5).s3H/I)JC%&
r   )r   r   r   r   r/   r;   r%   IntegerFieldr&   r   r@   __classcell__)rF   s   @r   r1   r1   *   sy    ,K,,M 3+22 /k..!O

 

 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"   r9   coder:   r*   r$   current_priceNr<   r   r   r   r   rL   Z   r=   r   r   c                     | j                   d   j                  j                  }|j                  j	                  |d      j                  d      j                         }|rt        |      j                  S d S )NrequestT)r$   r*   z-effective_from)	contextuseractive_companypricesfilterorder_byfirstr   data)rC   objr$   prices       r   get_current_pricez#ServiceSerializer.get_current_pricef   sl    ,,y)..==

!! " 
 ($
%eeg 	
 6;%e,11DDr   )r   r   r   r   	CharFieldrM   r-   r$   SerializerMethodFieldrN   r   r[   r   r   r   rJ   rJ   U   sF     ;  40D%k%%d3G5K557M

 

Er   rJ   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   requiredr4      USDr   )r`   r4   N)r   r   r   r   r/   r
   r%   r&   r\   r'   r.   r+   	DateFieldr(   r)   r   r   r   r_   r_   q   s    )))RJJ2+22	 /k..	O %{$$U3H*+**59K*[**EdKN(;((%DILr   r_   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r`   allow_blankr4   r`   c                     |S )Nr   )rC   validated_datas     r   createz!ServiceWithPriceSerializer.create   s    r   N)
r   r   r   r   r\   r9   r:   r_   rZ   rm   r   r   r   re   re      s@     ;  C0D'+''K
 (6Er   re   c                       e Zd Z ej                  dd      Z ej                  ddd      Z ej                  d      Z e	d      Z
y) ServiceWithPriceUpdateSerializerrf   F)rg   r`   Trh   rj   N)r   r   r   r   r\   r9   r:   r.   r*   r_   rZ   r   r   r   ro   ro      sO     ;  C%@D'+''K
 )((%8I'6Er   ro   N)rest_frameworkr   apps.companies.modelsr   r   ModelSerializerr   r   r1   rJ   
Serializerr_   re   ro   r   r   r   <module>rt      s    & 7
K$?$? 

[88 
:(K77 (VE33 E8J+"8"8 J(
!7!7 
7{'='= 7r   