Skip to content

Bhanuanish kitchenandinventory inventoryitems#2018

Open
bhanuanishakkineni wants to merge 4 commits intodevelopmentfrom
bhanuanish-kitchenandinventory-inventoryitems
Open

Bhanuanish kitchenandinventory inventoryitems#2018
bhanuanishakkineni wants to merge 4 commits intodevelopmentfrom
bhanuanish-kitchenandinventory-inventoryitems

Conversation

@bhanuanishakkineni
Copy link

Description

image

Related PRS (if any):

No related PRs. Checkout to the branch in this PR.

Main changes explained:

  • Created a db model for KIInventoryItems
  • Implemented routes and endpoints to add items, get items and update items from kitchen inventory.
  • add Item endpoint to create and add new item to inventory
  • getItems and getItemsByCategory endpoints to retrieve all items and get items based on given category to display in required tab.
  • Also created an endpoint to get preserved items which gives items from ingredients with expiry greater than or equal to one year from now.
  • Implemented update endpoints to update stock based on usage, adding new stock and also for updating harvest details.

How to test:

  1. check into current branch
  2. do npm install and npm run dev to run this PR locally
  3. Use postman or similar tool to test API endpoints.
  4. Use admin/owner credentials to login using post 'http://localhost:4500/api/login' and put the token obtained in the Authorization header of next requests to endpoints of inventory items.
  5. Test the below endpoints (Check screenshots)

Screenshots or videos of changes:

Below are the screenshots of testing of API endpoints.
addItem
getItems
getItembyCategory
getPreservedItems
updateUsage
updateStoredQuantity
updateNextHarvest

Note:

Include the information the reviewers need to know.

@bhanuanishakkineni bhanuanishakkineni added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Jan 25, 2026
Copy link
Contributor

@sayali-2308 sayali-2308 left a comment

Choose a reason for hiding this comment

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

Backend running on: http://localhost:4500
Branch: bhanuanish-kitchenandinventory-inventoryitems
Testing tool: Postman
Database: MongoDB with test data
Date: February 2, 2026

API Endpoint Testing:

  1. POST /api/kitchenandinventory/inventory/items - Status 201 Created - Successfully creates new inventory item. Tested with Tomatoes (50kg, Vegetable, INGREDIENT category, expiry Dec 31 2026). All required fields validated (name, category, type, quantity, unit, storedQuantity, monthlyUsage, reorderAt, expiryDate). Response includes auto-generated ID (698130cb5cf7ed18701b6981), timestamps (createdAt, updatedAt), presentQuantity automatically matches storedQuantity on creation. All fields stored correctly.
  2. GET /api/kitchenandinventory/inventory/items - Status 200 OK - Returns array of all inventory items with complete details. Verified Tomatoes item returned with all fields (name, storedQuantity: 50, presentQuantity: 50, unit, type, monthlyUsage, category, expiryDate, reorderAt, timestamps). Data structure correct, all properties present.
  3. GET /api/kitchenandinventory/inventory/items/INGREDIENT - Status 200 OK - Successfully filters items by category. Tested with INGREDIENT category, correctly returns only items matching specified category. Tomatoes item returned with accurate data. Category filtering working as expected.
  4. GET /api/kitchenandinventory/inventory/items/ingredients/preserved - Status 200 OK - Returns preserved items with expiry ≥ 1 year from now. Response: empty array (correct behavior - Tomatoes expire in 10 months, not preserved). Endpoint working correctly, filtering logic accurate.
  5. POST /api/kitchenandinventory/inventory/items/usage - Status 200 OK - Successfully updates item usage and reduces stock. Request body: {"itemId": "698130cb5cf7ed18701b6981", "usedQuantity": 5}. Response: presentQuantity reduced from 50 to 45 (5kg used), storedQuantity remains 50 (original stock preserved), updatedAt timestamp refreshed. Message confirms "Item usage updated successfully". Note: Endpoint expects usedQuantity field (not quantityUsed as might be assumed).
  6. POST /api/kitchenandinventory/inventory/items/storedQuantity - Status 200 OK - Successfully adds new stock to inventory. Request body: {"itemId": "698130cb5cf7ed18701b6981", "addedQuantity": 20}. Response: storedQuantity increased from 50 to 70 (+20kg), presentQuantity increased from 45 to 65 (+20kg), both quantities updated correctly when new stock added. Message confirms "Stored quantity updated successfully". updatedAt timestamp refreshed.
  7. PUT /api/kitchenandinventory/inventory/items/nextHarvest - Status 200 OK - Successfully updates harvest date information. Request body: {"itemId": "698130cb5cf7ed18701b6981", "nextHarvestDate": "2026-08-15", "lastHarvestDate": "2026-02-01"}. Response: nextHarvestDate field added with value "2026-08-15T00:00:00.000Z", field successfully stored in database, all other fields preserved, updatedAt timestamp refreshed. Message confirms "Next harvest details updated successfully".

Functionality:
All CRUD operations working correctly
Proper HTTP status codes (200 OK, 201 Created)
Data validation functioning as expected (validation errors caught missing required fields during testing)
Automatic timestamp generation working (createdAt, updatedAt)
Database integration successful
Category filtering accurate
Stock quantity calculations correct (usage reduces presentQuantity, adding stock increases both storedQuantity and presentQuantity)
Response messages clear and informative
Authorization required (Bearer token authentication working)

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.

2 participants

Comments