
    nj0Q                     6   d dl mZ ddlmZmZmZmZmZmZm	Z	m
Z
mZmZ d dlmZ d dlmZmZmZ d dl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 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" G d" d#ej*                        Z# G d$ d%ej*                        Z$ G d& d'ej*                        Z%y())    )serializers   )
AdditionalDetailsCustomOrderTrackingOrderProductCustomizationOrdersOrderProductsAdsDiscountCouponsOrderDeliverySomeOneElse)reverse)ProductImageProductsCustomProductImage)CustomProductSerializerc                        e Zd Z G d d      Zy)SomeOneElseDataSerializerc                       e Zd ZeZddgZy)SomeOneElseDataSerializer.Metanamephone_numberN)__name__
__module____qualname__r   modelfields     PC:\Users\Saasvaap\Desktop\Akash\Saasvaap\DEMO\Navya-Bakers\orders\serializers.pyMetar   
   s    .)r    r"   Nr   r   r   r"   r   r    r!   r   r   	   s    * *r    r   c                        e Zd Z G d d      Zy)#OrderProductCustomizationSerializerc                       e Zd ZeZg dZy(OrderProductCustomizationSerializer.Meta)idcustom_notecustom_imageNr   r   r   r   r   r   r   r    r!   r"   r(          )6r    r"   Nr#   r   r    r!   r%   r%          7 7r    r%   c                       e Zd Z ej                  d      Z ej                  d      Z ej                  d      Z ej                  d      Z e	dd      Z
 G d d	      Zy
)OrderProductSerializerzsku.sku_namesourcezsku.sku_quantityzsku.sku_unitz!sku.product.veg_or_non_veg_statusTmany	read_onlyc                       e Zd ZeZg dZy)OrderProductSerializer.Meta)skuquantitypricesku_nameveg_or_non_vegsku_quantitysku_unitcustomizationsN)r   r   r   r	   r   r   r   r    r!   r"   r7      s    	
r    r"   N)r   r   r   r   	CharFieldr;   r=   r>   r<   r%   r?   r"   r   r    r!   r0   r0      sb    ${$$N;H(;((0BCL${$$N;H*[**2UVN8ddSN
 
r    r0   c                        e Zd Z edd      Z ej                  d      Z ej                  d      Z ej                  d      Z	 e
d      Z G d d	      Z fd
Z xZS )PickUpOrderSerializerTr3   store_uuid.unit_namer1   store_uuid.unit_locationstore_uuid.contact_nor5   c                       e Zd ZeZg dZy)PickUpOrderSerializer.Meta)uuidorder_ID
order_typeorder_status	sub_totaltaxes_and_chargesdelivery_chargesgrand_total
order_datacreated_date	shop_nameshop_locationshop_contactdelivery_slot_datedelivery_slot_timesome_one_else_orderNr   r   r   r   r   r   r   r    r!   r"   rH   5   s    
r    r"   c                 R    t         |   |      }|j                  d      i |d<   |S NrX   superto_representationgetselfinstancerepresentation	__class__s      r!   r^   z'PickUpOrderSerializer.to_representationI   5    28<34<46N01r    )r   r   r   r0   rQ   r   r@   rS   rT   rU   r   rX   r"   r^   __classcell__rd   s   @r!   rB   rB   /   sg    0ddKJ/+//7MNI/+//7QRM/+//7NOL3dC
 
( r    rB   c                       e Zd Z edd      Z ej                  d      Z ej                  d      Z ej                  d      Z	 ej                  ddd	      Z
 ej                  d
dd	      Z ej                  ddd	      Z ej                  ddd	      Z ed      Z ej                          Z ej                          Z G d d      Zd Zd Z fdZ xZS )OrderSerializerTr3   rC   r1   rD   rE   drop_address.address_typeFr2   
allow_nullrequired!drop_address.house_number_or_namedrop_address.land_markpayment_mode.mode_namerF   c                       e Zd ZeZg dZy)OrderSerializer.Meta)rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   address_typepayment_mode	address_1	address_2rX   discountadditional_infomobile_numberNrY   r   r    r!   r"   rr   d   s    
r    r"   c                     	 t         j                  j                  |      j                         }|r|j                  S dS # t
        $ r Y yw xY wN)order r   objectsfilterfirstrx   	Exceptionra   objdetailss      r!   get_additional_infoz#OrderSerializer.get_additional_info   N    	'//66S6AGGIG.57**=2= 		   ;A  A   	AAc                     	 t         j                  j                  |      j                         }|r|j                  S dS # t
        $ r Y yw xY wr{   r   r   r   r   ry   r   r   s      r!   get_mobile_numberz!OrderSerializer.get_mobile_number   N    	'//66S6AGGIG,37((;; 		r   c                 R    t         |   |      }|j                  d      i |d<   |S r[   r\   r`   s      r!   r^   z!OrderSerializer.to_representation   s5    28<34<46N01r    )r   r   r   r0   rQ   r   r@   rS   rT   rU   rs   ru   rv   rt   r   rX   SerializerMethodFieldrx   ry   r"   r   r   r^   rf   rg   s   @r!   ri   ri   R   s    'TTBJ%%%-CDI)K))1KLM(;((0GHL(;((0KX\glmL%%%-P]alqrI%%%-ERVafgI(;((0HUYdijL3dC 8k779O5K557M
 
< r    ri   c                        e Zd Z G d d      Zy)CourierDetailsSerializerc                       e Zd ZeZg dZy)CourierDetailsSerializer.Meta)courier_service_namepackage_numberexpected_date_of_deliverytracking_linkN)r   r   r   r   r   r   r   r    r!   r"   r      s    ir    r"   Nr#   r   r    r!   r   r      s    j jr    r   c                       e Zd Z edd      Z ej                  d      Z ej                  d      Z ej                  d      Z	 ej                  ddd	      Z
 ej                  d
dd	      Z ej                  ddd	      Z ej                  ddd	      Z ej                         Z ej                         Z ed      Z G d d      Zd Zd Z fdZ xZS )OrderSerializer2Tr3   zpu_uuid.pu_namer1   zpu_uuid.pu_locationzpu_uuid.contact_norj   Frk   rn   ro   rp   rF   c                       e Zd ZeZg dZy)OrderSerializer2.Meta)rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   pu_namepu_location
pu_contactrV   rW   rs   rt   ru   rv   rX   rw   rx   ry   NrY   r   r    r!   r"   r      s    
r    r"   c                     	 t         j                  j                  |      j                         }|r|j                  S dS # t
        $ r Y yw xY wr{   r~   r   s      r!   r   z$OrderSerializer2.get_additional_info   r   r   c                     	 t         j                  j                  |      j                         }|r|j                  S dS # t
        $ r Y yw xY wr{   r   r   s      r!   r   z"OrderSerializer2.get_mobile_number   r   r   c                 R    t         |   |      }|j                  d      i |d<   |S r[   r\   r`   s      r!   r^   z"OrderSerializer2.to_representation   re   r    )r   r   r   r0   rQ   r   r@   r   r   r   rs   ru   rv   rt   r   rx   ry   r   rX   r"   r   r   r^   rf   rg   s   @r!   r   r      s   'TTBJ#k##+<=G'+''/DEK&&&.BCJ(;((*L
 &%%2I
 &%%'I );(('L
 8k779O5K557M3dC
 
8 r    r   c                   p    e Zd Z ej                  d      Z ej                  d      Z ej                  d      Z ej                  ddd      Z ej                  d	dd      Z	 ej                  d
dd      Z
 ej                  ddd      Z ed      Z ed      Z G d d      Z fdZ xZS )CustomOrderCreateSerializerrC   r1   rD   rE   rj   TFrk   rn   ro   rp   rF   c                       e Zd ZeZg dZy) CustomOrderCreateSerializer.Meta)rI   rJ   rK   rL   rM   rN   rO   rP   rR   rS   rT   rU   rV   rW   rs   ru   rv   custom_productdescriptionmessagerX   rt   NrY   r   r    r!   r"   r      s    
