// Test Data Factories
// Generate test data for various entities

import { v4 as uuidv4 } from 'uuid';
import { Decimal } from '@prisma/client/runtime/library';

export const testFactories = {
  /**
   * Create test sovereign bank data
   */
  sovereignBank: (overrides?: Record<string, unknown>) => ({
    sovereignCode: `TEST-${uuidv4().substring(0, 8)}`,
    name: 'Test Sovereign Bank',
    bic: `TEST${uuidv4().substring(0, 4)}`,
    status: 'active',
    ...overrides,
  }),

  /**
   * Create test bank account data
   */
  bankAccount: (sovereignBankId: string, overrides?: Record<string, unknown>) => ({
    accountNumber: `ACC-${uuidv4()}`,
    sovereignBankId,
    accountType: 'commercial',
    currencyCode: 'USD',
    balance: new Decimal('1000.00'),
    availableBalance: new Decimal('1000.00'),
    reservedBalance: new Decimal('0'),
    status: 'active',
    ...overrides,
  }),

  /**
   * Create test ledger entry data
   */
  ledgerEntry: (
    debitAccountId: string,
    creditAccountId: string,
    overrides?: Record<string, unknown>
  ) => ({
    ledgerId: 'MASTER',
    debitAccountId,
    creditAccountId,
    amount: new Decimal('100.00'),
    currencyCode: 'USD',
    assetType: 'fiat',
    transactionType: 'TYPE_A',
    referenceId: `REF-${uuidv4()}`,
    blockHash: `HASH-${uuidv4()}`,
    status: 'pending',
    ...overrides,
  }),

  /**
   * Create test payment data
   */
  payment: (overrides?: Record<string, unknown>) => ({
    sourceAccountId: uuidv4(),
    destinationAccountId: uuidv4(),
    amount: '100.00',
    currencyCode: 'USD',
    paymentType: 'transfer',
    ...overrides,
  }),

  /**
   * Create test FX order data
   */
  fxOrder: (overrides?: Record<string, unknown>) => ({
    pair: 'USD/EUR',
    amount: '1000.00',
    orderType: 'market',
    settlement: 'RTGS',
    ...overrides,
  }),
};

