chore: complete create discount

This commit is contained in:
Matin
2025-02-12 14:25:39 +03:30
parent 22198f3240
commit 95b9c38031
11 changed files with 343 additions and 2 deletions
@@ -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[];
}