import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne } from 'typeorm'; import { User } from '../users/user.entity'; import { Project } from '../projects/project.entity'; @Entity('advance_payments') export class AdvancePayment { @PrimaryGeneratedColumn('uuid') id: string; @Column({ type: 'uuid', nullable: false }) user_id: string; @ManyToOne(() => User) user: User; @Column({ type: 'varchar', length: 20, nullable: false }) expense_type: string; // company or project @Column({ type: 'uuid', nullable: true }) project_id: string; @ManyToOne(() => Project, project => project.advance_payments) project: Project; @Column({ type: 'decimal', precision: 18, scale: 2, nullable: false }) amount: number; @Column({ type: 'varchar', length: 10, nullable: false }) currency: string; @Column({ type: 'decimal', precision: 18, scale: 2, nullable: false }) rmb_equivalent: number; @Column({ type: 'varchar', length: 255, nullable: false }) purpose: string; @Column({ type: 'varchar', length: 50, nullable: false }) status: string; @Column({ type: 'uuid', nullable: true }) approver_id: string; @ManyToOne(() => User) approver: User; @Column({ type: 'text', nullable: true }) description: string; @Column({ type: 'datetime', nullable: true }) submitted_at: Date; @Column({ type: 'datetime', nullable: true }) approved_at: Date; @Column({ type: 'datetime', nullable: true }) rejected_at: Date; @Column({ type: 'decimal', precision: 18, scale: 2, default: 0 }) used_amount: number; @Column({ type: 'decimal', precision: 18, scale: 2, default: 0 }) remaining_amount: number; @CreateDateColumn() created_at: Date; @UpdateDateColumn() updated_at: Date; }