Skip to content

SaiKrishna add donut chart route and controller for planned cost breakdown#1699

Merged
one-community merged 5 commits intodevelopmentfrom
saikrishna_donutChartForPlannedCostBreakdown
Feb 23, 2026
Merged

SaiKrishna add donut chart route and controller for planned cost breakdown#1699
one-community merged 5 commits intodevelopmentfrom
saikrishna_donutChartForPlannedCostBreakdown

Conversation

@saikrishnaraoyadagiri
Copy link
Contributor

@saikrishnaraoyadagiri saikrishnaraoyadagiri commented Sep 3, 2025

Description

Summary Dashboard: Create a Donut Chart showing Planned Cost Breakdown by Type of Expenditure (WIP Sai Krishna)

The chart should display four categories: Plumbing, Electrical, Structural, and Mechanical, each represented by a different color.
The percentage of the total cost for each category should be displayed next to it in hover text.
Include two filters:
A Project filter to view the cost breakdown for a specific project.
Backend Requirements
API Endpoint:
GET /api/projects/:id/planned-cost-breakdown
Data Structure:
{
plumbing: 5500,
electrical: 4800,
structural: 7600,
mechanical: 6300
}
Database Schema:
{
projectId: ObjectId,
category: String, // Plumbing / Electrical / Structural / Mechanical
plannedCost: Number
}
Data Retrieval Logic:
Query by projectId.
Group planned costs by category.
Sum up planned costs per category.
Return structured breakdown.

Related PRS (if any):

To test this backend PR you need to checkout the #4011 frontend PR.

Main changes explained:

  • Added plannedcostcontroller.js, plannedcost.js, plannedcostrouter.js
  • updated routes.js

How to test:

  1. check into current branch
  2. do npm install and ... to run this PR locally
  3. Clear site data/cache
  4. log as admin user
  5. Go to http://localhost:4500/api/projects/:ProjectId/planned-cost-breakdown (replace the project id with the actual project id). I have set up the data for this project id 68747d37c71d9f67ac207eef
    http://localhost:4500/api/projects/68747d37c71d9f67ac207eef/planned-cost-breakdown
    6.You can setup the data for other project ids and can test. you need to setup the data in this collection " plannedCosts"
  6. Each type can have multiple entries with different costs in the same project and when we hit the api we should get the combined costs

Screenshots or videos of changes:

image

Copy link

@aditya2512 aditya2512 left a comment

Choose a reason for hiding this comment

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

The new API endpoint /api/projects/:id/planned-cost-breakdown leverages MongoDB aggregation to accurately sum planned costs by category for each project, which is ideal for powering a frontend donut chart. The aggregation pipeline is both efficient and easily extensible the $match, $group, and $project stages are well-organized and target the most common reporting needs (Plumbing, Electrical, Structural, Mechanical). I appreciate the use of service/controller layering for separation of concerns, and the parameter validation on projectId reduces risk of erroneous queries.
Returning the results as a category keyed flat object is optimal for direct consumption on the frontend, minimizing data transformation.

@saikrishnaraoyadagiri saikrishnaraoyadagiri changed the title feat: add donut chart route and controller for planned cost breakdown SaiKrishna_add donut chart route and controller for planned cost breakdown Sep 30, 2025
@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 Oct 6, 2025
Copy link

@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 Sai Krishna,

I have reviewed your PR locally and have mentioned issues with the frontend. The backend API response is as expected
Screenshot 2025-12-11 at 1 15 37 AM

@saikrishnaraoyadagiri saikrishnaraoyadagiri changed the title SaiKrishna_add donut chart route and controller for planned cost breakdown SaiKrishna add donut chart route and controller for planned cost breakdown Feb 19, 2026
@one-community
Copy link
Member

Thank you all, merging!

@one-community one-community merged commit fcee570 into development Feb 23, 2026
2 checks 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