From 8828a0230e80b0b858d666c9f00d6c3d0ace59a5 Mon Sep 17 00:00:00 2001 From: fadlydev Date: Wed, 8 Jan 2025 21:46:51 +0700 Subject: [PATCH] adding fixed_assets and asset_depreciation --- src/entity/asset_depreciation.ts | 84 ++++++++++++++++ src/entity/fixed_assets_classification.ts | 113 ++++++++++++++++++++++ src/index.ts | 4 + 3 files changed, 201 insertions(+) create mode 100644 src/entity/asset_depreciation.ts create mode 100644 src/entity/fixed_assets_classification.ts diff --git a/src/entity/asset_depreciation.ts b/src/entity/asset_depreciation.ts new file mode 100644 index 0000000..16f7c76 --- /dev/null +++ b/src/entity/asset_depreciation.ts @@ -0,0 +1,84 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + Index, + ManyToOne, + JoinColumn, +} from 'typeorm'; + +import { User } from './users'; +import { FixedAssetClassification } from './fixed_assets_classification'; + +@Entity('asset_depreciation') +export class AssetDepreciation { + @PrimaryGeneratedColumn('uuid') + id: string; + + @ManyToOne(() => FixedAssetClassification, (asset) => asset.id, { nullable: false }) + @JoinColumn({ name: 'asset_id' }) + asset: FixedAssetClassification; + + @Column({ + nullable: false, + type: 'uuid', + }) + asset_id: string; + + @Column({ + nullable: false, + type: 'date', + }) + depreciation_date: Date; + + @Column({ + nullable: false, + type: 'decimal', + precision: 12, + scale: 2, + }) + depreciation_amount: number; + + @Column({ + nullable: true, + type: 'text', + }) + remarks: string; + + @ManyToOne(() => User, (user) => user.id, { nullable: true }) + @JoinColumn({ name: 'created_by' }) + createdBy: User; + + @Index() + @Column({ + nullable: true, + type: 'uuid', + }) + created_by: string; + + @ManyToOne(() => User, (user) => user.id, { 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/entity/fixed_assets_classification.ts b/src/entity/fixed_assets_classification.ts new file mode 100644 index 0000000..469e0ea --- /dev/null +++ b/src/entity/fixed_assets_classification.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('fixed_assets') +export class FixedAssetClassification { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 128, + }) + name: string; + + @Column({ + nullable: true, + length: 255, + }) + description: string; + + @Column({ + nullable: false, + length: 64, + unique: true, + }) + asset_code: string; + + @Column({ + nullable: false, + type: 'decimal', + precision: 12, + scale: 2, + }) + acquisition_cost: number; + + @Column({ + nullable: true, + type: 'date', + }) + acquisition_date: Date; + + @Column({ + nullable: true, + type: 'date', + }) + depreciation_start_date: Date; + + @Column({ + nullable: true, + type: 'decimal', + precision: 5, + scale: 2, + }) + depreciation_rate: number; + + @Column({ + nullable: true, + type: 'uuid', + }) + category_id: string; + + @ManyToOne(() => User, (user) => user.id, { nullable: true }) + @JoinColumn({ name: 'created_by' }) + createdBy: User; + + @Index() + @Column({ + nullable: true, + type: 'uuid', + }) + created_by: string; + + @ManyToOne(() => User, (user) => user.id, { nullable: true }) + @JoinColumn({ name: 'updated_by' }) + updatedBy: User; + + @Index() + @Column({ + nullable: true, + type: 'uuid', + }) + updated_by: string; + + @Column({ + nullable: false, + length: 64, + }) + status: Status; + + @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 e311688..42cf25b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,7 +48,9 @@ import { CreditApplicationStatus } from "./types/credit"; import { CreditApplicationForm } from "./entity/credit_application_forms"; import { Application } from "./entity/application"; import { AssetClassification } from "./entity/asset_classification" +import { FixedAssetClassification } from "./entity/fixed_assets_classification"; import { Employee } from "./entity/employee"; +import { AssetDepreciation } from "./entity/asset_depreciation"; export { User, // UserRole, @@ -96,6 +98,8 @@ export { Supplier, AssetCategory, AssetClassification, + FixedAssetClassification, + AssetDepreciation, Employee, Ledger, CreditCompany,