o
    hR                     @   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&dS )3    )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                   @   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)related_namer   r   r]   
order_datar   r   N)r*   r+   r,   r   rE   rF   rG   order_product_idr-   product_namer1   r   r   r   quantityrQ   pricerV   r2   orderr&   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-   delivery_typer1   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   customizationsr   Tr]   zcustom_images/)	upload_tor   r   c                 C   s   t | jp	| jp	| jS N)boolcustom_notecustom_imagecustom_image_idr$   r&   r&   r'   has_customization   r   z'CartItemCustomization.has_customizationc                 C   r"   )NzCustomization for )	cart_itemr$   r&   r&   r'   r(      r)   zCartItemCustomization.__str__N)r*   r+   r,   r   r1   r2   r   r   r   
ImageFieldr   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(     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(   /     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>6  s    z-Ads.get_placement_display.<locals>.<listcomp>,)dictplacement_choicesAdPlacementsplitr$   r&   r  r'   get_placement_display2  s   
zAds.get_placement_displayN)r*   r+   r,   r   rE   rF   rG   r!  r-   r  AdDescriptionr   r"  AdTyper   r  r  r1   r  r2   r   r  r   r   r6   r   r(   r$  r&   r&   r&   r'   r    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))Emailr(  )SmsSMS)WhatsappWhatsAppTFr;   r   r<   r   rD   r   r  rr   c                 C   r  r   )message_typer$   r&   r&   r'   r(   D  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'   r'  8  s    r'  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(   N     zCommunication.__str__N)r*   r+   r,   r   r1   r	   r2   r   r'  r   r6   r   r   is_sendr(   r&   r&   r&   r'   r1  H  s    r1  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   r6  r   rr   c                 C   s   d| j j d| j S )NzPayment for z - Status: )r   r|   payment_statusr$   r&   r&   r'   r(   l  r   zPayment.__str__N)r*   r+   r,   r   r   rV   r2   r   r-   bill_desk_order_idr;  	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'   r5  S  s.    r5  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(   z  r   zNotificationStat.__str__N)r*   r+   r,   r   r-   Sendmsgr1   r	   r2   rN  rV   rM  Descriptionr6   r7   r8   r(   r&   r&   r&   r'   rL  r  s    rL  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'   rQ  ~  s    rQ  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'   rV    s6    



rV  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   rY  rZ  r[  free_delivery_min_order_valuefree_delivery_max_distancer(   r&   r&   r&   r'   rW    s    rW  c                   @   s0   e Zd ZejdddZejdddZdd ZdS )DeliveryDiscountrX  r  )r  r  r  c                 C   r2  )Nu   % off for orders > ₹)discount_percentmin_order_valuer$   r&   r&   r'   r(     r3  zDeliveryDiscount.__str__N)r*   r+   r,   r   r  r`  r_  r(   r&   r&   r&   r'   r^    s    r^  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   rX  r  r  c                 C   s   | j  S r   )coupon_namer$   r&   r&   r'   r(     s   zCustomCouponSettings.__str__N)r*   r+   r,   r   r-   rb  r   coupon_descriptionr  lower_limit_pricehigher_limit_pricediscount_amountr(   r&   r&   r&   r'   ra    s    ra  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 rS  )r   rb  coupon_coder$   r&   r&   r'   r(     r   zCustomCoupon.__str__N)r*   r+   r,   r   r-   rh  r1   ra  r2   r   r	   r   r6   r7   r(   r&   r&   r&   r'   rg    s    rg  )'	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'  r1  r5  rL  rQ  rV  rW  r^  ra  rg  r&   r&   r&   r'   <module>   s8    ]
:
	