// <auto-generated />
using System;
using ERPCore.Infra.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace ERPCore.Infra.Persistence.Migrations
{
    [DbContext(typeof(ErpDbContext))]
    partial class ErpDbContextModelSnapshot : ModelSnapshot
    {
        protected override void BuildModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "10.0.9")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

            modelBuilder.Entity("ERPCore.Domain.Entities.AuditLog", b =>
                {
                    b.Property<int>("AuditId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("AuditId"));

                    b.Property<string>("Action")
                        .IsRequired()
                        .HasMaxLength(10)
                        .HasColumnType("character varying(10)");

                    b.Property<string>("ChangeSet")
                        .IsRequired()
                        .HasColumnType("jsonb");

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("EntityId")
                        .HasColumnType("integer");

                    b.Property<string>("EntityType")
                        .IsRequired()
                        .HasMaxLength(80)
                        .HasColumnType("character varying(80)");

                    b.Property<int>("UserId")
                        .HasColumnType("integer");

                    b.HasKey("AuditId");

                    b.HasIndex("CreatedAt");

                    b.HasIndex("UserId");

                    b.HasIndex("EntityType", "EntityId");

                    b.ToTable("audit_logs", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Batch", b =>
                {
                    b.Property<int>("BatchId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("BatchId"));

                    b.Property<string>("BatchNo")
                        .IsRequired()
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.Property<DateOnly?>("ExpiryDate")
                        .HasColumnType("date");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.HasKey("BatchId");

                    b.HasIndex("ItemId", "BatchNo")
                        .IsUnique();

                    b.ToTable("batches", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Bin", b =>
                {
                    b.Property<int>("BinId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("BinId"));

                    b.Property<string>("BinType")
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.Property<string>("Code")
                        .IsRequired()
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("BinId");

                    b.HasIndex("WarehouseId", "Code")
                        .IsUnique();

                    b.ToTable("bins", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
                {
                    b.Property<int>("CategoryId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("CategoryId"));

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<int?>("ParentId")
                        .HasColumnType("integer");

                    b.HasKey("CategoryId");

                    b.HasIndex("ParentId");

                    b.ToTable("categories", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b =>
                {
                    b.Property<int>("GrnId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("GrnId"));

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("CreatedBy")
                        .HasColumnType("integer");

                    b.Property<string>("DocNo")
                        .IsRequired()
                        .HasMaxLength(30)
                        .HasColumnType("character varying(30)");

                    b.Property<int?>("PoId")
                        .HasColumnType("integer");

                    b.Property<DateTime?>("PostedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<uint>("RowVersion")
                        .IsConcurrencyToken()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("xid")
                        .HasColumnName("xmin");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<int>("VendorId")
                        .HasColumnType("integer");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("GrnId");

                    b.HasIndex("CreatedBy");

                    b.HasIndex("DocNo")
                        .IsUnique();

                    b.HasIndex("PoId");

                    b.HasIndex("Status");

                    b.HasIndex("VendorId");

                    b.HasIndex("WarehouseId");

                    b.ToTable("grns", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.GrnLine", b =>
                {
                    b.Property<int>("GrnLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("GrnLineId"));

                    b.Property<int?>("BatchId")
                        .HasColumnType("integer");

                    b.Property<int?>("BinId")
                        .HasColumnType("integer");

                    b.Property<int>("GrnId")
                        .HasColumnType("integer");

                    b.Property<string>("HoldStatus")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<int?>("PoLineId")
                        .HasColumnType("integer");

                    b.Property<decimal>("Qty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal>("ReceivedValue")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal>("UnitCost")
                        .HasPrecision(18, 6)
                        .HasColumnType("numeric(18,6)");

                    b.Property<int>("UomId")
                        .HasColumnType("integer");

                    b.HasKey("GrnLineId");

                    b.HasIndex("BatchId");

                    b.HasIndex("BinId");

                    b.HasIndex("GrnId");

                    b.HasIndex("ItemId");

                    b.HasIndex("PoLineId");

                    b.HasIndex("UomId");

                    b.ToTable("grn_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
                {
                    b.Property<int>("ItemId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ItemId"));

                    b.Property<int>("BaseUomId")
                        .HasColumnType("integer");

                    b.Property<int>("CategoryId")
                        .HasColumnType("integer");

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int?>("DefaultVendorId")
                        .HasColumnType("integer");

                    b.Property<string>("Description")
                        .HasMaxLength(1000)
                        .HasColumnType("character varying(1000)");

                    b.Property<string>("ItemType")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<uint>("RowVersion")
                        .IsConcurrencyToken()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("xid")
                        .HasColumnName("xmin");

                    b.Property<string>("Sku")
                        .IsRequired()
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.Property<string>("Status")
                        .IsRequired()
                        .ValueGeneratedOnAdd()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)")
                        .HasDefaultValue("Active");

                    b.Property<string>("TaxClass")
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<string>("TrackingMode")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<DateTime?>("UpdatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.HasKey("ItemId");

                    b.HasIndex("BaseUomId");

                    b.HasIndex("CategoryId");

                    b.HasIndex("DefaultVendorId");

                    b.HasIndex("Sku")
                        .IsUnique();

                    b.HasIndex("Status");

                    b.ToTable("items", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b =>
                {
                    b.Property<int>("ReorderId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ReorderId"));

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("ReorderPoint")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal>("ReorderQty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("ReorderId");

                    b.HasIndex("WarehouseId");

                    b.HasIndex("ItemId", "WarehouseId")
                        .IsUnique();

                    b.ToTable("item_reorders", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b =>
                {
                    b.Property<int>("JournalId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("JournalId"));

                    b.Property<decimal>("Amount")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<string>("CreditAccount")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<string>("DebitAccount")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<int>("SourceDocId")
                        .HasColumnType("integer");

                    b.Property<string>("SourceDocType")
                        .IsRequired()
                        .HasMaxLength(10)
                        .HasColumnType("character varying(10)");

                    b.HasKey("JournalId");

                    b.HasIndex("SourceDocType", "SourceDocId");

                    b.ToTable("journal_entry_stubs", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.NumberSequence", b =>
                {
                    b.Property<int>("SequenceId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SequenceId"));

                    b.Property<string>("DocType")
                        .IsRequired()
                        .HasMaxLength(10)
                        .HasColumnType("character varying(10)")
                        .HasColumnName("doc_type");

                    b.Property<int>("LastNumber")
                        .HasColumnType("integer")
                        .HasColumnName("last_number");

                    b.Property<int>("Year")
                        .HasColumnType("integer")
                        .HasColumnName("year");

                    b.HasKey("SequenceId");

                    b.HasIndex("DocType", "Year")
                        .IsUnique();

                    b.ToTable("number_sequences", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b =>
                {
                    b.Property<int>("PoLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("PoLineId"));

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<int>("PoId")
                        .HasColumnType("integer");

                    b.Property<decimal>("Qty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal>("QtyReceived")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal>("Tax")
                        .HasPrecision(9, 4)
                        .HasColumnType("numeric(9,4)");

                    b.Property<decimal>("UnitPrice")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int>("UomId")
                        .HasColumnType("integer");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("PoLineId");

                    b.HasIndex("ItemId");

                    b.HasIndex("PoId");

                    b.HasIndex("UomId");

                    b.HasIndex("WarehouseId");

                    b.ToTable("po_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b =>
                {
                    b.Property<int>("PoId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("PoId"));

                    b.Property<bool>("ApprovalRequired")
                        .HasColumnType("boolean");

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("CreatedBy")
                        .HasColumnType("integer");

                    b.Property<string>("DocNo")
                        .IsRequired()
                        .HasMaxLength(30)
                        .HasColumnType("character varying(30)");

                    b.Property<int?>("RequisitionId")
                        .HasColumnType("integer");

                    b.Property<uint>("RowVersion")
                        .IsConcurrencyToken()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("xid")
                        .HasColumnName("xmin");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<DateTime?>("UpdatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("VendorId")
                        .HasColumnType("integer");

                    b.HasKey("PoId");

                    b.HasIndex("CreatedBy");

                    b.HasIndex("DocNo")
                        .IsUnique();

                    b.HasIndex("RequisitionId");

                    b.HasIndex("Status");

                    b.HasIndex("VendorId");

                    b.ToTable("purchase_orders", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseReturn", b =>
                {
                    b.Property<int>("ReturnId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ReturnId"));

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("CreatedBy")
                        .HasColumnType("integer");

                    b.Property<string>("DocNo")
                        .IsRequired()
                        .HasMaxLength(30)
                        .HasColumnType("character varying(30)");

                    b.Property<int>("ReasonCodeId")
                        .HasColumnType("integer");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<int>("VendorId")
                        .HasColumnType("integer");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("ReturnId");

                    b.HasIndex("CreatedBy");

                    b.HasIndex("DocNo")
                        .IsUnique();

                    b.HasIndex("ReasonCodeId");

                    b.HasIndex("VendorId");

                    b.HasIndex("WarehouseId");

                    b.ToTable("purchase_returns", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseReturnLine", b =>
                {
                    b.Property<int>("ReturnLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ReturnLineId"));

                    b.Property<int?>("GrnLineId")
                        .HasColumnType("integer");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("Qty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int>("ReturnId")
                        .HasColumnType("integer");

                    b.HasKey("ReturnLineId");

                    b.HasIndex("GrnLineId");

                    b.HasIndex("ItemId");

                    b.HasIndex("ReturnId");

                    b.ToTable("purchase_return_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.ReasonCode", b =>
                {
                    b.Property<int>("ReasonCodeId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ReasonCodeId"));

                    b.Property<string>("Code")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<string>("Context")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<string>("Description")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.HasKey("ReasonCodeId");

                    b.HasIndex("Context", "Code")
                        .IsUnique();

                    b.ToTable("reason_codes", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Requisition", b =>
                {
                    b.Property<int>("RequisitionId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("RequisitionId"));

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("DocNo")
                        .IsRequired()
                        .HasMaxLength(30)
                        .HasColumnType("character varying(30)");

                    b.Property<int>("RequestedBy")
                        .HasColumnType("integer");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.HasKey("RequisitionId");

                    b.HasIndex("DocNo")
                        .IsUnique();

                    b.HasIndex("RequestedBy");

                    b.HasIndex("Status");

                    b.ToTable("requisitions", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.RequisitionLine", b =>
                {
                    b.Property<int>("ReqLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ReqLineId"));

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("Qty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<DateOnly?>("RequiredBy")
                        .HasColumnType("date");

                    b.Property<int>("RequisitionId")
                        .HasColumnType("integer");

                    b.HasKey("ReqLineId");

                    b.HasIndex("ItemId");

                    b.HasIndex("RequisitionId");

                    b.ToTable("requisition_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Rfq", b =>
                {
                    b.Property<int>("RfqId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("RfqId"));

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("DocNo")
                        .IsRequired()
                        .HasMaxLength(30)
                        .HasColumnType("character varying(30)");

                    b.Property<int>("RequisitionId")
                        .HasColumnType("integer");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.HasKey("RfqId");

                    b.HasIndex("DocNo")
                        .IsUnique();

                    b.HasIndex("RequisitionId");

                    b.ToTable("rfqs", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.RfqLine", b =>
                {
                    b.Property<int>("RfqLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("RfqLineId"));

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("Qty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int>("RfqId")
                        .HasColumnType("integer");

                    b.HasKey("RfqLineId");

                    b.HasIndex("ItemId");

                    b.HasIndex("RfqId");

                    b.ToTable("rfq_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b =>
                {
                    b.Property<int>("SerialId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SerialId"));

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<string>("SerialNo")
                        .IsRequired()
                        .HasMaxLength(100)
                        .HasColumnType("character varying(100)");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.HasKey("SerialId");

                    b.HasIndex("ItemId", "SerialNo")
                        .IsUnique();

                    b.ToTable("serials", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockAdjustment", b =>
                {
                    b.Property<int>("AdjustmentId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("AdjustmentId"));

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("CreatedBy")
                        .HasColumnType("integer");

                    b.Property<string>("DocNo")
                        .IsRequired()
                        .HasMaxLength(30)
                        .HasColumnType("character varying(30)");

                    b.Property<int>("ReasonCodeId")
                        .HasColumnType("integer");

                    b.Property<uint>("RowVersion")
                        .IsConcurrencyToken()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("xid")
                        .HasColumnName("xmin");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("AdjustmentId");

                    b.HasIndex("CreatedBy");

                    b.HasIndex("DocNo")
                        .IsUnique();

                    b.HasIndex("ReasonCodeId");

                    b.HasIndex("WarehouseId");

                    b.ToTable("stock_adjustments", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockAdjustmentLine", b =>
                {
                    b.Property<int>("AdjLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("AdjLineId"));

                    b.Property<int>("AdjustmentId")
                        .HasColumnType("integer");

                    b.Property<int?>("BatchId")
                        .HasColumnType("integer");

                    b.Property<int?>("BinId")
                        .HasColumnType("integer");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("QtyDelta")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int?>("SerialId")
                        .HasColumnType("integer");

                    b.HasKey("AdjLineId");

                    b.HasIndex("AdjustmentId");

                    b.HasIndex("BatchId");

                    b.HasIndex("BinId");

                    b.HasIndex("ItemId");

                    b.HasIndex("SerialId");

                    b.ToTable("stock_adjustment_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockCount", b =>
                {
                    b.Property<int>("CountId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("CountId"));

                    b.Property<string>("CountType")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("CreatedBy")
                        .HasColumnType("integer");

                    b.Property<string>("DocNo")
                        .IsRequired()
                        .HasMaxLength(30)
                        .HasColumnType("character varying(30)");

                    b.Property<uint>("RowVersion")
                        .IsConcurrencyToken()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("xid")
                        .HasColumnName("xmin");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("CountId");

                    b.HasIndex("CreatedBy");

                    b.HasIndex("DocNo")
                        .IsUnique();

                    b.HasIndex("Status");

                    b.HasIndex("WarehouseId");

                    b.ToTable("stock_counts", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockCountLine", b =>
                {
                    b.Property<int>("CountLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("CountLineId"));

                    b.Property<int?>("BinId")
                        .HasColumnType("integer");

                    b.Property<int>("CountId")
                        .HasColumnType("integer");

                    b.Property<decimal?>("CountedQty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("SystemQty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal?>("Variance")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.HasKey("CountLineId");

                    b.HasIndex("BinId");

                    b.HasIndex("CountId");

                    b.HasIndex("ItemId");

                    b.ToTable("stock_count_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockLayer", b =>
                {
                    b.Property<int>("LayerId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("LayerId"));

                    b.Property<int?>("BatchId")
                        .HasColumnType("integer");

                    b.Property<int?>("GrnLineId")
                        .HasColumnType("integer");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("QtyReceived")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal>("QtyRemaining")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<DateTime>("ReceiptDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int?>("SerialId")
                        .HasColumnType("integer");

                    b.Property<decimal>("UnitCost")
                        .HasPrecision(18, 6)
                        .HasColumnType("numeric(18,6)");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("LayerId");

                    b.HasIndex("BatchId");

                    b.HasIndex("GrnLineId");

                    b.HasIndex("SerialId");

                    b.HasIndex("WarehouseId");

                    b.HasIndex("ItemId", "WarehouseId", "ReceiptDate", "LayerId");

                    b.ToTable("stock_layers", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockLedger", b =>
                {
                    b.Property<int>("LedgerId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("LedgerId"));

                    b.Property<int?>("BatchId")
                        .HasColumnType("integer");

                    b.Property<int?>("BinId")
                        .HasColumnType("integer");

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("Direction")
                        .IsRequired()
                        .HasMaxLength(5)
                        .HasColumnType("character varying(5)");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("QtyBase")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal>("RunningBalance")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int?>("SerialId")
                        .HasColumnType("integer");

                    b.Property<int>("SourceDocId")
                        .HasColumnType("integer");

                    b.Property<string>("SourceDocType")
                        .IsRequired()
                        .HasMaxLength(10)
                        .HasColumnType("character varying(10)");

                    b.Property<decimal>("UnitCost")
                        .HasPrecision(18, 6)
                        .HasColumnType("numeric(18,6)");

                    b.Property<int>("UserId")
                        .HasColumnType("integer");

                    b.Property<decimal>("Value")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int>("WarehouseId")
                        .HasColumnType("integer");

                    b.HasKey("LedgerId");

                    b.HasIndex("BatchId");

                    b.HasIndex("BinId");

                    b.HasIndex("SerialId");

                    b.HasIndex("UserId");

                    b.HasIndex("WarehouseId");

                    b.HasIndex("SourceDocType", "SourceDocId");

                    b.HasIndex("ItemId", "WarehouseId", "CreatedAt");

                    b.HasIndex("ItemId", "WarehouseId", "LedgerId");

                    b.ToTable("stock_ledger", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockTransfer", b =>
                {
                    b.Property<int>("TransferId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("TransferId"));

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("CreatedBy")
                        .HasColumnType("integer");

                    b.Property<int>("DestWarehouseId")
                        .HasColumnType("integer");

                    b.Property<string>("DocNo")
                        .IsRequired()
                        .HasMaxLength(30)
                        .HasColumnType("character varying(30)");

                    b.Property<uint>("RowVersion")
                        .IsConcurrencyToken()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("xid")
                        .HasColumnName("xmin");

                    b.Property<int>("SrcWarehouseId")
                        .HasColumnType("integer");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.HasKey("TransferId");

                    b.HasIndex("CreatedBy");

                    b.HasIndex("DestWarehouseId");

                    b.HasIndex("DocNo")
                        .IsUnique();

                    b.HasIndex("SrcWarehouseId");

                    b.HasIndex("Status");

                    b.ToTable("stock_transfers", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockTransferLine", b =>
                {
                    b.Property<int>("TransferLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("TransferLineId"));

                    b.Property<int?>("BatchId")
                        .HasColumnType("integer");

                    b.Property<int?>("DestBinId")
                        .HasColumnType("integer");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<decimal>("Qty")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<decimal>("QtyReceived")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.Property<int?>("SerialId")
                        .HasColumnType("integer");

                    b.Property<int?>("SrcBinId")
                        .HasColumnType("integer");

                    b.Property<int>("TransferId")
                        .HasColumnType("integer");

                    b.Property<decimal?>("UnitCost")
                        .HasPrecision(18, 6)
                        .HasColumnType("numeric(18,6)");

                    b.HasKey("TransferLineId");

                    b.HasIndex("BatchId");

                    b.HasIndex("DestBinId");

                    b.HasIndex("ItemId");

                    b.HasIndex("SerialId");

                    b.HasIndex("SrcBinId");

                    b.HasIndex("TransferId");

                    b.ToTable("stock_transfer_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b =>
                {
                    b.Property<int>("UomId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UomId"));

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.HasKey("UomId");

                    b.HasIndex("Name")
                        .IsUnique();

                    b.ToTable("uoms", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.UomConversion", b =>
                {
                    b.Property<int>("ConversionId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ConversionId"));

                    b.Property<decimal>("Factor")
                        .HasPrecision(18, 6)
                        .HasColumnType("numeric(18,6)");

                    b.Property<int>("FromUomId")
                        .HasColumnType("integer");

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<int>("ToUomId")
                        .HasColumnType("integer");

                    b.HasKey("ConversionId");

                    b.HasIndex("FromUomId");

                    b.HasIndex("ToUomId");

                    b.HasIndex("ItemId", "FromUomId", "ToUomId")
                        .IsUnique();

                    b.ToTable("uom_conversions", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.User", b =>
                {
                    b.Property<int>("UserId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserId"));

                    b.Property<Guid?>("AuthUserId")
                        .HasColumnType("uuid")
                        .HasColumnName("auth_user_id");

                    b.Property<string>("DisplayName")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)");

                    b.Property<string>("Username")
                        .IsRequired()
                        .HasMaxLength(100)
                        .HasColumnType("character varying(100)");

                    b.HasKey("UserId");

                    b.HasIndex("AuthUserId")
                        .IsUnique();

                    b.HasIndex("Username")
                        .IsUnique();

                    b.ToTable("users", (string)null);

                    b.HasData(
                        new
                        {
                            UserId = 1,
                            DisplayName = "System",
                            Status = "Active",
                            Username = "system"
                        });
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Vendor", b =>
                {
                    b.Property<int>("VendorId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("VendorId"));

                    b.Property<string>("Code")
                        .IsRequired()
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("Currency")
                        .IsRequired()
                        .ValueGeneratedOnAdd()
                        .HasMaxLength(3)
                        .HasColumnType("character varying(3)")
                        .HasDefaultValue("LKR");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<uint>("RowVersion")
                        .IsConcurrencyToken()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("xid")
                        .HasColumnName("xmin");

                    b.Property<string>("Status")
                        .IsRequired()
                        .ValueGeneratedOnAdd()
                        .HasMaxLength(20)
                        .HasColumnType("character varying(20)")
                        .HasDefaultValue("Active");

                    b.Property<string>("TaxReg")
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.Property<string>("Terms")
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.Property<DateTime?>("UpdatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.HasKey("VendorId");

                    b.HasIndex("Code")
                        .IsUnique();

                    b.HasIndex("Status");

                    b.ToTable("vendors", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotation", b =>
                {
                    b.Property<int>("QuotationId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("QuotationId"));

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int>("RfqId")
                        .HasColumnType("integer");

                    b.Property<int>("VendorId")
                        .HasColumnType("integer");

                    b.HasKey("QuotationId");

                    b.HasIndex("VendorId");

                    b.HasIndex("RfqId", "VendorId")
                        .IsUnique();

                    b.ToTable("vendor_quotations", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotationLine", b =>
                {
                    b.Property<int>("QuotationLineId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("QuotationLineId"));

                    b.Property<int>("ItemId")
                        .HasColumnType("integer");

                    b.Property<int>("LeadDays")
                        .HasColumnType("integer");

                    b.Property<int>("QuotationId")
                        .HasColumnType("integer");

                    b.Property<decimal>("UnitPrice")
                        .HasPrecision(18, 4)
                        .HasColumnType("numeric(18,4)");

                    b.HasKey("QuotationLineId");

                    b.HasIndex("ItemId");

                    b.HasIndex("QuotationId");

                    b.ToTable("vendor_quotation_lines", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Warehouse", b =>
                {
                    b.Property<int>("WarehouseId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("WarehouseId"));

                    b.Property<string>("Code")
                        .IsRequired()
                        .HasMaxLength(50)
                        .HasColumnType("character varying(50)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.HasKey("WarehouseId");

                    b.HasIndex("Code")
                        .IsUnique();

                    b.ToTable("warehouses", (string)null);
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.AuditLog", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.User", null)
                        .WithMany()
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Batch", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Item");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Bin", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
                        .WithMany("Bins")
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Warehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Category", "Parent")
                        .WithMany("Children")
                        .HasForeignKey("ParentId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.Navigation("Parent");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.User", "Creator")
                        .WithMany()
                        .HasForeignKey("CreatedBy")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.PurchaseOrder", "PurchaseOrder")
                        .WithMany()
                        .HasForeignKey("PoId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Vendor", "Vendor")
                        .WithMany()
                        .HasForeignKey("VendorId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
                        .WithMany()
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Creator");

                    b.Navigation("PurchaseOrder");

                    b.Navigation("Vendor");

                    b.Navigation("Warehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.GrnLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Batch", "Batch")
                        .WithMany()
                        .HasForeignKey("BatchId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Bin", "Bin")
                        .WithMany()
                        .HasForeignKey("BinId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Grn", "Grn")
                        .WithMany("Lines")
                        .HasForeignKey("GrnId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.PoLine", "PoLine")
                        .WithMany()
                        .HasForeignKey("PoLineId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Uom", "Uom")
                        .WithMany()
                        .HasForeignKey("UomId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Batch");

                    b.Navigation("Bin");

                    b.Navigation("Grn");

                    b.Navigation("Item");

                    b.Navigation("PoLine");

                    b.Navigation("Uom");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Uom", "BaseUom")
                        .WithMany()
                        .HasForeignKey("BaseUomId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Category", "Category")
                        .WithMany()
                        .HasForeignKey("CategoryId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Vendor", "DefaultVendor")
                        .WithMany()
                        .HasForeignKey("DefaultVendorId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.Navigation("BaseUom");

                    b.Navigation("Category");

                    b.Navigation("DefaultVendor");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany("ReorderSettings")
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
                        .WithMany()
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Item");

                    b.Navigation("Warehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.PurchaseOrder", "PurchaseOrder")
                        .WithMany("Lines")
                        .HasForeignKey("PoId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Uom", "Uom")
                        .WithMany()
                        .HasForeignKey("UomId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
                        .WithMany()
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Item");

                    b.Navigation("PurchaseOrder");

                    b.Navigation("Uom");

                    b.Navigation("Warehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.User", "Creator")
                        .WithMany()
                        .HasForeignKey("CreatedBy")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Requisition", "Requisition")
                        .WithMany()
                        .HasForeignKey("RequisitionId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Vendor", "Vendor")
                        .WithMany()
                        .HasForeignKey("VendorId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Creator");

                    b.Navigation("Requisition");

                    b.Navigation("Vendor");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseReturn", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.User", "Creator")
                        .WithMany()
                        .HasForeignKey("CreatedBy")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.ReasonCode", "ReasonCode")
                        .WithMany()
                        .HasForeignKey("ReasonCodeId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Vendor", "Vendor")
                        .WithMany()
                        .HasForeignKey("VendorId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
                        .WithMany()
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Creator");

                    b.Navigation("ReasonCode");

                    b.Navigation("Vendor");

                    b.Navigation("Warehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseReturnLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.GrnLine", "GrnLine")
                        .WithMany()
                        .HasForeignKey("GrnLineId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.PurchaseReturn", "Return")
                        .WithMany("Lines")
                        .HasForeignKey("ReturnId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("GrnLine");

                    b.Navigation("Item");

                    b.Navigation("Return");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Requisition", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.User", "Requester")
                        .WithMany()
                        .HasForeignKey("RequestedBy")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Requester");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.RequisitionLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Requisition", "Requisition")
                        .WithMany("Lines")
                        .HasForeignKey("RequisitionId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Item");

                    b.Navigation("Requisition");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Rfq", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Requisition", "Requisition")
                        .WithMany()
                        .HasForeignKey("RequisitionId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Requisition");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.RfqLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Rfq", "Rfq")
                        .WithMany("Lines")
                        .HasForeignKey("RfqId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Item");

                    b.Navigation("Rfq");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Item");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockAdjustment", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.User", "Creator")
                        .WithMany()
                        .HasForeignKey("CreatedBy")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.ReasonCode", "ReasonCode")
                        .WithMany()
                        .HasForeignKey("ReasonCodeId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
                        .WithMany()
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Creator");

                    b.Navigation("ReasonCode");

                    b.Navigation("Warehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockAdjustmentLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.StockAdjustment", "Adjustment")
                        .WithMany("Lines")
                        .HasForeignKey("AdjustmentId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Batch", null)
                        .WithMany()
                        .HasForeignKey("BatchId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Bin", null)
                        .WithMany()
                        .HasForeignKey("BinId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Serial", null)
                        .WithMany()
                        .HasForeignKey("SerialId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.Navigation("Adjustment");

                    b.Navigation("Item");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockCount", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.User", "Creator")
                        .WithMany()
                        .HasForeignKey("CreatedBy")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
                        .WithMany()
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Creator");

                    b.Navigation("Warehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockCountLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Bin", null)
                        .WithMany()
                        .HasForeignKey("BinId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.StockCount", "Count")
                        .WithMany("Lines")
                        .HasForeignKey("CountId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Count");

                    b.Navigation("Item");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockLayer", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Batch", "Batch")
                        .WithMany()
                        .HasForeignKey("BatchId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.GrnLine", "GrnLine")
                        .WithMany()
                        .HasForeignKey("GrnLineId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Serial", "Serial")
                        .WithMany()
                        .HasForeignKey("SerialId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
                        .WithMany()
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Batch");

                    b.Navigation("GrnLine");

                    b.Navigation("Item");

                    b.Navigation("Serial");

                    b.Navigation("Warehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockLedger", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Batch", null)
                        .WithMany()
                        .HasForeignKey("BatchId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Bin", null)
                        .WithMany()
                        .HasForeignKey("BinId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Item", null)
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Serial", null)
                        .WithMany()
                        .HasForeignKey("SerialId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.User", null)
                        .WithMany()
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", null)
                        .WithMany()
                        .HasForeignKey("WarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockTransfer", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.User", "Creator")
                        .WithMany()
                        .HasForeignKey("CreatedBy")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "DestWarehouse")
                        .WithMany()
                        .HasForeignKey("DestWarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Warehouse", "SrcWarehouse")
                        .WithMany()
                        .HasForeignKey("SrcWarehouseId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Creator");

                    b.Navigation("DestWarehouse");

                    b.Navigation("SrcWarehouse");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockTransferLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Batch", null)
                        .WithMany()
                        .HasForeignKey("BatchId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Bin", null)
                        .WithMany()
                        .HasForeignKey("DestBinId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Serial", null)
                        .WithMany()
                        .HasForeignKey("SerialId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.Bin", null)
                        .WithMany()
                        .HasForeignKey("SrcBinId")
                        .OnDelete(DeleteBehavior.Restrict);

                    b.HasOne("ERPCore.Domain.Entities.StockTransfer", "Transfer")
                        .WithMany("Lines")
                        .HasForeignKey("TransferId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Item");

                    b.Navigation("Transfer");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.UomConversion", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Uom", "FromUom")
                        .WithMany()
                        .HasForeignKey("FromUomId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany("UomConversions")
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Uom", "ToUom")
                        .WithMany()
                        .HasForeignKey("ToUomId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("FromUom");

                    b.Navigation("Item");

                    b.Navigation("ToUom");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotation", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Rfq", "Rfq")
                        .WithMany("Quotations")
                        .HasForeignKey("RfqId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.Vendor", "Vendor")
                        .WithMany()
                        .HasForeignKey("VendorId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Rfq");

                    b.Navigation("Vendor");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotationLine", b =>
                {
                    b.HasOne("ERPCore.Domain.Entities.Item", "Item")
                        .WithMany()
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("ERPCore.Domain.Entities.VendorQuotation", "Quotation")
                        .WithMany("Lines")
                        .HasForeignKey("QuotationId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Item");

                    b.Navigation("Quotation");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
                {
                    b.Navigation("Children");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b =>
                {
                    b.Navigation("Lines");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
                {
                    b.Navigation("ReorderSettings");

                    b.Navigation("UomConversions");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b =>
                {
                    b.Navigation("Lines");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseReturn", b =>
                {
                    b.Navigation("Lines");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Requisition", b =>
                {
                    b.Navigation("Lines");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Rfq", b =>
                {
                    b.Navigation("Lines");

                    b.Navigation("Quotations");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockAdjustment", b =>
                {
                    b.Navigation("Lines");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockCount", b =>
                {
                    b.Navigation("Lines");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.StockTransfer", b =>
                {
                    b.Navigation("Lines");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotation", b =>
                {
                    b.Navigation("Lines");
                });

            modelBuilder.Entity("ERPCore.Domain.Entities.Warehouse", b =>
                {
                    b.Navigation("Bins");
                });
#pragma warning restore 612, 618
        }
    }
}
