All files / src/domains/inventory/warehouses/schemas warehouse.schema.ts

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

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                                                                                                                                         
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
 
@Schema({ timestamps: true })
export class Warehouse extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true, index: true })
  warehouseCode: string;
 
  @Prop({ required: true })
  name: string;
 
  @Prop({ default: null })
  parentWarehouseId: string;
 
  @Prop({ required: true, default: 'Main', enum: ['Main', 'Quarantine', 'Damaged', 'Transit', 'Consignment'] })
  warehouseType: string;
 
  @Prop({ default: 'BR-1' })
  branchId: string;
 
  @Prop({ default: 'LE-1' })
  legalEntityId: string;
 
  @Prop({ default: 0 })
  capacityVolumeCubeMeters: number;
 
  @Prop({ default: 0 })
  capacityWeightKg: number;
 
  @Prop({ required: true, default: true })
  active: boolean;
}
 
export const WarehouseSchema = SchemaFactory.createForClass(Warehouse);
WarehouseSchema.index({ tenantId: 1, warehouseCode: 1 }, { unique: true });
 
@Schema({ timestamps: true })
export class StorageLocation extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true, index: true })
  warehouseId: string;
 
  @Prop({ required: true })
  zoneCode: string;
 
  @Prop({ required: true })
  aisle: string;
 
  @Prop({ required: true })
  rack: string;
 
  @Prop({ required: true })
  shelf: string;
 
  @Prop({ required: true })
  bin: string;
 
  @Prop({ required: true, default: true })
  active: boolean;
}
 
export const StorageLocationSchema = SchemaFactory.createForClass(StorageLocation);
StorageLocationSchema.index({ tenantId: 1, warehouseId: 1, zoneCode: 1, aisle: 1, rack: 1, shelf: 1, bin: 1 }, { unique: true });