using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using MS.Entities.Models;
using System;
using System.Collections.Generic;
using System.Text;
using MS.Entities.Core;

namespace MS.DbContexts.Mappings
{
    public class PosTrxesMap : IEntityTypeConfiguration<PosTrxes>
    {
        public void Configure(EntityTypeBuilder<PosTrxes> builder)
        {
            builder.ToTable("PosTrxes");

            builder.HasIndex(e => e.CreatedDateTime)
                     .HasName("idx_created_datetime");

            builder.HasIndex(e => e.CurrencyId)
                .HasName("PosTrxes_IX_CurrencyId");

            builder.HasIndex(e => e.EinvoiceId)
                .HasFilter("(\"EInvoiceId\" IS NOT NULL)");

            builder.HasIndex(e => e.ShiftId)
                .HasName("PosTrxes_IX_ShiftId");

            builder.HasIndex(e => e.TargetBusinessUnitId);

            builder.HasIndex(e => e.TransactionStatus)
                .HasName("idx_transaction_status");

            builder.HasIndex(e => e.TransactionType);

            builder.Property(e => e.Id).HasDefaultValueSql("uuid_generate_v4()");

            builder.Property(e => e.EinvoiceId).HasColumnName("EInvoiceId");

            builder.Property(e => e.GrossAmount).HasColumnType("numeric(12,3)");

            builder.Property(e => e.ModifiedDateTime).HasDefaultValueSql("'0001-01-01 00:00:00'::timestamp without time zone");

            builder.Property(e => e.NetAmount).HasColumnType("numeric(12,3)");

            builder.Property(e => e.ReceiptId).HasMaxLength(20);

            //builder.HasOne(d => d.Currency)
            //    .WithMany(p => p.PosTrxes)
            //    .HasForeignKey(d => d.CurrencyId)
            //    .HasConstraintName("FK_public.PosTrxes_public.Currencies_CurrencyId");
        }
    }
}
