Skip to content

Juhitha fix financials endpoints validation#1769

Merged
one-community merged 2 commits into
developmentfrom
Juhitha_fix_financials_endpoints_validation
Mar 1, 2026
Merged

Juhitha fix financials endpoints validation#1769
one-community merged 2 commits into
developmentfrom
Juhitha_fix_financials_endpoints_validation

Conversation

@Juhitha-Reddy
Copy link
Copy Markdown
Contributor

Description

Fix backend errors and finalize Financials endpoints for Phase 2 Summary Dashboard. Correct the materials cost calculation and add defensive validation so the UI KPIs can reliably consume:

  • Total Project Cost
  • Material Cost
  • Labor Cost
  • Equipment Cost

Fixes: High bug where Financials endpoints could return 500 for valid requests (incorrect helper usage, missing ObjectId validation).
Implements: Backend support for Phase 2 Financials KPIs (WBS), aligned to frontend integration.

Related PRS (if any):

Main changes explained:

  • Update src/controllers/bmdashboard/bmFinancialController.js
    • Correct calls to calculateMaterialsCost to pass only projectId (previously passed model + id).
    • Add ObjectId validation and clearer errors for:
      • GET /api/financials/project/:projectId/total-cost
      • GET /api/financials/project/:projectId/costs
    • Keep existing response shapes:
      • total-cost{ totalCost }
      • costs{ materialsCost, laborCost, equipmentCost }
      • mom-changes unchanged → { materialCostChange, laborCostChange, equipmentCostChange }
  • No unrelated code or formatting changes.

How to test:

  1. Check into this backend branch.

  2. Environment setup:

    • Use Node 18+ (or 20) and recent npm.
    • Install dependencies:
      npm install
    • If your local start crashes on optional LB/SMS modules, either install missing deps or disable those features locally:
      npm run build
      npm run start
      
  3. run the frontend application.

  4. Navigate to /bmdashboard/totalconstructionsummary → expand “Financials” and verify:

  5. Navigate to /bmdashboard/totalconstructionsummary → expand “Financials” and verify:

    • Project dropdown appears as soon as project IDs load.
    • After financial APIs resolve, four KPI tiles render with values:
      • Total Project Cost (from total-cost)
      • Material/Labor/Equipment (from costs)
      • Optional “MoM: …%” on Equipment when available (from mom-changes).
    • ExpenseBarChart remains visible.
    • Selecting a different project updates KPI values.
  6. Verify the new feature works in dark mode.

Screenshots or videos of changes:

Screen.Recording.2025-10-01.at.9.55.12.PM.mov

Copy link
Copy Markdown

@vivekchandrabs vivekchandrabs left a comment

Choose a reason for hiding this comment

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

I checkout to the backend branch and also to the proper frontend branch, but when I ran the application the project card was not rendering.

image Screenshot 2025-11-14 at 6 53 14 PM

@vivekchandrabs vivekchandrabs self-requested a review November 16, 2025 02:07
@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Dec 19, 2025
Copy link
Copy Markdown

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

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

Hi Juhitha,

I have reviewed your PR locally and the backend works as per requirement.
Screenshot 2025-12-23 at 11 54 22 PM
Screenshot 2025-12-23 at 11 54 42 PM
Screenshot 2025-12-23 at 11 54 53 PM
Screenshot 2025-12-23 at 11 55 01 PM

@one-community
Copy link
Copy Markdown
Member

Thank you all, merging!

@one-community one-community merged commit 3bca3e7 into development Mar 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants