Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/app/services/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CREATE TABLE reservations (
tenant_id TEXT REFERENCES tenants(id),
check_in_date TIMESTAMP WITH TIME ZONE NOT NULL,
check_out_date TIMESTAMP WITH TIME ZONE NOT NULL,
total_amount NUMERIC(10, 3) NOT NULL, -- storing as numeric with 3 decimals to allow sub-cent precision tracking
total_amount NUMERIC(10, 2) NOT NULL, -- storing as numeric with 2 decimals to allow sub-cent precision tracking
currency TEXT DEFAULT 'USD',
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
FOREIGN KEY (property_id, tenant_id) REFERENCES properties(id, tenant_id)
Expand Down
8 changes: 4 additions & 4 deletions database/seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ INSERT INTO properties (id, tenant_id, name, timezone) VALUES

-- Sample reservation data (tenant-a).
INSERT INTO reservations (id, property_id, tenant_id, check_in_date, check_out_date, total_amount) VALUES
('res-tz-1', 'prop-001', 'tenant-a', '2024-02-29 23:30:00+00', '2024-03-05 10:00:00+00', 1250.000);
('res-tz-1', 'prop-001', 'tenant-a', '2024-02-29 23:30:00+00', '2024-03-05 10:00:00+00', 1250.00);

-- Additional sample reservation data.
INSERT INTO reservations (id, property_id, tenant_id, check_in_date, check_out_date, total_amount) VALUES
-- prop-001: Beach House Alpha (tenant-a)
('res-dec-1', 'prop-001', 'tenant-a', '2024-03-15 10:00:00+00', '2024-03-18 10:00:00+00', 333.333),
('res-dec-2', 'prop-001', 'tenant-a', '2024-03-16 10:00:00+00', '2024-03-19 10:00:00+00', 333.333),
('res-dec-3', 'prop-001', 'tenant-a', '2024-03-17 10:00:00+00', '2024-03-20 10:00:00+00', 333.334),
('res-dec-1', 'prop-001', 'tenant-a', '2024-03-15 10:00:00+00', '2024-03-18 10:00:00+00', 333.33),
('res-dec-2', 'prop-001', 'tenant-a', '2024-03-16 10:00:00+00', '2024-03-19 10:00:00+00', 333.33),
('res-dec-3', 'prop-001', 'tenant-a', '2024-03-17 10:00:00+00', '2024-03-20 10:00:00+00', 333.33),

-- prop-002: City Apartment Downtown (tenant-a) - High-value urban property
('res-004', 'prop-002', 'tenant-a', '2024-03-05 14:00:00+00', '2024-03-08 11:00:00+00', 1250.00),
Expand Down