import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, Unique } from 'typeorm'; import { Host } from './host.entity'; @Entity('host_billing_records') @Unique(['host_id', 'billing_month']) export class HostBillingRecord { @PrimaryGeneratedColumn('uuid') id: string; @Column({ type: 'uuid' }) host_id: string; @Column({ type: 'date' }) billing_month: Date; @Column({ type: 'integer' }) active_license_count: number; @Column({ type: 'decimal', precision: 10, scale: 2 }) wholesale_rate_usd: number; @Column({ type: 'decimal', precision: 10, scale: 2 }) total_amount_usd: number; @Column({ type: 'timestamptz', default: () => 'NOW()' }) generated_at: Date; @ManyToOne(() => Host, { onDelete: 'CASCADE' }) @JoinColumn({ name: 'host_id' }) host: Host; }