import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne, OneToMany } from 'typeorm'; import { Project } from '../projects/project.entity'; import { PaymentTerm } from '../contracts/payment-term.entity'; import { FinancialTransaction } from './financial-transaction.entity'; @Entity('financial_records') export class FinancialRecord { @PrimaryGeneratedColumn('uuid') id: string; @Column({ type: 'varchar', length: 50, nullable: false }) type: string; @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: 'uuid', nullable: true }) project_id: string; @ManyToOne(() => Project, project => project.financial_records) project: Project; @Column({ type: 'uuid', nullable: true }) related_id: string; @Column({ type: 'varchar', length: 50, nullable: true }) related_type: string; @Column({ type: 'uuid', nullable: true }) payment_term_id: string; @ManyToOne(() => PaymentTerm, paymentTerm => paymentTerm.financial_records) payment_term: PaymentTerm; @Column({ type: 'varchar', length: 50, nullable: false }) status: string; @Column({ type: 'text', nullable: true }) description: string; @CreateDateColumn() created_at: Date; @UpdateDateColumn() updated_at: Date; @OneToMany(() => FinancialTransaction, financialTransaction => financialTransaction.financial_record) financial_transactions: FinancialTransaction[]; }