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

export enum RefundStatus { PENDING = 'pending', APPROVED = 'approved', COMPLETED = 'completed', REJECTED = 'rejected' }

@Entity('refunds')
export class Refund {
  @PrimaryGeneratedColumn('uuid') id: string;
  @Column({ name: 'order_id', type: 'uuid' }) orderId: string;
  @Column({ name: 'user_id', type: 'uuid' }) userId: string;
  @Column({ type: 'numeric', precision: 20, scale: 8 }) amount: string;
  @Column({ type: 'varchar', length: 200 }) reason: string;
  @Column({ type: 'varchar', length: 20, default: 'pending' }) status: RefundStatus;
  @Column({ name: 'processed_by', type: 'uuid', nullable: true }) processedBy: string | null;
  @Column({ name: 'processed_at', type: 'timestamptz', nullable: true }) processedAt: Date | null;
  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date;
}
