ADD: Warehouse inventory management system

- Add WarehouseItem model with bilingual names (FA/EN) and bilingual counting units
- Add WarehouseItemTransaction model for IN/OUT movements with reason and actor
- Add WarehouseItemStock model for denormalized per-(item×warehouse) running balance
- Add warehouseItemService with full CRUD, atomic stock updates via $inc, negative stock guard, and aggregation queries for per-item/per-warehouse/total stock
- Add warehouseItemController and REST routes at /api/warehouse-items
- Add warehouseService, warehouseController, warehouseRoutes for warehouse location CRUD at /api/warehouses
- Register both route groups in routerEndpoints.js
This commit is contained in:
2026-08-11 20:09:10 +03:30
parent 0fe799e008
commit a9432b96c0
11 changed files with 653 additions and 6 deletions
+34
View File
@@ -0,0 +1,34 @@
const mongoose = require('mongoose')
const ObjectID = mongoose.Schema.Types.ObjectId
const warehouseSchema = new mongoose.Schema(
{
name: {
type: String,
required: true,
},
code: {
type: String,
unique: true,
},
location: {
address: String,
coordinates: [Number], // [long, lat]
},
manager: {
type: ObjectID,
ref: 'User',
},
description: String,
isActive: {
type: Boolean,
default: true,
},
},
{
timestamps: true,
}
)
const Warehouse = mongoose.model('Warehouse', warehouseSchema)
module.exports = Warehouse