All files / src/domains/manufacturing/schemas production-routing.schema.ts

0% Statements 0/32
0% Branches 0/10
100% Functions 0/0
0% Lines 0/28

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                                                                                                                                                     
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'manufacturing_routings' })
export class ProductionRouting extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true })
  routingCode: string;
 
  @Prop({ required: true })
  itemCode: string;
 
  @Prop({ required: true })
  routingName: string;
 
  @Prop({ default: 1 })
  version: number;
 
  @Prop({ default: 'Active' })
  status: string; // 'Draft' | 'Active' | 'Inactive'
 
  @Prop({ default: true })
  isActive: boolean;
}
 
export const ProductionRoutingSchema = SchemaFactory.createForClass(ProductionRouting);
ProductionRoutingSchema.index({ tenantId: 1, routingCode: 1 }, { unique: true });
 
@Schema({ timestamps: true, collection: 'manufacturing_routing_operations' })
export class RoutingOperation extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'ProductionRouting', required: true })
  routingId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  operationCode: string;
 
  @Prop({ required: true })
  operationName: string;
 
  @Prop({ required: true, default: 10 })
  sequence: number; // e.g. 10, 20, 30
 
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'WorkCenter', required: true })
  workCenterId: MongooseSchema.Types.ObjectId;
 
  @Prop({ default: 0 })
  setupTimeMinutes: number;
 
  @Prop({ default: 0 })
  runTimeMinutes: number;
 
  @Prop({ default: 0 })
  laborTimeMinutes: number;
 
  @Prop({ default: 0 })
  machineTimeMinutes: number;
 
  @Prop({ default: false })
  subcontracted: boolean;
 
  @Prop({ default: false })
  qualityInspectionRequired: boolean;
 
  @Prop()
  instructions?: string;
}
 
export const RoutingOperationSchema = SchemaFactory.createForClass(RoutingOperation);
RoutingOperationSchema.index({ tenantId: 1, routingId: 1, sequence: 1 });