package br.gov.sigefp.budget.domain;

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

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

@Entity
@Table(name = "budget_entry", indexes = {
        @Index(name = "idx_budget_entry_line", columnList = "budget_line_id"),
        @Index(name = "idx_budget_entry_date", columnList = "transaction_date")
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class BudgetEntry extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "budget_line_id", nullable = false)
    private BudgetLine budgetLine;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false, length = 30)
    private BudgetEntryType type;

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

    @Column(name = "transaction_date", nullable = false)
    private LocalDate transactionDate; // Data da Lei/Decreto

    @Column(nullable = false, length = 100, name = "document_reference")
    private String documentReference; // Ex: "Lei do Orçamento 2024", "Decreto 12/2024"

    @Column(length = 255)
    private String description;
}
