package br.gov.sigefp.rh.domain;

import br.gov.sigefp.common.domain.AuditableEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import lombok.*;
import lombok.experimental.SuperBuilder;

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

/**
 * Representa uma regra de desconto global (ex: INPS 7%, Imposto de Selo 0.3%).
 */
@Entity
@Table(name = "global_deduction_rule")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class GlobalDeductionRule extends AuditableEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "deduction_type_id", nullable = false)
    private DeductionType deductionType;

    @Column(nullable = false, precision = 5, scale = 4)
    private BigDecimal percentage; // Ex: 0.07 para 7%, 0.003 para 0.3%

    @Column(precision = 19, scale = 2)
    private BigDecimal amountFixed;

    @Column(nullable = false, name = "valid_from")
    private LocalDate validFrom;

    @Column(name = "valid_to")
    private LocalDate validTo;

    @Builder.Default
    @Column(nullable = false)
    private boolean active = true;
}
