chore: add discount logic to apply to the plan price and ...
This commit is contained in:
@@ -20,6 +20,9 @@ export class Invoice extends BaseEntity {
|
||||
@Column({ type: "decimal", precision: 16, scale: 2, nullable: false, transformer: new DecimalTransformer() })
|
||||
totalPrice: Decimal;
|
||||
|
||||
@Column({ type: "decimal", precision: 16, scale: 2, nullable: true, transformer: new DecimalTransformer() })
|
||||
originalPrice?: Decimal;
|
||||
|
||||
@Column({ type: "enum", enum: InvoiceStatus, default: InvoiceStatus.PENDING })
|
||||
status: InvoiceStatus;
|
||||
|
||||
@@ -40,8 +43,8 @@ export class Invoice extends BaseEntity {
|
||||
@OneToMany(() => InvoiceItem, (invoiceItem) => invoiceItem.invoice, { cascade: true })
|
||||
items: InvoiceItem[];
|
||||
|
||||
@ManyToOne(() => Discount, { nullable: true, onDelete: "SET NULL" })
|
||||
discount: Discount;
|
||||
@ManyToOne(() => Discount, (discount) => discount.invoices, { nullable: true, onDelete: "RESTRICT" })
|
||||
discount?: Discount;
|
||||
|
||||
get isOverdue(): boolean {
|
||||
return this.status === InvoiceStatus.PENDING && new Date() > this.dueDate;
|
||||
|
||||
Reference in New Issue
Block a user