o
    î|iŠ  ã                   @   s*   d dl Zd dlmZ G dd„ dejƒZdS )é    N)ÚVehiclec                	   @   sL  e Zd ZdZejedejdd�ZdZ	ej
de	dd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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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ejd
d�Zejd
d�Zejd
d�ZddgddœgddœZdd„ Z dde!de"de!de"fdd„Z#dS )ÚVehiclePricingz§
    Stores pricing details directly linked to a specific vehicle,
    including hourly and monthly rates for small (S), medium (M),
    and large (L) categories.
    Tz$The vehicle this pricing belongs to.)ÚrequiredÚreverse_delete_ruleÚ	help_text)ÚASSIGNEDÚNOT_ASSIGNEDr   z;Indicates whether the pricing is currently assigned or not.)r   ÚchoicesÚdefaultr   )r   g        )r
   Úvehicle_pricingÚvehicle)ÚfieldsÚuniqueF)Ú
collectionÚindexesÚstrictc                 C   sN   t t| jddƒƒ}t| jdd ƒrt| jjddƒnd}d|› d|› d| j› d	�S )
NÚidÚUnknownÚmodelÚnamezUnknown ModelzPricing for z (ID: z) [ú])ÚstrÚgetattrr   r   Ústatus)ÚselfÚ
vehicle_idÚvehicle_model© r   ú;/var/www/html/Moveonwheels/move_on_wheels/pricing/models.pyÚ__str__K   s   "zVehiclePricing.__str__ÚhourlyÚsizeÚtotal_kmÚduration_typeÚreturnc                 C   s„   |dkrt | d|› �ƒ}t | d|› �ƒ}t | d|› �ƒ}nt | d|› �ƒ}t | d|› �ƒ}t | d|› �ƒ}td|| ƒ}|||  S )	zÔ
        Calculate total cost based on:
        - duration_type: 'hourly' or 'monthly'
        - size: 's', 'm', or 'l'
        - total_km: distance traveled in kilometers
        Includes base_KM logic.
        ÚmonthlyÚmonthly_price_Úmonthly_base_km_Úmonthly_extra_price_per_km_Úhourly_price_Úhourly_base_km_Úhourly_extra_price_per_km_r   )r   Úmax)r   r!   r"   r#   Ú
base_priceÚbase_kmÚ
extra_rateÚextra_kmr   r   r   Úcalculate_total_priceS   s   z$VehiclePricing.calculate_total_priceN)r    )$Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚmeÚReferenceFieldr   ÚCASCADEr   ÚSTATUS_CHOICESÚStringFieldr   Ú
FloatFieldÚhourly_price_sÚhourly_price_mÚhourly_price_lÚhourly_base_km_sÚhourly_base_km_mÚhourly_base_km_lÚhourly_extra_price_per_km_sÚhourly_extra_price_per_km_mÚhourly_extra_price_per_km_lÚmonthly_price_sÚmonthly_price_mÚmonthly_price_lÚmonthly_base_km_sÚmonthly_base_km_mÚmonthly_base_km_lÚmonthly_extra_price_per_km_sÚmonthly_extra_price_per_km_mÚmonthly_extra_price_per_km_lÚmetar   r   Úfloatr1   r   r   r   r   r      sN    	ü
ü
ý r   )Úmongoenginer6   Úvehicles.modelsr   ÚDocumentr   r   r   r   r   Ú<module>   s    