Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 58 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { |
||
2 | Entity, |
||
3 | Column, |
||
4 | PrimaryGeneratedColumn, |
||
5 | ManyToOne, |
||
6 | UpdateDateColumn |
||
7 | } from 'typeorm'; |
||
8 | import {Customer} from '../Customer/Customer.entity'; |
||
9 | import {Project} from '../Project/Project.entity'; |
||
10 | import {User} from '../User/User.entity'; |
||
11 | |||
12 | @Entity() |
||
13 | export class Quote { |
||
14 | public static readonly STATUS_DRAFT = 'draft'; |
||
15 | public static readonly STATUS_SENT = 'sent'; |
||
16 | public static readonly STATUS_REFUSED = 'refused'; |
||
17 | public static readonly STATUS_ACCEPTED = 'accepted'; |
||
18 | public static readonly STATUS_CANCEL = 'canceled'; |
||
19 | |||
20 | @PrimaryGeneratedColumn('uuid') |
||
21 | private id: string; |
||
22 | |||
23 | @Column({type: 'varchar', nullable: false}) |
||
24 | private status: string; |
||
25 | |||
26 | @Column({type: 'varchar', nullable: false, unique: true}) |
||
27 | private quoteId: string; |
||
28 | |||
29 | @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'}) |
||
30 | private createdAt: Date; |
||
31 | |||
32 | @ManyToOne(type => User, {nullable: false}) |
||
33 | private owner: User; |
||
34 | |||
35 | @ManyToOne(type => Customer, {nullable: false}) |
||
36 | private customer: Customer; |
||
37 | |||
38 | @ManyToOne(type => Project, {nullable: true}) |
||
39 | private project: Project; |
||
40 | |||
41 | constructor( |
||
42 | quoteId: string, |
||
43 | owner: User, |
||
44 | customer: Customer, |
||
45 | project?: Project | null |
||
46 | ) { |
||
47 | this.quoteId = quoteId; |
||
48 | this.owner = owner; |
||
49 | this.customer = customer; |
||
50 | this.project = project; |
||
51 | this.status = Quote.STATUS_DRAFT; |
||
52 | } |
||
53 | |||
54 | public getId(): string { |
||
55 | return this.id; |
||
56 | } |
||
57 | } |
||
58 |