import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne, OneToMany } from 'typeorm'; import { Customer } from '../customers/customer.entity'; import { Contract } from '../contracts/contract.entity'; import { Purchase } from '../purchases/purchase.entity'; import { Subcontract } from '../subcontracts/subcontract.entity'; import { FinancialRecord } from '../finance/financial-record.entity'; import { ExpenseClaim } from '../finance/expense-claim.entity'; import { AdvancePayment } from '../finance/advance-payment.entity'; @Entity('projects') export class Project { @PrimaryGeneratedColumn('uuid') id: string; @Column({ type: 'varchar', length: 255, nullable: false }) name: string; @Column({ type: 'uuid', nullable: true }) customer_id: string; @ManyToOne(() => Customer, customer => customer.projects) customer: Customer; @Column({ type: 'varchar', length: 100, unique: true, nullable: false }) contract_number: string; @Column({ type: 'decimal', precision: 18, scale: 2, nullable: false }) contract_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: 'date', nullable: true }) start_date: Date; @Column({ type: 'date', nullable: true }) end_date: Date; @Column({ type: 'varchar', length: 50, nullable: false }) status: string; @Column({ type: 'varchar', length: 20, nullable: true }) settlement_type: string; // 'lump_sum' 或 'unit_price' @Column({ type: 'decimal', precision: 18, scale: 2, nullable: true }) estimated_quantity: number; @Column({ type: 'decimal', precision: 18, scale: 2, nullable: true }) unit_price: number; @CreateDateColumn() created_at: Date; @UpdateDateColumn() updated_at: Date; @OneToMany(() => Contract, contract => contract.project) contracts: Contract[]; @OneToMany(() => Purchase, purchase => purchase.project) purchases: Purchase[]; @OneToMany(() => Subcontract, subcontract => subcontract.project) subcontracts: Subcontract[]; @OneToMany(() => FinancialRecord, financialRecord => financialRecord.project) financial_records: FinancialRecord[]; @OneToMany(() => ExpenseClaim, expenseClaim => expenseClaim.project) expense_claims: ExpenseClaim[]; @OneToMany(() => AdvancePayment, advancePayment => advancePayment.project) advance_payments: AdvancePayment[]; }