35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import mongoose, { Schema, Document } from 'mongoose';
|
|
|
|
export interface IInternalOrder extends Document {
|
|
requestId: string;
|
|
ioNumber: string;
|
|
ioAvailableBalance: number;
|
|
ioBlockedAmount: number;
|
|
ioRemainingBalance: number;
|
|
ioRemark?: string;
|
|
status: 'PENDING' | 'BLOCKED' | 'RELEASED';
|
|
sapDocId?: string;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
const InternalOrderSchema = new Schema<IInternalOrder>({
|
|
requestId: { type: String, required: true, unique: true, index: true },
|
|
ioNumber: { type: String, required: true },
|
|
ioAvailableBalance: { type: Number, default: 0 },
|
|
ioBlockedAmount: { type: Number, default: 0 },
|
|
ioRemainingBalance: { type: Number, default: 0 },
|
|
ioRemark: String,
|
|
status: {
|
|
type: String,
|
|
enum: ['PENDING', 'BLOCKED', 'RELEASED'],
|
|
default: 'PENDING'
|
|
},
|
|
sapDocId: String
|
|
}, {
|
|
timestamps: true,
|
|
collection: 'internal_orders'
|
|
});
|
|
|
|
export const InternalOrderModel = mongoose.model<IInternalOrder>('InternalOrder', InternalOrderSchema);
|