diff --git a/src/entity/assets.ts b/src/entity/assets.ts index 0a3a734..dbae781 100644 --- a/src/entity/assets.ts +++ b/src/entity/assets.ts @@ -2,13 +2,14 @@ import { Entity, PrimaryGeneratedColumn, Column, + ManyToOne, CreateDateColumn, UpdateDateColumn, - ManyToOne, - JoinColumn, + DeleteDateColumn, + JoinColumn } from 'typeorm'; - -import { Goods } from './goods'; +import { Supplier } from './supplier'; +import { AssetCategory } from './asset_category'; import { Department } from './department'; @Entity('assets') @@ -16,75 +17,57 @@ export class Asset { @PrimaryGeneratedColumn('uuid') id: string; - @ManyToOne(() => Goods, (goods) => goods.id, { nullable: false }) - @JoinColumn({ name: 'goods_id' }) - goods: Goods; + @Column({ type: 'varchar', length: 255 }) + name: string; - @Column({ - nullable: false, - type: 'uuid', - }) - goods_id: string; + @Column({ type: 'varchar', length: 100, unique: true }) + assetCode: string; - @Column({ - nullable: false, - length: 128, - }) - asset_code: string; + @ManyToOne(() => AssetCategory, (category) => category, { nullable: false }) + @JoinColumn({ name: 'category_id' }) + category: AssetCategory; - @Column({ - nullable: false, - length: 256, - }) - asset_name: string; + @ManyToOne(() => Supplier, (supplier) => supplier.id, { nullable: true }) + @JoinColumn({ name: 'supplier_id' }) + supplier: Supplier; - @Column({ - nullable: true, - type: 'text', - }) - description: string; + @Column({ type: 'decimal', precision: 10, scale: 2 }) + cost: number; - @ManyToOne(() => Department, (department) => department.id, { nullable: false }) - @JoinColumn({ name: 'department_id' }) - department: Department; + @Column({ type: 'int' }) + quantity: number; - @Column({ - nullable: false, - type: 'uuid', - }) - department_id: string; - - @Column({ - nullable: false, - type: 'decimal', - precision: 12, - scale: 2, - }) - purchase_price: number; - - @Column({ - nullable: false, - type: 'date', - }) - purchase_date: Date; - - @Column({ - nullable: true, - type: 'text', - }) + @Column({ type: 'varchar', length: 255, nullable: true }) location: string; - @Column({ - nullable: false, - length: 64, - }) - status: string; + @ManyToOne(() => Department, (department) => department.code, { nullable: true }) + @JoinColumn({ name: 'assigned_to' }) + assignedTo: Department; - @Column() - @CreateDateColumn() - created_at: Date; + @Column({ type: 'enum', enum: ['Active', 'In Maintenance', 'Retired'], default: 'Active' }) + status: 'Active' | 'In Maintenance' | 'Retired'; - @Column({ nullable: true }) - @UpdateDateColumn() - updated_at: Date; + @Column({ type: 'varchar', length: 255, nullable: true }) + condition: string; + + @Column({ type: 'timestamp', nullable: true }) + acquisitionDate: Date; + + @Column({ type: 'timestamp', nullable: true }) + lastMaintenanceDate: Date; + + @Column({ type: 'timestamp', nullable: true }) + nextScheduledMaintenance: Date; + + @Column({ type: 'text', nullable: true }) + remarks: string; + + @CreateDateColumn({ type: 'timestamp' }) + createdAt: Date; + + @UpdateDateColumn({ type: 'timestamp' }) + updatedAt: Date; + + @DeleteDateColumn({ type: 'timestamp' }) + deletedAt: Date; }