Completed
Push — master ( 9166c6...df0fb2 )
by Mathieu
16s queued 12s
created

UserSavingsRecord   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 37
dl 0
loc 42
c 0
b 0
f 0
rs 10

4 Functions

Rating   Name   Duplication   Size   Complexity  
A getType 0 3 1
A getAmount 0 3 1
A getId 0 3 1
A getUser 0 3 1
1
import {
2
  Entity,
3
  Column,
4
  PrimaryGeneratedColumn,
5
  ManyToOne
6
} from 'typeorm';
7
import { User } from '../User/User.entity';
8
9
export enum SavingsRecordType {
10
  INPUT = 'input',
11
  OUTPUT = 'output'
12
}
13
14
@Entity()
15
export class UserSavingsRecord {
16
  @PrimaryGeneratedColumn('uuid')
17
  private id: string;
18
19
  @Column({ type: 'integer', nullable: false, comment: 'Stored in base 100' })
20
  private amount: number;
21
22
  @Column('enum', { enum: SavingsRecordType, nullable: false })
23
  private type: SavingsRecordType;
24
25
  @ManyToOne(type => User, { nullable: false, onDelete: 'CASCADE' })
26
  private user: User;
27
28
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
29
  private createdAt: Date;
30
31
  constructor(
32
    amount: number,
33
    type: SavingsRecordType,
34
    user: User,
35
  ) {
36
    this.amount = amount;
37
    this.type = type;
38
    this.user = user;
39
  }
40
41
  public getId(): string {
42
    return this.id;
43
  }
44
45
  public getAmount(): number {
46
    return this.amount;
47
  }
48
49
  public getType(): SavingsRecordType {
50
    return this.type;
51
  }
52
53
  public getUser(): User {
54
    return this.user;
55
  }
56
}
57