chore: complete create discount
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import Decimal from "decimal.js";
|
||||
import { Column, Entity, JoinTable, ManyToMany } from "typeorm";
|
||||
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { DecimalTransformer } from "../../../common/transformers/decimal.transformer";
|
||||
import { DanakService } from "../../danak-services/entities/danak-service.entity";
|
||||
import { DiscountCalculationType, DiscountType } from "../enums/discount-type.enum";
|
||||
|
||||
@Entity()
|
||||
export class Discount extends BaseEntity {
|
||||
@Column({ type: "varchar", length: 200, nullable: false })
|
||||
title: string;
|
||||
|
||||
@Column({ type: "enum", enum: DiscountType })
|
||||
type: DiscountType;
|
||||
|
||||
@Column({ type: "enum", enum: DiscountCalculationType })
|
||||
calculationType: DiscountCalculationType;
|
||||
|
||||
@Column({ type: "decimal", precision: 10, scale: 2, nullable: false, transformer: new DecimalTransformer() })
|
||||
amount: Decimal;
|
||||
|
||||
@Column({ type: "boolean", default: true })
|
||||
isActive: boolean;
|
||||
|
||||
@Column({ nullable: true })
|
||||
code?: string;
|
||||
|
||||
@Column({ type: "timestamptz" })
|
||||
startDate: Date;
|
||||
|
||||
@Column({ type: "timestamptz" })
|
||||
endDate: Date;
|
||||
|
||||
@ManyToMany(() => DanakService, (danakService) => danakService.discounts, { nullable: true })
|
||||
@JoinTable()
|
||||
services?: DanakService[];
|
||||
}
|
||||
Reference in New Issue
Block a user