import { Entity, Column, Unique } from 'typeorm';
import { BaseEntity } from '../database/base.entity';

export enum CurrencyRounding {
  R1 = 1,
  R5 = 5,
  R10 = 10,
  R50 = 50,
  R100 = 100,
}

export enum CurrencyFormat {
  INDIAN = 'indian',           // 1,23,45,678.90
  INTERNATIONAL = 'international', // 1,234,567.90
  DOT = 'dot',                 // 1.234.567,90
}

/**
 * Currency entity — tenant-scoped master table.
 *
 * Used by: Destination (default currency), Pricing, Quotation, Booking, Payment Settlement.
 * Seeded on tenant onboarding: USD, EUR, GBP, INR, AED (is_system = true).
 */
@Entity('currencies')
@Unique(['tenant_id', 'code'])
export class CurrencyEntity extends BaseEntity {
  @Column({ type: 'varchar', length: 255 })
  name: string;

  @Column({ type: 'varchar', length: 10 })
  code: string;

  @Column({ type: 'varchar', length: 5 })
  symbol: string;

  @Column({ type: 'int', default: 1 })
  rounding: number;

  @Column({ type: 'enum', enum: CurrencyFormat, default: CurrencyFormat.INTERNATIONAL })
  format: CurrencyFormat;

  @Column({ type: 'boolean', default: true })
  is_active: boolean;

  @Column({ type: 'boolean', default: false })
  is_system: boolean;
}
