All files / src/domains/manufacturing/schemas subcontracting.schema.ts

0% Statements 0/18
0% Branches 0/9
100% Functions 0/0
0% Lines 0/16

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                                                                               
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'manufacturing_subcontract_orders' })
export class SubcontractOrder extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true, unique: true })
  subcontractOrderNumber: string;
 
  @Prop({ required: true })
  vendorId: string; // subcontractor identifier from Procurement vendor
 
  @Prop({ required: true })
  itemCode: string;
 
  @Prop({ required: true, default: 0 })
  plannedQuantity: number;
 
  @Prop({ default: 0 })
  receivedQuantity: number;
 
  @Prop({ default: 'draft' })
  status: string; // 'draft' | 'released' | 'materials_sent' | 'partially_received' | 'completed' | 'cancelled'
 
  @Prop({ default: 0 })
  serviceChargeMinor: number; // cost posting parameter
 
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'BillOfMaterial', required: true })
  bomId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  dueDate: Date;
}
 
export const SubcontractOrderSchema = SchemaFactory.createForClass(SubcontractOrder);
SubcontractOrderSchema.index({ tenantId: 1, subcontractOrderNumber: 1 }, { unique: true });
SubcontractOrderSchema.index({ tenantId: 1, status: 1 });