Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 64 |
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 | |||
19 | @PrimaryGeneratedColumn('uuid') |
||
20 | private id: string; |
||
21 | |||
22 | @Column({type: 'varchar', nullable: false}) |
||
23 | private status: string; |
||
24 | |||
25 | @Column({type: 'varchar', nullable: false, unique: true}) |
||
26 | private quoteId: string; |
||
27 | |||
28 | @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'}) |
||
29 | private date: Date; |
||
30 | |||
31 | @UpdateDateColumn() |
||
32 | private expiryDate: Date; |
||
33 | |||
34 | @ManyToOne(type => User, {nullable: false}) |
||
35 | private owner: User; |
||
36 | |||
37 | @ManyToOne(type => Customer, {nullable: false}) |
||
38 | private customer: Customer; |
||
39 | |||
40 | @ManyToOne(type => Project, {nullable: true}) |
||
41 | private project: Project; |
||
42 | |||
43 | constructor( |
||
44 | quoteId: string, |
||
45 | date: Date, |
||
46 | expiryDate: Date, |
||
47 | owner: User, |
||
48 | customer: Customer, |
||
49 | project?: Project | null |
||
50 | ) { |
||
51 | this.quoteId = quoteId; |
||
52 | this.status = Quote.STATUS_DRAFT; |
||
53 | this.date = date; |
||
54 | this.expiryDate = expiryDate; |
||
55 | this.owner = owner; |
||
56 | this.customer = customer; |
||
57 | this.project = project; |
||
58 | } |
||
59 | |||
60 | public getId(): string { |
||
61 | return this.id; |
||
62 | } |
||
63 | } |
||
64 |