Skip to content

Fix tenant revenue dashboard calculations - #234

Open
tonycletus wants to merge 1 commit into
Base360-AI:mainfrom
tonycletus:codex/fix-tenant-revenue-dashboard
Open

tonycletus wants to merge 1 commit into
Base360-AI:mainfrom
tonycletus:codex/fix-tenant-revenue-dashboard

Conversation

@tonycletus

Copy link
Copy Markdown

Summary

Fix the revenue dashboard issues described in ASSIGNMENT.md.

Findings and fixes

  • Cross-tenant cache leakage: the revenue cache key used only the property ID. Added tenant ID to the key and made cache read/write failures fall back to the database.
  • Incorrect monthly revenue: the monthly service was a placeholder returning zero. It now queries reservations for the authenticated tenant and property, using the property's local month boundaries.
  • Cents-level discrepancies: aggregate totals are rounded once to cents using decimal arithmetic with half-up rounding.
  • Async database setup: the backend now uses the configured database URL, removes the synchronous pool class from the async engine, and awaits the session context correctly.
  • Unsafe fallback data / tenant context: removed mock revenue results on database errors; the dashboard now requires tenant context and reports unavailable data instead of returning fabricated totals.

Verification

  • Logged in with both provided client accounts and checked their property summaries.
  • Confirmed the same property ID returns tenant-specific totals and separate cache keys.
  • Checked March local-time boundary handling and decimal aggregation.
  • Verified revenue calculation continues if Redis is unavailable.
  • Backend API and frontend returned successfully in the local setup; frontend production build completed.
  • git diff --check passed.

The local Docker database and Redis services were used with the frontend/backend running locally.

@tonycletus
tonycletus marked this pull request as ready for review November 2, 2026 19:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T19:54:22.976842Z 14c9779 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14c9779267

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


result = await session.execute(
text("""
SELECT COALESCE(SUM(total_amount), 0) AS total, COUNT(*) AS reservation_count

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve currency when computing monthly revenue

When a property's monthly reservations include non-USD amounts, this raw sum combines nominal values without conversion, and the dashboard labels the result as USD. Clients therefore see an inaccurate total; convert amounts using an explicit rate or return separate totals by currency.

Useful? React with 👍 / 👎.

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.

1 participant