package dev.lions.unionflow.server.entity.agricole;

import dev.lions.unionflow.server.api.enums.agricole.StatutCampagneAgricole;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Organisation;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;

import java.math.BigDecimal;

@Entity
@Table(name = "campagnes_agricoles", indexes = {
        @Index(name = "idx_agricole_organisation", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class CampagneAgricole extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "organisation_id", nullable = false)
    private Organisation organisation;

    @NotBlank
    @Column(name = "designation", nullable = false, length = 200)
    private String designation;

    @Column(name = "type_culture", length = 100)
    private String typeCulturePrincipale;

    @Column(name = "surface_estimee_ha", precision = 19, scale = 4)
    private BigDecimal surfaceTotaleEstimeeHectares;

    @Column(name = "volume_prev_tonnes", precision = 19, scale = 4)
    private BigDecimal volumePrevisionnelTonnes;

    @Column(name = "volume_reel_tonnes", precision = 19, scale = 4)
    private BigDecimal volumeReelTonnes;

    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "statut", nullable = false, length = 50)
    @Builder.Default
    private StatutCampagneAgricole statut = StatutCampagneAgricole.PREPARATION;
}
