All files / src/models request.model.ts

97.06% Statements 33/34
100% Branches 0/0
90% Functions 9/10
96.88% Lines 31/32

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 971x 1x 1x   1x 1x 1x 1x             1x       1x         1x                 1x             1x   36x 1x           1x   36x 1x   36x 1x     36x               1x   36x 1x   36x 1x   36x 1x   36x 1x   36x 1x                                
import {belongsTo, hasMany, model, property} from '@loopback/repository';
import {BaseEntity, FilesMapping, User} from '.';
import {Constants} from '../configs';
import {Created, Modified} from '../types';
import {Company} from './company.model';
import {Persona} from './persona.model';
import {RequestDiscussion} from './request-discussion.model';
import {Status} from './status';
 
@model({
  settings: {
    postgresql: {table: 'requests'},
  },
})
export class Request extends BaseEntity implements Created, Modified {
  @property({
    type: 'string',
  })
  remarks?: string;
 
  @property({
    type: 'string',
  })
  quotation?: string;
 
  @property({
    type: 'number',
    required: true,
    jsonSchema: {
      enum: Object.values(Status.Request),
    },
  })
  status: number;
 
  @property({
    type: 'date',
    required: true,
    defaultFn: 'now',
  })
  created_date: Date;
 
  @belongsTo(() => User, {name: 'creator'})
  created_by: number;
 
  @property({
    type: 'date',
    required: true,
  })
  modified_date: Date;
 
  @belongsTo(() => Company, {name: 'provider_company'})
  provider_company_id: number;
 
  @belongsTo(() => Persona, {name: 'request_persona'})
  requester_persona_id: number;
 
  @belongsTo(
    () => Persona,
    {name: 'provider_persona'},
    {
      jsonSchema: {
        enum: Object.values(Constants.RequestPersona),
      },
    },
  )
  provider_persona_id: number;
 
  @belongsTo(() => User, {name: 'modifier'})
  modified_by: number;
 
  @hasMany(() => RequestDiscussion, {keyTo: 'request_id'})
  discussions: RequestDiscussion[];
 
  @belongsTo(() => Company, {name: 'requester_company'})
  requester_company_id: number;
 
  @belongsTo(() => User, {name: 'requester'})
  requester_id: number;
 
  @belongsTo(() => User, {name: 'provider'})
  provider_id: number;
 
  constructor(data?: Partial<Request>) {
    super(data);
  }
}
 
export interface RequestRelations {
  // describe navigational properties here
  creator?: User;
  modifier?: User;
  documents: FilesMapping[];
  provider_persona?: Persona;
}
 
export type RequestWithRelations = Request & RequestRelations;