import { Entity, Column, Index, OneToMany } from 'typeorm';
import { BaseEntity } from '../database/base.entity';
import { BankAccountEntity } from './bank-account.entity';

/**
 * Bank entity — tenant-scoped master of bank names.
 *
 * Used by Bank Account Master (`bank_id` FK). Lookups feed settlement
 * Deposit To / Paid From pickers once those screens are wired.
 */
@Entity('banks')
@Index(['tenant_id', 'is_deleted'])
export class BankEntity extends BaseEntity {
  @Column({ type: 'varchar', length: 255 })
  name: string;

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

  @OneToMany(() => BankAccountEntity, (account) => account.bank)
  accounts: BankAccountEntity[];
}
