import { ApiProperty } from "@nestjs/swagger";
import { InvoiceItemType, InvoiceStatus } from "@prisma/client";

export class InvoiceItemDto {
  @ApiProperty()
  id!: string;

  @ApiProperty({ enum: InvoiceItemType })
  type!: InvoiceItemType;

  @ApiProperty({ example: "Fee mensual" })
  description!: string;

  @ApiProperty({ example: 1 })
  quantity!: number;

  @ApiProperty({ example: "150000.0000" })
  unitAmount!: string;

  @ApiProperty({ example: "150000.0000" })
  totalAmount!: string;
}

export class InvoiceDto {
  @ApiProperty()
  id!: string;

  @ApiProperty()
  merchantId!: string;

  @ApiProperty({ example: "Acme S.A.", required: false })
  merchantName?: string;

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

  @ApiProperty({ example: "150000.0000" })
  monthlyFeeAmount!: string;

  @ApiProperty({ example: "21000.0000" })
  txFeesAmount!: string;

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

  @ApiProperty({ example: "171000.0000" })
  totalAmount!: string;

  @ApiProperty({ example: "PYG" })
  currency!: string;

  @ApiProperty({ enum: InvoiceStatus })
  status!: InvoiceStatus;

  @ApiProperty({ format: "date-time" })
  issuedAt!: string;

  @ApiProperty({ format: "date-time" })
  dueAt!: string;

  @ApiProperty({ format: "date-time", nullable: true })
  paidAt!: string | null;

  @ApiProperty({
    nullable: true,
    description:
      "Si el plan tiene self-billing, ID del PaymentIntent creado para cobrar el fee vía Novasis Pay.",
  })
  selfBillingIntentId!: string | null;

  @ApiProperty({ type: [InvoiceItemDto] })
  items!: InvoiceItemDto[];
}

export class InvoiceListDto {
  @ApiProperty({ type: [InvoiceDto] })
  data!: InvoiceDto[];

  @ApiProperty({ nullable: true })
  nextCursor!: string | null;
}
