import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"
import {
  IsInt,
  IsOptional,
  IsString,
  IsNotEmpty,
  IsEnum,
} from "class-validator"

export enum PaymentMethodEnum {
  CASH = "cash",
  CREDIT_CARD = "credit_card",
  BANK_TRANSFER = "bank_transfer",
  CHEQUE = "cheque",
}

export enum PaymentStatusEnum {
  PAID = "paid",
  PENDING = "pending",
  PARTIALLY_PAID = "partially_paid",
}

export class CreatePaymentDto {
  @ApiProperty({ description: "ID of the invoice this payment belongs to" })
  @IsInt()
  @IsNotEmpty()
  invoice_id: number

  client_id?: number

  @ApiProperty({ description: "Amount of the payment" })
  @IsString()
  @IsNotEmpty()
  amount: string

  @ApiPropertyOptional({
    description:
      "Payment method used (e.g., cash, credit_card, bank_transfer, check)",
    enum: PaymentMethodEnum,
  })
  @IsOptional()
  @IsEnum(PaymentMethodEnum)
  payment_method?: string

  @ApiPropertyOptional({ description: "Reference number for the payment" })
  @IsString()
  @IsOptional()
  reference_number?: string

  @ApiPropertyOptional({ description: "Additional notes for the payment" })
  @IsString()
  @IsOptional()
  notes?: string

  @ApiPropertyOptional({
    description: "Date of the payment",
    type: String,
    example: "2025-10-09",
  })
  @IsString()
  @IsOptional()
  payment_date?: string

  @ApiPropertyOptional({ description: "Status of the payment" })
  @IsEnum(PaymentStatusEnum)
  @IsOptional()
  status?: string
}
