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

import dev.lions.unionflow.server.api.enums.ong.StatutProjetOng;
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;
import java.time.LocalDate;

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

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

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

    @Column(name = "description", columnDefinition = "TEXT")
    private String descriptionMandat;

    @Column(name = "zone_geographique", length = 200)
    private String zoneGeographiqueIntervention;

    @Column(name = "budget_previsionnel", precision = 19, scale = 4)
    private BigDecimal budgetPrevisionnel;

    @Column(name = "depenses_reelles", precision = 19, scale = 4)
    @Builder.Default
    private BigDecimal depensesReelles = BigDecimal.ZERO;

    @Column(name = "date_lancement")
    private LocalDate dateLancement;

    @Column(name = "date_fin_estimee")
    private LocalDate dateFinEstimee;

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