chore: discount module

This commit is contained in:
Matin
2025-02-16 16:30:17 +03:30
parent 6785b3e9d0
commit 20d6c5b294
31 changed files with 1752 additions and 141 deletions
@@ -0,0 +1,24 @@
import { Column, Entity, JoinColumn, OneToOne, Unique } from "typeorm";
import { User } from "./user.entity";
import { BaseEntity } from "../../../common/entities/base.entity";
@Unique(["user"])
@Entity()
export class LegalUser extends BaseEntity {
@Column({ nullable: true })
economicCode: string;
@Column({ nullable: true })
registrationId: string;
@Column({ nullable: true })
nationalId: string;
@Column({ nullable: true })
number: string;
@OneToOne(() => User, (user) => user.legalUser, { onDelete: "CASCADE" })
@JoinColumn()
user: User;
}
@@ -0,0 +1,26 @@
import { Column, Entity, JoinColumn, OneToOne, Unique } from "typeorm";
import { User } from "./user.entity";
import { BaseEntity } from "../../../common/entities/base.entity";
import { GenderType } from "../enums/gender-type.enum";
@Unique(["user"])
@Entity()
export class RealUser extends BaseEntity {
@Column({
type: "enum",
enum: GenderType,
nullable: true,
})
gender: GenderType;
@Column({ nullable: true })
fatherName: string;
@Column({ nullable: true })
nationality: string;
@OneToOne(() => User, (user) => user.realUser, { onDelete: "CASCADE" })
@JoinColumn()
user: User;
}
@@ -1,31 +0,0 @@
import { Column, Entity, ManyToOne, Unique } from "typeorm";
import { User } from "./user.entity";
import { BaseEntity } from "../../../common/entities/base.entity";
import { FinancialType } from "../enums/financial-type.enum";
@Unique(["user", "type"])
@Entity()
export class UserFinancial extends BaseEntity {
@Column({
type: "enum",
enum: FinancialType,
default: FinancialType.REAL,
})
type: FinancialType;
@Column({ nullable: true })
economicCode: string;
@Column({ nullable: true })
registrationId: string;
@Column({ nullable: true })
nationalId: string;
@Column({ nullable: true })
number: string;
@ManyToOne(() => User, (user) => user.userFinancials)
user: User;
}
+11 -3
View File
@@ -1,12 +1,14 @@
import { Exclude } from "class-transformer";
import { Column, Entity, ManyToMany, ManyToOne, OneToMany, OneToOne } from "typeorm";
import { LegalUser } from "./legal-user.entity";
import { RealUser } from "./real-user.entity";
import { Role } from "./role.entity";
import { UserFinancial } from "./user-financial.entity";
import { UserGroup } from "./user-group.entity";
import { BaseEntity } from "../../../common/entities/base.entity";
import { UserAnnouncement } from "../../announcements/entities/user-announcement.entity";
import { Criticism } from "../../criticisms/entities/criticism.entity";
import { Discount } from "../../discounts/entities/discount.entity";
import { Invoice } from "../../invoices/entities/invoice.entity";
import { LearningProgress } from "../../learnings/entities/learning-progress.entity";
import { Notification } from "../../notifications/entities/notification.entity";
@@ -84,8 +86,14 @@ export class User extends BaseEntity {
@OneToMany(() => LearningProgress, (learningProgress) => learningProgress.learning)
learningProgress: LearningProgress[];
@OneToMany(() => UserFinancial, (userFinancial) => userFinancial.user)
userFinancials: UserFinancial[];
@ManyToMany(() => Discount, (discount) => discount.subscriptionPlans)
discounts: Discount[];
@OneToOne(() => RealUser, (realUser) => realUser.user, { cascade: true, nullable: true })
realUser: RealUser;
@OneToOne(() => LegalUser, (legalUser) => legalUser.user, { cascade: true, nullable: true })
legalUser: LegalUser;
}
// @ManyToMany(() => DanakService, (danakService) => danakService.users)