Total Complexity | 5 |
Complexity/F | 1 |
Lines of Code | 58 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'; |
||
2 | import { School } from './School.entity'; |
||
3 | |||
4 | export enum DiscountType { |
||
5 | PERCENT = 'percent', |
||
6 | AMOUNT = 'amount' |
||
7 | } |
||
8 | |||
9 | @Entity() |
||
10 | export class Discount { |
||
11 | @PrimaryGeneratedColumn('uuid') |
||
12 | private id: string; |
||
13 | |||
14 | @Column('enum', { enum: DiscountType, nullable: false }) |
||
15 | protected type: DiscountType; |
||
16 | |||
17 | @Column({ type: 'integer', nullable: false }) |
||
18 | private amount: number; |
||
19 | |||
20 | @Column({ type: 'integer', nullable: false }) |
||
21 | private value: number; |
||
22 | |||
23 | @ManyToOne(() => School, { nullable: false, onDelete: 'CASCADE' }) |
||
24 | private school: School; |
||
25 | |||
26 | constructor( |
||
27 | type: DiscountType, |
||
28 | amount: number, |
||
29 | value: number, |
||
30 | school: School |
||
31 | ) { |
||
32 | this.type = type; |
||
33 | this.amount = amount; |
||
34 | this.value = value; |
||
35 | this.school = school; |
||
36 | } |
||
37 | |||
38 | public getId(): string { |
||
39 | return this.id; |
||
40 | } |
||
41 | |||
42 | public getAmount(): number { |
||
43 | return this.amount; |
||
44 | } |
||
45 | |||
46 | public getValue(): number { |
||
47 | return this.value; |
||
48 | } |
||
49 | |||
50 | public getType(): DiscountType { |
||
51 | return this.type; |
||
52 | } |
||
53 | |||
54 | public getSchool(): School { |
||
55 | return this.school; |
||
56 | } |
||
57 | } |
||
58 |