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

export enum InvoiceType {
  ALL = "all",
  SINGLE = "single",
}

export class CreateInvoiceDto {
  @ApiProperty({
    description: "Indicates if the invoice is for a direct customer",
    default: false,
  })
  @IsBoolean()
  @IsOptional()
  is_direct_customer?: boolean

  @ApiPropertyOptional({ description: "ID of the client company" })
  @IsInt()
  @IsOptional()
  client_id?: number

  @ApiPropertyOptional({ description: "ID of the customer" })
  @IsInt()
  @IsOptional()
  customer_id?: number

  @ApiPropertyOptional({
    description:
      "ID of the city to filter trips (optional - to avoid multiple city trips in single invoice)",
  })
  @IsInt()
  @IsOptional()
  city_id?: number

  @ApiProperty({ description: "Type of invoice" })
  @IsEnum(InvoiceType)
  invoice_type: string

  @ApiPropertyOptional({
    description: "Invoice start date",
    type: String,
    example: "2025-10-06",
  })
  @IsString()
  @IsOptional()
  start_date?: string

  @ApiPropertyOptional({
    description: "Invoice end date",
    type: String,
    example: "2025-10-31",
  })
  @IsString()
  @IsOptional()
  end_date?: string

  @ApiPropertyOptional({
    description: "Invoice due date",
    type: String,
    example: "2025-11-05",
  })
  @IsString()
  @IsOptional()
  due_date?: string

  @ApiPropertyOptional({
    description: "Discount applied to the invoice",
    default: 0,
  })
  @IsInt()
  @IsOptional()
  discount?: number

  @ApiPropertyOptional({
    description: "Tax amount of the invoice",
    default: 0,
  })
  @IsInt()
  @IsOptional()
  invoice_tax?: number

  @ApiPropertyOptional({
    description: "Enter the status of the invoice",
    type: String,
  })
  @IsString()
  @IsOptional()
  status?: string

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