package br.gov.sigefp.treasury.domain;

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

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.UUID;

/**
 * Entidade que representa um pagamento.
 * Usa LocalDate para todas as datas relacionadas.
 */
@Entity
@Table(name = "payments", indexes = {
    @Index(name = "idx_payment_number", columnList = "payment_number"),
    @Index(name = "idx_payment_date", columnList = "payment_date"),
    @Index(name = "idx_payment_status", columnList = "status")
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Payment extends AuditableEntity {

    @Column(nullable = false, unique = true, length = 50)
    private String paymentNumber;

    @Column(name = "budget_execution_id")
    private UUID budgetExecutionId; // Referência à execução orçamentária

    @Column(nullable = false)
    private LocalDate paymentDate;

    @Column(nullable = false)
    private LocalDate dueDate;

    private LocalDate paidDate;

    @Column(nullable = false, precision = 19, scale = 2)
    private BigDecimal amount;

    @Column(nullable = false, length = 50)
    @Builder.Default
    private String status = "PENDING"; // PENDING, APPROVED, PAID, CANCELLED

    @Column(nullable = false, length = 200)
    private String beneficiary;

    @Column(length = 50)
    private String beneficiaryDocument; // NIF, CNPJ, etc.

    @Column(length = 500)
    private String description;

    @Column(length = 100)
    private String paymentMethod; // BANK_TRANSFER, CHECK, CASH, etc.

    @Column(length = 500)
    private String notes;
}

