chore: discount module
This commit is contained in:
@@ -5,6 +5,7 @@ import { Column, Entity, ManyToOne, OneToMany } from "typeorm";
|
||||
import { InvoiceItem } from "./invoice-item.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { DecimalTransformer } from "../../../common/transformers/decimal.transformer";
|
||||
import { Discount } from "../../discounts/entities/discount.entity";
|
||||
import { User } from "../../users/entities/user.entity";
|
||||
import { InvoiceStatus } from "../enums/invoice-status.enum";
|
||||
|
||||
@@ -28,9 +29,14 @@ export class Invoice extends BaseEntity {
|
||||
@Column({ type: "int", default: 0 })
|
||||
tax: number;
|
||||
|
||||
//---------------------------------------------
|
||||
|
||||
@OneToMany(() => InvoiceItem, (invoiceItem) => invoiceItem.invoice, { cascade: true })
|
||||
items: InvoiceItem[];
|
||||
|
||||
@ManyToOne(() => Discount, { nullable: true, onDelete: "SET NULL" })
|
||||
discount: Discount;
|
||||
|
||||
get isOverdue(): boolean {
|
||||
return this.status === InvoiceStatus.PENDING && new Date() > this.dueDate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user