import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn, } from 'typeorm'; import { Student } from './student.entity'; import { Room } from './room.entity'; import { Organization } from './organization.entity'; import { Bed } from './bed.entity'; import { Locker } from './locker.entity'; @Entity('occupancies') export class Occupancy { @PrimaryGeneratedColumn() id: number; @Column({ name: 'student_id' }) studentId: number; @Column({ name: 'room_id' }) roomId: number; @Column({ name: 'check_in_date', type: 'date' }) checkInDate: string; @Column({ name: 'check_out_date', type: 'date', nullable: true }) checkOutDate: string; @Column({ name: 'billing_start_date', type: 'date' }) billingStartDate: string; @Column({ name: 'billing_end_date', type: 'date', nullable: true }) billingEndDate: string; @Column({ name: 'check_out_reason', length: 100, nullable: true }) checkOutReason: string; @Column({ type: 'text', nullable: true }) notes: string; @Column({ type: 'varchar', length: 20, default: 'active' }) status: 'active' | 'archived'; @Column({ name: 'bed_id', type: 'integer', nullable: true }) bedId: number; @ManyToOne(() => Bed, { nullable: true }) @JoinColumn({ name: 'bed_id' }) bed: Bed; @Column({ name: 'locker_id', type: 'integer', nullable: true }) lockerId: number; @ManyToOne(() => Locker, { nullable: true }) @JoinColumn({ name: 'locker_id' }) locker: Locker; @Column({ name: 'stay_type', length: 10, default: 'short' }) stayType: string; @Column({ name: 'responsible_organization_id', type: 'integer', nullable: true }) responsibleOrganizationId: number; @ManyToOne(() => Organization, { nullable: true }) @JoinColumn({ name: 'responsible_organization_id' }) responsibleOrganization: Organization; @CreateDateColumn({ name: 'created_at' }) createdAt: Date; @ManyToOne(() => Student, (s) => s.occupancies) @JoinColumn({ name: 'student_id' }) student: Student; @ManyToOne(() => Room, (r) => r.occupancies) @JoinColumn({ name: 'room_id' }) room: Room; }