r    r"   c                 R    t         |   |      }|j                  d      i |d<   |S r[   r\   r`   s      r!   r^   z-CustomOrderCreateSerializer.to_representation  re   r    )r   r   r   r   r@   rS   rT   rU   rs   ru   rv   rt   r   r   r   rX   r"   r^   rf   rg   s   @r!   r   r      s    %%%-CDI)K))1KLM(;((0GHL(;((0KX\fklL%%%-P]alqrI%%%-ERVafgI(;((0HUYdijL,>N3dC
 
4 r    r   c                       e Zd Z ej                  d      Z ej                  d      Z ej                  d      Z ej                  ddd      Z ej                  d	dd      Z	 ej                  d
dd      Z
 ed      Z ed      Z ej                  ddd      Z ej                          Z ej                          Z ej                          Z ej                          Z ej                          Z ej                          Z ej                          Z G d d      Zd Zd Zd Zd Zd Zd Zd Zd Z  fdZ! xZ"S )CustomOrderSerializerrC   r1   rD   rE   rj   TFrk   rn   ro   rF   rp   c                       e Zd ZeZg dZy)CustomOrderSerializer.Meta)rI   rJ   rK   rL   rM   rN   rO   rP   rw   rR   rS   rT   rU   rV   rW   rs   ru   rv   r   r   r   rX   r+   r9   quantity_unitdelivery_typelatitude	longitudert   	is_editedNrY   r   r    r!   r"   r   9  s    
r    r"   c                     t        | d      s2	 t        j                  j                  |      | _        | j                  S | j                  S # t        j
                  $ r d | _        Y | j                  S w xY w)N_tracking_cache)order_id)hasattrr   r   r_   r   DoesNotExistra   r   s     r!   get_trackingz"CustomOrderSerializer.get_tracking]  ss    t./,':'B'B'F'FPS'F'T$ ###t### '33 ,'+$###,s   %A A32A3c                     | j                  |      }|r>|j                  r2| j                  d   j                  |j                  j                        S y )Nrequest)r   r+   contextbuild_absolute_uriurlra   r   trackings      r!   get_custom_imagez&CustomOrderSerializer.get_custom_imagee  sF    $$S)--<<	*==h>S>S>W>WXXr    c                 D    | j                  |      }|r|j                  S d S N)r   r9   r   s      r!   get_quantityz"CustomOrderSerializer.get_quantityk  s%    $$S)$,x  6$6r    c                 D    | j                  |      }|r|j                  S d S r   )r   r   r   s      r!   get_quantity_unitz'CustomOrderSerializer.get_quantity_unito  %    $$S))1x%%;t;r    c                 D    | j                  |      }|r|j                  S d S r   )r   r   r   s      r!   get_delivery_typez'CustomOrderSerializer.get_delivery_types  r   r    c                     | j                  |      }|r1|j                  dk(  r"|j                  r|j                  j                  S y NzPick Up)r   r   drop_addressr   r   s      r!   get_latitudez"CustomOrderSerializer.get_latitudew  s?    $$S)..);@P@P##,,,r    c                     | j                  |      }|r1|j                  dk(  r"|j                  r|j                  j                  S y r   )r   r   r   r   r   s      r!   get_longitudez#CustomOrderSerializer.get_longitude}  s?    $$S)..);@P@P##---r    c                 :    | j                   j                  dd      S )Nr   F)r   r_   r   s     r!   get_is_editedz#CustomOrderSerializer.get_is_edited  s    ||U33r    c                 R    t         |   |      }|j                  d      i |d<   |S r[   r\   r`   s      r!   r^   z'CustomOrderSerializer.to_representation  re   r    )#r   r   r   r   r@   rS   rT   rU   rs   ru   rv   r   r   r   rX   rt   r   r+   r9   r   r   r   r   r   r"   r   r   r   r   r   r   r   r   r^   rf   rg   s   @r!   r   r     sf   %%%-CDI)K))1KLM(;((0GHL(;((0KX\glmL%%%-P]alqrI%%%-ERVafgI,t<N3dC(;((0HUYdijL 5;446L0{002H5K557M5K557M0{002H1113I 2113I!
 !
