chore: complete the discount service and test the logic to create
This commit is contained in:
@@ -3,6 +3,8 @@ import { Column, DeleteDateColumn, Entity, OneToMany } from "typeorm";
|
||||
import { UsageDiscount } from "./usage-discount.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { DecimalTransformer } from "../../../common/transformers/decimal.transformer";
|
||||
import { SubscriptionPlan } from "../../subscriptions/entities/subscription.entity";
|
||||
import { DiscountApplicationType } from "../enums/discount-application-type.enum";
|
||||
import { DiscountType } from "../enums/discount-type.enum";
|
||||
|
||||
@Entity()
|
||||
@@ -10,8 +12,11 @@ export class Discount extends BaseEntity {
|
||||
@Column({ type: "varchar", length: 150 })
|
||||
title: string;
|
||||
|
||||
@Column({ type: "varchar", length: 100, unique: true })
|
||||
code: string;
|
||||
@Column({ type: "enum", enum: DiscountApplicationType })
|
||||
applicationType: DiscountApplicationType;
|
||||
|
||||
@Column({ type: "varchar", length: 100, unique: true, nullable: true })
|
||||
code?: string;
|
||||
|
||||
@Column({ type: "enum", enum: DiscountType, default: DiscountType.PERCENTAGE })
|
||||
type: DiscountType;
|
||||
@@ -31,9 +36,13 @@ export class Discount extends BaseEntity {
|
||||
@Column({ type: "boolean", default: true })
|
||||
isActive: boolean;
|
||||
|
||||
@DeleteDateColumn({ nullable: true })
|
||||
deletedAt?: Date;
|
||||
|
||||
// Relations
|
||||
@OneToMany(() => UsageDiscount, (usageDiscount) => usageDiscount.discount)
|
||||
usages: UsageDiscount[];
|
||||
|
||||
@DeleteDateColumn({ nullable: true })
|
||||
deletedAt?: Date;
|
||||
@OneToMany(() => SubscriptionPlan, (subscriptionPlan) => subscriptionPlan.directDiscount)
|
||||
subscriptionPlans: SubscriptionPlan[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user