All files / src/models entry.model.ts

92.31% Statements 36/39
100% Branches 0/0
70% Functions 7/10
91.89% Lines 34/37

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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 1541x 1x 1x                 1x             1x           1x         1x     1x       1x   80x 1x   80x 1x   80x 1x   80x 1x   80x 1x           1x               1x               1x               1x               1x               1x                 1x                 1x         1x           1x           1x   80x 1x   80x 1x                              
import {belongsTo, hasMany, model, property} from '@loopback/repository';
import {Exclude} from 'class-transformer';
import {
  BaseEntity,
  Company,
  EntryRecord,
  FlowAction,
  FlowJourneyPoint,
  FlowReference,
  User,
} from '.';
import {Status} from './status';
 
@model({
  settings: {
    postgresql: {table: 'entries'},
  },
})
export class Entry extends BaseEntity {
  @property({
    type: 'number',
    id: true,
    generated: true,
  })
  id: number;
 
  @property({
    type: 'number',
  })
  flow_id: number;
 
  @belongsTo(() => FlowJourneyPoint, {name: 'journey_point'})
  journey_point_id: number;
 
  @Exclude()
  @belongsTo(() => FlowAction, {name: 'flow_action'})
  flow_action_id: number;
 
  @belongsTo(() => Company, {name: 'company'})
  company_id: number;
 
  @belongsTo(() => Company, {name: 'delivered_company'})
  delivered_company_id: number;
 
  @belongsTo(() => Company, {name: 'company_other'})
  company_other_id: number;
 
  @belongsTo(() => User, {name: 'delivered'})
  delivered_by: number;
 
  @belongsTo(() => User, {name: 'supervise'})
  supervise_by: number;
 
  @property({
    type: 'number',
    required: true,
  })
  company_other_type: number;
 
  @property({
    type: 'string',
    jsonSchema: {
      maxLength: 100,
    },
  })
  vehicle_no: string;
  
  @property({
    type: 'string',
    jsonSchema: {
      nullable: true,
    },
  })
  driven_name?: string;
 
  @property({
    type: 'string',
    jsonSchema: {
      maxLength: 100,
    },
  })
  tank_no: string;
 
  @property({
    type: 'string',
    jsonSchema: {
      maxLength: 100,
    },
  })
  order_no: string;
 
  @property({
    type: 'string',
    jsonSchema: {
      maxLength: 100,
    },
  })
  product_no: string;
 
  @property({
    type: 'number',
    required: true,
    jsonSchema: {
      enum: Object.values(Status.Entries),
    },
  })
  status: number;
 
  @property({
    type: 'date',
    nullable: true,
    jsonSchema: {
      nullable: true,
    },
  })
  actual_date: Date;
 
  @property({
    type: 'date',
  })
  expected_date: Date;
 
  @property({
    type: 'date',
    defaultFn: 'now',
  })
  created_date: Date;
 
  @property({
    type: 'date',
    defaultFn: 'now',
  })
  modified_date: Date;
 
  @belongsTo(() => User, {name: 'modifier'})
  modified_by?: number;
 
  @hasMany(() => EntryRecord, {keyTo: 'entry_id'})
  entry_records: EntryRecord[];
 
  constructor(data?: Partial<Entry>) {
    super(data);
  }
}
 
export interface EntryRelations {
  // describe navigational properties here
  creator?: User;
  modifier?: User;
  ref_documents?: FlowReference[];
}
 
export type EntryWithRelations = Entry & EntryRelations;