diff --git a/backend/app/services/cache.py b/backend/app/services/cache.py index b81474957..d797c8b9d 100644 --- a/backend/app/services/cache.py +++ b/backend/app/services/cache.py @@ -10,7 +10,9 @@ async def get_revenue_summary(property_id: str, tenant_id: str) -> Dict[str, Any """ Fetches revenue summary, utilizing caching to improve performance. """ - cache_key = f"revenue:{property_id}" + # cache_key = f"revenue:{property_id}" + # The cache key is fixed 112233 + cache_key = f"revenue:{tenant_id}:{property_id}" # Try to get from cache cached = await redis_client.get(cache_key) diff --git a/backend/app/services/reservations.py b/backend/app/services/reservations.py index 384bd00ab..89f60a0b3 100644 --- a/backend/app/services/reservations.py +++ b/backend/app/services/reservations.py @@ -48,10 +48,22 @@ async def calculate_total_revenue(property_id: str, tenant_id: str) -> Dict[str, # Use SQLAlchemy text for raw SQL from sqlalchemy import text + # query = text(""" + # SELECT + # property_id, + # SUM(total_amount) as total_revenue, + # COUNT(*) as reservation_count + # FROM reservations + # WHERE property_id = :property_id AND tenant_id = :tenant_id + # GROUP BY property_id + # """) + + # Small rounding error fixed 112233 + query = text(""" SELECT property_id, - SUM(total_amount) as total_revenue, + SUM(ROUND(total_amount, 2)) as total_revenue, COUNT(*) as reservation_count FROM reservations WHERE property_id = :property_id AND tenant_id = :tenant_id