Skip to content

Add debugging support and improve revenue calculations - #140

Open
beki-kel wants to merge 1 commit into
Base360-AI:mainfrom
beki-kel:main
Open

Add debugging support and improve revenue calculations#140
beki-kel wants to merge 1 commit into
Base360-AI:mainfrom
beki-kel:main

Conversation

@beki-kel

Copy link
Copy Markdown
  • Enhanced launch configuration for debugging backend and frontend in VS Code.
  • Created DEBUGGING.md for a comprehensive debugging walkthrough.
  • Updated dashboard.py to handle revenue lookup errors gracefully and ensure accurate revenue calculations using Decimal.
  • Modified database_pool.py to use AsyncAdaptedQueuePool for async database connections.
  • Adjusted cache.py to include tenant_id in cache keys for accurate revenue summaries.
  • Improved reservations.py to calculate monthly revenue based on property timezone.
  • Updated requirements.txt to specify sqlalchemy with asyncio support.
  • Added docker-compose.debug.yml for debugging without rebuilding the image.
  • Refined RevenueSummary.tsx to prevent floating-point precision issues.

- Introduced .gitignore to exclude local environment files and Vite cache.
- Enhanced launch configuration for debugging backend and frontend in VS Code.
- Created DEBUGGING.md for a comprehensive debugging walkthrough.
- Updated dashboard.py to handle revenue lookup errors gracefully and ensure accurate revenue calculations using Decimal.
- Modified database_pool.py to use AsyncAdaptedQueuePool for async database connections.
- Adjusted cache.py to include tenant_id in cache keys for accurate revenue summaries.
- Improved reservations.py to calculate monthly revenue based on property timezone.
- Updated requirements.txt to specify sqlalchemy with asyncio support.
- Added docker-compose.debug.yml for debugging without rebuilding the image.
- Refined RevenueSummary.tsx to prevent floating-point precision issues.
Copilot AI review requested due to automatic review settings July 31, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves developer debugging ergonomics (VS Code + Docker attach workflow) and fixes correctness issues in revenue reporting by tightening tenant isolation, using async-safe SQLAlchemy pooling, and eliminating floating-point rounding drift.

Changes:

  • Add end-to-end debugging docs and VS Code/Docker configurations (local launch + Docker attach).
  • Fix revenue isolation/accuracy: tenant-scoped cache keys, DB-backed revenue queries, Decimal rounding on the backend, and timezone-correct month boundaries.
  • Update async DB infrastructure: use AsyncAdaptedQueuePool and correct session factory usage; update requirements to include SQLAlchemy asyncio extras.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
frontend/src/components/RevenueSummary.tsx Removes redundant frontend re-rounding to avoid reintroducing float drift.
docker-compose.debug.yml Adds a compose overlay to run backend under debugpy without rebuilding the image.
DEBUGGING.md Provides a step-by-step debugging walkthrough and reproduction steps for prior bugs.
backend/requirements.txt Switches to sqlalchemy[asyncio] to support async engine runtime requirements.
backend/app/services/reservations.py Moves revenue computation to real DB queries; adds timezone-aware month boundaries and shared pool usage.
backend/app/services/cache.py Fixes cache key to include tenant_id for isolation.
backend/app/core/database_pool.py Corrects async engine pooling (AsyncAdaptedQueuePool) and session context manager behavior.
backend/app/api/v1/dashboard.py Adds error handling (503 on lookup failure) and backend Decimal rounding to cents.
.vscode/launch.json Adds/updates launch + attach configs and a full-stack compound debug config.
.gitignore Ignores local venvs, bytecode, and Vite’s regenerated cache.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return "UTC"


async def calculate_monthly_revenue(property_id: str, tenant_id: str, month: int, year: int, db_session=None) -> Decimal:
Comment on lines +46 to +47
property_timezone = await _get_property_timezone(property_id, tenant_id)
local_tz = ZoneInfo(property_timezone)
Comment on lines 15 to 18
async def get_dashboard_summary(
property_id: str,
current_user: dict = Depends(get_current_user)
) -> Dict[str, Any]:
Comment on lines +24 to +27
except Exception as e:
# Surface the outage instead of serving substitute figures: a revenue
# dashboard must never display numbers it cannot attribute to real data.
logger.error(f"Revenue lookup failed for {property_id} (tenant: {tenant_id}): {e}")
Comment thread docker-compose.debug.yml
Comment on lines +9 to +11
ports:
- "8000:8000"
- "5678:5678" # debugpy
Comment thread docker-compose.debug.yml
Comment on lines +12 to +15
command: >
sh -c "pip install --no-cache-dir debugpy &&
python -m debugpy --listen 0.0.0.0:5678
-m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants