using ERPCore.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace ERPCore.Infra.Persistence.Configurations;

public sealed class PayrollStatutorySettingConfiguration : IEntityTypeConfiguration<PayrollStatutorySetting>
{
    public void Configure(EntityTypeBuilder<PayrollStatutorySetting> builder)
    {
        builder.ToTable("hr_payroll_statutory_settings");
        builder.HasKey(s => s.PayrollStatutorySettingId);

        builder.Property(s => s.EpfEmployeeRate).HasPrecision(6, 4);
        builder.Property(s => s.EpfEmployerRate).HasPrecision(6, 4);
        builder.Property(s => s.EtfEmployerRate).HasPrecision(6, 4);
        builder.Property(s => s.OtMultiplierDefault).HasPrecision(6, 2);

        builder.Property(s => s.CreatedAt).IsRequired();
        builder.Property(s => s.RowVersion).IsRowVersion();

        builder.HasIndex(s => s.EffectiveFrom);
    }
}

public sealed class TaxSlabConfiguration : IEntityTypeConfiguration<TaxSlab>
{
    public void Configure(EntityTypeBuilder<TaxSlab> builder)
    {
        builder.ToTable("hr_tax_slabs");
        builder.HasKey(s => s.TaxSlabId);

        builder.Property(s => s.LowerBound).HasPrecision(18, 2);
        builder.Property(s => s.UpperBound).HasPrecision(18, 2);
        builder.Property(s => s.Rate).HasPrecision(6, 4);

        builder.Property(s => s.CreatedAt).IsRequired();
        builder.Property(s => s.RowVersion).IsRowVersion();

        builder.HasIndex(s => s.EffectiveFrom);
    }
}
