package br.gov.sigefp.treasury.domain;

import br.gov.sigefp.common.domain.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

import java.time.Instant;

/**
 * Entidade que representa um pagamento efetivado pela tesouraria.
 * Usa Instant para timestamps.
 */
@Entity
@Table(name = "treasury_payment", indexes = {
    @Index(name = "idx_treasury_payment_order", columnList = "payment_order_id"),
    @Index(name = "idx_treasury_payment_status", columnList = "status"),
    @Index(name = "idx_treasury_payment_paid", columnList = "paid_at")
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TreasuryPayment extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "payment_order_id", nullable = false)
    private PaymentOrder paymentOrder;

    @Column(name = "paid_at")
    private Instant paidAt; // Data/hora do pagamento efetivo

    @Column(length = 100, name = "transaction_ref")
    private String transactionRef; // Referência da transação bancária

    @Column(nullable = false, length = 20)
    @Builder.Default
    private String status = "PENDING"; // PENDING, PAID, REJECTED, CANCELLED - preparado para enum

    @Column(length = 1000)
    private String message; // Mensagem de retorno do banco ou observações
}

