update: the danak services module and add new route to fetch the danak service
This commit is contained in:
Executable → Regular
+16
-28
@@ -1,34 +1,24 @@
|
||||
// eslint-disable-next-line import/no-named-as-default
|
||||
import Decimal from "decimal.js";
|
||||
import { Column, Entity, JoinTable, ManyToMany, OneToMany } from "typeorm";
|
||||
import { Column, Entity, OneToMany } from "typeorm";
|
||||
|
||||
import { DiscountService } from "./discount-product.entity";
|
||||
import { UsageDiscount } from "./usage-discount.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { DecimalTransformer } from "../../../common/transformers/decimal.transformer";
|
||||
import { Invoice } from "../../invoices/entities/invoice.entity";
|
||||
import { SubscriptionPlan } from "../../subscriptions/entities/subscription.entity";
|
||||
import { User } from "../../users/entities/user.entity";
|
||||
import { DiscountCalculationType, DiscountType } from "../enums/discount-type.enum";
|
||||
import { DiscountType } from "../enums/discount-type.enum";
|
||||
|
||||
@Entity()
|
||||
export class Discount extends BaseEntity {
|
||||
@Column({ type: "varchar", length: 200, nullable: false })
|
||||
@Column({ type: "varchar", length: 150 })
|
||||
title: string;
|
||||
|
||||
@Column({ type: "enum", enum: DiscountType })
|
||||
@Column({ type: "varchar", length: 100, unique: true })
|
||||
code: string;
|
||||
|
||||
@Column({ type: "enum", enum: DiscountType, default: DiscountType.PERCENTAGE })
|
||||
type: DiscountType;
|
||||
|
||||
@Column({ type: "enum", enum: DiscountCalculationType })
|
||||
calculationType: DiscountCalculationType;
|
||||
|
||||
@Column({ type: "decimal", precision: 16, scale: 2, nullable: false, transformer: new DecimalTransformer() })
|
||||
amount: Decimal;
|
||||
|
||||
@Column({ type: "boolean", default: true })
|
||||
isActive: boolean;
|
||||
|
||||
@Column({ nullable: true })
|
||||
code?: string;
|
||||
@Column({ type: "decimal", precision: 16, scale: 2, transformer: new DecimalTransformer() })
|
||||
value: number;
|
||||
|
||||
@Column({ type: "timestamptz" })
|
||||
startDate: Date;
|
||||
@@ -36,16 +26,14 @@ export class Discount extends BaseEntity {
|
||||
@Column({ type: "timestamptz" })
|
||||
endDate: Date;
|
||||
|
||||
@ManyToMany(() => SubscriptionPlan, { nullable: true })
|
||||
@JoinTable()
|
||||
subscriptionPlans: SubscriptionPlan[];
|
||||
@Column({ type: "int", default: 0 })
|
||||
usedCount: number;
|
||||
|
||||
@ManyToMany(() => User, (user) => user.discounts, { nullable: true })
|
||||
@JoinTable()
|
||||
users: User[];
|
||||
@Column({ type: "boolean", default: true })
|
||||
isActive: boolean;
|
||||
|
||||
@OneToMany(() => Invoice, (invoice) => invoice.discount)
|
||||
invoice: Invoice;
|
||||
@OneToMany(() => DiscountService, (discountService) => discountService.discount, { cascade: true })
|
||||
discountServices: DiscountService[];
|
||||
|
||||
@OneToMany(() => UsageDiscount, (usageDiscount) => usageDiscount.discount)
|
||||
usages: UsageDiscount[];
|
||||
|
||||
Reference in New Issue
Block a user