
    j                     P    d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	  G d d      Z
y)	aI  
Pricing service for Aimantis dashboard.

Calculates average nightly rates (ADR) for:
- Today
- Next 7 days
- Next 30 days

Uses centralized dashboard_metrics_service for proper PMS stay-night
expansion logic consistent with ISTAT and city tax calculations.

All monetary calculations use Decimal to avoid floating-point issues.
    )date)DictOptional)calculate_all_adr_metrics)	get_todayc                   :    e Zd ZdZddee   fdZdeee	f   fdZ
y)PricingServicea  
    Service for calculating average nightly rates (ADR).
    
    Delegates to centralized dashboard_metrics_service which implements
    proper PMS stay-night expansion logic:
    - check_in_date is INCLUDED
    - check_out_date is EXCLUDED
    - Revenue allocated per night: total_price / length_of_stay
    - Only checked-in bookings for today
    - All bookings (checked-in + future) for 7/30-day windows
    
    All monetary calculations use Decimal to avoid
    floating-point precision issues.
    Nstructure_idc                 0    || _         t               | _        y)z
        Initialize the pricing service.
        
        Args:
            structure_id: Optional structure ID for multi-tenant filtering
        N)r
   r   today)selfr
   s     ./backend/dashboard/services/pricing_service.py__init__zPricingService.__init__&   s     )[
    returnc                 D    t        | j                  | j                        S )a  
        Get all average rate metrics in a single optimized call.
        
        Uses centralized ADR calculation with proper PMS logic.
        
        Returns:
            Dict with average rates for different time windows:
            - today: ADR for today (checked-in bookings only)
            - next_7_days: ADR for next 7 days (all bookings)
            - next_30_days: ADR for next 30 days (all bookings)
        )r
   r   )r   r
   r   )r   s    r   get_average_ratesz PricingService.get_average_rates0   s!     )****
 	
r   )N)__name__
__module____qualname____doc__r   intr   r   strfloatr    r   r   r	   r	      s,    !Xc] !
4U
#3 
r   r	   N)r   datetimer   typingr   r   ,dashboard.services.dashboard_metrics_servicer   dashboard.services.utilsr   r	   r   r   r   <module>r       s"     ! R .)
 )
r   