/**
 * Transaction DTOs
 */

import { PaymentSourceType, PaymentMethod, PaymentStatus } from '../../mobile/entities/payment-transaction.entity';

export class ProcessPaymentDto {
  terminalId: string;
  amount: number;
  currency?: string;
  tipAmount?: number;
  sourceType: PaymentSourceType;
  sourceId: string;
  description?: string;
  customerEmail?: string;
  customerPhone?: string;
}

export class PaymentResultDto {
  success: boolean;
  transactionId?: string;
  externalTransactionId?: string;
  amount: number;
  totalAmount: number;
  tipAmount: number;
  currency: string;
  status: PaymentStatus;
  paymentMethod?: PaymentMethod;
  cardBrand?: string;
  cardLastFour?: string;
  receiptUrl?: string;
  error?: string;
  errorCode?: string;
}

export class ProcessRefundDto {
  transactionId: string;
  amount?: number; // Partial refund if provided
  reason?: string;
}

export class RefundResultDto {
  success: boolean;
  refundId?: string;
  amount: number;
  status: 'pending' | 'completed' | 'failed';
  error?: string;
}

export class SendReceiptDto {
  email?: string;
  phone?: string;
}

export class TransactionFilterDto {
  branchId?: string;
  userId?: string;
  status?: PaymentStatus;
  startDate?: Date;
  endDate?: Date;
  sourceType?: PaymentSourceType;
  terminalProvider?: string;
  limit?: number;
  offset?: number;
}

export class TransactionStatsDto {
  total: number;
  totalAmount: number;
  byStatus: Record<PaymentStatus, number>;
  byProvider: Record<string, { count: number; amount: number }>;
  byPaymentMethod: Record<PaymentMethod, number>;
  averageAmount: number;
  successRate: number;
}
