import { ApiProperty } from "@nestjs/swagger";

export class CurrencyVolumeDto {
  @ApiProperty({ example: "PYG", description: "ISO 4217" })
  currency!: string;

  @ApiProperty({ example: 42 })
  approvedCount!: number;

  @ApiProperty({
    example: "2500000.0000",
    description: "Decimal serializado como string para preservar precisión.",
  })
  approvedVolume!: string;
}

export class MerchantBillingStatsDto {
  @ApiProperty()
  merchantId!: string;

  @ApiProperty({ example: "2026-06", description: "Período YYYY-MM (UTC)." })
  period!: string;

  @ApiProperty({ example: 42 })
  approvedCount!: number;

  @ApiProperty({ example: 3 })
  rejectedCount!: number;

  @ApiProperty({
    example: 5,
    description:
      "Intents en estados no terminales: created + pending + processing.",
  })
  pendingCount!: number;

  @ApiProperty({ type: [CurrencyVolumeDto] })
  volumes!: CurrencyVolumeDto[];
}

export class TopMerchantDto {
  @ApiProperty()
  merchantId!: string;

  @ApiProperty()
  merchantName!: string;

  @ApiProperty({ example: 120 })
  approvedCount!: number;

  @ApiProperty({
    example: "8500000.0000",
    description: "Volumen aprobado en PYG (ranking por esta moneda).",
  })
  approvedVolumePyg!: string;
}

export class GlobalBillingStatsDto {
  @ApiProperty({ example: "2026-06" })
  period!: string;

  @ApiProperty({ example: 320 })
  approvedCount!: number;

  @ApiProperty({ example: 18 })
  rejectedCount!: number;

  @ApiProperty({
    example: 295,
    description: "Tx aprobadas del período anterior — sirve para calcular delta.",
  })
  previousApprovedCount!: number;

  @ApiProperty({ example: 12 })
  activeMerchants!: number;

  @ApiProperty({ type: [CurrencyVolumeDto] })
  volumes!: CurrencyVolumeDto[];

  @ApiProperty({ type: [TopMerchantDto] })
  topMerchants!: TopMerchantDto[];
}
