package org.octopus.internal.web.dtos

import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.DecimalMin
import org.hibernate.validator.constraints.Length
import org.octopus.internal.web.dtos.validators.EntryHexColorValidator
import org.octopus.internal.web.dtos.validators.EntryMonthValidator
import org.octopus.internal.web.dtos.validators.EntryTypeValidator
import java.util.Date

data class EntryDto(
    @field:Schema(description = "The name of the entry (between 1 and 50 characters long).")
    @field:Length(min = 1, max = 50, message = "The name must be between 1 and 50 characters long.")
    val name: String,

    @field:Schema(description = "The type of entry (INCOME, OUTCOME, INVESTMENT).")
    @field:EntryTypeValidator.Validate
    val type: String,

    @field:Schema(description = "The amount of the entry (greater than 0.00).")
    @field:DecimalMin(value="0.00", inclusive = false, message = "The amount must be greater than 0.00.")
    val amount: Double,

    @field:Schema(description = "IF NOT recurrent: when is the entry being counted.")
    val fixedDate: Date?,

    @field:Schema(description = "IF recurrent: must be true")
    val recurrent: Boolean?,

    @field:Schema(description = "IF recurrent: list of month in which the event is repeated (1=JAN, 12=DEC)")
    @field:EntryMonthValidator.Validate
    val recurrentMonths: List<Int>?,

    @field:Schema(description = "IF recurrent: starting date of the repetition")
    val startDate: Date?,

    @field:Schema(description = "IF recurrent: ending date of the repetition")
    val endDate: Date?,

    @field:Schema(description = "Color of the entry in the UI")
    @field:EntryHexColorValidator.Validate
    val color: String = "0xFFFFFF"
)