| Total Complexity | 6 |
| Complexity/F | 1 |
| Lines of Code | 66 |
| Function Count | 6 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'; |
||
| 2 | import { Invoice } from './Invoice.entity'; |
||
| 3 | |||
| 4 | @Entity() |
||
| 5 | export class InvoiceItem { |
||
| 6 | @PrimaryGeneratedColumn('uuid') |
||
| 7 | private id: string; |
||
| 8 | |||
| 9 | @Column({type: 'varchar', nullable: false}) |
||
| 10 | private title: string; |
||
| 11 | |||
| 12 | @Column({type: 'integer', nullable: false}) |
||
| 13 | private quantity: number; |
||
| 14 | |||
| 15 | @Column({type: 'integer', nullable: false}) |
||
| 16 | private amount: number; |
||
| 17 | |||
| 18 | @Column({type: 'integer', nullable: true, default: 0}) |
||
| 19 | private discount: number; |
||
| 20 | |||
| 21 | @ManyToOne( |
||
| 22 | type => Invoice, |
||
| 23 | invoice => invoice.items, |
||
| 24 | {nullable: false, onDelete: 'CASCADE'} |
||
| 25 | ) |
||
| 26 | invoice: Invoice; |
||
| 27 | |||
| 28 | constructor( |
||
| 29 | invoice: Invoice, |
||
| 30 | title: string, |
||
| 31 | quantity: number, |
||
| 32 | amount: number, |
||
| 33 | discount?: number |
||
| 34 | ) { |
||
| 35 | this.invoice = invoice; |
||
| 36 | this.title = title; |
||
| 37 | this.quantity = quantity; |
||
| 38 | this.amount = amount; |
||
| 39 | this.discount = discount; |
||
| 40 | } |
||
| 41 | |||
| 42 | public getId(): string { |
||
| 43 | return this.id; |
||
| 44 | } |
||
| 45 | |||
| 46 | public getTitle(): string { |
||
| 47 | return this.title; |
||
| 48 | } |
||
| 49 | |||
| 50 | public getAmount(): number { |
||
| 51 | return this.amount; |
||
| 52 | } |
||
| 53 | |||
| 54 | public getDiscount(): number { |
||
| 55 | return this.discount; |
||
| 56 | } |
||
| 57 | |||
| 58 | public getQuantity(): number { |
||
| 59 | return this.quantity; |
||
| 60 | } |
||
| 61 | |||
| 62 | public getInvoice(): Invoice { |
||
| 63 | return this.invoice; |
||
| 64 | } |
||
| 65 | } |
||
| 66 |