using Lada.Framework.Data.Domains.Finance;
using Lada.Framework.Data.Mappings;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Lada.Framework.Data.Mappings.EntityMappings.Finance
{
    /// <summary>
    /// Cấu hình FluentAPI cho VatInvoice
    /// </summary>
    public class VatInvoiceMap : IEntityMappingConfiguration<VatInvoice>
    {
        public void Map(EntityTypeBuilder<VatInvoice> builder)
        {
            builder.ToTable("VatInvoices");

            // Unique index cho ExternalId để tránh trùng lặp khi đồng bộ
            builder.HasIndex(x => x.ExternalId).IsUnique();

            // Index cho các trường tìm kiếm thường xuyên
            builder.HasIndex(x => x.InvoiceNumber);
            builder.HasIndex(x => x.IssueDate);
            builder.HasIndex(x => x.SellerTaxCode);
            builder.HasIndex(x => x.BuyerTaxCode);
            builder.HasIndex(x => x.SyncTime);
        }
    }
}
