All files / src/domains/inventory/items/schemas item.schema.ts

0% Statements 0/26
100% Branches 0/0
100% Functions 0/0
0% Lines 0/22

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                                                                                                                       
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
 
@Schema({ _id: false })
export class ItemUomConversion {
  @Prop({ required: true })
  fromUom: string;
 
  @Prop({ required: true })
  toUom: string;
 
  @Prop({ required: true })
  conversionFactor: number;
}
 
@Schema({ timestamps: true })
export class InventoryItem extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true, index: true })
  itemCode: string;
 
  @Prop({ required: true })
  itemName: string;
 
  @Prop({ default: '' })
  description: string;
 
  @Prop({ required: true, default: 'Stock Item', enum: ['Stock Item', 'Non-Stock Item', 'Service', 'Raw Material', 'Finished Goods', 'Consumable'] })
  itemType: string;
 
  @Prop({ required: true, default: 'None', enum: ['None', 'Batch', 'Serial', 'Batch and Serial'] })
  trackingType: string;
 
  @Prop({ required: true, default: 'PCS' })
  baseUom: string;
 
  @Prop({ type: [ItemUomConversion], default: [] })
  uomConversions: ItemUomConversion[];
 
  @Prop({ default: 0 })
  reorderPoint: number;
 
  @Prop({ default: 0 })
  safetyStock: number;
 
  @Prop({ default: 0 })
  minStock: number;
 
  @Prop({ default: 0 })
  maxStock: number;
 
  @Prop({ required: true, default: true })
  active: boolean;
}
 
export const InventoryItemSchema = SchemaFactory.createForClass(InventoryItem);
InventoryItemSchema.index({ tenantId: 1, itemCode: 1 }, { unique: true });