Bhanuanish kitchenandinventory inventoryitems#2018
Bhanuanish kitchenandinventory inventoryitems#2018bhanuanishakkineni wants to merge 4 commits intodevelopmentfrom
Conversation
sayali-2308
left a comment
There was a problem hiding this comment.
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:
- 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.
- 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.
- 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.
- 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.
- 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).
- 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.
- 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)
Description
Related PRS (if any):
No related PRs. Checkout to the branch in this PR.
…
Main changes explained:
…
How to test:
npm installandnpm run devto run this PR locallyScreenshots or videos of changes:
Below are the screenshots of testing of API endpoints.







Note:
Include the information the reviewers need to know.