All files / src/dtos transport.dto.ts

76.19% Statements 32/42
0% Branches 0/5
0% Functions 0/5
75% Lines 30/40

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 1111x 1x 1x 1x     1x       1x   1x               1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x       1x       1x       1x       1x       1x     1x                               1x     1x     1x            
import { AnyObject, model, property } from '@loopback/repository';
import { Exclude, Expose, Transform, Type } from 'class-transformer';
import { CompanyDto, CompanyLocationDto, UserDto } from '.';
import { Transport } from '../models';
import { GeoPoint } from '../types';
import { DateUtils } from '../utils/date';
import { TimeZoneTransform, UserTransform } from '@logchain/decorators';
 
@Exclude()
@model({ name: 'TransportDto' })
export class TransportDto extends Transport {
  @Expose()
  id: number;
 
  @property({
    type: 'string',
    jsonSchema: {
      format: 'uuid',
    },
  })
  driven_by_identifier: string;
 
  @Expose()
  flow_id: number;
 
  @Expose()
  production_location_id: number;
 
  @Expose()
  expected_arrival_time: Date;
 
  @Expose()
  actual_start_time: Date;
 
  @Expose({ groups: ['single'] })
  actual_end_time: Date;
 
  @Expose({ groups: ['single'] })
  location_start: GeoPoint;
 
  @Expose({ groups: ['single'] })
  location_end: GeoPoint;
 
  @Expose({ groups: ['single'] })
  travel_time: number;
 
  @Expose({ groups: ['single'] })
  travel_distance: number;
 
  @Expose({ groups: ['single'] })
  travel_screenshot: string;
 
  @Expose()
  status: number;
 
  @Exclude()
  modified_by: number;
 
  @Exclude()
  created_by: number;
 
  @Expose({ groups: ['single'] })
  @TimeZoneTransform()
  created_date: Date;
 
  @Expose({ groups: ['single'] })
  @TimeZoneTransform()
  modified_date: Date;
 
  @Expose()
  @Type(() => CompanyDto)
  company: CompanyDto;
 
  @Expose()
  @Type(() => CompanyLocationDto)
  production: CompanyLocationDto;
 
  @Expose()
  @Type(() => UserDto)
  driver: UserDto;
 
  @Expose()
  status_name() {
    switch (this.status) {
      case 0:
        return 'New';
      case 1:
        return 'In Progress';
      case 2:
        return 'In Pause';
      case 3:
        return 'Cancelled';
      case 4:
        return 'Completed';
    }
  }
 
  @UserTransform('created_name', ['single'])
  creator?: UserDto;
 
  @UserTransform('modified_name', ['single'])
  modifier?: UserDto;
 
  @Expose()
  ref_documents?: AnyObject[];
 
  constructor(data?: Partial<TransportDto>) {
    super(data);
  }
}