using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SolutionErp.Domain.Hrm;

namespace SolutionErp.Infrastructure.Persistence.Configurations;

// EF Mig 35 G-H2 (S34) — Loại phép. Catalog standalone, no FK.
public class LeaveTypeConfiguration : IEntityTypeConfiguration<LeaveType>
{
    public void Configure(EntityTypeBuilder<LeaveType> e)
    {
        e.ToTable("LeaveTypes");

        e.Property(x => x.Code).HasMaxLength(50).IsRequired();
        e.Property(x => x.Name).HasMaxLength(200).IsRequired();
        e.Property(x => x.DaysPerYear).HasColumnType("decimal(5,2)");
        e.Property(x => x.Description).HasMaxLength(500);

        e.HasIndex(x => x.Code).IsUnique().HasFilter("[IsDeleted] = 0");   // Mig 45 (S51 gotcha #57) — soft-deleted slot reusable, khớp handler !IsDeleted
    }
}
