o
    4%iV                     @   s  d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
 d dlmZ d dlmZmZ G dd dejZG d	d
 d
ejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd  d ejZG d!d" d"ejZG d#d$ d$ejZG d%d& d&ejZ G d'd( d(ejZ!G d)d* d*ejZ"G d+d, d,ejZ#G d-d. d.ejZ$G d/d0 d0ejZ%G d1d2 d2ejZ&G d3d4 d4ejZ'G d5d6 d6ejZ(dS )7    )models)DecimalN)SKUProductsProductSubCategoryProductCategoryCustomProduct)Users)ShopProductionUnitc                   @   s   e Zd ZejddddZejdddddZejddddddZej	e
ejddd	Zejd
ddgddZejd
ddgddZejdddZejdddZdd ZdS )DeliveryBoys   T
max_lengthblanknull   )r   r   r   uniquezemail address   )verbose_namer   r   r   r   	on_deleter   r   d   )assignedr   )not assignedr   r   r   choicesdefault)not verifiedr   )verifiedr   r   )auto_now_addr   )auto_nowr   c                 C      d| j  S )NzDelivery Boy )team_member_nameself r&   7/var/www/html/Testing_prj/Navya-Bakers/orders/models.py__str__      zDeliveryBoys.__str__N)__name__
__module____qualname__r   	CharFieldr#   phone_number
EmailFieldemail
ForeignKeyr
   CASCADEshopdelivery_boy_statusstatusDateTimeFieldcreated_dateupdated_dater(   r&   r&   r&   r'   r   
   s(    
r   c                   @   s   e Zd ZejdejdddZejddZejddZ	ejddZ
ejddddZejddZejd	dddZejddZe Ze Ze Zejdg d
dZejddZdS )DropaddressTFprimary_keyr   r   editable   r   r      r   2   ))homerA   )workrB   )othersrC   r   r   r   N)r*   r+   r,   r   	UUIDFielduuiduuid4r-   namehouse_number_or_namestreet	land_markcitydistrictstate_or_provinceIntegerFieldpin_code
FloatFieldlatitude	longitudeaddress_typecontact_numberr&   r&   r&   r'   r9   "   s&    
r9   c                   @   s  e Zd ZejdejdddZejddddZejdg d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dg d
dZejeejddidZejeddejdZejeejdddZejeejdddZejeejdddZejddd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%ddd	Z&ej'ddd	Z(ejddg ddZ)ej"ddZ*ej"ddZ+ej"d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	Z0ejddd	Z1ejddg ddZ2dd Z3dS )OrdersTFr:   r   r   r@   )Local OrdersrX   )Long Distance OrdersrY   )Custom OrdersrZ   Pick Upr\   rD   r   r   )	New Orderr_   )Enquiryr`   )	Confirmedra   )Viewedrb   )Order Packedrc   )Delivery Assignedrd   )
Despatchedre   )	Contactedrf   )Bill Createdrg   )	Deliveredrh   )Failedri   	user_typeCustomer)r   limit_choices_tor   r   r   r   ))Whitern   )Yellowro   )Orangerp   )Redrq   )zDark Redz	Dark  Red)r   r   r   r    r!   ))Andriodrt   )IOSru   )Webrv   )Otherrw   c                 C      dt | j d t | j S NzOrderID:z       Order_type    strorder_ID
order_typer$   r&   r&   r'   r(         zOrders.__str__N)4r*   r+   r,   r   rE   rF   rG   r-   r|   r}   rQ   	sub_totaltaxes_and_chargesdelivery_chargesgrand_totalorder_statusr1   r	   r2   	user_uuidr
   SET_NULL
