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

import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;

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

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

@Entity
@Table(name = "contributions_collecte", indexes = {
        @Index(name = "idx_contribution_campagne", columnList = "campagne_id"),
        @Index(name = "idx_contribution_membre", columnList = "membre_donateur_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ContributionCollecte extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "campagne_id", nullable = false)
    private CampagneCollecte campagne;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "membre_donateur_id")
    private Membre membreDonateur;

    @Column(name = "alias_donateur", length = 150)
    private String aliasDonateur;

    @Column(name = "est_anonyme", nullable = false)
    @Builder.Default
    private Boolean estAnonyme = false;

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

    @Column(name = "message_soutien", length = 500)
    private String messageSoutien;

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

    @Column(name = "transaction_paiement_id", length = 100)
    private String transactionPaiementId;

    @Enumerated(EnumType.STRING)
    @Column(name = "statut_paiement", length = 50)
    private StatutTransactionWave statutPaiement;
}
