import { Entity , Column , PrimaryGeneratedColumn , ManyToOne } from 'typeorm' ; import { Invoice } from './Invoice.entity' ; @ Entity ( ) export class InvoiceItem { @ PrimaryGeneratedColumn ( 'uuid' ) private id : string ; @ Column ( { type : 'varchar' , nullable : false } ) private title : string ; @ Column ( { type : 'integer' , nullable : false , comment : 'Stored in base 100' } ) private quantity : number ; @ Column ( { type : 'integer' , nullable : false , comment : 'Stored in base 100' } ) private amount : number ; @ Column ( { type : 'integer' , nullable : true , default : 0 , comment : 'Stored in base 100' } ) private discount : number ; @ ManyToOne ( type => Invoice , invoice => invoice . items , { nullable : false , onDelete : 'CASCADE' } ) invoice : Invoice ; constructor ( invoice , title , quantity , amount , discount ? ) { this . invoice = invoice ; this . title = title ; this . quantity = quantity ; this . amount = amount ; this . discount = discount ; } public getId ( ) { return this . id ; } public getTitle ( ) { return this . title ; } public getAmount ( ) { return this . amount ; } public getDiscount ( ) { return this . discount ; } public getQuantity ( ) { return this . quantity ; } public getInvoice ( ) { return this . invoice ; } }