summaryrefslogtreecommitdiff
path: root/src/models/waybill
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/waybill')
-rw-r--r--src/models/waybill/waybill.schema.ts32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/models/waybill/waybill.schema.ts b/src/models/waybill/waybill.schema.ts
index ce14525..bbebcd4 100644
--- a/src/models/waybill/waybill.schema.ts
+++ b/src/models/waybill/waybill.schema.ts
@@ -2,29 +2,41 @@ import { Document, Schema, Types } from 'mongoose';
export interface WaybillSchema extends Document {
operation: 'in' | 'out';
- productId: string;
- quantity: number;
+ records: [{
+ productId: string;
+ price: number;
+ quantity: number;
+ }];
contractorId: string;
status: 'waiting' | 'executed' | 'cancelled';
}
-export const waybillSchema = new Schema({
- operation: {
- type: String,
- required: true,
- },
- contractorId: {
+
+const recordSchema = new Schema({
+ productId: {
type: Types.ObjectId,
required: true,
},
- productId: {
- type: Types.ObjectId,
+ price: {
+ type: Number,
required: true,
},
quantity: {
type: Number,
min: 1,
},
+});
+
+export const waybillSchema = new Schema({
+ operation: {
+ type: String,
+ required: true,
+ },
+ contractorId: {
+ type: Types.ObjectId,
+ required: true,
+ },
+ records: [recordSchema],
status: {
type: String,
default: 'waiting',