| Current Path : /proc/thread-self/root/home/deltalab/PMS/ims-connector/models/mongoose/ |
| Current File : //proc/thread-self/root/home/deltalab/PMS/ims-connector/models/mongoose/warehouse.js |
const mongoose = require('mongoose');
const { AddressSchema } = require('./address');
// SCHEMA ============================================
const WarehouseAssignmentSchema = new mongoose.Schema(
{
name: String,
partnerId: {
type: mongoose.Schema.Types.ObjectId,
required: false,
ref: 'Partner',
},
inboundRate: Number,
storageRate: Number,
storageMode: {
type: String,
enum: [
'LINEAR',
'CUBIC'],
},
minimumStorage: Number, // fixed value in case of linear meters, minimum of cubic meters invoiced in case of cubic meters
orderRate: Number,
returnRate: Number,
refrigerated: { type: Boolean, default: false },
initialDate: Date,
endDate: Date,
},
{
timestamps: true,
versionKey: false,
},
);
const WarehouseChannelSchema = new mongoose.Schema(
{
channelId: { type: mongoose.Schema.Types.ObjectId, required: false, ref: 'Channel' },
shipmentWarehouse: Boolean,
storageWarehouse: Boolean,
},
{
timestamps: true,
versionKey: false,
},
);
const WarehouseSchema = new mongoose.Schema(
{
name: String,
address: {
type: AddressSchema,
required: true,
},
email: [String],
phone: String,
type: String,
size: Number,
isIndaco: Boolean, // only indaco admin can edit this warehouse and its inventory
isShared: Boolean, // is it shared for use among the platform users or not
partnerId: {
type: mongoose.Schema.Types.ObjectId,
required: false,
ref: 'Partner',
},
refrigerated: { type: Boolean, default: false },
assignments: { type: [WarehouseAssignmentSchema], default: [] },
channels: [{ type: mongoose.Schema.Types.ObjectId, required: false, ref: 'Channel' }],
channelAssignments: { type: [WarehouseChannelSchema], default: [] },
},
{
timestamps: true,
versionKey: false,
},
);
// MODELS ============================================
const warehouseModel = mongoose.model('Warehouse', WarehouseSchema);
// EXPORTS ===========================================
module.exports = {
warehouseModel,
WarehouseSchema,
};