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

@Entity('redemptions')
@Index('idx_redemptions_coupon', ['couponId'])
@Index('idx_redemptions_issuer', ['issuerId'])
@Index('idx_redemptions_user', ['userId'])
@Index('idx_redemptions_store', ['storeId'])
export class Redemption {
  @PrimaryGeneratedColumn('uuid') id: string;
  @Column({ name: 'coupon_id', type: 'uuid' }) couponId: string;
  @Column({ name: 'issuer_id', type: 'uuid' }) issuerId: string;
  @Column({ name: 'user_id', type: 'uuid' }) userId: string;
  @Column({ name: 'store_id', type: 'uuid', nullable: true }) storeId: string | null;
  @Column({ type: 'varchar', length: 20 }) method: string; // 'scan' | 'manual' | 'batch'
  @Column({ type: 'numeric', precision: 12, scale: 2 }) amount: string;
  @Column({ type: 'varchar', length: 20, default: 'completed' }) status: string;
  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date;
}
