import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { Student } from './student.entity';

@Entity('personal_expenses')
export class PersonalExpense {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ name: 'student_id' })
  studentId: number;

  @Column({ name: 'room_id', nullable: true })
  roomId: number;

  @Column({ name: 'expense_type', type: 'varchar', length: 20 })
  expenseType: string;

  @Column({ type: 'decimal', precision: 10, scale: 2 })
  amount: number;

  @Column({ name: 'expense_date', type: 'date' })
  expenseDate: string;

  @Column({ type: 'text', nullable: true })
  description: string;

  @Column({ name: 'recorded_by', nullable: true })
  recordedBy: number;

  @Column({ type: 'varchar', length: 20, default: 'active' })
  status: 'active' | 'archived';

  @Column({ name: 'bill_id', type: 'integer', nullable: true })
  billId: number | null;

  @CreateDateColumn({ name: 'created_at' })
  createdAt: Date;

  @ManyToOne(() => Student, (s) => s.personalExpenses)
  @JoinColumn({ name: 'student_id' })
  student: Student;

}
