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

namespace SolutionErp.Infrastructure.Persistence.Configurations;

// EF Mig 35 G-H2 (S34) — Chính sách OT. Catalog standalone.
// Future business logic: G-P1 chấm công + G-O4 OtRequest reference IsActive=true.
public class OtPolicyConfiguration : IEntityTypeConfiguration<OtPolicy>
{
    public void Configure(EntityTypeBuilder<OtPolicy> e)
    {
        e.ToTable("OtPolicies");

        e.Property(x => x.Code).HasMaxLength(50).IsRequired();
        e.Property(x => x.Name).HasMaxLength(200).IsRequired();
        e.Property(x => x.MultiplierWeekday).HasColumnType("decimal(4,2)");
        e.Property(x => x.MultiplierWeekend).HasColumnType("decimal(4,2)");
        e.Property(x => x.MultiplierHoliday).HasColumnType("decimal(4,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
    }
}
