update asset list

This commit is contained in:
fadlydev
2025-01-15 10:15:24 +07:00
parent 8c1c035b8f
commit e8c65a6c35

View File

@ -2,13 +2,14 @@ import {
Entity, Entity,
PrimaryGeneratedColumn, PrimaryGeneratedColumn,
Column, Column,
ManyToOne,
CreateDateColumn, CreateDateColumn,
UpdateDateColumn, UpdateDateColumn,
ManyToOne, DeleteDateColumn,
JoinColumn, JoinColumn
} from 'typeorm'; } from 'typeorm';
import { Supplier } from './supplier';
import { Goods } from './goods'; import { AssetCategory } from './asset_category';
import { Department } from './department'; import { Department } from './department';
@Entity('assets') @Entity('assets')
@ -16,75 +17,57 @@ export class Asset {
@PrimaryGeneratedColumn('uuid') @PrimaryGeneratedColumn('uuid')
id: string; id: string;
@ManyToOne(() => Goods, (goods) => goods.id, { nullable: false }) @Column({ type: 'varchar', length: 255 })
@JoinColumn({ name: 'goods_id' }) name: string;
goods: Goods;
@Column({ @Column({ type: 'varchar', length: 100, unique: true })
nullable: false, assetCode: string;
type: 'uuid',
})
goods_id: string;
@Column({ @ManyToOne(() => AssetCategory, (category) => category, { nullable: false })
nullable: false, @JoinColumn({ name: 'category_id' })
length: 128, category: AssetCategory;
})
asset_code: string;
@Column({ @ManyToOne(() => Supplier, (supplier) => supplier.id, { nullable: true })
nullable: false, @JoinColumn({ name: 'supplier_id' })
length: 256, supplier: Supplier;
})
asset_name: string;
@Column({ @Column({ type: 'decimal', precision: 10, scale: 2 })
nullable: true, cost: number;
type: 'text',
})
description: string;
@ManyToOne(() => Department, (department) => department.id, { nullable: false }) @Column({ type: 'int' })
@JoinColumn({ name: 'department_id' }) quantity: number;
department: Department;
@Column({ @Column({ type: 'varchar', length: 255, nullable: true })
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',
})
location: string; location: string;
@Column({ @ManyToOne(() => Department, (department) => department.code, { nullable: true })
nullable: false, @JoinColumn({ name: 'assigned_to' })
length: 64, assignedTo: Department;
})
status: string;
@Column() @Column({ type: 'enum', enum: ['Active', 'In Maintenance', 'Retired'], default: 'Active' })
@CreateDateColumn() status: 'Active' | 'In Maintenance' | 'Retired';
created_at: Date;
@Column({ nullable: true }) @Column({ type: 'varchar', length: 255, nullable: true })
@UpdateDateColumn() condition: string;
updated_at: Date;
@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;
} }