o
    'jja                     @   sx  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(G d7d8 d8ejZ)G d9d: 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 dAdB dBejZ.dS )C    )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&   A/var/www/html/collabkart/collabkart.saasvaap.com/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Z2ejdejdddZ3dd Z4dS )OrdersTFr:   r   r   r@   )Local OrdersrX   )Long Distance OrdersrY   )Custom OrdersrZ   Pick Upr\   rD   r   r   )	New Orderr_   Enquiryra   	Confirmedrc   Viewedre   Order Packedrg   Delivery Assignedri   
Despatchedrk   	Contactedrm   Bill Createdro   	Deliveredrq   Failedrs   )	Cancelledrt   	user_typeCustomer)r   limit_choices_tor   r   r   r   ))Whitery   )Yellowrz   )Oranger{   )Redr|   )zDark Redz	Dark  Red)r   r   r   r    r!   ))Andriodr   )IOSr   )Webr   )Otherr   )Flutter_web_appr   PaymentModesc                 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)5r*   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platformpayment_moder(   r&   r&   r&   r'   rV   8   sv    





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   r}   r~   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     r}   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   r}   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   r}   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/  )Bannerr0  r@   r   r?   r   r   ))r  r  )Couponr1  r   )Othersr2  r   r   r$  r   r%  r   r   r   r}   c                 C      | j S r   )AdTitler$   r&   r&   r'   r(   Q     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>X  s    z-Ads.get_placement_display.<locals>.<listcomp>,)dictplacement_choicesAdPlacementsplitr$   r&   r9  r'   get_placement_displayT  s   
zAds.get_placement_displayN)r*   r+   r,   r   rE   rF   rG   r>  r-   r5  AdDescriptionr   r?  AdTyper   r+  r,  r1   r  r2   r   r1  r   r   r6   r   r(   rA  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))EmailrE  )SmsSMS)WhatsappWhatsAppTFr;   r   r<   r   rD   r   r3  r}   c                 C   r4  r   )message_typer$   r&   r&   r'   r(   f  r6  zMessage.__str__N)r*   r+   r,   MESSAGE_TYPE_CHOICESr   rE   rF   rG   r-   rK  r   r   r1   r-  r2   adsr6   r   r(   r&   r&   r&   r'   rD  Z  s    rD  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 )Communicationru   rv   )rw   r   r   Tr}   Fr   c                 C      | j  d| j S )Nz - )r   r   r$   r&   r&   r'   r(   p  r   zCommunication.__str__N)r*   r+   r,   r   r1   r	   r2   r   rD  r   r6   r   r  is_sendr(   r&   r&   r&   r'   rN  j  s    rN  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)failedrs   rR  r   r}   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_idrW  	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'   rQ  u  s.    rQ  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   r}   r~   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   rj  rV   ri  Descriptionr6   r7   r8   r(   r&   r&   r&   r'   rh    s    rh  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 )SomeOneElseTFrJ  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'   rm    s    rm  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^   r`   rb   rd   rf   rh   rj   rl   rn   rp   rr   rx   r   c                 C   r   r   r   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'   rr    s6    



rr  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   ru  rv  rw  free_delivery_min_order_valuefree_delivery_max_distancer(   r&   r&   r&   r'   rs    s    rs  c                   @   s0   e Zd ZejdddZejdddZdd ZdS )DeliveryDiscountrt  r   )r"  r#  r  c                 C   rO  )Nu   % off for orders > ₹)discount_percentmin_order_valuer$   r&   r&   r'   r(     r   zDeliveryDiscount.__str__N)r*   r+   r,   r   r*  r|  r{  r(   r&   r&   r&   r'   rz    s    rz  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   rt  r   r!  c                 C   s   | j  S r   )coupon_namer$   r&   r&   r'   r(     s   zCustomCouponSettings.__str__N)r*   r+   r,   r   r-   r~  r   coupon_descriptionr*  lower_limit_pricehigher_limit_pricediscount_amountr(   r&   r&   r&   r'   r}    s    r}  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   r}   c                 C   s   | j j d| j S ro  )r   r~  coupon_coder$   r&   r&   r'   r(     r   zCustomCoupon.__str__N)r*   r+   r,   r   r-   r  r1   r}  r2   r   r	   r   r6   r7   r(   r&   r&   r&   r'   r    s    r  c                   @   sP   e Zd ZejddZejddZejddZ	ej
ddZej
ddZdd	 Zd
S )r   T)r;   r   r>   r   r}   r~   c                 C   r4  r   )	mode_namer$   r&   r&   r'   r(     r6  zPaymentModes.__str__N)r*   r+   r,   r   	AutoFieldidr-   r  r  r5   r6   r   r   r(   r&   r&   r&   r'   r     s    r   c                   @   s@   e Zd ZejeejdZejddZ	ej
ddZejddZdS )	DeliveryOTPr      r>   Fr   Tr}   N)r*   r+   r,   r   r   rV   r2   r   r-   otpr  is_verifiedr6   r   r&   r&   r&   r'   r    s
    r  c                   @   s   e Zd ZejeejdZejddgdZ	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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ZejddZdS )	Delhiveryr   r@   )	DELHIVERYr  rD   Tr   r   r   CREATED)r   r   r}   r~   N)r*   r+   r,   r   r   rV   r2   r   r-   r   rO   weight_gramsmoder   
awb_numberr   tracking_urlr5   r6   delivered_datepickup_dater   eddr   r   r&   r&   r&   r'   r    s"    r  c                   @   sB   e Zd ZejeejdZejdddZ	ej
ddddZdd ZdS )	AdditionalDetailsr   Tr]   r   r   c                 C   s   d| j j S )NzAdditional Details for )r   r   r$   r&   r&   r'   r(   6  s   zAdditionalDetails.__str__N)r*   r+   r,   r   r   rV   r2   r   r   additional_infor-   mobile_numberr(   r&   r&   r&   r'   r  1  s
    r  c                   @   sf   e Zd Zej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G dd dZd	S )
DeliveryMatrixr   r>   T)db_indexrt  r   c                   @   s   e Zd ZejddgdgZdS )zDeliveryMatrix.Metapincodedestination_city)fieldsN)r*   r+   r,   r   Indexindexesr&   r&   r&   r'   MetaB  s    r  N)r*   r+   r,   r   r-   originrO   r  r  zonetat_surfacetat_expressr  r&   r&   r&   r'   r  :  s    r  c                   @   s(   e Zd ZejeejdZejddZ	dS )
BillEditedr   Fr   N)
r*   r+   r,   r   r1   rV   r2   r   r  	is_editedr&   r&   r&   r'   r  H  s    r  )/	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-  rD  rN  rQ  rh  rm  rr  rs  rz  r}  r  r   r  r  r  r  r  r&   r&   r&   r'   <module>   sH    c
:
	
	