Initial commit
This commit is contained in:
19
server/models/InventoryHistory.js
Normal file
19
server/models/InventoryHistory.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
const inventoryHistorySchema = new mongoose.Schema({
|
||||
product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product', required: true },
|
||||
sku: { type: String, required: true },
|
||||
changeType: {
|
||||
type: String,
|
||||
enum: ['Order Placed', 'Order Cancelled', 'Manual Adjustment', 'Restock', 'Returned Product'],
|
||||
required: true
|
||||
},
|
||||
quantityChanged: { type: Number, required: true }, // positive for addition, negative for deduction
|
||||
previousStock: { type: Number, required: true },
|
||||
newStock: { type: Number, required: true },
|
||||
reason: { type: String, default: '' },
|
||||
performedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User', default: null }
|
||||
}, { timestamps: true });
|
||||
|
||||
module.exports = mongoose.model('InventoryHistory', inventoryHistorySchema);
|
||||
|
||||
Reference in New Issue
Block a user