Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; @Schema({ timestamps: true, collection: 'manufacturing_quality_plans' }) export class QualityPlan extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true }) planCode: string; @Prop({ required: true }) itemCode: string; @Prop({ required: true }) planName: string; @Prop({ default: true }) isActive: boolean; } export const QualityPlanSchema = SchemaFactory.createForClass(QualityPlan); QualityPlanSchema.index({ tenantId: 1, planCode: 1 }, { unique: true }); @Schema({ timestamps: true, collection: 'manufacturing_inspection_lots' }) export class InspectionLot extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true }) lotNumber: string; @Prop({ required: true }) sourceType: string; // 'Production' | 'Incoming' | 'Subcontract' @Prop({ required: true }) sourceDocumentId: string; // ProductionOrderId, GoodsReceiptId, etc. @Prop({ required: true }) itemCode: string; @Prop({ required: true, default: 0 }) lotQuantity: number; @Prop({ default: 'Pending' }) status: string; // 'Pending' | 'Inspected' | 'Released' | 'Rejected' | 'Quarantine' @Prop() inspectorId?: string; @Prop() decision?: string; // 'Approved' | 'Rejected' | 'Quarantine' | 'Scrap' } export const InspectionLotSchema = SchemaFactory.createForClass(InspectionLot); InspectionLotSchema.index({ tenantId: 1, lotNumber: 1 }, { unique: true }); InspectionLotSchema.index({ tenantId: 1, status: 1 }); @Schema({ timestamps: true, collection: 'manufacturing_non_conformances' }) export class NonConformance extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'InspectionLot', required: true }) inspectionLotId: MongooseSchema.Types.ObjectId; @Prop({ required: true }) itemCode: string; @Prop({ required: true }) defectDescription: string; @Prop({ required: true, default: 1 }) defectiveQuantity: number; @Prop({ default: 'Open' }) status: string; // 'Open' | 'Resolved' | 'Closed' @Prop() dispositionAction?: string; // 'Scrap' | 'Rework' | 'ReturnToVendor' | 'AcceptAsIs' } export const NonConformanceSchema = SchemaFactory.createForClass(NonConformance); NonConformanceSchema.index({ tenantId: 1, status: 1 }); |