Skip to content

Mani shashank : add BM expenditure API routes for dashboard charts#1797

Open
shashankm9 wants to merge 1 commit intodevelopmentfrom
fix/bm-expenditure-api
Open

Mani shashank : add BM expenditure API routes for dashboard charts#1797
shashankm9 wants to merge 1 commit intodevelopmentfrom
fix/bm-expenditure-api

Conversation

@shashankm9
Copy link
Contributor

Description

This PR restores the missing Financials Tracking functionality in the BM Dashboard that was showing "Failed to load projects" error. The expenditure pie charts and cost prediction features are now fully functional with proper authentication and CSS modules implementation.
image
image

Related PRS (if any):

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

Main changes explained:

  • Create bmExpenditureRouter: New router with endpoints /expenditure/projects and /expenditure/:projectId/pie
  • Add expenditureController: Controller functions getProjectIdsWithExpenditure and getProjectExpensesPie
  • Create Expenditure model: MongoDB schema for expenditure data with projectId, category, type, and amount fields
  • Update routes.js: Register bmExpenditureRouter under /api/bm path
  • Fix router export pattern: Ensure consistent router export structure across BM dashboard routers

How to test:

  1. Check into current branch fix/bm-expenditure-api
  2. Run npm install and npm run build to compile changes
  3. Start the server with npm start
  4. Test API endpoints:
    • GET /api/bm/expenditure/projects (requires authentication)
    • GET /api/bm/expenditure/:projectId/pie (requires authentication)
  5. Verify endpoints return proper JSON responses:
    • Projects endpoint: ["projectId1", "projectId2", ...]
    • Pie endpoint: {"actual": [...], "planned": [...]}
  6. Test with frontend PR to ensure full integration works

Screenshots or videos of changes:

Recording.2025-10-09.215401.mp4

@Sriamshreddy000
Copy link

Hi Mani Shashank,
Tested this PR along with the related frontend PR. The backend runs without issues, but the frontend fails to load due to a duplicate import error in routes.jsx. I’ve left a detailed comment and screenshot in the frontend PR for reference.

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 Mani Shashankl,

I have reviewed your Pr locally and have given my comments on frontend, now as to backend - i was not able to run the second API.

http://localhost:4500/api/bm/expenditure/:projectId/pie
Screenshot 2025-11-14 at 12 18 32 AM

http://localhost:4500/api/bm/expenditure/projects
Screenshot 2025-11-14 at 12 18 27 AM

Copy link

@bhanuanishakkineni bhanuanishakkineni left a comment

Choose a reason for hiding this comment

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

Hello Shashank,
I have reviewed this PR and posted some comments for frontend PR#4193 of this PR. Please checkout those.
For the backend, I tested the API endpoints using postman.
First endpoint is working fine and returning JSON of projectIDs
image
Second endpoint is also working as expected and returning JSON with actual and planned values.
image

@SwathiAngadi
Copy link

Hi Mani Shashank,

I have reviewed your PR. Commented on Front End PR.
OneCommunityGlobal/HighestGoodNetworkApp#4193 (comment)

For the backend I have tested the end points. First one returned the projectIDs and second returned actual and planned values. Both working as expected.

Screenshot 2025-12-10 235031 Screenshot 2025-12-10 235757

@abhinav-TB
Copy link
Member

Hi Mani , I tried to test your PR with fix/bm-expenditure-charts , I have left a comment on OneCommunityGlobal/HighestGoodNetworkApp#4193 (comment)

Copy link

@Shravan-neelamsetty Shravan-neelamsetty left a comment

Choose a reason for hiding this comment

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

hi shashank i have tested the backend endpoints using postman and i have pasted my comments on the related frontend PR as well.
Screenshot 2026-01-18 at 11 14 38 PM
Screenshot 2026-01-18 at 11 16 04 PM

Copy link

@Ganesh112001 Ganesh112001 left a comment

Choose a reason for hiding this comment

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

I tested Backend PR #1797 via Postman and verified that the API endpoints are functional. The POST /api/login endpoint successfully returns authentication tokens with 200 OK status. Both GET /api/bm/expenditure/projects and GET /api/bm/expenditure/:projectId/pie endpoints exist and properly enforce authentication, returning 401 Unauthorized responses. The endpoints correctly validate authorization and implement proper security by requiring BM Portal access permissions. However, I cannot verify the full data responses because the test admin account has "canAccessBMPortal" set to false in the JWT token, preventing access to BM Dashboard endpoints. The backend API implementation is functional with correct authentication and authorization enforcement. The endpoints are properly secured and ready for integration once frontend PR #4193 build errors are resolved and appropriate user permissions are configured.

Screenshot 2026-01-24 at 4 23 59 AM

@maithili20
Copy link

Hi @shashankm9
Left my comments here. OneCommunityGlobal/HighestGoodNetworkApp#4193 (comment)
I tried to run via postman but both the APIs are giving 401 unauthorized error.

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 Mani Shashank,

I have re-reviewed your PR locally and API generates responses as per requirement.

Image Image

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.

10 participants