Passed
Pull Request — master (#107)
by Mathieu
01:38
created

server/src/Domain/HumanResource/Holiday/Holiday.entity.ts   A

Complexity

Total Complexity 9
Complexity/F 1

Size

Lines of Code 108
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 91
mnd 0
bc 0
fnc 9
dl 0
loc 108
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

9 Functions

Rating   Name   Duplication   Size   Complexity  
A Holiday.isAllDayOnEnd 0 3 1
A Holiday.getStartDate 0 3 1
A Holiday.getComment 0 3 1
A Holiday.getId 0 3 1
A Holiday.getLeaveType 0 3 1
A Holiday.getStatus 0 3 1
A Holiday.isAllDayOnStart 0 3 1
A Holiday.getEndDate 0 3 1
A Holiday.getUser 0 3 1
1
import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from 'typeorm';
2
import {User} from '../User/User.entity';
3
4
export enum HolidayStatus {
5
  WAITING = 'waiting',
6
  ACCEPTED = 'accepted',
7
  REFUSED = 'refused'
8
}
9
10
export enum HolidayLeaveType {
11
  PAID = 'paid',
12
  UNPAID = 'unpaid',
13
  SPECIAL = 'special',
14
  MEDICAL = 'medical'
15
}
16
17
@Entity()
18
export class Holiday {
19
  @PrimaryGeneratedColumn('uuid')
20
  private id: string;
21
22
  @Column('enum', {enum: HolidayStatus, nullable: false})
23
  private status: HolidayStatus;
24
25
  @Column('enum', {enum: HolidayLeaveType, nullable: false})
26
  private leaveType: HolidayLeaveType;
27
28
  @Column({type: 'timestamp', nullable: false})
29
  private startDate: string;
30
31
  @Column({type: 'boolean', nullable: false, default: true})
32
  private allDayOnStart: boolean;
33
34
  @Column({type: 'timestamp', nullable: false})
35
  private endDate: string;
36
37
  @Column({type: 'boolean', nullable: false, default: true})
38
  private allDayOnEnd: boolean;
39
40
  @Column({type: 'varchar', nullable: true})
41
  private comment: string;
42
43
  @Column({type: 'timestamp', nullable: true})
44
  private moderateAt: string;
45
46
  @ManyToOne(type => User, {nullable: true})
47
  private moderator: User;
48
49
  @ManyToOne(type => User, {nullable: false})
50
  private user: User;
51
52
  constructor(
53
    user: User,
54
    status: HolidayStatus,
55
    leaveType: HolidayLeaveType,
56
    startDate: string,
57
    allDayOnStart: boolean,
58
    endDate: string,
59
    allDayOnEnd: boolean,
60
    comment?: string
61
  ) {
62
    this.user = user;
63
    this.status = status;
64
    this.leaveType = leaveType;
65
    this.startDate = startDate;
66
    this.allDayOnStart = allDayOnStart;
67
    this.endDate = endDate;
68
    this.allDayOnEnd = allDayOnEnd;
69
    this.comment = comment;
70
  }
71
72
  public getId(): string {
73
    return this.id;
74
  }
75
76
  public getUser(): User {
77
    return this.user;
78
  }
79
80
  public getStatus(): HolidayStatus {
81
    return this.status;
82
  }
83
84
  public getLeaveType(): HolidayLeaveType {
85
    return this.leaveType;
86
  }
87
88
  public getStartDate(): string {
89
    return this.startDate;
90
  }
91
92
  public isAllDayOnStart(): boolean {
93
    return this.allDayOnStart;
94
  }
95
96
  public getEndDate(): string {
97
    return this.endDate;
98
  }
99
100
  public isAllDayOnEnd(): boolean {
101
    return this.allDayOnEnd;
102
  }
103
104
  public getComment(): string {
105
    return this.comment;
106
  }
107
}
108