Passed
Pull Request — master (#70)
by Mathieu
01:45
created

server/src/Domain/Billing/Quote.entity.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 64
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A Quote.getId 0 3 1
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_BILLED = 'billed';
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