chore: complete the the invoice module - not tested
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// eslint-disable-next-line import/no-named-as-default
|
||||
import Decimal from "decimal.js";
|
||||
import { Column, Entity, ManyToOne } from "typeorm";
|
||||
|
||||
import { Invoice } from "./invoice.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { DecimalTransformer } from "../../../common/transformers/decimal.transformer";
|
||||
import { SubscriptionPlan } from "../../subscriptions/entities/subscription.entity";
|
||||
|
||||
@Entity()
|
||||
export class InvoiceItem extends BaseEntity {
|
||||
@ManyToOne(() => Invoice, (invoice) => invoice.items, { onDelete: "CASCADE" })
|
||||
invoice: Invoice;
|
||||
|
||||
@Column({ type: "varchar", length: 150, nullable: false })
|
||||
name: string;
|
||||
|
||||
@Column({ type: "int", nullable: false })
|
||||
count: number;
|
||||
|
||||
@Column({ type: "decimal", precision: 16, scale: 2, nullable: false, transformer: new DecimalTransformer() })
|
||||
unitPrice: Decimal;
|
||||
|
||||
@Column({ type: "int", nullable: false })
|
||||
discount: number;
|
||||
|
||||
@Column({ type: "decimal", precision: 16, scale: 2, nullable: false, transformer: new DecimalTransformer() })
|
||||
totalPrice: Decimal;
|
||||
|
||||
@ManyToOne(() => SubscriptionPlan, { nullable: true, onDelete: "RESTRICT" })
|
||||
subscriptionPlan: SubscriptionPlan | null;
|
||||
}
|
||||
Reference in New Issue
Block a user