store_uuidr   pu_uuidr   custom_productOneToOneFieldr9   drop_addressdelivery_boy	TextFielddelivery_instructioncooking_instructionr6   order_assigntimeorder_delivered_time	DateFielddelivery_slot_date	TimeFielddelivery_slot_timecolor_statuscolor_status_updation_timer7   r8   total_savingscoupon_savingsdiscountdescriptionmessageplatformr(   r&   r&   r&   r'   rV   8   sp    
	


rV   c                   @   s`   e Zd ZejddejdZejddddZej	ddddZ
ej	ddddZej	d	g d
dZdS )CustomOrderTrackingrV   custom_orderrelated_namer   zcustomize_images/T	upload_tor   r      r   r@   ))gramsr   )kgr   )nosr   rD   N)r*   r+   r,   r   r1   r2   order_id
ImageFieldcustom_imager-   quantitydelivery_typequantity_unitr&   r&   r&   r'   r      s    
r   c                   @   st   e Zd ZejdejdddZejddddZ	ej
eddejdZejddddZejdddZej
ed	ejd
ZdS )OrderProductsTFr:   r   r   sku)r   r   r   r]   
order_datar   N)r*   r+   r,   r   rE   rF   rG   order_product_idr-   product_namer1   r   r   r   r   rQ   pricerV   r2   orderr&   r&   r&   r'   r      s    


r   c                   @   sT   e Zd ZejddejdZejdddZej	ddddZ
ejdddd	Zd
d ZdS )OrderProductCustomizationr   customizationsr   Tr]   zorder_custom_images/r   r   r   c                 C   s   d| j jpd S )NCustomization for Unnamed)order_productr   r$   r&   r&   r'   r(         z!OrderProductCustomization.__str__N)r*   r+   r,   r   r1   r2   r   r   custom_noter   r   r-   custom_image_idr(   r&   r&   r&   r'   r      s    r   c                   @   s   e Zd Zejdg ddZejeejdddZ	ejddddZ
ejddddZejdddZejdddZejeejdddZd	S )
OrderDeliveryr@   ))Own Deliveryr   )Courier Deliveryr   r[   rD   Tr   r   r   r]   N)r*   r+   r,   r   r-   r   r1   r   r2   r   courier_service_namepackage_numberr   expected_date_of_deliveryURLFieldtracking_linkrV   r   r&   r&   r&   r'   r      s    
r   c                   @   st   e Zd ZejeddejdZejddddZ	ej
ddZej
ddZejdddejdZejddddZdd	 Zd
S )CartT)r   r   r   r@   r   r   r   rr   rs   Couponsc                 C   s&   d| j sdt| j  S | j j S )Nz	Cart for zanonymous user)userr{   anonymous_id
first_namer$   r&   r&   r'   r(      s   &zCart.__str__N)r*   r+   r,   r   r   r	   r2   r   r-   r   r6   
created_at
updated_atr1   couponcustom_couponr(   r&   r&   r&   r'   r      s    r   c                   @   sB   e Zd ZejedejdZejdejdZej	ddZ
dd Zd	S )
CartItemitemsr   zproducts.SKUr      r   c                 C   s   | j  d| jj dS )Nz of z in Cart)r   r   sku_namer$   r&   r&   r'   r(         zCartItem.__str__N)r*   r+   r,   r   r1   r   r2   cartr   PositiveIntegerFieldr   r(   r&   r&   r&   r'   r      s
    r   c                   @   sZ   e Zd ZejddejdZejdddZej	ddddZ
ejdddZdd	 Zd
d ZdS )CartItemCustomizationr   r   r   Tr]   zcustom_images/r   c                 C   s   t | jp	| jp	| jS N)boolr   r   r   r$   r&   r&   r'   has_customization   r   z'CartItemCustomization.has_customizationc                 C   r"   )Nr   )	cart_itemr$   r&   r&   r'   r(      r)   zCartItemCustomization.__str__N)r*   r+   r,   r   r1   r2   r   r   r   r   r   r   r   r(   r&   r&   r&   r'   r      s    r   c                   @   s>  e Zd ZejddddZejddddZejddddZejddddZ	ej
edddZejg dd	d
Zej
eddZej
eddZej
eddZej
eddZejddddZejdddZejdddZejddgdd
Ze Ze Ze ZejddddZ ejdddZ!ejddZ"ejddddZ#dd Z$dS )r   r@   Tr   r?   zicons/r   r   r   r   r   )Categoryr   )SubCategoryr   Productr   )Skur   (   r   r   r   r   )amountr   )
percentager     rr   z3Maximum discount amount when percentage is selected)r   r   	help_textc                 C      d| j  d| j S )NzCoupons--)
CouponName
CouponCoder$   r&   r&   r'   r(        zCoupons.__str__N)%r*   r+   r,   r   r-   r   r   CouponDescriptionr   IconManyToManyFieldr	   
CouponUsedCouponOnr   ApplicableCategoryr   ApplicableSubCategoryr   ApplicableProductr   ApplicableSkurQ   TotalBillAmountrO   DiscountAmountDiscountPercentage
CouponTypeMaxNumberofUsersr6   Validity_start_datevalidity_end_dateTermsAndConditionsNotificationScheduler   MaxDiscountAmountForPercentager(   r&   r&   r&   r'   r      s.    r   c                   @   s\   e Zd Ze Ze ZejddZej	dddgddZ
ejddZd	d
 Zedd ZdS )DeliverySlotTr   r   )activeActive)inactiveInactiver  r   rr   c                 C   s   | j d d| jd S )Nz%H:%Mz to )
start_timestrftimeend_timer$   r&   r&   r'   r(        zDeliverySlot.__str__c                 C   s   | j | j S r   )r
  r  r$   r&   r&   r'   duration!  s   zDeliverySlot.durationN)r*   r+   r,   r   r   r  r
  BooleanFieldis_availabler-   r5   r6   r   r(   propertyr  r&   r&   r&   r'   r    s    
r  c                   @   s   e Zd ZejddddZejdddddZejddddZejg dddZej	e
dd	Zej	edd	Zej	edd	Zej	edd	Zejd
ddddZejddZejddddZejddddZdd ZdS )Discountr@   Tr   )r   r   r   r   r?   r   r   r   r         
max_digitsdecimal_placesr   r   rr   standard_images/r   banners/c                 C   r   )Nz	Discount-r   )DiscountNameDiscountCoder$   r&   r&   r'   r(   4  r   zDiscount.__str__N)r*   r+   r,   r   r-   r  r  DiscountDescription
DiscountOnr   r   r   r   r   r   r   r   r   DecimalFieldr   r6   r   r   StandardImageBannerImager(   r&   r&   r&   r'   r  &  s    r  c                   @   s   e Zd ZejdejdddZg dZejddddZ	ejddddZ
ejdddd	Zejg d
ddZejddddZejddddZejeejdddZejeejdddZejeejdddZejddZdd Zdd ZdS )AdsTFr:   ))Topr   )Bottomr!  )Bannerr"  r@   r   r?   r   r   ))r  r  )Couponr#  r   r   r   r  r   r  r   r   r   rr   c                 C      | j S r   )AdTitler$   r&   r&   r'   r(   J     zAds.__str__c                    s.   t | j | js
g S  fdd| jdD S )Nc                    s   g | ]
}| v r | qS r&   r&   ).0	placementplacement_dictr&   r'   
<listcomp>Q  s    z-Ads.get_placement_display.<locals>.<listcomp>,)dictplacement_choicesAdPlacementsplitr$   r&   r*  r'   get_placement_displayM  s   
zAds.get_placement_displayN)r*   r+   r,   r   rE   rF   rG   r/  r-   r&  AdDescriptionr   r0  AdTyper   r  r  r1   r  r2   r   r#  r   r   r6   r   r(   r2  r&   r&   r&   r'   r  9  s"    
r  c                   @   sj   e Zd Zg dZejdejddZejdedZ	ej
dddZejeejdddZejdd	Zd
d ZdS )Message))Emailr6  )SmsSMS)WhatsappWhatsAppTFr;   r   r<   r   rD   r   r$  rr   c                 C   r%  r   )message_typer$   r&   r&   r'   r(   _  r'  zMessage.__str__N)r*   r+   r,   MESSAGE_TYPE_CHOICESr   rE   rF   rG   r-   r<  r   r   r1   r  r2   adsr6   r   r(   r&   r&   r&   r'   r5  S  s    r5  c                   @   sR   e Zd ZejeddiejdZejeejdZ	ej
ddZejddZd	d
 ZdS )Communicationrj   rk   )rl   r   r   Trr   Fr   c                 C      | j  d| j S )Nz - )r   r   r$   r&   r&   r'   r(   i  r   zCommunication.__str__N)r*   r+   r,   r   r1   r	   r2   r   r5  r   r6   r   r  is_sendr(   r&   r&   r&   r'   r?  c  s    r?  c                   @   sD  e Zd ZejeejdZejddddZ	ejdg dddZ
ejddddZejddddZejddddZejddddZejddddZejddddZejddddZejddddZejddddZejddddZejddddZejddddZejddddZejddddZejddddZejdd	Zd
d ZdS )Paymentr   r   Tr   r@   ))pendingPending)paidPaid)failedri   rC  r   rr   c                 C   s   d| j j d| j S )NzPayment for z - Status: )r   r|   payment_statusr$   r&   r&   r'   r(     r   zPayment.__str__N)r*   r+   r,   r   r   rV   r2   r   r-   bill_desk_order_idrH  	surchargepayment_method_typer   transaction_error_typepayment_categorybank_ref_notransactionidtxn_process_typebankiditemcodetransaction_error_codecurrencyauth_statustransaction_error_desccharge_amountr6   payment_dater(   r&   r&   r&   r'   rB  n  s.    rB  c                   @   sh   e Zd ZejddZejeejdZ	eje
ejdZejddddZejddZejddZd	d
 ZdS )NotificationStatr   r>   r   i  Tr   rr   rs   c                 C   s   t | jt | j S r   )r{   OrderIDsendTor$   r&   r&   r'   r(     r   zNotificationStat.__str__N)r*   r+   r,   r   r-   Sendmsgr1   r	   r2   r[  rV   rZ  Descriptionr6   r7   r8   r(   r&   r&   r&   r'   rY    s    rY  c                   @   sx   e Zd ZejdejddZejddZejddZ	ejddddZ
ejeejddd	Zejed
ejdddZdd ZdS )SomeOneElseTFr;  r=   r>   r   r   r   r   some_one_else_order)r   r   r   r   c                 C   s   t | jd t | j S N_)r{   rH   r.   r$   r&   r&   r'   r(     s   zSomeOneElse.__str__N)r*   r+   r,   r   rE   rF   rG   r-   rH   r.   r   r   r   r   r   rV   r2   ordersr(   r&   r&   r&   r'   r^    s    r^  c                   @   s   e Zd ZejdejdddZejddddZejdg ddZ	ej
ddd	Zejdg d
dZejeddejdZejeejdddZejeejdddZejddd	Zejddd	Ze Zejddd	Zejddd	Zdd ZdS )DeletedOrdersTFr:   r   r   r@   rW   rD   r]   r^   rm   r   c                 C   rx   ry   rz   r$   r&   r&   r'   r(     r~   zDeletedOrders.__str__N)r*   r+   r,   r   rE   rF   rG   r-   r|   r}   rQ   r   r   r1   r
   r   r   r   r   r   r2   r   r6   r   r   r7   r   r   r   r(   r&   r&   r&   r'   rc    s6    



rc  c                   @   sx   e Zd ZejddeddZejddeddZejddeddZejddeddZ	ejddeddZ
d	d
 ZdS )DeliverySettings
   r  z20.0)r  r  r   r  z3.0z5.0z0.0c                 C   s   d| j  d| j d| j dS )Nu   Base Fee: ₹z for u    km, ₹z	/km after)base_feebase_km
per_km_feer$   r&   r&   r'   r(     r  zDeliverySettings.__str__N)r*   r+   r,   r   r  r   rf  rg  rh  free_delivery_min_order_valuefree_delivery_max_distancer(   r&   r&   r&   r'   rd    s    rd  c                   @   s0   e Zd ZejdddZejdddZdd ZdS )DeliveryDiscountre  r  )r  r  r  c                 C   r@  )Nu   % off for orders > ₹)discount_percentmin_order_valuer$   r&   r&   r'   r(     r   zDeliveryDiscount.__str__N)r*   r+   r,   r   r  rm  rl  r(   r&   r&   r&   r'   rk    s    rk  c                   @   sh   e Zd ZejddddZejdddZejdddddZ	ejdddddZ
ejdddddZdd	 Zd
S )CustomCouponSettingsr   Tr   r   re  r  r  c                 C   s   | j  S r   )coupon_namer$   r&   r&   r'   r(     s   zCustomCouponSettings.__str__N)r*   r+   r,   r   r-   ro  r   coupon_descriptionr  lower_limit_pricehigher_limit_pricediscount_amountr(   r&   r&   r&   r'   rn    s    rn  c                   @   sX   e Zd ZejddddZejeejdddZ	eje
ejdddZejddZdd ZdS )	CustomCouponr@   Tr   r   rr   c                 C   s   | j j d| j S r`  )r   ro  coupon_coder$   r&   r&   r'   r(     r   zCustomCoupon.__str__N)r*   r+   r,   r   r-   ru  r1   rn  r2   r   r	   r   r6   r7   r(   r&   r&   r&   r'   rt    s    rt  ))	django.dbr   decimalr   rF   products.modelsr   r   r   r   r   accounts.modelsr	   shops.modelsr
   r   Modelr   r9   rV   r   r   r   r   r   r   r   r   r  r  r  r5  r?  rB  rY  r^  rc  rd  rk  rn  rt  r&   r&   r&   r'   <module>   s<    \
:
	