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:
@@ -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
|
||||
Reference in New Issue
Block a user