Passed
Pull Request — master (#432)
by
unknown
05:29
created

Project.isDisabled   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
1
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
2
import { Customer } from '../Customer/Customer.entity';
3
4
export enum InvoiceUnits {
5
  DAY = 'day',
6
  HOUR = 'hour'
7
}
8
9
@Entity()
10
export class Project {
11
  @PrimaryGeneratedColumn('uuid')
12
  private id: string;
13
14
  @Column({ type: 'varchar', nullable: false })
15
  private name: string;
16
17
  @Column('enum', { enum: InvoiceUnits, nullable: false })
18
  private invoiceUnit: InvoiceUnits;
19
20
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
21
  private createdAt: Date;
22
23
  @Column({ type: 'boolean', nullable: false, default: false })
24
  private disabled: boolean;
25
26
  @ManyToOne(type => Customer, { nullable: false, onDelete: 'CASCADE' })
27
  private customer: Customer;
28
29
  constructor(name: string, invoiceUnit: InvoiceUnits, disabled: boolean, customer: Customer) {
30
    this.name = name;
31
    this.invoiceUnit = invoiceUnit;
32
    this.customer = customer;
33
    this.disabled = disabled;
34
  }
35
36
  public getId(): string {
37
    return this.id;
38
  }
39
40
  public getName(): string {
41
    return this.name;
42
  }
43
44
  public getInvoiceUnit(): InvoiceUnits {
45
    return this.invoiceUnit;
46
  }
47
48
  public getCreatedAt(): Date {
49
    return this.createdAt;
50
  }
51
52
  public getCustomer(): Customer {
53
    return this.customer;
54
  }
55
56
  public getFullName(): string {
57
    return `[${this.customer.getName()}] ${this.getName()}`;
58
  }
59
60
  public isDisabled(): boolean {
61
    return this.disabled;
62
  }
63
64
  public update(
65
    customer: Customer,
66
    invoiceUnit: InvoiceUnits,
67
    name: string,
68
    disabled: boolean
69
  ): void {
70
    this.customer = customer;
71
    this.invoiceUnit = invoiceUnit;
72
    this.name = name;
73
    this.disabled = disabled;
74
  }
75
}
76