feat: add rental_category/rate to Room, rental_type/tenant_id to Occupancy, tenant_id to Student

This commit is contained in:
2026-07-05 19:31:03 +08:00
parent 92e6ba0e34
commit 881e9c6175
8 changed files with 95 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import {
} from 'typeorm';
import { Student } from './student.entity';
import { Room } from './room.entity';
import { Tenant } from './tenant.entity';
@Entity('occupancies')
export class Occupancy {
@@ -38,6 +39,16 @@ export class Occupancy {
@Column({ type: 'text', nullable: true })
notes: string;
@Column({ name: 'rental_type', length: 10, default: 'short' })
rentalType: string;
@Column({ name: 'tenant_id', type: 'integer', nullable: true })
tenantId: number;
@ManyToOne(() => Tenant, { nullable: true })
@JoinColumn({ name: 'tenant_id' })
tenant: Tenant;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;

View File

@@ -28,6 +28,12 @@ export class Room {
@Column({ length: 10, nullable: true })
gender: string;
@Column({ name: 'rental_category', length: 10, default: 'short' })
rentalCategory: string;
@Column({ name: 'monthly_rate', type: 'decimal', precision: 10, scale: 2, default: 0 })
monthlyRate: number;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;

View File

@@ -4,11 +4,14 @@ import {
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
JoinColumn,
OneToMany,
} from 'typeorm';
import { Occupancy } from './occupancy.entity';
import { PersonalExpense } from './personal-expense.entity';
import { Bill } from './bill.entity';
import { Tenant } from './tenant.entity';
@Entity('students')
export class Student {
@@ -54,6 +57,13 @@ export class Student {
@OneToMany(() => Occupancy, (o) => o.student)
occupancies: Occupancy[];
@Column({ name: 'tenant_id', type: 'integer', nullable: true })
tenantId: number;
@ManyToOne(() => Tenant, { nullable: true })
@JoinColumn({ name: 'tenant_id' })
tenant: Tenant;
@OneToMany(() => PersonalExpense, (e) => e.student)
personalExpenses: PersonalExpense[];