import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn } from 'typeorm';

@Entity('credit_metrics')
export class CreditMetric {
  @PrimaryGeneratedColumn('uuid') id: string;
  @Column({ name: 'issuer_id', type: 'uuid' }) issuerId: string;
  @Column({ name: 'redemption_rate', type: 'numeric', precision: 5, scale: 4, default: '0' }) redemptionRate: string;
  @Column({ name: 'breakage_ratio', type: 'numeric', precision: 5, scale: 4, default: '0' }) breakageRate: string;
  @Column({ name: 'market_tenure_months', type: 'int', default: 0 }) tenureDays: number;
  @Column({ name: 'user_satisfaction', type: 'numeric', precision: 5, scale: 4, default: '0' }) satisfactionScore: string;
  @Column({ name: 'computed_score', type: 'numeric', precision: 5, scale: 2, default: '0' }) compositeScore: string;
  @Column({ name: 'computed_rating', type: 'varchar', length: 5, nullable: true }) scoreLevel: string;
  @Column({ name: 'snapshot_date', type: 'date', default: () => 'CURRENT_DATE' }) calculatedAt: Date;
}
