diff options
author | eug-vs <eug-vs@keemail.me> | 2021-03-17 02:47:50 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-03-17 02:47:50 +0300 |
commit | 920ff53d1a9a4840fb6ad9198c5db176d70c7edf (patch) | |
tree | b550f70f3099c114e22b6a88b1fb482a6ff8efb4 /src/models/waybill/waybill.schema.ts | |
parent | a76ec7c41ebc5c208d7b31c81f8a659bd1be159c (diff) | |
download | commercel-api-920ff53d1a9a4840fb6ad9198c5db176d70c7edf.tar.gz |
feat: allow multiple products in a waybill
Diffstat (limited to 'src/models/waybill/waybill.schema.ts')
-rw-r--r-- | src/models/waybill/waybill.schema.ts | 32 |
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', |