package br.gov.sigefp.budget.domain;

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

import java.math.BigDecimal;

/**
 * Entidade que representa uma alocação orçamentária.
 * Usa BigDecimal para valores financeiros.
 */
@Entity
@Table(name = "budget_allocation", indexes = {
    @Index(name = "idx_budget_allocation_line", columnList = "budget_line_id"),
    @Index(name = "idx_budget_allocation_created", columnList = "created_at")
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class BudgetAllocation extends BaseEntity {

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

    @Column(nullable = false, precision = 19, scale = 2, name = "initial_amount")
    private BigDecimal initialAmount; // Valor inicial alocado

    @Column(nullable = false, precision = 19, scale = 2, name = "adjustment_amount")
    @Builder.Default
    private BigDecimal adjustmentAmount = BigDecimal.ZERO; // Ajustes (positivos ou negativos)
}

