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

export enum AccountTypeEnum {
  ASSET = 'asset',
  LIABILITY = 'liability',
  EQUITY = 'equity',
  INCOME = 'income',
  EXPENSE = 'expense',
}

@Entity({ schema: 'financial', name: 'account_types' })
@Index('idx_account_types_code', ['code'], { unique: true })
export class AccountType {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'varchar', length: 20, nullable: false, unique: true })
  code: string;

  @Column({ type: 'varchar', length: 100, nullable: false })
  name: string;

  @Column({
    type: 'enum',
    enum: AccountTypeEnum,
    nullable: false,
    name: 'account_type',
  })
  accountType: AccountTypeEnum;

  @Column({ type: 'text', nullable: true })
  description: string | null;
}
