package dev.lions.unionflow.server.api.dto.finance_workflow.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * DTO de réponse pour un budget
 *
 * @author UnionFlow Team
 * @version 1.0
 * @since 2026-03-13
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class BudgetResponse {

    private UUID id;

    @NotBlank
    private String name;

    private String description;

    @NotNull
    private UUID organizationId;

    @NotBlank
    private String period; // MONTHLY, QUARTERLY, SEMIANNUAL, ANNUAL

    @NotNull
    private Integer year;

    private Integer month;

    @NotBlank
    private String status; // DRAFT, ACTIVE, CLOSED, CANCELLED

    @Builder.Default
    private List<BudgetLineResponse> lines = new ArrayList<>();

    @NotNull
    private BigDecimal totalPlanned;

    @NotNull
    private BigDecimal totalRealized;

    @NotBlank
    private String currency;

    @NotNull
    private UUID createdById;

    @NotNull
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
    private LocalDateTime createdAt;

    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
    private LocalDateTime approvedAt;

    private UUID approvedById;

    @NotNull
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate startDate;

    @NotNull
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate endDate;

    private String metadata;

    // Champs calculés
    private Double realizationRate;
    private BigDecimal variance;
    private Double varianceRate;
    private Boolean isOverBudget;
    private Boolean isActive;
    private Boolean isCurrentPeriod;
}
