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

@Entity('associate_cv_usage')
export class AssociateCvUsage {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ comment: 'References associates.id (NOT users.id)' })
  associate_id: number;

  @Column({
    type: 'enum',
    enum: ['free', 'basic', 'premium', 'enterprise', 'unlimited'],
    default: 'free',
  })
  plan_type: string;

  @Column({
    default: 100,
    comment: 'Total CV downloads allowed per month. -1 means unlimited',
  })
  total_cv_limit: number;

  @Column({ default: 0 })
  used_cv_downloads: number;

  @Column({
    default: 100,
    comment: 'Remaining CV downloads for this month. -1 means unlimited',
  })
  remaining_cv_downloads: number;

  @Column({ type: 'timestamp', nullable: true })
  last_download_at: Date;

  @Column({ type: 'date' })
  plan_start_date: Date;

  @Column({ type: 'date', nullable: true })
  plan_end_date: Date;

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;
}
