import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
import { Bill } from './bill.entity';

@Entity('bill_items')
export class BillItem {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ name: 'bill_id' })
  billId: number;

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

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

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

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

  @Column({ length: 200, nullable: true })
  description: string;

  @Column({ nullable: true })
  days: number;

  @Column({ name: 'total_room_days', nullable: true })
  totalRoomDays: number;

  @Column({ name: 'room_total_amount', type: 'decimal', precision: 10, scale: 2, nullable: true })
  roomTotalAmount: number;

  @Column({ name: 'student_amount', type: 'decimal', precision: 10, scale: 2, nullable: true })
  studentAmount: number;

  @ManyToOne(() => Bill, (b) => b.items)
  @JoinColumn({ name: 'bill_id' })
  bill: Bill;
}
