Passed
Pull Request — master (#257)
by Mathieu
02:28
created

UserSavingsRecord.getInterestRate   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
1
import {
2
  Entity,
3
  Column,
4
  PrimaryGeneratedColumn,
5
  ManyToOne
6
} from 'typeorm';
7
import { User } from '../User/User.entity';
8
import { InterestRate } from './InterestRate.entity';
9
10
export enum SavingsRecordType {
11
  INPUT = 'input',
12
  OUTPUT = 'output'
13
}
14
15
@Entity()
16
export class UserSavingsRecord {
17
  @PrimaryGeneratedColumn('uuid')
18
  private id: string;
19
20
  @Column({ type: 'integer', nullable: false, comment: 'Stored in base 100' })
21
  private amount: number;
22
23
  @Column('enum', { enum: SavingsRecordType, nullable: false })
24
  private type: SavingsRecordType;
25
26
  @ManyToOne(type => User, { nullable: false, onDelete: 'CASCADE' })
27
  private user: User;
28
29
  @ManyToOne(type => InterestRate, { nullable: true })
30
  private interestRate: InterestRate;
31
32
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
33
  private createdAt: Date;
34
35
  constructor(
36
    amount: number,
37
    type: SavingsRecordType,
38
    user: User,
39
    interestRate?: InterestRate
40
  ) {
41
    this.amount = amount;
42
    this.type = type;
43
    this.user = user;
44
    this.interestRate = interestRate;
45
  }
46
47
  public getId(): string {
48
    return this.id;
49
  }
50
51
  public getAmount(): number {
52
    return this.amount;
53
  }
54
55
  public getType(): SavingsRecordType {
56
    return this.type;
57
  }
58
59
  public getInterestRate(): InterestRate {
60
    return this.interestRate;
61
  }
62
63
  public getUser(): User {
64
    return this.user;
65
  }
66
}
67