Repository navigation
Conversation
- Cache revenue per tenant (key was property-only; prop-001 exists in two tenants) - Fix DB pool so dashboard reads Postgres instead of hardcoded mock data: use settings.database_url, drop sync QueuePool, make get_session sync, share one pool, add sqlalchemy[asyncio] for greenlet - Remove tenant-agnostic mock revenue fallback; surface DB errors - Reject users without a tenant instead of defaulting to tenant-a - Round revenue with Decimal ROUND_HALF_UP server-side - Month bounds in calculate_monthly_revenue use property timezone - Add /dashboard/properties scoped to tenant; frontend selector uses it instead of a hardcoded cross-tenant property list Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the three issues reported on the revenue dashboard.
Cross-tenant data leak (Ocean Rentals)
revenue:{property_id}was shared bytenant-aandtenant-b, which both own aprop-001. Whoever loaded first had their figures cached for 5 minutes and shown to the other company. Key is nowrevenue:{tenant_id}:{property_id}.calculate_total_revenuereturned hardcoded per-property figures to every tenant. Removed; errors now surface.TenantResolverdefaulted unknown users totenant-a, and the dashboard defaulted to"default_tenant". Both now refuse instead: no tenant / 403.GET /api/v1/dashboard/propertiesreturns only the caller's properties, and the frontend uses it.Wrong March totals (Sunset Properties)
DatabasePoolhad four bugs:supabase_db_*settings.QueuePoolon an async engine.get_sessionwasasync defbut used withasync with.greenletwas missing (fixed withsqlalchemy[asyncio]).prop-001shows 2250.00 / 4 bookings. The mock showed 1000.00 / 3 and droppedres-tz-1, which is 2024-02-29 23:30 UTC = 1 March in Europe/Paris.calculate_monthly_revenuenow computes month boundaries in the property's timezone and takestenant_id.Totals off by a few cents
NUMERIC(10,3). They were converted tofloatand then rounded in JS withMath.round(x*100)/100. They are now rounded server-side withDecimal.quantize(..., ROUND_HALF_UP).Test plan
docker compose up -d --build(the backend needs the newgreenletdependency)docker compose exec redis redis-cli FLUSHALL(the old cache keys are tenant-less)sunset@propertyflow.com: the selector lists only Beach House Alpha, City Apartment Downtown and Country Villa Estate;prop-001shows 2250.00, 4 bookingsocean@propertyflow.com: the selector lists only Mountain Lodge Beta, Lakeside Cottage and Urban Loft Modern;prop-001shows 0.00, not Sunset's figures🤖 Generated with Claude Code