Total Complexity | 7 |
Complexity/F | 1 |
Lines of Code | 70 |
Function Count | 7 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 | @ManyToOne(type => Customer, { nullable: false, onDelete: 'CASCADE' }) |
||
24 | private customer: Customer; |
||
25 | |||
26 | constructor( |
||
27 | name: string, |
||
28 | invoiceUnit: InvoiceUnits, |
||
29 | customer: Customer |
||
30 | ) { |
||
31 | this.name = name; |
||
32 | this.invoiceUnit = invoiceUnit; |
||
33 | this.customer = customer; |
||
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 update( |
||
61 | customer: Customer, |
||
62 | invoiceUnit: InvoiceUnits, |
||
63 | name: string |
||
64 | ): void { |
||
65 | this.customer = customer; |
||
66 | this.invoiceUnit = invoiceUnit; |
||
67 | this.name = name; |
||
68 | } |
||
69 | } |
||
70 |