From c71937849a59b6217a061cd5874f1a3d9ed80ae6 Mon Sep 17 00:00:00 2001 From: fadlydev Date: Wed, 8 Jan 2025 09:51:02 +0700 Subject: [PATCH] fix asset class and add employee --- .../asset_classification.ts} | 2 +- src/entity/employee.ts | 113 ++++++++++++++++++ src/index.ts | 4 +- 3 files changed, 117 insertions(+), 2 deletions(-) rename src/{assetClasification.ts => entity/asset_classification.ts} (96%) create mode 100644 src/entity/employee.ts diff --git a/src/assetClasification.ts b/src/entity/asset_classification.ts similarity index 96% rename from src/assetClasification.ts rename to src/entity/asset_classification.ts index 76fff7c..56b745d 100644 --- a/src/assetClasification.ts +++ b/src/entity/asset_classification.ts @@ -7,7 +7,7 @@ DeleteDateColumn, } from 'typeorm'; - @Entity('assetClassification') + @Entity('asset_classification') export class AssetClassification { @PrimaryGeneratedColumn('uuid') id: string; diff --git a/src/entity/employee.ts b/src/entity/employee.ts new file mode 100644 index 0000000..6ad637a --- /dev/null +++ b/src/entity/employee.ts @@ -0,0 +1,113 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + Index, + ManyToOne, + JoinColumn, +} from 'typeorm'; + +import { Status } from '../types/status'; +import { User } from './users'; + +@Entity('employees') +export class Employee { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 64, + }) + first_name: string; + + @Column({ + nullable: false, + length: 64, + }) + last_name: string; + + @Column({ + nullable: false, + unique: true, + length: 128, + }) + email: string; + + @Column({ + nullable: true, + length: 15, + }) + phone_number: string; + + @Column({ + nullable: false, + length: 128, + }) + position: string; + + @Column({ + nullable: true, + type: 'uuid', + }) + branch_id: string; + + @Column({ + nullable: false, + type: 'date', + }) + hired_date: Date; + + @ManyToOne(() => Employee, { nullable: true }) + @JoinColumn({ name: 'manager_id' }) + manager: Employee; + + @Column({ + nullable: true, + type: 'uuid', + }) + manager_id: string; + + @Column({ + nullable: false, + length: 64, + }) + status: Status; + + @ManyToOne(() => User, { nullable: true }) + @JoinColumn({ name: 'created_by' }) + createdBy: User; + + @Index() + @Column({ + nullable: true, + type: 'uuid', + }) + created_by: string; + + @ManyToOne(() => User, { nullable: true }) + @JoinColumn({ name: 'updated_by' }) + updatedBy: User; + + @Index() + @Column({ + nullable: true, + type: 'uuid', + }) + updated_by: string; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} diff --git a/src/index.ts b/src/index.ts index 6a8cac2..e311688 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,7 +47,8 @@ import { CreditApplication } from "./entity/credit_applications"; import { CreditApplicationStatus } from "./types/credit"; import { CreditApplicationForm } from "./entity/credit_application_forms"; import { Application } from "./entity/application"; -import { AssetClassification } from "./assetClasification"; +import { AssetClassification } from "./entity/asset_classification" +import { Employee } from "./entity/employee"; export { User, // UserRole, @@ -95,6 +96,7 @@ export { Supplier, AssetCategory, AssetClassification, + Employee, Ledger, CreditCompany, CreditDebtor,