mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 05:42:27 +00:00
101 lines
3.1 KiB
TypeScript
101 lines
3.1 KiB
TypeScript
import {
|
|
BaseEntity,
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
Generated,
|
|
JoinColumn,
|
|
OneToOne,
|
|
PrimaryColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Document } from '~/document/entities';
|
|
import { Guardian } from '~/guardian/entities/guradian.entity';
|
|
import { Junior } from '~/junior/entities';
|
|
import { User } from '~/user/entities';
|
|
import { CustomerStatus, KycStatus } from '../enums';
|
|
|
|
@Entity('customers')
|
|
export class Customer extends BaseEntity {
|
|
@PrimaryColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column('varchar', { length: 255, default: CustomerStatus.PENDING, name: 'customer_status' })
|
|
customerStatus!: CustomerStatus;
|
|
|
|
@Column('varchar', { length: 255, default: KycStatus.PENDING, name: 'kyc_status' })
|
|
kycStatus!: KycStatus;
|
|
|
|
@Column('text', { nullable: true, name: 'rejection_reason' })
|
|
rejectionReason!: string | null;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'first_name' })
|
|
firstName!: string;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'last_name' })
|
|
lastName!: string;
|
|
|
|
@Column('date', { nullable: true, name: 'date_of_birth' })
|
|
dateOfBirth!: Date;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'national_id' })
|
|
nationalId!: string;
|
|
|
|
@Column('date', { nullable: true, name: 'national_id_expiry' })
|
|
nationalIdExpiry!: Date;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'country_of_residence' })
|
|
countryOfResidence!: string;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'source_of_income' })
|
|
sourceOfIncome!: string;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'profession' })
|
|
profession!: string;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'profession_type' })
|
|
professionType!: string;
|
|
|
|
@Column('boolean', { default: false, name: 'is_pep' })
|
|
isPep!: boolean;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'gender' })
|
|
gender!: string;
|
|
|
|
@Column('boolean', { default: false, name: 'is_junior' })
|
|
isJunior!: boolean;
|
|
|
|
@Column('boolean', { default: false, name: 'is_guardian' })
|
|
isGuardian!: boolean;
|
|
|
|
@Column('int', { name: 'application_number' })
|
|
@Generated('increment')
|
|
applicationNumber!: number;
|
|
|
|
@Column('varchar', { name: 'user_id' })
|
|
userId!: string;
|
|
|
|
@Column('varchar', { name: 'profile_picture_id', nullable: true })
|
|
profilePictureId!: string;
|
|
|
|
@OneToOne(() => Document, (document) => document.customerPicture, { cascade: true, nullable: true })
|
|
@JoinColumn({ name: 'profile_picture_id' })
|
|
profilePicture!: Document;
|
|
|
|
@OneToOne(() => User, (user) => user.customer, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'user_id' })
|
|
user!: User;
|
|
|
|
@OneToOne(() => Junior, (junior) => junior.customer, { cascade: true })
|
|
junior!: Junior;
|
|
|
|
@OneToOne(() => Guardian, (guardian) => guardian.customer, { cascade: true })
|
|
guardian!: Guardian;
|
|
|
|
@CreateDateColumn({ type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP', name: 'created_at' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP', name: 'updated_at' })
|
|
updatedAt!: Date;
|
|
}
|