H$7<<4 r    r   c                        e Zd Z G d d      Zy)r%   c                       e Zd ZeZg dZyr'   r,   r   r    r!   r"   z(OrderProductCustomizationSerializer.Meta  r-   r    r"   Nr#   r   r    r!   r%   r%     r.   r    c                   ~    e Zd Z ej                         Z ej                         Z ej                  dd      Z	 ej                         Z ej                         Z ej                         Z ej                         Z ej                         Z ej                  ddd      Z G d d      Zd Zd	 Z fd
Z xZS )PastOrderListSerializerFT)rm   rl   rj   rk   c                       e Zd ZeZg dZy)PastOrderListSerializer.Meta)rI   rJ   rV   rW   rP   rL   rK   product_namesproduct_imagers   r   NrY   r   r    r!   r"   r     s    
r    r"   c                     |j                   dk(  r|j                  j                  gS |j                  j	                         D cg c]  }|j
                   c}S c c}w )NCustom Orders)rK   r   	item_namerQ   allproduct_name)ra   r   order_products      r!   get_product_namesz)PastOrderListSerializer.get_product_names  sP    >>_,&&0011@C@R@R@TU@T}**@TUUUs   Ac                    |j                   dk(  rPt        j                  j                  |j                        j                         }|r|j                  j                  S |j                  j                         D ]p  }|j                  s|j                  j                  }|s)t        j                  j                  |      j                         }|sZ|j                  j                  c S  y )Nr   )r   )product)rK   r   r   r   r   r   imager   rQ   r   r8   r   r   )ra   r   product_image_customr   r   r   s         r!   get_product_imagez)PastOrderListSerializer.get_product_image  s    >>_,#5#=#=#D#D"11 $E $eg ! $+11555 ^^//1M $$#''//G (0077 8 eg  $**...! 2$ r    c                 R    t         |   |      }|j                  d      sd|d<   |S )NrW   zNot Providedr\   )ra   rb   datard   s      r!   r^   z)PastOrderListSerializer.to_representation  s/    w(2xx,-)7D%&r    )r   r   r   r   r@   rJ   	DateFieldrV   	TimeFieldrW   
