From 00b9427bc716ca6164603749a27ba5c9883b932b Mon Sep 17 00:00:00 2001 From: yofaka Date: Fri, 25 Sep 2026 21:56:52 +0300 Subject: [PATCH] Bug a: due to incorrect timezone definitiion in comparison Bug b: caching issue after checking tenant a when checking tenant-b acct data is shown from tenant-a the key for caching is only tagged with property-id not tenant_id causing mismatch when fetching from cache. --- backend/app/services/cache.py | 2 +- backend/app/services/reservations.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/app/services/cache.py b/backend/app/services/cache.py index b81474957..672e3f9d6 100644 --- a/backend/app/services/cache.py +++ b/backend/app/services/cache.py @@ -10,7 +10,7 @@ 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:{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..a4596b83f 100644 --- a/backend/app/services/reservations.py +++ b/backend/app/services/reservations.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timezone from decimal import Decimal from typing import Dict, Any, List @@ -7,11 +7,11 @@ async def calculate_monthly_revenue(property_id: str, month: int, year: int, db_ Calculates revenue for a specific month. """ - start_date = datetime(year, month, 1) + start_date = datetime(year, month, 1, tzinfo=timezone.utc) if month < 12: - end_date = datetime(year, month + 1, 1) + end_date = datetime(year, month + 1, 1, tzinfo=timezone.utc) else: - end_date = datetime(year + 1, 1, 1) + end_date = datetime(year + 1, 1, 1, tzinfo=timezone.utc) print(f"DEBUG: Querying revenue for {property_id} from {start_date} to {end_date}")