
    mei	J                     2   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 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   )	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     4E:\Akash\Saasvaap\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!   r6      s    	
r   r!   N)r   r   r   r   	CharFieldr:   r<   r=   r;   r$   r>   r!   r   r   r    r/   r/      sb    ${$$N;H(;((0BCL${$$N;H*[**2UVN8ddSN
 
r   r/   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 )PickUpOrderSerializerTr2   store_uuid.unit_namer0   store_uuid.unit_locationstore_uuid.contact_nor4   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!   rG   5   s    
r   r!   c                 R    t         |   |      }|j                  d      i |d<   |S NrW   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   r/   rP   r   r?   rR   rS   rT   r   rW   r!   r]   __classcell__rc   s   @r    rA   rA   /   sg    0ddKJ/+//7MNI/+//7QRM/+//7NOL3dC
 
( r   rA   c                   H    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d      Z G d d      Z fdZ xZS )OrderSerializerTr2   rB   r0   rC   rD   drop_address.address_typeFr1   
allow_nullrequired!drop_address.house_number_or_namedrop_address.land_markrE   c                       e Zd ZeZg dZy)OrderSerializer.Meta)rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   address_type	address_1	address_2rW   NrX   r   r   r    r!   rp   [       
r   r!   c                 R    t         |   |      }|j                  d      i |d<   |S rZ   r[   r_   s      r    r]   z!OrderSerializer.to_representationr   rd   r   )r   r   r   r/   rP   r   r?   rR   rS   rT   rq   rr   rs   r   rW   r!   r]   re   rf   s   @r    rh   rh   R   s    'TTBJ%%%-CDI)K))1KLM(;((0GHL(;((0KX\fklL%%%-P]alqrI%%%-ERVafgI3dC
 
. r   rh   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!   ry   y   s    ir   r!   Nr"   r   r   r    rw   rw   x   s    j jr   rw   c                   H    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d      Z G d d      Z fdZ xZS )OrderSerializer2Tr2   zpu_uuid.pu_namer0   zpu_uuid.pu_locationzpu_uuid.contact_nori   Frj   rm   rn   rE   c                       e Zd ZeZg dZy)OrderSerializer2.Meta)rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   pu_namepu_location
pu_contactrU   rV   rq   rr   rs   rW   NrX   r   r   r    r!   r      rt   r   r!   c                 R    t         |   |      }|j                  d      i |d<   |S rZ   r[   r_   s      r    r]   z"OrderSerializer2.to_representation   rd   r   )r   r   r   r/   rP   r   r?   r   r   r   rq   rr   rs   r   rW   r!   r]   re   rf   s   @r    r   r   ~   s    'TTBJ#k##+<=G'+''/DEK&&&.BCJ(;((0KX\fklL%%%-P]alqrI%%%-ERVafgI3dC
 
