/**
 * BranchPaymentTerminal Entity Stub
 * TODO: Implement when branches module is created
 */

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

export type HealthStatus = 'healthy' | 'degraded' | 'offline' | 'unknown';
export type TerminalProvider = 'clip' | 'mercadopago' | 'stripe' | 'stripe_terminal';

@Entity({ name: 'branch_payment_terminals' })
export class BranchPaymentTerminal {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'tenant_id', type: 'uuid' })
  tenantId: string;

  @Column({ name: 'branch_id', type: 'uuid' })
  branchId: string;

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

  @Column({ name: 'terminal_name', type: 'varchar', length: 100, nullable: true })
  terminalName: string | undefined;

  @Column({ name: 'terminal_provider', type: 'varchar', length: 50 })
  terminalProvider: TerminalProvider;

  @Column({ name: 'provider', type: 'varchar', length: 50 })
  provider: string;

  @Column({ name: 'credentials', type: 'jsonb', nullable: true })
  credentials: Record<string, any>;

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

  @Column({ name: 'is_primary', type: 'boolean', default: false })
  isPrimary: boolean;

  @Column({ name: 'health_status', type: 'varchar', length: 50, default: 'unknown' })
  healthStatus: HealthStatus;

  @Column({ name: 'last_health_check_at', type: 'timestamptz', nullable: true })
  lastHealthCheckAt: Date | undefined;

  @Column({ name: 'last_transaction_at', type: 'timestamptz', nullable: true })
  lastTransactionAt: Date | undefined;

  @Column({ name: 'daily_limit', type: 'decimal', precision: 16, scale: 2, nullable: true })
  dailyLimit: number | undefined;

  @Column({ name: 'transaction_limit', type: 'decimal', precision: 16, scale: 2, nullable: true })
  transactionLimit: number | undefined;

  @Column({ name: 'config', type: 'jsonb', nullable: true })
  config: Record<string, any> | null;

  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz', nullable: true })
  updatedAt: Date | null;
}
