package dev.lions.unionflow.server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * Session de formation LBC/FT (lutte contre le blanchiment de capitaux et le financement du
 * terrorisme).
 *
 * <p>Obligation annuelle posée par l'<strong>Instruction BCEAO 001-03-2025 du 18 mars 2025</strong>
 * pour le compliance officer + les dirigeants + les membres exposés (trésorier, secrétaire,
 * commissaires aux comptes).
 *
 * @since 2026-04-25 (P1-NEW-12)
 */
@Entity
@Table(name = "formations_lbcft", indexes = {
    @Index(name = "idx_formation_org_annee", columnList = "organisation_id,annee_reference"),
    @Index(name = "idx_formation_date", columnList = "date_session")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class FormationLbcFt extends BaseEntity {

  @NotNull
  @Column(name = "organisation_id", nullable = false)
  private UUID organisationId;

  @NotBlank
  @Column(name = "titre", nullable = false, length = 255)
  private String titre;

  @NotBlank
  @Column(name = "type_formation", nullable = false, length = 30)
  @Builder.Default
  private String typeFormation = "STANDARD"; // STANDARD, AVANCE, COMPLIANCE_OFFICER, DIRIGEANT

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

  @Column(name = "intervenant", length = 255)
  private String intervenant;

  @Column(name = "duree_heures", precision = 4, scale = 1, nullable = false)
  @Builder.Default
  private BigDecimal dureeHeures = new BigDecimal("4.0");

  @NotNull
  @Column(name = "date_session", nullable = false)
  private LocalDateTime dateSession;

  @Column(name = "lieu", length = 255)
  private String lieu;

  @NotNull
  @Column(name = "annee_reference", nullable = false)
  private Integer anneeReference;

  @NotBlank
  @Column(name = "statut", nullable = false, length = 20)
  @Builder.Default
  private String statut = "PLANIFIEE"; // PLANIFIEE, EN_COURS, TERMINEE, ANNULEE
}