FloatFieldrP   rL   rK   r   r   r   rs   r"   r   r   r^   rf   rg   s   @r!   r   r     s    ${$$&H...0...$O(+((*K(;((*L&&&(J5K557M5K557M(;((0KX\fklL
 
 V
8 r    r   c                        e Zd Z G d d      Zy)ProductSerializerc                       e Zd ZeZg dZy)ProductSerializer.Meta)r)   r   	item_codeN)r   r   r   r   r   r   r   r    r!   r"   r     s    1r    r"   Nr#   r   r    r!   r   r     s    2 2r    r   c                        e Zd Z G d d      Zy)CouponSerializerc                       e Zd ZeZg dZy)CouponSerializer.Meta)r)   
CouponName
CouponCodeN)r   r   r   r   r   r   r   r    r!   r"   r   "  s    3r    r"   Nr#   r   r    r!   r   r   !  s    4 4r    r   c                        e Zd Z G d d      Zy)DiscountSerializerc                       e Zd ZeZg dZy)DiscountSerializer.Meta)r)   DiscountNameDiscountCodeNr   r   r   r   r   r   r   r    r!   r"   r   '  s    7r    r"   Nr#   r   r    r!   r   r   &  s    8 8r    r   c                       e Zd Z ej                  dd      Z ej                  dd      Z ed      Z e	d      Z
 ed      Z G d d      Zy)	AdSerializerStandardImageF)r2   rm   BannerImage)rm   c                       e Zd ZeZg dZy)AdSerializer.Meta)	AdTitleAdDescriptionAdPlacementAdType	web_imagemobile_imager   CouponProductN)r   r   r   r
   r   r   r   r    r!   r"   r  5  s    

r    r"   N)r   r   r   r   
ImageFieldr  r  r   r   r   r	  r   r
  r"   r   r    r!   r   r   -  sR    &&&oNI);))OL!51Hu-F/G
 
r    r   c                        e Zd Z G d d      Zy)DiscountDetailSerializerc                       e Zd ZeZg dZy)DiscountDetailSerializer.Meta)r)   r   r   DiscountDescription
DiscountOnApplicableCategoryApplicableSubCategoryApplicableProductApplicableSkuDiscountPercentager   r   Nr   r   r    r!   r"   r  D  s     hr    r"   Nr#   r   r    r!   r  r  C  s    h hr    r  c                        e Zd Z G d d      Zy)OrderBillDetailsSerializerc                       e Zd ZeZg dZy)OrderBillDetailsSerializer.Meta)rM   rN   rO   rP   total_savingscoupon_savingsrw   NrY   r   r    r!   r"   r  J  s     Cr    r"   Nr#   r   r    r!   r  r  I  s    C Cr    r  N)&rest_frameworkr   modelsr   r   r   r   r	   r
   r   r   r   r   django.urlsr   products.modelsr   r   r   products.serializersr   ModelSerializerr   r%   r0   rB   ri   r   r   r   r   r   r   r   r   r   r  r  r   r    r!   <module>r#     sm   & `  `  `  F F 8* ; ; *7+*E*E 7
[88 
0K77 FDk11 DLj{:: jM{22 M`(+"="= (blK77 ln7+*E*E 7BCk99 CJ233 2
4{22 4
844 8
;.. 
,h{:: hC!<!< Cr    