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

import dev.lions.unionflow.server.api.enums.culte.TypeDonReligieux;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;
import dev.lions.unionflow.server.entity.Organisation;

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

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Entity
@Table(name = "dons_religieux", indexes = {
        @Index(name = "idx_don_c_organisation", columnList = "institution_id"),
        @Index(name = "idx_don_c_fidele", columnList = "fidele_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class DonReligieux extends BaseEntity {

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

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fidele_id")
    private Membre fidele;

    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "type_don", nullable = false, length = 50)
    private TypeDonReligieux typeDon;

    @NotNull
    @Column(name = "montant", nullable = false, precision = 19, scale = 4)
    private BigDecimal montant;

    @NotNull
    @Column(name = "date_encaissement", nullable = false)
    @Builder.Default
    private LocalDateTime dateEncaissement = LocalDateTime.now();

    @Column(name = "periode_nature", length = 150)
    private String periodeOuNatureAssociee;
}