. r   r   c                   F    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 G d d      Z fdZ xZS )CustomOrderCreateSerializerrB   r0   rC   rD   ri   TFrj   rm   rn   rE   c                       e Zd ZeZg dZy) CustomOrderCreateSerializer.Meta)rH   rI   rJ   rK   rL   rM   rN   rO   rQ   rR   rS   rT   rU   rV   rq   rr   rs   custom_productdescriptionmessagerW   NrX   r   r   r    r!   r      s    
r   r!   c                 R    t         |   |      }|j                  d      i |d<   |S rZ   r[   r_   s      r    r]   z-CustomOrderCreateSerializer.to_representation   rd   r   )r   r   r   r   r?   rR   rS   rT   rq   rr   rs   r   r   r   rW   r!   r]   re   rf   s   @r    r   r      s    %%%-CDI)K))1KLM(;((0GHL(;((0KX\fklL%%%-P]alqrI%%%-ERVafgI,>N3dC
 
2 r   r   c                   6    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                         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 fdZ xZS )CustomOrderSerializerrB   r0   rC   rD   ri   TFrj   rm   rn   rE   c                       e Zd ZeZg dZy)CustomOrderSerializer.Meta)rH   rI   rJ   rK   rL   rM   rN   rO   discountrQ   rR   rS   rT   rU   rV   rq   rr   rs   r   r   r   rW   r*   r8   quantity_unitdelivery_typelatitude	longitudeNrX   r   r   r    r!   r      s    
r   r!   c                     	 t         j                  j                  |      }|j                  r2| j                  d   j                  |j                  j                        S y # t         j                  $ r Y y w xY w)Norder_idrequest)r   objectsr^   r*   contextbuild_absolute_uriurlDoesNotExistr`   objcustom_trackings      r    get_custom_imagez&CustomOrderSerializer.get_custom_image  sj    	199==s=KO++||I.AA/B^B^BbBbcc"// 		s   AA! !A76A7c                     	 t         j                  j                  |      }|j                  S # t         j                  $ r Y y w xY wNr   )r   r   r^   r8   r   r   s      r    get_quantityz"CustomOrderSerializer.get_quantity  sD    	199==s=KO"+++"// 		   +. AAc                     	 t         j                  j                  |      }|j                  S # t         j                  $ r Y y w xY wr   )r   r   r^   r   r   r   s      r    get_quantity_unitz'CustomOrderSerializer.get_quantity_unit  D    	199==s=KO"000"// 		r   c                     	 t         j                  j                  |      }|j                  S # t         j                  $ r Y y w xY wr   )r   r   r^   r   r   r   s      r    get_delivery_typez'CustomOrderSerializer.get_delivery_type  r   r   c                     	 t         j                  j                  |      }|j                  dk(  r"|j                  r|j                  j
                  S y # t         j                  $ r Y y w xY wNr   zPick Up)r   r   r^   r   drop_addressr   r   r   s      r    get_latitudez"CustomOrderSerializer.get_latitude&  sc    	199==s=KO,,	9c>N>N''000"// 		   AA A*)A*c                     	 t         j                  j                  |      }|j                  dk(  r"|j                  r|j                  j
                  S y # t         j                  $ r Y y w xY wr   )r   r   r^   r   r   r   r   r   s      r    get_longitudez#CustomOrderSerializer.get_longitude0  sc    	199==s=KO,,	9c>N>N''111"// 		r   c                 R    t         |   |      }|j                  d      i |d<   |S rZ   r[   r_   s      r    r]   z'CustomOrderSerializer.to_representation:  rd   r   )r   r   r   r   r?   rR   rS   rT   rq   rr   rs   r   r   r   rW   SerializerMethodFieldr*   r8   r   r   r   r   r!   r   r   r   r   r   r   r]   re   rf   s   @r    r   r      s3   %%%-CDI)K))1KLM(;((0GHL(;((0KX\glmL%%%-P]alqrI%%%-ERVafgI,t<N3dC 5;446L0{002H5K557M5K557M 1{002H1113I
 
B 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.MetaK  r,   r   r!   Nr"   r   r   r    r$   r$   J  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)rl   rk   ri   rj   c                       e Zd ZeZg dZy)PastOrderListSerializer.Meta)rH   rI   rU   rV   rO   rK   rJ   product_namesproduct_imagerq   r   NrX   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)rJ   r   	item_namerP   allproduct_name)r`   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 ]^  }t        j                  j                  |j                  j                        j                         }|sH|j                  j                  c S  y )Nr   )r   )product)rJ   r   r   filterr   firstimager   rP   r   r   r7   r   )r`   r   product_image_customr   r   s        r    get_product_imagez)PastOrderListSerializer.get_product_image  s    >>_,#5#=#=#D#D"11 $E $eg ! $+11555 ^^//1M(0077%))11 8 eg  $**... 2 r   c                 R    t         |   |      }|j                  d      sd|d<   |S )NrV   zNot Providedr[   )r`   ra   datarc   s      r    r]   z)PastOrderListSerializer.to_representation  s/    w(2xx,-)7D%&r   )r   r   r   r   r?   rI   	DateFieldrU   	TimeFieldrV   
FloatFieldrO   rK   rJ   r   r   r   rq   r!   r   r   r]   re   rf   s   @r    r   r     s    ${$$&H...0...$O(+((*K(;((*L&&&(J5K557M5K557M(;((0KX\fklL
 
 V
 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                         Z ej                         Z ej                         Z ej                         Z ej                         Z
 ej                         Z e       Z e       Z e       Z G d d      Zy)AdSerializerc                       e Zd ZeZg dZy)AdSerializer.Meta)	AdTitleAdDescriptionAdPlacementAdTypeStandardImageBannerImager
   CouponProductN)r   r   r   r	   r   r   r   r   r    r!   r     s    

r   r!   N)r   r   r   r   r?   r   r   r   r   
ImageFieldr   r   r   r
   r   r   r   r   r!   r   r   r    r   r     s    #k##%G)K))+M'+'')K"[""$F*K**,M(+((*K!#H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     s     hr   r!   Nr"   r   r   r    r   r     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)rL   rM   rN   rO   total_savingscoupon_savingsr   NrX   r   r   r    r!   r     s     Cr   r!   Nr"   r   r   r    r   r     s    C Cr   r   N)%rest_frameworkr   modelsr   r   r   r   r	   r
   r   r   r   django.urlsr   products.modelsr   r   r   products.serializersr   ModelSerializerr   r$   r/   rA   rh   rw   r   r   r   r   r   r   r   r   r   r   r   r   r    <module>r     sg   & M  M  M  F F 8* ; ; *7+*E*E 7
[88 
0K77 F$k11 $Lj{:: j${22 $L&+"="= &^kK77 kn7+*E*E 7B5k99 5n233 2
4{22 4
844 8
;.. 
0h{:: hC!<!< Cr   