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

export enum JournalType {
  ISSUANCE = 'issuance', REDEMPTION = 'redemption', TRADE_FEE = 'trade_fee',
  BREAKAGE = 'breakage', REFUND = 'refund', SETTLEMENT = 'settlement',
}

@Entity('journal_entries')
export class JournalEntry {
  @PrimaryGeneratedColumn('uuid') id: string;
  @Column({ name: 'entry_type', type: 'varchar', length: 50 }) entryType: JournalType;
  @Column({ name: 'reference_id', type: 'uuid' }) referenceId: string;
  @Column({ name: 'reference_type', type: 'varchar', length: 50 }) referenceType: string;
  @Column({ name: 'debit_account', type: 'varchar', length: 100 }) debitAccount: string;
  @Column({ name: 'credit_account', type: 'varchar', length: 100 }) creditAccount: string;
  @Column({ type: 'numeric', precision: 20, scale: 8 }) amount: string;
  @Column({ type: 'varchar', length: 10, default: 'USD' }) currency: string;
  @Column({ type: 'text', nullable: true }) description: string | null;
  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date;
}
