Skip to content

Conversation

@csk731
Copy link
Contributor

@csk731 csk731 commented Jan 18, 2026

Description

Implements the backend API for the "Material Stock-Out Risk Indicator" to support the frontend visualization of inventory risks.

Screenshot 2026-01-17 at 11 34 43 PM Screenshot 2026-01-17 at 11 35 03 PM

Related PRS:

Main changes explained:

  • src/controllers/bmdashboard/bmMaterialsController.js:
    • Added bmGetMaterialStockOutRisk controller function.
    • Logic:
      • Fetches all building materials and populates project/itemType details.
      • Analyzes updateRecord for the last 30 days to calculate averageDailyUsage.
      • Calculates daysUntilStockOut = stockAvailable / averageDailyUsage.
      • Sorts results in ascending order of days remaining (highest risk first).
      • Includes project filtering capability via projectIds query parameter.
  • src/routes/bmdashboard/bmMaterialsRouter.js:
    • Registered the new GET route /materials/stock-out-risk pointing to the controller.

How to test:

  1. Check into current branch.
  2. Run npm install and start the server (npm run dev).
  3. Frontend Integration Test:
    • Run the associated Frontend PR.
    • Navigate to the "Material Stock-Out Risk Indicator" on the dashboard.
    • Confirm data matches the backend response.

Screenshots or videos of changes:

  • Check the Frontend PR

##Note:

  • To test this, you can use the corresponding Frontend PR

@csk731 csk731 added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Jan 18, 2026
@abhinav-TB
Copy link
Member

Hi Chaitanya, I have tested this PR locally along with the frontend PR. I have left my comment here. OneCommunityGlobal/HighestGoodNetworkApp#4733 (comment)

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 Chaitanya,

I have reviewed your PR locally and the API works as expecetd.
Screenshot 2026-01-19 at 3 47 44 PM

@one-community one-community merged commit 1637e36 into development Jan 22, 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.

5 participants