Passed
Push — master ( 9141d4...2cdb9e )
by Mathieu
02:07
created

SchoolProduct.getParentPriceFromCents   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
rs 10
c 0
b 0
f 0
cc 1
1
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
2
import { Product } from '../Product/Product.entity';
3
import { School } from './School.entity';
4
5
@Entity()
6
export class SchoolProduct {
7
  @PrimaryGeneratedColumn('uuid')
8
  private id: string;
9
10
  @Column({ type: 'integer', nullable: false, default: 0 })
11
  private parentUnitPrice: number;
12
13
  @Column({ type: 'integer', nullable: false, default: 0 })
14
  private photographerUnitPrice: number;
15
16
  @ManyToOne(() => School, { nullable: false, onDelete: 'CASCADE' })
17
  private school: School;
18
19
  @ManyToOne(() => Product, { nullable: true, onDelete: 'CASCADE' })
20
  private product: Product;
21
22
  constructor(
23
    parentUnitPrice: number,
24
    photographerUnitPrice: number,
25
    school: School,
26
    product: Product
27
  ) {
28
    this.parentUnitPrice = parentUnitPrice;
29
    this.photographerUnitPrice = photographerUnitPrice;
30
    this.school = school;
31
    this.product = product;
32
  }
33
34
  public updatePrices(parentUnitPrice: number, photographerUnitPrice: number): void {
35
    this.parentUnitPrice = parentUnitPrice;
36
    this.photographerUnitPrice = photographerUnitPrice;
37
  }
38
39
  public getId(): string {
40
    return this.id;
41
  }
42
43
  public getPhotographerUnitPrice(): number {
44
    return this.photographerUnitPrice;
45
  }
46
47
  public getPhotographerPriceFromCents(): number {
48
    return this.photographerUnitPrice / 100;
49
  }
50
51
  public getParentUnitPrice(): number {
52
    return this.parentUnitPrice;
53
  }
54
55
  public getParentPriceFromCents(): number {
56
    return this.parentUnitPrice / 100;
57
  }
58
59
  public getSchool(): School {
60
    return this.school;
61
  }
62
63
  public getProduct(): Product {
64
    return this.product;
65
  }
66
}
67