chore: complete the the invoice module - not tested

This commit is contained in:
mahyargdz
2025-02-11 14:25:49 +03:30
parent bbdc5996b5
commit 49c62018f0
24 changed files with 674 additions and 74 deletions
@@ -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;
}