diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260715093552_InitialCreate.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260715093552_InitialCreate.Designer.cs deleted file mode 100644 index 0406326..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260715093552_InitialCreate.Designer.cs +++ /dev/null @@ -1,2229 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260715093552_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(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("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("ParentId") - .HasColumnType("integer"); - - b.HasKey("CategoryId"); - - b.HasIndex("ParentId"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("ItemType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("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("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260715093552_InitialCreate.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260715093552_InitialCreate.cs deleted file mode 100644 index 1d0bd52..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260715093552_InitialCreate.cs +++ /dev/null @@ -1,1791 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "categories", - columns: table => new - { - CategoryId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - ParentId = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_categories", x => x.CategoryId); - table.ForeignKey( - name: "FK_categories_categories_ParentId", - column: x => x.ParentId, - principalTable: "categories", - principalColumn: "CategoryId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "journal_entry_stubs", - columns: table => new - { - JournalId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SourceDocType = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), - SourceDocId = table.Column(type: "integer", nullable: false), - DebitAccount = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - CreditAccount = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Amount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_journal_entry_stubs", x => x.JournalId); - }); - - migrationBuilder.CreateTable( - name: "number_sequences", - columns: table => new - { - SequenceId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - doc_type = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), - year = table.Column(type: "integer", nullable: false), - last_number = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_number_sequences", x => x.SequenceId); - }); - - migrationBuilder.CreateTable( - name: "reason_codes", - columns: table => new - { - ReasonCodeId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Description = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Context = table.Column(type: "character varying(20)", maxLength: 20, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_reason_codes", x => x.ReasonCodeId); - }); - - migrationBuilder.CreateTable( - name: "uoms", - columns: table => new - { - UomId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_uoms", x => x.UomId); - }); - - migrationBuilder.CreateTable( - name: "users", - columns: table => new - { - UserId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Username = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), - DisplayName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - auth_user_id = table.Column(type: "uuid", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_users", x => x.UserId); - }); - - migrationBuilder.CreateTable( - name: "vendors", - columns: table => new - { - VendorId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Terms = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - TaxReg = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - Currency = table.Column(type: "character varying(3)", maxLength: 3, nullable: false, defaultValue: "LKR"), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_vendors", x => x.VendorId); - }); - - migrationBuilder.CreateTable( - name: "warehouses", - columns: table => new - { - WarehouseId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_warehouses", x => x.WarehouseId); - }); - - migrationBuilder.CreateTable( - name: "audit_logs", - columns: table => new - { - AuditId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UserId = table.Column(type: "integer", nullable: false), - EntityType = table.Column(type: "character varying(80)", maxLength: 80, nullable: false), - EntityId = table.Column(type: "integer", nullable: false), - Action = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), - ChangeSet = table.Column(type: "jsonb", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_audit_logs", x => x.AuditId); - table.ForeignKey( - name: "FK_audit_logs_users_UserId", - column: x => x.UserId, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "requisitions", - columns: table => new - { - RequisitionId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - RequestedBy = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_requisitions", x => x.RequisitionId); - table.ForeignKey( - name: "FK_requisitions_users_RequestedBy", - column: x => x.RequestedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "items", - columns: table => new - { - ItemId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Sku = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Description = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), - CategoryId = table.Column(type: "integer", nullable: false), - BaseUomId = table.Column(type: "integer", nullable: false), - DefaultVendorId = table.Column(type: "integer", nullable: true), - ItemType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - TrackingMode = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - TaxClass = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_items", x => x.ItemId); - table.ForeignKey( - name: "FK_items_categories_CategoryId", - column: x => x.CategoryId, - principalTable: "categories", - principalColumn: "CategoryId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_items_uoms_BaseUomId", - column: x => x.BaseUomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_items_vendors_DefaultVendorId", - column: x => x.DefaultVendorId, - principalTable: "vendors", - principalColumn: "VendorId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "bins", - columns: table => new - { - BinId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - WarehouseId = table.Column(type: "integer", nullable: false), - Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - BinType = table.Column(type: "character varying(50)", maxLength: 50, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_bins", x => x.BinId); - table.ForeignKey( - name: "FK_bins_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "purchase_returns", - columns: table => new - { - ReturnId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - VendorId = table.Column(type: "integer", nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - ReasonCodeId = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_purchase_returns", x => x.ReturnId); - table.ForeignKey( - name: "FK_purchase_returns_reason_codes_ReasonCodeId", - column: x => x.ReasonCodeId, - principalTable: "reason_codes", - principalColumn: "ReasonCodeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_purchase_returns_users_CreatedBy", - column: x => x.CreatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_purchase_returns_vendors_VendorId", - column: x => x.VendorId, - principalTable: "vendors", - principalColumn: "VendorId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_purchase_returns_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "stock_adjustments", - columns: table => new - { - AdjustmentId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - ReasonCodeId = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stock_adjustments", x => x.AdjustmentId); - table.ForeignKey( - name: "FK_stock_adjustments_reason_codes_ReasonCodeId", - column: x => x.ReasonCodeId, - principalTable: "reason_codes", - principalColumn: "ReasonCodeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_adjustments_users_CreatedBy", - column: x => x.CreatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_adjustments_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "stock_counts", - columns: table => new - { - CountId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - CountType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stock_counts", x => x.CountId); - table.ForeignKey( - name: "FK_stock_counts_users_CreatedBy", - column: x => x.CreatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_counts_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "stock_transfers", - columns: table => new - { - TransferId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - SrcWarehouseId = table.Column(type: "integer", nullable: false), - DestWarehouseId = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stock_transfers", x => x.TransferId); - table.ForeignKey( - name: "FK_stock_transfers_users_CreatedBy", - column: x => x.CreatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_transfers_warehouses_DestWarehouseId", - column: x => x.DestWarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_transfers_warehouses_SrcWarehouseId", - column: x => x.SrcWarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "purchase_orders", - columns: table => new - { - PoId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - VendorId = table.Column(type: "integer", nullable: false), - RequisitionId = table.Column(type: "integer", nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ApprovalRequired = table.Column(type: "boolean", nullable: false), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_purchase_orders", x => x.PoId); - table.ForeignKey( - name: "FK_purchase_orders_requisitions_RequisitionId", - column: x => x.RequisitionId, - principalTable: "requisitions", - principalColumn: "RequisitionId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_purchase_orders_users_CreatedBy", - column: x => x.CreatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_purchase_orders_vendors_VendorId", - column: x => x.VendorId, - principalTable: "vendors", - principalColumn: "VendorId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "rfqs", - columns: table => new - { - RfqId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - RequisitionId = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_rfqs", x => x.RfqId); - table.ForeignKey( - name: "FK_rfqs_requisitions_RequisitionId", - column: x => x.RequisitionId, - principalTable: "requisitions", - principalColumn: "RequisitionId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "batches", - columns: table => new - { - BatchId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "integer", nullable: false), - BatchNo = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - ExpiryDate = table.Column(type: "date", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_batches", x => x.BatchId); - table.ForeignKey( - name: "FK_batches_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "item_reorders", - columns: table => new - { - ReorderId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "integer", nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - ReorderPoint = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ReorderQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_item_reorders", x => x.ReorderId); - table.ForeignKey( - name: "FK_item_reorders_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_item_reorders_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "requisition_lines", - columns: table => new - { - ReqLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RequisitionId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: false), - Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - RequiredBy = table.Column(type: "date", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_requisition_lines", x => x.ReqLineId); - table.ForeignKey( - name: "FK_requisition_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_requisition_lines_requisitions_RequisitionId", - column: x => x.RequisitionId, - principalTable: "requisitions", - principalColumn: "RequisitionId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "serials", - columns: table => new - { - SerialId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "integer", nullable: false), - SerialNo = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_serials", x => x.SerialId); - table.ForeignKey( - name: "FK_serials_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "uom_conversions", - columns: table => new - { - ConversionId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "integer", nullable: false), - FromUomId = table.Column(type: "integer", nullable: false), - ToUomId = table.Column(type: "integer", nullable: false), - Factor = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_uom_conversions", x => x.ConversionId); - table.ForeignKey( - name: "FK_uom_conversions_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_uom_conversions_uoms_FromUomId", - column: x => x.FromUomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_uom_conversions_uoms_ToUomId", - column: x => x.ToUomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "stock_count_lines", - columns: table => new - { - CountLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - CountId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: false), - BinId = table.Column(type: "integer", nullable: true), - SystemQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - CountedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: true), - Variance = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_stock_count_lines", x => x.CountLineId); - table.ForeignKey( - name: "FK_stock_count_lines_bins_BinId", - column: x => x.BinId, - principalTable: "bins", - principalColumn: "BinId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_count_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_count_lines_stock_counts_CountId", - column: x => x.CountId, - principalTable: "stock_counts", - principalColumn: "CountId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "grns", - columns: table => new - { - GrnId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - PoId = table.Column(type: "integer", nullable: true), - VendorId = table.Column(type: "integer", nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - PostedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_grns", x => x.GrnId); - table.ForeignKey( - name: "FK_grns_purchase_orders_PoId", - column: x => x.PoId, - principalTable: "purchase_orders", - principalColumn: "PoId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_grns_users_CreatedBy", - column: x => x.CreatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_grns_vendors_VendorId", - column: x => x.VendorId, - principalTable: "vendors", - principalColumn: "VendorId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_grns_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "po_lines", - columns: table => new - { - PoLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - PoId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: false), - UomId = table.Column(type: "integer", nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - UnitPrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - Tax = table.Column(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false), - QtyReceived = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_po_lines", x => x.PoLineId); - table.ForeignKey( - name: "FK_po_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_po_lines_purchase_orders_PoId", - column: x => x.PoId, - principalTable: "purchase_orders", - principalColumn: "PoId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_po_lines_uoms_UomId", - column: x => x.UomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_po_lines_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "rfq_lines", - columns: table => new - { - RfqLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RfqId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: false), - Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_rfq_lines", x => x.RfqLineId); - table.ForeignKey( - name: "FK_rfq_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_rfq_lines_rfqs_RfqId", - column: x => x.RfqId, - principalTable: "rfqs", - principalColumn: "RfqId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "vendor_quotations", - columns: table => new - { - QuotationId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RfqId = table.Column(type: "integer", nullable: false), - VendorId = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_vendor_quotations", x => x.QuotationId); - table.ForeignKey( - name: "FK_vendor_quotations_rfqs_RfqId", - column: x => x.RfqId, - principalTable: "rfqs", - principalColumn: "RfqId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_vendor_quotations_vendors_VendorId", - column: x => x.VendorId, - principalTable: "vendors", - principalColumn: "VendorId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "stock_adjustment_lines", - columns: table => new - { - AdjLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - AdjustmentId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: false), - BinId = table.Column(type: "integer", nullable: true), - BatchId = table.Column(type: "integer", nullable: true), - SerialId = table.Column(type: "integer", nullable: true), - QtyDelta = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stock_adjustment_lines", x => x.AdjLineId); - table.ForeignKey( - name: "FK_stock_adjustment_lines_batches_BatchId", - column: x => x.BatchId, - principalTable: "batches", - principalColumn: "BatchId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_adjustment_lines_bins_BinId", - column: x => x.BinId, - principalTable: "bins", - principalColumn: "BinId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_adjustment_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_adjustment_lines_serials_SerialId", - column: x => x.SerialId, - principalTable: "serials", - principalColumn: "SerialId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_adjustment_lines_stock_adjustments_AdjustmentId", - column: x => x.AdjustmentId, - principalTable: "stock_adjustments", - principalColumn: "AdjustmentId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "stock_ledger", - columns: table => new - { - LedgerId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "integer", nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - BinId = table.Column(type: "integer", nullable: true), - BatchId = table.Column(type: "integer", nullable: true), - SerialId = table.Column(type: "integer", nullable: true), - UserId = table.Column(type: "integer", nullable: false), - Direction = table.Column(type: "character varying(5)", maxLength: 5, nullable: false), - QtyBase = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - UnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), - Value = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - RunningBalance = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - SourceDocType = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), - SourceDocId = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stock_ledger", x => x.LedgerId); - table.ForeignKey( - name: "FK_stock_ledger_batches_BatchId", - column: x => x.BatchId, - principalTable: "batches", - principalColumn: "BatchId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_ledger_bins_BinId", - column: x => x.BinId, - principalTable: "bins", - principalColumn: "BinId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_ledger_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_ledger_serials_SerialId", - column: x => x.SerialId, - principalTable: "serials", - principalColumn: "SerialId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_ledger_users_UserId", - column: x => x.UserId, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_ledger_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "stock_transfer_lines", - columns: table => new - { - TransferLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TransferId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: false), - SrcBinId = table.Column(type: "integer", nullable: true), - DestBinId = table.Column(type: "integer", nullable: true), - BatchId = table.Column(type: "integer", nullable: true), - SerialId = table.Column(type: "integer", nullable: true), - Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - UnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: true), - QtyReceived = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stock_transfer_lines", x => x.TransferLineId); - table.ForeignKey( - name: "FK_stock_transfer_lines_batches_BatchId", - column: x => x.BatchId, - principalTable: "batches", - principalColumn: "BatchId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_transfer_lines_bins_DestBinId", - column: x => x.DestBinId, - principalTable: "bins", - principalColumn: "BinId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_transfer_lines_bins_SrcBinId", - column: x => x.SrcBinId, - principalTable: "bins", - principalColumn: "BinId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_transfer_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_transfer_lines_serials_SerialId", - column: x => x.SerialId, - principalTable: "serials", - principalColumn: "SerialId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_transfer_lines_stock_transfers_TransferId", - column: x => x.TransferId, - principalTable: "stock_transfers", - principalColumn: "TransferId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "grn_lines", - columns: table => new - { - GrnLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - GrnId = table.Column(type: "integer", nullable: false), - PoLineId = table.Column(type: "integer", nullable: true), - ItemId = table.Column(type: "integer", nullable: false), - UomId = table.Column(type: "integer", nullable: false), - BinId = table.Column(type: "integer", nullable: true), - BatchId = table.Column(type: "integer", nullable: true), - Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - UnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), - ReceivedValue = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - HoldStatus = table.Column(type: "character varying(20)", maxLength: 20, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_grn_lines", x => x.GrnLineId); - table.ForeignKey( - name: "FK_grn_lines_batches_BatchId", - column: x => x.BatchId, - principalTable: "batches", - principalColumn: "BatchId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_grn_lines_bins_BinId", - column: x => x.BinId, - principalTable: "bins", - principalColumn: "BinId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_grn_lines_grns_GrnId", - column: x => x.GrnId, - principalTable: "grns", - principalColumn: "GrnId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_grn_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_grn_lines_po_lines_PoLineId", - column: x => x.PoLineId, - principalTable: "po_lines", - principalColumn: "PoLineId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_grn_lines_uoms_UomId", - column: x => x.UomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "vendor_quotation_lines", - columns: table => new - { - QuotationLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - QuotationId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: false), - UnitPrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - LeadDays = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_vendor_quotation_lines", x => x.QuotationLineId); - table.ForeignKey( - name: "FK_vendor_quotation_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_vendor_quotation_lines_vendor_quotations_QuotationId", - column: x => x.QuotationId, - principalTable: "vendor_quotations", - principalColumn: "QuotationId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "purchase_return_lines", - columns: table => new - { - ReturnLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ReturnId = table.Column(type: "integer", nullable: false), - GrnLineId = table.Column(type: "integer", nullable: true), - ItemId = table.Column(type: "integer", nullable: false), - Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_purchase_return_lines", x => x.ReturnLineId); - table.ForeignKey( - name: "FK_purchase_return_lines_grn_lines_GrnLineId", - column: x => x.GrnLineId, - principalTable: "grn_lines", - principalColumn: "GrnLineId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_purchase_return_lines_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_purchase_return_lines_purchase_returns_ReturnId", - column: x => x.ReturnId, - principalTable: "purchase_returns", - principalColumn: "ReturnId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "stock_layers", - columns: table => new - { - LayerId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "integer", nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - BatchId = table.Column(type: "integer", nullable: true), - SerialId = table.Column(type: "integer", nullable: true), - GrnLineId = table.Column(type: "integer", nullable: true), - QtyReceived = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - QtyRemaining = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - UnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), - ReceiptDate = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stock_layers", x => x.LayerId); - table.ForeignKey( - name: "FK_stock_layers_batches_BatchId", - column: x => x.BatchId, - principalTable: "batches", - principalColumn: "BatchId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_layers_grn_lines_GrnLineId", - column: x => x.GrnLineId, - principalTable: "grn_lines", - principalColumn: "GrnLineId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_layers_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_layers_serials_SerialId", - column: x => x.SerialId, - principalTable: "serials", - principalColumn: "SerialId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stock_layers_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.InsertData( - table: "users", - columns: new[] { "UserId", "auth_user_id", "DisplayName", "Status", "Username" }, - values: new object[] { 1, null, "System", "Active", "system" }); - - migrationBuilder.CreateIndex( - name: "IX_audit_logs_CreatedAt", - table: "audit_logs", - column: "CreatedAt"); - - migrationBuilder.CreateIndex( - name: "IX_audit_logs_EntityType_EntityId", - table: "audit_logs", - columns: new[] { "EntityType", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_audit_logs_UserId", - table: "audit_logs", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_batches_ItemId_BatchNo", - table: "batches", - columns: new[] { "ItemId", "BatchNo" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_bins_WarehouseId_Code", - table: "bins", - columns: new[] { "WarehouseId", "Code" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_categories_ParentId", - table: "categories", - column: "ParentId"); - - migrationBuilder.CreateIndex( - name: "IX_grn_lines_BatchId", - table: "grn_lines", - column: "BatchId"); - - migrationBuilder.CreateIndex( - name: "IX_grn_lines_BinId", - table: "grn_lines", - column: "BinId"); - - migrationBuilder.CreateIndex( - name: "IX_grn_lines_GrnId", - table: "grn_lines", - column: "GrnId"); - - migrationBuilder.CreateIndex( - name: "IX_grn_lines_ItemId", - table: "grn_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_grn_lines_PoLineId", - table: "grn_lines", - column: "PoLineId"); - - migrationBuilder.CreateIndex( - name: "IX_grn_lines_UomId", - table: "grn_lines", - column: "UomId"); - - migrationBuilder.CreateIndex( - name: "IX_grns_CreatedBy", - table: "grns", - column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_grns_DocNo", - table: "grns", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_grns_PoId", - table: "grns", - column: "PoId"); - - migrationBuilder.CreateIndex( - name: "IX_grns_Status", - table: "grns", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_grns_VendorId", - table: "grns", - column: "VendorId"); - - migrationBuilder.CreateIndex( - name: "IX_grns_WarehouseId", - table: "grns", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_item_reorders_ItemId_WarehouseId", - table: "item_reorders", - columns: new[] { "ItemId", "WarehouseId" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_item_reorders_WarehouseId", - table: "item_reorders", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_items_BaseUomId", - table: "items", - column: "BaseUomId"); - - migrationBuilder.CreateIndex( - name: "IX_items_CategoryId", - table: "items", - column: "CategoryId"); - - migrationBuilder.CreateIndex( - name: "IX_items_DefaultVendorId", - table: "items", - column: "DefaultVendorId"); - - migrationBuilder.CreateIndex( - name: "IX_items_Sku", - table: "items", - column: "Sku", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_items_Status", - table: "items", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_journal_entry_stubs_SourceDocType_SourceDocId", - table: "journal_entry_stubs", - columns: new[] { "SourceDocType", "SourceDocId" }); - - migrationBuilder.CreateIndex( - name: "IX_number_sequences_doc_type_year", - table: "number_sequences", - columns: new[] { "doc_type", "year" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_po_lines_ItemId", - table: "po_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_po_lines_PoId", - table: "po_lines", - column: "PoId"); - - migrationBuilder.CreateIndex( - name: "IX_po_lines_UomId", - table: "po_lines", - column: "UomId"); - - migrationBuilder.CreateIndex( - name: "IX_po_lines_WarehouseId", - table: "po_lines", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_orders_CreatedBy", - table: "purchase_orders", - column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_orders_DocNo", - table: "purchase_orders", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_purchase_orders_RequisitionId", - table: "purchase_orders", - column: "RequisitionId"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_orders_Status", - table: "purchase_orders", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_orders_VendorId", - table: "purchase_orders", - column: "VendorId"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_return_lines_GrnLineId", - table: "purchase_return_lines", - column: "GrnLineId"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_return_lines_ItemId", - table: "purchase_return_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_return_lines_ReturnId", - table: "purchase_return_lines", - column: "ReturnId"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_returns_CreatedBy", - table: "purchase_returns", - column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_returns_DocNo", - table: "purchase_returns", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_purchase_returns_ReasonCodeId", - table: "purchase_returns", - column: "ReasonCodeId"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_returns_VendorId", - table: "purchase_returns", - column: "VendorId"); - - migrationBuilder.CreateIndex( - name: "IX_purchase_returns_WarehouseId", - table: "purchase_returns", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_reason_codes_Context_Code", - table: "reason_codes", - columns: new[] { "Context", "Code" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_requisition_lines_ItemId", - table: "requisition_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_requisition_lines_RequisitionId", - table: "requisition_lines", - column: "RequisitionId"); - - migrationBuilder.CreateIndex( - name: "IX_requisitions_DocNo", - table: "requisitions", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_requisitions_RequestedBy", - table: "requisitions", - column: "RequestedBy"); - - migrationBuilder.CreateIndex( - name: "IX_requisitions_Status", - table: "requisitions", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_rfq_lines_ItemId", - table: "rfq_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_rfq_lines_RfqId", - table: "rfq_lines", - column: "RfqId"); - - migrationBuilder.CreateIndex( - name: "IX_rfqs_DocNo", - table: "rfqs", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_rfqs_RequisitionId", - table: "rfqs", - column: "RequisitionId"); - - migrationBuilder.CreateIndex( - name: "IX_serials_ItemId_SerialNo", - table: "serials", - columns: new[] { "ItemId", "SerialNo" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustment_lines_AdjustmentId", - table: "stock_adjustment_lines", - column: "AdjustmentId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustment_lines_BatchId", - table: "stock_adjustment_lines", - column: "BatchId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustment_lines_BinId", - table: "stock_adjustment_lines", - column: "BinId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustment_lines_ItemId", - table: "stock_adjustment_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustment_lines_SerialId", - table: "stock_adjustment_lines", - column: "SerialId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustments_CreatedBy", - table: "stock_adjustments", - column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustments_DocNo", - table: "stock_adjustments", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustments_ReasonCodeId", - table: "stock_adjustments", - column: "ReasonCodeId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_adjustments_WarehouseId", - table: "stock_adjustments", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_count_lines_BinId", - table: "stock_count_lines", - column: "BinId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_count_lines_CountId", - table: "stock_count_lines", - column: "CountId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_count_lines_ItemId", - table: "stock_count_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_counts_CreatedBy", - table: "stock_counts", - column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_stock_counts_DocNo", - table: "stock_counts", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_stock_counts_Status", - table: "stock_counts", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_stock_counts_WarehouseId", - table: "stock_counts", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_layers_BatchId", - table: "stock_layers", - column: "BatchId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_layers_GrnLineId", - table: "stock_layers", - column: "GrnLineId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_layers_ItemId_WarehouseId_ReceiptDate_LayerId", - table: "stock_layers", - columns: new[] { "ItemId", "WarehouseId", "ReceiptDate", "LayerId" }); - - migrationBuilder.CreateIndex( - name: "IX_stock_layers_SerialId", - table: "stock_layers", - column: "SerialId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_layers_WarehouseId", - table: "stock_layers", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_ledger_BatchId", - table: "stock_ledger", - column: "BatchId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_ledger_BinId", - table: "stock_ledger", - column: "BinId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_ledger_ItemId_WarehouseId_CreatedAt", - table: "stock_ledger", - columns: new[] { "ItemId", "WarehouseId", "CreatedAt" }); - - migrationBuilder.CreateIndex( - name: "IX_stock_ledger_ItemId_WarehouseId_LedgerId", - table: "stock_ledger", - columns: new[] { "ItemId", "WarehouseId", "LedgerId" }); - - migrationBuilder.CreateIndex( - name: "IX_stock_ledger_SerialId", - table: "stock_ledger", - column: "SerialId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_ledger_SourceDocType_SourceDocId", - table: "stock_ledger", - columns: new[] { "SourceDocType", "SourceDocId" }); - - migrationBuilder.CreateIndex( - name: "IX_stock_ledger_UserId", - table: "stock_ledger", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_ledger_WarehouseId", - table: "stock_ledger", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfer_lines_BatchId", - table: "stock_transfer_lines", - column: "BatchId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfer_lines_DestBinId", - table: "stock_transfer_lines", - column: "DestBinId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfer_lines_ItemId", - table: "stock_transfer_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfer_lines_SerialId", - table: "stock_transfer_lines", - column: "SerialId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfer_lines_SrcBinId", - table: "stock_transfer_lines", - column: "SrcBinId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfer_lines_TransferId", - table: "stock_transfer_lines", - column: "TransferId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfers_CreatedBy", - table: "stock_transfers", - column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfers_DestWarehouseId", - table: "stock_transfers", - column: "DestWarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfers_DocNo", - table: "stock_transfers", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfers_SrcWarehouseId", - table: "stock_transfers", - column: "SrcWarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_stock_transfers_Status", - table: "stock_transfers", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_uom_conversions_FromUomId", - table: "uom_conversions", - column: "FromUomId"); - - migrationBuilder.CreateIndex( - name: "IX_uom_conversions_ItemId_FromUomId_ToUomId", - table: "uom_conversions", - columns: new[] { "ItemId", "FromUomId", "ToUomId" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_uom_conversions_ToUomId", - table: "uom_conversions", - column: "ToUomId"); - - migrationBuilder.CreateIndex( - name: "IX_uoms_Name", - table: "uoms", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_users_auth_user_id", - table: "users", - column: "auth_user_id", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_users_Username", - table: "users", - column: "Username", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_vendor_quotation_lines_ItemId", - table: "vendor_quotation_lines", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_vendor_quotation_lines_QuotationId", - table: "vendor_quotation_lines", - column: "QuotationId"); - - migrationBuilder.CreateIndex( - name: "IX_vendor_quotations_RfqId_VendorId", - table: "vendor_quotations", - columns: new[] { "RfqId", "VendorId" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_vendor_quotations_VendorId", - table: "vendor_quotations", - column: "VendorId"); - - migrationBuilder.CreateIndex( - name: "IX_vendors_Code", - table: "vendors", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_vendors_Status", - table: "vendors", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_warehouses_Code", - table: "warehouses", - column: "Code", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "audit_logs"); - - migrationBuilder.DropTable( - name: "item_reorders"); - - migrationBuilder.DropTable( - name: "journal_entry_stubs"); - - migrationBuilder.DropTable( - name: "number_sequences"); - - migrationBuilder.DropTable( - name: "purchase_return_lines"); - - migrationBuilder.DropTable( - name: "requisition_lines"); - - migrationBuilder.DropTable( - name: "rfq_lines"); - - migrationBuilder.DropTable( - name: "stock_adjustment_lines"); - - migrationBuilder.DropTable( - name: "stock_count_lines"); - - migrationBuilder.DropTable( - name: "stock_layers"); - - migrationBuilder.DropTable( - name: "stock_ledger"); - - migrationBuilder.DropTable( - name: "stock_transfer_lines"); - - migrationBuilder.DropTable( - name: "uom_conversions"); - - migrationBuilder.DropTable( - name: "vendor_quotation_lines"); - - migrationBuilder.DropTable( - name: "purchase_returns"); - - migrationBuilder.DropTable( - name: "stock_adjustments"); - - migrationBuilder.DropTable( - name: "stock_counts"); - - migrationBuilder.DropTable( - name: "grn_lines"); - - migrationBuilder.DropTable( - name: "serials"); - - migrationBuilder.DropTable( - name: "stock_transfers"); - - migrationBuilder.DropTable( - name: "vendor_quotations"); - - migrationBuilder.DropTable( - name: "reason_codes"); - - migrationBuilder.DropTable( - name: "batches"); - - migrationBuilder.DropTable( - name: "bins"); - - migrationBuilder.DropTable( - name: "grns"); - - migrationBuilder.DropTable( - name: "po_lines"); - - migrationBuilder.DropTable( - name: "rfqs"); - - migrationBuilder.DropTable( - name: "items"); - - migrationBuilder.DropTable( - name: "purchase_orders"); - - migrationBuilder.DropTable( - name: "warehouses"); - - migrationBuilder.DropTable( - name: "categories"); - - migrationBuilder.DropTable( - name: "uoms"); - - migrationBuilder.DropTable( - name: "requisitions"); - - migrationBuilder.DropTable( - name: "vendors"); - - migrationBuilder.DropTable( - name: "users"); - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260716134938_AddBrandsSubcategoriesItemTypesAndProductConfig.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260716134938_AddBrandsSubcategoriesItemTypesAndProductConfig.Designer.cs deleted file mode 100644 index 829393d..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260716134938_AddBrandsSubcategoriesItemTypesAndProductConfig.Designer.cs +++ /dev/null @@ -1,2454 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260716134938_AddBrandsSubcategoriesItemTypesAndProductConfig")] - partial class AddBrandsSubcategoriesItemTypesAndProductConfig - { - /// - protected override void BuildTargetModel(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("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("BinId"); - - b.HasIndex("WarehouseId", "Code") - .IsUnique(); - - b.ToTable("bins", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Brand", b => - { - b.Property("BrandId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BrandId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BrandId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("brands", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CategoryId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("BrandId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StockNature") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SubCategoryId") - .HasColumnType("integer"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemId"); - - b.HasIndex("BaseUomId"); - - b.HasIndex("BrandId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("DefaultVendorId"); - - b.HasIndex("Sku") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("SubCategoryId"); - - b.ToTable("items", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b => - { - b.Property("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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.ItemType", b => - { - b.Property("ItemTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemTypeId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemTypeId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("item_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b => - { - b.Property("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("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("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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.ProductConfig", b => - { - b.Property("ConfigId") - .HasColumnType("integer"); - - b.Property("BrandsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("ItemTypesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SubcategoriesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.HasKey("ConfigId"); - - b.HasIndex("UpdatedBy"); - - b.ToTable("product_config", null, t => - { - t.HasCheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b => - { - b.Property("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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.SubCategory", b => - { - b.Property("SubCategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubCategoryId")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SubCategoryId"); - - b.HasIndex("Status"); - - b.HasIndex("CategoryId", "Name") - .IsUnique(); - - b.ToTable("subcategories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b => - { - b.Property("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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.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.Brand", "Brand") - .WithMany() - .HasForeignKey("BrandId") - .OnDelete(DeleteBehavior.Restrict); - - 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.HasOne("ERPCore.Domain.Entities.SubCategory", "SubCategory") - .WithMany() - .HasForeignKey("SubCategoryId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("BaseUom"); - - b.Navigation("Brand"); - - b.Navigation("Category"); - - b.Navigation("DefaultVendor"); - - b.Navigation("SubCategory"); - }); - - 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.ProductConfig", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser") - .WithMany() - .HasForeignKey("UpdatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("UpdatedByUser"); - }); - - 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.SubCategory", b => - { - b.HasOne("ERPCore.Domain.Entities.Category", "Category") - .WithMany("SubCategories") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Category"); - }); - - 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("SubCategories"); - }); - - 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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260716134938_AddBrandsSubcategoriesItemTypesAndProductConfig.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260716134938_AddBrandsSubcategoriesItemTypesAndProductConfig.cs deleted file mode 100644 index a7e0ac5..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260716134938_AddBrandsSubcategoriesItemTypesAndProductConfig.cs +++ /dev/null @@ -1,442 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - /// Adds the Brand / SubCategory / ItemType masters and the singleton product config, - /// and converts CATEGORY from a self-nesting tree into a fixed two-level - /// Category → SubCategory hierarchy (docs/10 Part C.1). - /// - /// This migration carries data, not just DDL. The scaffolded version dropped - /// categories.ParentId outright, which would have silently flattened every - /// child category into a root and left items pointing at what is now a top-level - /// category — losing the parent entirely. The hand-written steps below (marked - /// "data migration") move child categories into subcategories and repoint items - /// onto the correct (category, subcategory) pair before the column goes away. - /// - /// - public partial class AddBrandsSubcategoriesItemTypesAndProductConfig : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - // NOTE: the ParentId drop is deliberately deferred to the bottom of this method — - // the data migration reads it. Order here is load-bearing. - migrationBuilder.RenameColumn( - name: "ItemType", - table: "items", - newName: "StockNature"); - - migrationBuilder.AddColumn( - name: "BrandId", - table: "items", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "SubCategoryId", - table: "items", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "CreatedAt", - table: "categories", - type: "timestamp with time zone", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - name: "Status", - table: "categories", - type: "character varying(20)", - maxLength: 20, - nullable: false, - defaultValue: "Active"); - - migrationBuilder.AddColumn( - name: "UpdatedAt", - table: "categories", - type: "timestamp with time zone", - nullable: true); - - migrationBuilder.AddColumn( - name: "xmin", - table: "categories", - type: "xid", - rowVersion: true, - nullable: false, - defaultValue: 0u); - - migrationBuilder.CreateTable( - name: "brands", - columns: table => new - { - BrandId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_brands", x => x.BrandId); - }); - - migrationBuilder.CreateTable( - name: "item_types", - columns: table => new - { - ItemTypeId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_item_types", x => x.ItemTypeId); - }); - - migrationBuilder.CreateTable( - name: "product_config", - columns: table => new - { - ConfigId = table.Column(type: "integer", nullable: false), - SubcategoriesEnabled = table.Column(type: "boolean", nullable: false, defaultValue: true), - BrandsEnabled = table.Column(type: "boolean", nullable: false, defaultValue: true), - ItemTypesEnabled = table.Column(type: "boolean", nullable: false, defaultValue: true), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - UpdatedBy = table.Column(type: "integer", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_product_config", x => x.ConfigId); - table.CheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - table.ForeignKey( - name: "FK_product_config_users_UpdatedBy", - column: x => x.UpdatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "subcategories", - columns: table => new - { - SubCategoryId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - CategoryId = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_subcategories", x => x.SubCategoryId); - table.ForeignKey( - name: "FK_subcategories_categories_CategoryId", - column: x => x.CategoryId, - principalTable: "categories", - principalColumn: "CategoryId", - onDelete: ReferentialAction.Restrict); - }); - - // --------------------------------------------------------------------------- - // DATA MIGRATION — must run before ParentId is dropped. - // --------------------------------------------------------------------------- - - // Existing categories predate CreatedAt; the added column defaulted them to - // 0001-01-01. Stamp them with the migration time instead of a sentinel date. - migrationBuilder.Sql(@" - UPDATE categories SET ""CreatedAt"" = NOW() AT TIME ZONE 'utc'; - "); - - // Carry the old category id alongside each new subcategory so items can be - // repointed by join below. Dropped again once the repoint is done. - migrationBuilder.Sql(@" - ALTER TABLE subcategories ADD COLUMN legacy_category_id integer; - "); - - // Walk the old tree to its roots. The previous model allowed unlimited nesting, - // but the new one is exactly two levels — so a category at any depth below the - // root collapses into a subcategory of its ROOT ancestor (a grandchild cannot - // become a subcategory of its immediate parent, since that parent is itself - // ceasing to be a category). - migrationBuilder.Sql(@" - WITH RECURSIVE tree AS ( - SELECT ""CategoryId"", ""ParentId"", ""Name"", ""CategoryId"" AS root_id - FROM categories - WHERE ""ParentId"" IS NULL - UNION ALL - SELECT c.""CategoryId"", c.""ParentId"", c.""Name"", t.root_id - FROM categories c - JOIN tree t ON c.""ParentId"" = t.""CategoryId"" - ) - INSERT INTO subcategories (""Name"", ""CategoryId"", ""Status"", ""CreatedAt"", legacy_category_id) - SELECT t.""Name"", t.root_id, 'Active', NOW() AT TIME ZONE 'utc', t.""CategoryId"" - FROM tree t - WHERE t.""ParentId"" IS NOT NULL; - "); - - // Repoint items: an item that pointed at a child category now carries the root - // category plus the subcategory it actually meant. - migrationBuilder.Sql(@" - UPDATE items i - SET ""SubCategoryId"" = s.""SubCategoryId"", - ""CategoryId"" = s.""CategoryId"" - FROM subcategories s - WHERE s.legacy_category_id = i.""CategoryId""; - "); - - // The self-FK must go before the delete, or RESTRICT rejects removing a parent - // whose own child row is still present. - migrationBuilder.DropForeignKey( - name: "FK_categories_categories_ParentId", - table: "categories"); - - // Every non-root category now lives in `subcategories`, and no item references - // one any more (repointed above), so the rows can go. - migrationBuilder.Sql(@" - DELETE FROM categories WHERE ""ParentId"" IS NOT NULL; - ALTER TABLE subcategories DROP COLUMN legacy_category_id; - "); - - migrationBuilder.DropIndex( - name: "IX_categories_ParentId", - table: "categories"); - - migrationBuilder.DropColumn( - name: "ParentId", - table: "categories"); - - // Seed the singleton config (FR-MD-11) — all features on. Item writes read this - // row, so it must exist before the app serves a single request. - migrationBuilder.Sql(@" - INSERT INTO product_config (""ConfigId"", ""SubcategoriesEnabled"", ""BrandsEnabled"", ""ItemTypesEnabled"") - VALUES (1, TRUE, TRUE, TRUE) - ON CONFLICT (""ConfigId"") DO NOTHING; - "); - - // --------------------------------------------------------------------------- - - migrationBuilder.CreateIndex( - name: "IX_items_BrandId", - table: "items", - column: "BrandId"); - - migrationBuilder.CreateIndex( - name: "IX_items_SubCategoryId", - table: "items", - column: "SubCategoryId"); - - migrationBuilder.CreateIndex( - name: "IX_categories_Name", - table: "categories", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_categories_Status", - table: "categories", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_brands_Name", - table: "brands", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_brands_Status", - table: "brands", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_item_types_Name", - table: "item_types", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_item_types_Status", - table: "item_types", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_product_config_UpdatedBy", - table: "product_config", - column: "UpdatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_subcategories_CategoryId_Name", - table: "subcategories", - columns: new[] { "CategoryId", "Name" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_subcategories_Status", - table: "subcategories", - column: "Status"); - - migrationBuilder.AddForeignKey( - name: "FK_items_brands_BrandId", - table: "items", - column: "BrandId", - principalTable: "brands", - principalColumn: "BrandId", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_items_subcategories_SubCategoryId", - table: "items", - column: "SubCategoryId", - principalTable: "subcategories", - principalColumn: "SubCategoryId", - onDelete: ReferentialAction.Restrict); - } - - /// - /// Reverses the schema change and puts the subcategory data back where it came from. - /// - /// The scaffolded version simply dropped subcategories, which would have - /// discarded exactly what preserved. Instead each subcategory is - /// restored as a child category and its items are repointed back onto it. This is - /// not perfectly lossless: the old tree's depth is gone (a former grandchild comes - /// back as a direct child of its root), and Brand data cannot survive a schema that - /// has nowhere to put it. - /// - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_items_brands_BrandId", - table: "items"); - - migrationBuilder.DropForeignKey( - name: "FK_items_subcategories_SubCategoryId", - table: "items"); - - // Restore the parent column + self-FK first so subcategories have somewhere to - // land, then move them back before the table is dropped. - migrationBuilder.AddColumn( - name: "ParentId", - table: "categories", - type: "integer", - nullable: true); - - // --------------------------------------------------------------------------- - // DATA MIGRATION (reverse) — must run before `subcategories` is dropped. - // --------------------------------------------------------------------------- - - migrationBuilder.Sql(@" - ALTER TABLE categories ADD COLUMN legacy_subcategory_id integer; - "); - - // Each subcategory becomes a child category again under the same parent. - migrationBuilder.Sql(@" - INSERT INTO categories (""Name"", ""ParentId"", ""CreatedAt"", ""Status"", legacy_subcategory_id) - SELECT s.""Name"", s.""CategoryId"", s.""CreatedAt"", s.""Status"", s.""SubCategoryId"" - FROM subcategories s; - "); - - // Items that carried a subcategory point back at the restored child category. - migrationBuilder.Sql(@" - UPDATE items i - SET ""CategoryId"" = c.""CategoryId"" - FROM categories c - WHERE c.legacy_subcategory_id = i.""SubCategoryId""; - "); - - migrationBuilder.Sql(@" - ALTER TABLE categories DROP COLUMN legacy_subcategory_id; - "); - - // --------------------------------------------------------------------------- - - migrationBuilder.DropTable( - name: "brands"); - - migrationBuilder.DropTable( - name: "item_types"); - - migrationBuilder.DropTable( - name: "product_config"); - - migrationBuilder.DropTable( - name: "subcategories"); - - migrationBuilder.DropIndex( - name: "IX_items_BrandId", - table: "items"); - - migrationBuilder.DropIndex( - name: "IX_items_SubCategoryId", - table: "items"); - - migrationBuilder.DropIndex( - name: "IX_categories_Name", - table: "categories"); - - migrationBuilder.DropIndex( - name: "IX_categories_Status", - table: "categories"); - - migrationBuilder.DropColumn( - name: "BrandId", - table: "items"); - - migrationBuilder.DropColumn( - name: "SubCategoryId", - table: "items"); - - migrationBuilder.DropColumn( - name: "CreatedAt", - table: "categories"); - - migrationBuilder.DropColumn( - name: "Status", - table: "categories"); - - migrationBuilder.DropColumn( - name: "UpdatedAt", - table: "categories"); - - migrationBuilder.DropColumn( - name: "xmin", - table: "categories"); - - migrationBuilder.RenameColumn( - name: "StockNature", - table: "items", - newName: "ItemType"); - - // ParentId itself was re-added at the top of this method, ahead of the reverse - // data migration that populates it. - migrationBuilder.CreateIndex( - name: "IX_categories_ParentId", - table: "categories", - column: "ParentId"); - - migrationBuilder.AddForeignKey( - name: "FK_categories_categories_ParentId", - table: "categories", - column: "ParentId", - principalTable: "categories", - principalColumn: "CategoryId", - onDelete: ReferentialAction.Restrict); - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260718081219_ini2.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260718081219_ini2.Designer.cs deleted file mode 100644 index 184ab18..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260718081219_ini2.Designer.cs +++ /dev/null @@ -1,2454 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260718081219_ini2")] - partial class ini2 - { - /// - protected override void BuildTargetModel(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("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("BinId"); - - b.HasIndex("WarehouseId", "Code") - .IsUnique(); - - b.ToTable("bins", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Brand", b => - { - b.Property("BrandId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BrandId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BrandId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("brands", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CategoryId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("BrandId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StockNature") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SubCategoryId") - .HasColumnType("integer"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemId"); - - b.HasIndex("BaseUomId"); - - b.HasIndex("BrandId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("DefaultVendorId"); - - b.HasIndex("Sku") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("SubCategoryId"); - - b.ToTable("items", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b => - { - b.Property("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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.ItemType", b => - { - b.Property("ItemTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemTypeId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemTypeId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("item_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b => - { - b.Property("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("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("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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.ProductConfig", b => - { - b.Property("ConfigId") - .HasColumnType("integer"); - - b.Property("BrandsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("ItemTypesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SubcategoriesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.HasKey("ConfigId"); - - b.HasIndex("UpdatedBy"); - - b.ToTable("product_config", null, t => - { - t.HasCheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b => - { - b.Property("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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.SubCategory", b => - { - b.Property("SubCategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubCategoryId")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SubCategoryId"); - - b.HasIndex("Status"); - - b.HasIndex("CategoryId", "Name") - .IsUnique(); - - b.ToTable("subcategories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b => - { - b.Property("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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.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.Brand", "Brand") - .WithMany() - .HasForeignKey("BrandId") - .OnDelete(DeleteBehavior.Restrict); - - 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.HasOne("ERPCore.Domain.Entities.SubCategory", "SubCategory") - .WithMany() - .HasForeignKey("SubCategoryId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("BaseUom"); - - b.Navigation("Brand"); - - b.Navigation("Category"); - - b.Navigation("DefaultVendor"); - - b.Navigation("SubCategory"); - }); - - 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.ProductConfig", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser") - .WithMany() - .HasForeignKey("UpdatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("UpdatedByUser"); - }); - - 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.SubCategory", b => - { - b.HasOne("ERPCore.Domain.Entities.Category", "Category") - .WithMany("SubCategories") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Category"); - }); - - 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("SubCategories"); - }); - - 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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260718081219_ini2.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260718081219_ini2.cs deleted file mode 100644 index 4c89398..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260718081219_ini2.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class ini2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260718092655_AddRolesNavPermissions.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260718092655_AddRolesNavPermissions.Designer.cs deleted file mode 100644 index ca80bfc..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260718092655_AddRolesNavPermissions.Designer.cs +++ /dev/null @@ -1,3001 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260718092655_AddRolesNavPermissions")] - partial class AddRolesNavPermissions - { - /// - protected override void BuildTargetModel(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("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("BinId"); - - b.HasIndex("WarehouseId", "Code") - .IsUnique(); - - b.ToTable("bins", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Brand", b => - { - b.Property("BrandId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BrandId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BrandId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("brands", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CategoryId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("BrandId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StockNature") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SubCategoryId") - .HasColumnType("integer"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemId"); - - b.HasIndex("BaseUomId"); - - b.HasIndex("BrandId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("DefaultVendorId"); - - b.HasIndex("Sku") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("SubCategoryId"); - - b.ToTable("items", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b => - { - b.Property("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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.ItemType", b => - { - b.Property("ItemTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemTypeId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemTypeId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("item_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b => - { - b.Property("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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.NavItem", b => - { - b.Property("NavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("NavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("nav_items", (string)null); - - b.HasData( - new - { - NavItemId = 1, - Code = "dashboard", - Href = "/dashboard", - Label = "Dashboard", - SortOrder = 1, - Status = "Active" - }, - new - { - NavItemId = 2, - Code = "products", - Href = "/dashboard/products", - Label = "Products", - SortOrder = 2, - Status = "Active" - }, - new - { - NavItemId = 3, - Code = "vendors", - Href = "/dashboard/vendors", - Label = "Vendors", - SortOrder = 3, - Status = "Active" - }, - new - { - NavItemId = 4, - Code = "procurement", - Href = "/dashboard/procurement", - Label = "Procurement", - SortOrder = 4, - Status = "Active" - }, - new - { - NavItemId = 5, - Code = "receiving", - Href = "/dashboard/receiving/grn", - Label = "Receiving", - SortOrder = 5, - Status = "Active" - }, - new - { - NavItemId = 6, - Code = "stock", - Href = "/dashboard/stock", - Label = "Stock", - SortOrder = 6, - Status = "Active" - }, - new - { - NavItemId = 7, - Code = "warehouses", - Href = "/dashboard/warehouse", - Label = "Warehouses", - SortOrder = 7, - Status = "Active" - }, - new - { - NavItemId = 8, - Code = "orders", - Href = "/dashboard/orders", - Label = "Orders", - SortOrder = 8, - Status = "Active" - }, - new - { - NavItemId = 9, - Code = "settings", - Href = "/dashboard/settings", - Label = "Settings", - SortOrder = 9, - Status = "Active" - }, - new - { - NavItemId = 10, - Code = "help", - Href = "/dashboard/help", - Label = "Help", - SortOrder = 10, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NumberSequence", b => - { - b.Property("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("Year") - .HasColumnType("integer") - .HasColumnName("year"); - - b.HasKey("SequenceId"); - - b.HasIndex("DocType", "Year") - .IsUnique(); - - b.ToTable("number_sequences", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.Property("PermissionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PermissionId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SubNavItemId") - .HasColumnType("integer"); - - b.HasKey("PermissionId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.HasIndex("SubNavItemId"); - - b.ToTable("permissions", (string)null); - - b.HasData( - new - { - PermissionId = 1, - Code = "NAV:dashboard", - NavItemId = 1 - }, - new - { - PermissionId = 2, - Code = "NAV:products", - NavItemId = 2 - }, - new - { - PermissionId = 3, - Code = "NAV:vendors", - NavItemId = 3 - }, - new - { - PermissionId = 4, - Code = "NAV:procurement", - NavItemId = 4 - }, - new - { - PermissionId = 5, - Code = "NAV:receiving", - NavItemId = 5 - }, - new - { - PermissionId = 6, - Code = "NAV:stock", - NavItemId = 6 - }, - new - { - PermissionId = 7, - Code = "NAV:warehouses", - NavItemId = 7 - }, - new - { - PermissionId = 8, - Code = "NAV:orders", - NavItemId = 8 - }, - new - { - PermissionId = 9, - Code = "NAV:settings", - NavItemId = 9 - }, - new - { - PermissionId = 10, - Code = "NAV:help", - NavItemId = 10 - }, - new - { - PermissionId = 11, - Code = "NAV:products.item", - SubNavItemId = 1 - }, - new - { - PermissionId = 12, - Code = "NAV:products.category", - SubNavItemId = 2 - }, - new - { - PermissionId = 13, - Code = "NAV:products.brand", - SubNavItemId = 3 - }, - new - { - PermissionId = 14, - Code = "NAV:products.item-type", - SubNavItemId = 4 - }, - new - { - PermissionId = 15, - Code = "NAV:products.uom", - SubNavItemId = 5 - }, - new - { - PermissionId = 16, - Code = "NAV:products.configuration", - SubNavItemId = 6 - }, - new - { - PermissionId = 17, - Code = "NAV:settings.roles", - SubNavItemId = 7 - }, - new - { - PermissionId = 18, - Code = "NAV:settings.users", - SubNavItemId = 8 - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b => - { - b.Property("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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.ProductConfig", b => - { - b.Property("ConfigId") - .HasColumnType("integer"); - - b.Property("BrandsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("ItemTypesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SubcategoriesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.HasKey("ConfigId"); - - b.HasIndex("UpdatedBy"); - - b.ToTable("product_config", null, t => - { - t.HasCheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b => - { - b.Property("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.HasKey("RfqLineId"); - - b.HasIndex("ItemId"); - - b.HasIndex("RfqId"); - - b.ToTable("rfq_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Role", b => - { - b.Property("RoleId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RoleId")); - - b.Property("AuthRoleId") - .HasColumnType("uuid") - .HasColumnName("auth_role_id"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsSystemRole") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(false); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("RoleId"); - - b.HasIndex("AuthRoleId") - .IsUnique(); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("roles", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RolePermission", b => - { - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("PermissionId") - .HasColumnType("integer"); - - b.HasKey("RoleId", "PermissionId"); - - b.HasIndex("PermissionId"); - - b.ToTable("role_permissions", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b => - { - b.Property("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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.SubCategory", b => - { - b.Property("SubCategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubCategoryId")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SubCategoryId"); - - b.HasIndex("Status"); - - b.HasIndex("CategoryId", "Name") - .IsUnique(); - - b.ToTable("subcategories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.Property("SubNavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubNavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("SubNavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.ToTable("sub_nav_items", (string)null); - - b.HasData( - new - { - SubNavItemId = 1, - Code = "products.item", - Href = "/dashboard/products", - Label = "Item", - NavItemId = 2, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 2, - Code = "products.category", - Href = "/dashboard/products/categories", - Label = "Category", - NavItemId = 2, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 3, - Code = "products.brand", - Href = "/dashboard/products/brands", - Label = "Brand", - NavItemId = 2, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 4, - Code = "products.item-type", - Href = "/dashboard/products/item-types", - Label = "Item Type", - NavItemId = 2, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 5, - Code = "products.uom", - Href = "/dashboard/products/uoms", - Label = "UOM", - NavItemId = 2, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 6, - Code = "products.configuration", - Href = "/dashboard/products/settings", - Label = "Configuration", - NavItemId = 2, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 7, - Code = "settings.roles", - Href = "/dashboard/settings/roles", - Label = "Roles", - NavItemId = 9, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 8, - Code = "settings.users", - Href = "/dashboard/settings/users", - Label = "Users", - NavItemId = 9, - SortOrder = 2, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b => - { - b.Property("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.HasKey("UserId"); - - b.HasIndex("AuthUserId") - .IsUnique(); - - b.HasIndex("RoleId"); - - 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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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.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.Brand", "Brand") - .WithMany() - .HasForeignKey("BrandId") - .OnDelete(DeleteBehavior.Restrict); - - 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.HasOne("ERPCore.Domain.Entities.SubCategory", "SubCategory") - .WithMany() - .HasForeignKey("SubCategoryId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("BaseUom"); - - b.Navigation("Brand"); - - b.Navigation("Category"); - - b.Navigation("DefaultVendor"); - - b.Navigation("SubCategory"); - }); - - 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.Permission", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany() - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.SubNavItem", "SubNavItem") - .WithMany() - .HasForeignKey("SubNavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("NavItem"); - - b.Navigation("SubNavItem"); - }); - - 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.ProductConfig", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser") - .WithMany() - .HasForeignKey("UpdatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("UpdatedByUser"); - }); - - 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.RolePermission", b => - { - b.HasOne("ERPCore.Domain.Entities.Permission", "Permission") - .WithMany() - .HasForeignKey("PermissionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Permission"); - - b.Navigation("Role"); - }); - - 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.SubCategory", b => - { - b.HasOne("ERPCore.Domain.Entities.Category", "Category") - .WithMany("SubCategories") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany("Children") - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NavItem"); - }); - - 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.User", b => - { - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Role"); - }); - - 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("SubCategories"); - }); - - 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.NavItem", b => - { - b.Navigation("Children"); - }); - - 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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260718092655_AddRolesNavPermissions.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260718092655_AddRolesNavPermissions.cs deleted file mode 100644 index 07ace7f..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260718092655_AddRolesNavPermissions.cs +++ /dev/null @@ -1,303 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class AddRolesNavPermissions : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "RoleId", - table: "users", - type: "integer", - nullable: true); - - migrationBuilder.CreateTable( - name: "nav_items", - columns: table => new - { - NavItemId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Label = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), - Icon = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - Href = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), - SortOrder = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active") - }, - constraints: table => - { - table.PrimaryKey("PK_nav_items", x => x.NavItemId); - }); - - migrationBuilder.CreateTable( - name: "roles", - columns: table => new - { - RoleId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - auth_role_id = table.Column(type: "uuid", nullable: false), - Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - IsSystemRole = table.Column(type: "boolean", nullable: false, defaultValue: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_roles", x => x.RoleId); - }); - - migrationBuilder.CreateTable( - name: "sub_nav_items", - columns: table => new - { - SubNavItemId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - NavItemId = table.Column(type: "integer", nullable: false), - Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Label = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), - Icon = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - Href = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), - SortOrder = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active") - }, - constraints: table => - { - table.PrimaryKey("PK_sub_nav_items", x => x.SubNavItemId); - table.ForeignKey( - name: "FK_sub_nav_items_nav_items_NavItemId", - column: x => x.NavItemId, - principalTable: "nav_items", - principalColumn: "NavItemId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "permissions", - columns: table => new - { - PermissionId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(80)", maxLength: 80, nullable: false), - NavItemId = table.Column(type: "integer", nullable: true), - SubNavItemId = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_permissions", x => x.PermissionId); - table.ForeignKey( - name: "FK_permissions_nav_items_NavItemId", - column: x => x.NavItemId, - principalTable: "nav_items", - principalColumn: "NavItemId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_permissions_sub_nav_items_SubNavItemId", - column: x => x.SubNavItemId, - principalTable: "sub_nav_items", - principalColumn: "SubNavItemId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "role_permissions", - columns: table => new - { - RoleId = table.Column(type: "integer", nullable: false), - PermissionId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_role_permissions", x => new { x.RoleId, x.PermissionId }); - table.ForeignKey( - name: "FK_role_permissions_permissions_PermissionId", - column: x => x.PermissionId, - principalTable: "permissions", - principalColumn: "PermissionId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_role_permissions_roles_RoleId", - column: x => x.RoleId, - principalTable: "roles", - principalColumn: "RoleId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "nav_items", - columns: new[] { "NavItemId", "Code", "Href", "Icon", "Label", "SortOrder" }, - values: new object[,] - { - { 1, "dashboard", "/dashboard", null, "Dashboard", 1 }, - { 2, "products", "/dashboard/products", null, "Products", 2 }, - { 3, "vendors", "/dashboard/vendors", null, "Vendors", 3 }, - { 4, "procurement", "/dashboard/procurement", null, "Procurement", 4 }, - { 5, "receiving", "/dashboard/receiving/grn", null, "Receiving", 5 }, - { 6, "stock", "/dashboard/stock", null, "Stock", 6 }, - { 7, "warehouses", "/dashboard/warehouse", null, "Warehouses", 7 }, - { 8, "orders", "/dashboard/orders", null, "Orders", 8 }, - { 9, "settings", "/dashboard/settings", null, "Settings", 9 }, - { 10, "help", "/dashboard/help", null, "Help", 10 } - }); - - migrationBuilder.UpdateData( - table: "users", - keyColumn: "UserId", - keyValue: 1, - column: "RoleId", - value: null); - - migrationBuilder.InsertData( - table: "permissions", - columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, - values: new object[,] - { - { 1, "NAV:dashboard", 1, null }, - { 2, "NAV:products", 2, null }, - { 3, "NAV:vendors", 3, null }, - { 4, "NAV:procurement", 4, null }, - { 5, "NAV:receiving", 5, null }, - { 6, "NAV:stock", 6, null }, - { 7, "NAV:warehouses", 7, null }, - { 8, "NAV:orders", 8, null }, - { 9, "NAV:settings", 9, null }, - { 10, "NAV:help", 10, null } - }); - - migrationBuilder.InsertData( - table: "sub_nav_items", - columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" }, - values: new object[,] - { - { 1, "products.item", "/dashboard/products", null, "Item", 2, 1 }, - { 2, "products.category", "/dashboard/products/categories", null, "Category", 2, 2 }, - { 3, "products.brand", "/dashboard/products/brands", null, "Brand", 2, 3 }, - { 4, "products.item-type", "/dashboard/products/item-types", null, "Item Type", 2, 4 }, - { 5, "products.uom", "/dashboard/products/uoms", null, "UOM", 2, 5 }, - { 6, "products.configuration", "/dashboard/products/settings", null, "Configuration", 2, 6 }, - { 7, "settings.roles", "/dashboard/settings/roles", null, "Roles", 9, 1 }, - { 8, "settings.users", "/dashboard/settings/users", null, "Users", 9, 2 } - }); - - migrationBuilder.InsertData( - table: "permissions", - columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, - values: new object[,] - { - { 11, "NAV:products.item", null, 1 }, - { 12, "NAV:products.category", null, 2 }, - { 13, "NAV:products.brand", null, 3 }, - { 14, "NAV:products.item-type", null, 4 }, - { 15, "NAV:products.uom", null, 5 }, - { 16, "NAV:products.configuration", null, 6 }, - { 17, "NAV:settings.roles", null, 7 }, - { 18, "NAV:settings.users", null, 8 } - }); - - migrationBuilder.CreateIndex( - name: "IX_users_RoleId", - table: "users", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_nav_items_Code", - table: "nav_items", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_permissions_Code", - table: "permissions", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_permissions_NavItemId", - table: "permissions", - column: "NavItemId"); - - migrationBuilder.CreateIndex( - name: "IX_permissions_SubNavItemId", - table: "permissions", - column: "SubNavItemId"); - - migrationBuilder.CreateIndex( - name: "IX_role_permissions_PermissionId", - table: "role_permissions", - column: "PermissionId"); - - migrationBuilder.CreateIndex( - name: "IX_roles_auth_role_id", - table: "roles", - column: "auth_role_id", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_roles_Code", - table: "roles", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_sub_nav_items_Code", - table: "sub_nav_items", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_sub_nav_items_NavItemId", - table: "sub_nav_items", - column: "NavItemId"); - - migrationBuilder.AddForeignKey( - name: "FK_users_roles_RoleId", - table: "users", - column: "RoleId", - principalTable: "roles", - principalColumn: "RoleId", - onDelete: ReferentialAction.Restrict); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_users_roles_RoleId", - table: "users"); - - migrationBuilder.DropTable( - name: "role_permissions"); - - migrationBuilder.DropTable( - name: "permissions"); - - migrationBuilder.DropTable( - name: "roles"); - - migrationBuilder.DropTable( - name: "sub_nav_items"); - - migrationBuilder.DropTable( - name: "nav_items"); - - migrationBuilder.DropIndex( - name: "IX_users_RoleId", - table: "users"); - - migrationBuilder.DropColumn( - name: "RoleId", - table: "users"); - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260720105238_AddLedgersNavSeed.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260720105238_AddLedgersNavSeed.Designer.cs deleted file mode 100644 index 40b45f2..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260720105238_AddLedgersNavSeed.Designer.cs +++ /dev/null @@ -1,3128 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260720105238_AddLedgersNavSeed")] - partial class AddLedgersNavSeed - { - /// - protected override void BuildTargetModel(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("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("BinId"); - - b.HasIndex("WarehouseId", "Code") - .IsUnique(); - - b.ToTable("bins", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Brand", b => - { - b.Property("BrandId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BrandId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BrandId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("brands", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CategoryId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("BrandId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StockNature") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SubCategoryId") - .HasColumnType("integer"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemId"); - - b.HasIndex("BaseUomId"); - - b.HasIndex("BrandId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("DefaultVendorId"); - - b.HasIndex("Sku") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("SubCategoryId"); - - b.ToTable("items", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b => - { - b.Property("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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.ItemType", b => - { - b.Property("ItemTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemTypeId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemTypeId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("item_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b => - { - b.Property("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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.NavItem", b => - { - b.Property("NavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("NavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("nav_items", (string)null); - - b.HasData( - new - { - NavItemId = 1, - Code = "dashboard", - Href = "/dashboard", - Label = "Dashboard", - SortOrder = 1, - Status = "Active" - }, - new - { - NavItemId = 2, - Code = "products", - Href = "/dashboard/products", - Label = "Products", - SortOrder = 2, - Status = "Active" - }, - new - { - NavItemId = 3, - Code = "vendors", - Href = "/dashboard/vendors", - Label = "Vendors", - SortOrder = 3, - Status = "Active" - }, - new - { - NavItemId = 4, - Code = "procurement", - Href = "/dashboard/procurement", - Label = "Procurement", - SortOrder = 4, - Status = "Active" - }, - new - { - NavItemId = 5, - Code = "receiving", - Href = "/dashboard/receiving/grn", - Label = "Receiving", - SortOrder = 5, - Status = "Active" - }, - new - { - NavItemId = 6, - Code = "stock", - Href = "/dashboard/stock", - Label = "Stock", - SortOrder = 6, - Status = "Active" - }, - new - { - NavItemId = 7, - Code = "warehouses", - Href = "/dashboard/warehouse", - Label = "Warehouses", - SortOrder = 7, - Status = "Active" - }, - new - { - NavItemId = 8, - Code = "orders", - Href = "/dashboard/orders", - Label = "Orders", - SortOrder = 8, - Status = "Active" - }, - new - { - NavItemId = 9, - Code = "settings", - Href = "/dashboard/settings", - Label = "Settings", - SortOrder = 9, - Status = "Active" - }, - new - { - NavItemId = 10, - Code = "help", - Href = "/dashboard/help", - Label = "Help", - SortOrder = 10, - Status = "Active" - }, - new - { - NavItemId = 11, - Code = "ledgers", - Href = "/dashboard/ledgers", - Label = "Ledgers", - SortOrder = 11, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NumberSequence", b => - { - b.Property("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("Year") - .HasColumnType("integer") - .HasColumnName("year"); - - b.HasKey("SequenceId"); - - b.HasIndex("DocType", "Year") - .IsUnique(); - - b.ToTable("number_sequences", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.Property("PermissionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PermissionId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SubNavItemId") - .HasColumnType("integer"); - - b.HasKey("PermissionId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.HasIndex("SubNavItemId"); - - b.ToTable("permissions", (string)null); - - b.HasData( - new - { - PermissionId = 1, - Code = "NAV:dashboard", - NavItemId = 1 - }, - new - { - PermissionId = 2, - Code = "NAV:products", - NavItemId = 2 - }, - new - { - PermissionId = 3, - Code = "NAV:vendors", - NavItemId = 3 - }, - new - { - PermissionId = 4, - Code = "NAV:procurement", - NavItemId = 4 - }, - new - { - PermissionId = 5, - Code = "NAV:receiving", - NavItemId = 5 - }, - new - { - PermissionId = 6, - Code = "NAV:stock", - NavItemId = 6 - }, - new - { - PermissionId = 7, - Code = "NAV:warehouses", - NavItemId = 7 - }, - new - { - PermissionId = 8, - Code = "NAV:orders", - NavItemId = 8 - }, - new - { - PermissionId = 9, - Code = "NAV:settings", - NavItemId = 9 - }, - new - { - PermissionId = 10, - Code = "NAV:help", - NavItemId = 10 - }, - new - { - PermissionId = 11, - Code = "NAV:products.item", - SubNavItemId = 1 - }, - new - { - PermissionId = 12, - Code = "NAV:products.category", - SubNavItemId = 2 - }, - new - { - PermissionId = 13, - Code = "NAV:products.brand", - SubNavItemId = 3 - }, - new - { - PermissionId = 14, - Code = "NAV:products.item-type", - SubNavItemId = 4 - }, - new - { - PermissionId = 15, - Code = "NAV:products.uom", - SubNavItemId = 5 - }, - new - { - PermissionId = 16, - Code = "NAV:products.configuration", - SubNavItemId = 6 - }, - new - { - PermissionId = 17, - Code = "NAV:settings.roles", - SubNavItemId = 7 - }, - new - { - PermissionId = 18, - Code = "NAV:settings.users", - SubNavItemId = 8 - }, - new - { - PermissionId = 19, - Code = "NAV:ledgers", - NavItemId = 11 - }, - new - { - PermissionId = 20, - Code = "NAV:ledgers.trial-balance", - SubNavItemId = 9 - }, - new - { - PermissionId = 21, - Code = "NAV:ledgers.balance-sheet", - SubNavItemId = 10 - }, - new - { - PermissionId = 22, - Code = "NAV:ledgers.general-ledger", - SubNavItemId = 11 - }, - new - { - PermissionId = 23, - Code = "NAV:ledgers.profit-and-loss", - SubNavItemId = 12 - }, - new - { - PermissionId = 24, - Code = "NAV:ledgers.cash-flow", - SubNavItemId = 13 - }, - new - { - PermissionId = 25, - Code = "NAV:ledgers.budget-vs-actual", - SubNavItemId = 14 - }, - new - { - PermissionId = 26, - Code = "NAV:ledgers.bank-accounts", - SubNavItemId = 15 - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b => - { - b.Property("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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.ProductConfig", b => - { - b.Property("ConfigId") - .HasColumnType("integer"); - - b.Property("BrandsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("ItemTypesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SubcategoriesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.HasKey("ConfigId"); - - b.HasIndex("UpdatedBy"); - - b.ToTable("product_config", null, t => - { - t.HasCheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b => - { - b.Property("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.HasKey("RfqLineId"); - - b.HasIndex("ItemId"); - - b.HasIndex("RfqId"); - - b.ToTable("rfq_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Role", b => - { - b.Property("RoleId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RoleId")); - - b.Property("AuthRoleId") - .HasColumnType("uuid") - .HasColumnName("auth_role_id"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsSystemRole") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(false); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("RoleId"); - - b.HasIndex("AuthRoleId") - .IsUnique(); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("roles", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RolePermission", b => - { - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("PermissionId") - .HasColumnType("integer"); - - b.HasKey("RoleId", "PermissionId"); - - b.HasIndex("PermissionId"); - - b.ToTable("role_permissions", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b => - { - b.Property("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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.SubCategory", b => - { - b.Property("SubCategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubCategoryId")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SubCategoryId"); - - b.HasIndex("Status"); - - b.HasIndex("CategoryId", "Name") - .IsUnique(); - - b.ToTable("subcategories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.Property("SubNavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubNavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("SubNavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.ToTable("sub_nav_items", (string)null); - - b.HasData( - new - { - SubNavItemId = 1, - Code = "products.item", - Href = "/dashboard/products", - Label = "Item", - NavItemId = 2, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 2, - Code = "products.category", - Href = "/dashboard/products/categories", - Label = "Category", - NavItemId = 2, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 3, - Code = "products.brand", - Href = "/dashboard/products/brands", - Label = "Brand", - NavItemId = 2, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 4, - Code = "products.item-type", - Href = "/dashboard/products/item-types", - Label = "Item Type", - NavItemId = 2, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 5, - Code = "products.uom", - Href = "/dashboard/products/uoms", - Label = "UOM", - NavItemId = 2, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 6, - Code = "products.configuration", - Href = "/dashboard/products/settings", - Label = "Configuration", - NavItemId = 2, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 7, - Code = "settings.roles", - Href = "/dashboard/settings/roles", - Label = "Roles", - NavItemId = 9, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 8, - Code = "settings.users", - Href = "/dashboard/settings/users", - Label = "Users", - NavItemId = 9, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 9, - Code = "ledgers.trial-balance", - Href = "/dashboard/ledgers/trial-balance", - Label = "Trial Balance", - NavItemId = 11, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 10, - Code = "ledgers.balance-sheet", - Href = "/dashboard/ledgers/balance-sheet", - Label = "Balance Sheet", - NavItemId = 11, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 11, - Code = "ledgers.general-ledger", - Href = "/dashboard/ledgers/general-ledger", - Label = "General Ledger", - NavItemId = 11, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 12, - Code = "ledgers.profit-and-loss", - Href = "/dashboard/ledgers/profit-and-loss", - Label = "Profit & Loss", - NavItemId = 11, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 13, - Code = "ledgers.cash-flow", - Href = "/dashboard/ledgers/cash-flow", - Label = "Cash Flow", - NavItemId = 11, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 14, - Code = "ledgers.budget-vs-actual", - Href = "/dashboard/ledgers/budget-vs-actual", - Label = "Budget vs Actual", - NavItemId = 11, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 15, - Code = "ledgers.bank-accounts", - Href = "/dashboard/ledgers/bank-accounts", - Label = "Cash / Bank Accounts", - NavItemId = 11, - SortOrder = 7, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b => - { - b.Property("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.HasKey("UserId"); - - b.HasIndex("AuthUserId") - .IsUnique(); - - b.HasIndex("RoleId"); - - 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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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.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.Brand", "Brand") - .WithMany() - .HasForeignKey("BrandId") - .OnDelete(DeleteBehavior.Restrict); - - 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.HasOne("ERPCore.Domain.Entities.SubCategory", "SubCategory") - .WithMany() - .HasForeignKey("SubCategoryId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("BaseUom"); - - b.Navigation("Brand"); - - b.Navigation("Category"); - - b.Navigation("DefaultVendor"); - - b.Navigation("SubCategory"); - }); - - 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.Permission", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany() - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.SubNavItem", "SubNavItem") - .WithMany() - .HasForeignKey("SubNavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("NavItem"); - - b.Navigation("SubNavItem"); - }); - - 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.ProductConfig", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser") - .WithMany() - .HasForeignKey("UpdatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("UpdatedByUser"); - }); - - 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.RolePermission", b => - { - b.HasOne("ERPCore.Domain.Entities.Permission", "Permission") - .WithMany() - .HasForeignKey("PermissionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Permission"); - - b.Navigation("Role"); - }); - - 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.SubCategory", b => - { - b.HasOne("ERPCore.Domain.Entities.Category", "Category") - .WithMany("SubCategories") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany("Children") - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NavItem"); - }); - - 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.User", b => - { - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Role"); - }); - - 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("SubCategories"); - }); - - 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.NavItem", b => - { - b.Navigation("Children"); - }); - - 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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260720105238_AddLedgersNavSeed.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260720105238_AddLedgersNavSeed.cs deleted file mode 100644 index ee22ca3..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260720105238_AddLedgersNavSeed.cs +++ /dev/null @@ -1,138 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class AddLedgersNavSeed : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.InsertData( - table: "nav_items", - columns: new[] { "NavItemId", "Code", "Href", "Icon", "Label", "SortOrder" }, - values: new object[] { 11, "ledgers", "/dashboard/ledgers", null, "Ledgers", 11 }); - - migrationBuilder.InsertData( - table: "permissions", - columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, - values: new object[] { 19, "NAV:ledgers", 11, null }); - - migrationBuilder.InsertData( - table: "sub_nav_items", - columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" }, - values: new object[,] - { - { 9, "ledgers.trial-balance", "/dashboard/ledgers/trial-balance", null, "Trial Balance", 11, 1 }, - { 10, "ledgers.balance-sheet", "/dashboard/ledgers/balance-sheet", null, "Balance Sheet", 11, 2 }, - { 11, "ledgers.general-ledger", "/dashboard/ledgers/general-ledger", null, "General Ledger", 11, 3 }, - { 12, "ledgers.profit-and-loss", "/dashboard/ledgers/profit-and-loss", null, "Profit & Loss", 11, 4 }, - { 13, "ledgers.cash-flow", "/dashboard/ledgers/cash-flow", null, "Cash Flow", 11, 5 }, - { 14, "ledgers.budget-vs-actual", "/dashboard/ledgers/budget-vs-actual", null, "Budget vs Actual", 11, 6 }, - { 15, "ledgers.bank-accounts", "/dashboard/ledgers/bank-accounts", null, "Cash / Bank Accounts", 11, 7 } - }); - - migrationBuilder.InsertData( - table: "permissions", - columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, - values: new object[,] - { - { 20, "NAV:ledgers.trial-balance", null, 9 }, - { 21, "NAV:ledgers.balance-sheet", null, 10 }, - { 22, "NAV:ledgers.general-ledger", null, 11 }, - { 23, "NAV:ledgers.profit-and-loss", null, 12 }, - { 24, "NAV:ledgers.cash-flow", null, 13 }, - { 25, "NAV:ledgers.budget-vs-actual", null, 14 }, - { 26, "NAV:ledgers.bank-accounts", null, 15 } - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 19); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 20); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 21); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 22); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 23); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 24); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 25); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 26); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 9); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 10); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 11); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 12); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 13); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 14); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 15); - - migrationBuilder.DeleteData( - table: "nav_items", - keyColumn: "NavItemId", - keyValue: 11); - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260730061542_AddTaxReportNavSeed.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260730061542_AddTaxReportNavSeed.Designer.cs deleted file mode 100644 index 94e0890..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260730061542_AddTaxReportNavSeed.Designer.cs +++ /dev/null @@ -1,3144 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260730061542_AddTaxReportNavSeed")] - partial class AddTaxReportNavSeed - { - /// - protected override void BuildTargetModel(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("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("BinId"); - - b.HasIndex("WarehouseId", "Code") - .IsUnique(); - - b.ToTable("bins", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Brand", b => - { - b.Property("BrandId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BrandId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BrandId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("brands", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CategoryId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("BrandId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StockNature") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SubCategoryId") - .HasColumnType("integer"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemId"); - - b.HasIndex("BaseUomId"); - - b.HasIndex("BrandId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("DefaultVendorId"); - - b.HasIndex("Sku") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("SubCategoryId"); - - b.ToTable("items", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b => - { - b.Property("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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.ItemType", b => - { - b.Property("ItemTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemTypeId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemTypeId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("item_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b => - { - b.Property("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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.NavItem", b => - { - b.Property("NavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("NavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("nav_items", (string)null); - - b.HasData( - new - { - NavItemId = 1, - Code = "dashboard", - Href = "/dashboard", - Label = "Dashboard", - SortOrder = 1, - Status = "Active" - }, - new - { - NavItemId = 2, - Code = "products", - Href = "/dashboard/products", - Label = "Products", - SortOrder = 2, - Status = "Active" - }, - new - { - NavItemId = 3, - Code = "vendors", - Href = "/dashboard/vendors", - Label = "Vendors", - SortOrder = 3, - Status = "Active" - }, - new - { - NavItemId = 4, - Code = "procurement", - Href = "/dashboard/procurement", - Label = "Procurement", - SortOrder = 4, - Status = "Active" - }, - new - { - NavItemId = 5, - Code = "receiving", - Href = "/dashboard/receiving/grn", - Label = "Receiving", - SortOrder = 5, - Status = "Active" - }, - new - { - NavItemId = 6, - Code = "stock", - Href = "/dashboard/stock", - Label = "Stock", - SortOrder = 6, - Status = "Active" - }, - new - { - NavItemId = 7, - Code = "warehouses", - Href = "/dashboard/warehouse", - Label = "Warehouses", - SortOrder = 7, - Status = "Active" - }, - new - { - NavItemId = 8, - Code = "orders", - Href = "/dashboard/orders", - Label = "Orders", - SortOrder = 8, - Status = "Active" - }, - new - { - NavItemId = 9, - Code = "settings", - Href = "/dashboard/settings", - Label = "Settings", - SortOrder = 9, - Status = "Active" - }, - new - { - NavItemId = 10, - Code = "help", - Href = "/dashboard/help", - Label = "Help", - SortOrder = 10, - Status = "Active" - }, - new - { - NavItemId = 11, - Code = "ledgers", - Href = "/dashboard/ledgers", - Label = "Ledgers", - SortOrder = 11, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NumberSequence", b => - { - b.Property("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("Year") - .HasColumnType("integer") - .HasColumnName("year"); - - b.HasKey("SequenceId"); - - b.HasIndex("DocType", "Year") - .IsUnique(); - - b.ToTable("number_sequences", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.Property("PermissionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PermissionId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SubNavItemId") - .HasColumnType("integer"); - - b.HasKey("PermissionId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.HasIndex("SubNavItemId"); - - b.ToTable("permissions", (string)null); - - b.HasData( - new - { - PermissionId = 1, - Code = "NAV:dashboard", - NavItemId = 1 - }, - new - { - PermissionId = 2, - Code = "NAV:products", - NavItemId = 2 - }, - new - { - PermissionId = 3, - Code = "NAV:vendors", - NavItemId = 3 - }, - new - { - PermissionId = 4, - Code = "NAV:procurement", - NavItemId = 4 - }, - new - { - PermissionId = 5, - Code = "NAV:receiving", - NavItemId = 5 - }, - new - { - PermissionId = 6, - Code = "NAV:stock", - NavItemId = 6 - }, - new - { - PermissionId = 7, - Code = "NAV:warehouses", - NavItemId = 7 - }, - new - { - PermissionId = 8, - Code = "NAV:orders", - NavItemId = 8 - }, - new - { - PermissionId = 9, - Code = "NAV:settings", - NavItemId = 9 - }, - new - { - PermissionId = 10, - Code = "NAV:help", - NavItemId = 10 - }, - new - { - PermissionId = 11, - Code = "NAV:products.item", - SubNavItemId = 1 - }, - new - { - PermissionId = 12, - Code = "NAV:products.category", - SubNavItemId = 2 - }, - new - { - PermissionId = 13, - Code = "NAV:products.brand", - SubNavItemId = 3 - }, - new - { - PermissionId = 14, - Code = "NAV:products.item-type", - SubNavItemId = 4 - }, - new - { - PermissionId = 15, - Code = "NAV:products.uom", - SubNavItemId = 5 - }, - new - { - PermissionId = 16, - Code = "NAV:products.configuration", - SubNavItemId = 6 - }, - new - { - PermissionId = 17, - Code = "NAV:settings.roles", - SubNavItemId = 7 - }, - new - { - PermissionId = 18, - Code = "NAV:settings.users", - SubNavItemId = 8 - }, - new - { - PermissionId = 19, - Code = "NAV:ledgers", - NavItemId = 11 - }, - new - { - PermissionId = 20, - Code = "NAV:ledgers.trial-balance", - SubNavItemId = 9 - }, - new - { - PermissionId = 21, - Code = "NAV:ledgers.balance-sheet", - SubNavItemId = 10 - }, - new - { - PermissionId = 22, - Code = "NAV:ledgers.general-ledger", - SubNavItemId = 11 - }, - new - { - PermissionId = 23, - Code = "NAV:ledgers.profit-and-loss", - SubNavItemId = 12 - }, - new - { - PermissionId = 24, - Code = "NAV:ledgers.cash-flow", - SubNavItemId = 13 - }, - new - { - PermissionId = 25, - Code = "NAV:ledgers.budget-vs-actual", - SubNavItemId = 14 - }, - new - { - PermissionId = 26, - Code = "NAV:ledgers.bank-accounts", - SubNavItemId = 15 - }, - new - { - PermissionId = 27, - Code = "NAV:ledgers.tax-report", - SubNavItemId = 16 - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b => - { - b.Property("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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.ProductConfig", b => - { - b.Property("ConfigId") - .HasColumnType("integer"); - - b.Property("BrandsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("ItemTypesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SubcategoriesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.HasKey("ConfigId"); - - b.HasIndex("UpdatedBy"); - - b.ToTable("product_config", null, t => - { - t.HasCheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b => - { - b.Property("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.HasKey("RfqLineId"); - - b.HasIndex("ItemId"); - - b.HasIndex("RfqId"); - - b.ToTable("rfq_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Role", b => - { - b.Property("RoleId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RoleId")); - - b.Property("AuthRoleId") - .HasColumnType("uuid") - .HasColumnName("auth_role_id"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsSystemRole") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(false); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("RoleId"); - - b.HasIndex("AuthRoleId") - .IsUnique(); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("roles", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RolePermission", b => - { - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("PermissionId") - .HasColumnType("integer"); - - b.HasKey("RoleId", "PermissionId"); - - b.HasIndex("PermissionId"); - - b.ToTable("role_permissions", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b => - { - b.Property("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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.SubCategory", b => - { - b.Property("SubCategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubCategoryId")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SubCategoryId"); - - b.HasIndex("Status"); - - b.HasIndex("CategoryId", "Name") - .IsUnique(); - - b.ToTable("subcategories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.Property("SubNavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubNavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("SubNavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.ToTable("sub_nav_items", (string)null); - - b.HasData( - new - { - SubNavItemId = 1, - Code = "products.item", - Href = "/dashboard/products", - Label = "Item", - NavItemId = 2, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 2, - Code = "products.category", - Href = "/dashboard/products/categories", - Label = "Category", - NavItemId = 2, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 3, - Code = "products.brand", - Href = "/dashboard/products/brands", - Label = "Brand", - NavItemId = 2, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 4, - Code = "products.item-type", - Href = "/dashboard/products/item-types", - Label = "Item Type", - NavItemId = 2, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 5, - Code = "products.uom", - Href = "/dashboard/products/uoms", - Label = "UOM", - NavItemId = 2, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 6, - Code = "products.configuration", - Href = "/dashboard/products/settings", - Label = "Configuration", - NavItemId = 2, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 7, - Code = "settings.roles", - Href = "/dashboard/settings/roles", - Label = "Roles", - NavItemId = 9, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 8, - Code = "settings.users", - Href = "/dashboard/settings/users", - Label = "Users", - NavItemId = 9, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 9, - Code = "ledgers.trial-balance", - Href = "/dashboard/ledgers/trial-balance", - Label = "Trial Balance", - NavItemId = 11, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 10, - Code = "ledgers.balance-sheet", - Href = "/dashboard/ledgers/balance-sheet", - Label = "Balance Sheet", - NavItemId = 11, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 11, - Code = "ledgers.general-ledger", - Href = "/dashboard/ledgers/general-ledger", - Label = "General Ledger", - NavItemId = 11, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 12, - Code = "ledgers.profit-and-loss", - Href = "/dashboard/ledgers/profit-and-loss", - Label = "Profit & Loss", - NavItemId = 11, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 13, - Code = "ledgers.cash-flow", - Href = "/dashboard/ledgers/cash-flow", - Label = "Cash Flow", - NavItemId = 11, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 14, - Code = "ledgers.budget-vs-actual", - Href = "/dashboard/ledgers/budget-vs-actual", - Label = "Budget vs Actual", - NavItemId = 11, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 15, - Code = "ledgers.bank-accounts", - Href = "/dashboard/ledgers/bank-accounts", - Label = "Cash / Bank Accounts", - NavItemId = 11, - SortOrder = 8, - Status = "Active" - }, - new - { - SubNavItemId = 16, - Code = "ledgers.tax-report", - Href = "/dashboard/ledgers/tax-report", - Label = "Tax Report", - NavItemId = 11, - SortOrder = 7, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b => - { - b.Property("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.HasKey("UserId"); - - b.HasIndex("AuthUserId") - .IsUnique(); - - b.HasIndex("RoleId"); - - 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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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.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.Brand", "Brand") - .WithMany() - .HasForeignKey("BrandId") - .OnDelete(DeleteBehavior.Restrict); - - 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.HasOne("ERPCore.Domain.Entities.SubCategory", "SubCategory") - .WithMany() - .HasForeignKey("SubCategoryId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("BaseUom"); - - b.Navigation("Brand"); - - b.Navigation("Category"); - - b.Navigation("DefaultVendor"); - - b.Navigation("SubCategory"); - }); - - 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.Permission", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany() - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.SubNavItem", "SubNavItem") - .WithMany() - .HasForeignKey("SubNavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("NavItem"); - - b.Navigation("SubNavItem"); - }); - - 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.ProductConfig", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser") - .WithMany() - .HasForeignKey("UpdatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("UpdatedByUser"); - }); - - 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.RolePermission", b => - { - b.HasOne("ERPCore.Domain.Entities.Permission", "Permission") - .WithMany() - .HasForeignKey("PermissionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Permission"); - - b.Navigation("Role"); - }); - - 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.SubCategory", b => - { - b.HasOne("ERPCore.Domain.Entities.Category", "Category") - .WithMany("SubCategories") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany("Children") - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NavItem"); - }); - - 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.User", b => - { - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Role"); - }); - - 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("SubCategories"); - }); - - 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.NavItem", b => - { - b.Navigation("Children"); - }); - - 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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260730061542_AddTaxReportNavSeed.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260730061542_AddTaxReportNavSeed.cs deleted file mode 100644 index f1dc932..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260730061542_AddTaxReportNavSeed.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class AddTaxReportNavSeed : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.UpdateData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 15, - column: "SortOrder", - value: 8); - - migrationBuilder.InsertData( - table: "sub_nav_items", - columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" }, - values: new object[] { 16, "ledgers.tax-report", "/dashboard/ledgers/tax-report", null, "Tax Report", 11, 7 }); - - migrationBuilder.InsertData( - table: "permissions", - columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, - values: new object[] { 27, "NAV:ledgers.tax-report", null, 16 }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 27); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 16); - - migrationBuilder.UpdateData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 15, - column: "SortOrder", - value: 7); - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260730105356_FixProcurementNavIdCollision.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260730105356_FixProcurementNavIdCollision.Designer.cs deleted file mode 100644 index 0b7a6f2..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260730105356_FixProcurementNavIdCollision.Designer.cs +++ /dev/null @@ -1,5152 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260730105356_FixProcurementNavIdCollision")] - partial class FixProcurementNavIdCollision - { - /// - protected override void BuildTargetModel(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.AttendanceRecord", b => - { - b.Property("AttendanceRecordId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AttendanceRecordId")); - - b.Property("AttendanceDate") - .HasColumnType("timestamp with time zone"); - - b.Property("AttendanceStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("AttendanceUploadBatchId") - .HasColumnType("integer"); - - b.Property("CheckIn") - .HasColumnType("interval"); - - b.Property("CheckOut") - .HasColumnType("interval"); - - b.Property("DuplicateOfAttendanceRecordId") - .HasColumnType("integer"); - - b.Property("EarlyLeaveMinutes") - .HasColumnType("integer"); - - b.Property("EditedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EditedBy") - .HasColumnType("integer"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("IsManualOverride") - .HasColumnType("boolean"); - - b.Property("LateMinutes") - .HasColumnType("integer"); - - b.Property("Notes") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("OvertimeMinutes") - .HasColumnType("integer"); - - b.Property("RowValidationStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("WorkShiftId") - .HasColumnType("integer"); - - b.Property("WorkingMinutes") - .HasColumnType("integer"); - - b.HasKey("AttendanceRecordId"); - - b.HasIndex("AttendanceUploadBatchId"); - - b.HasIndex("WorkShiftId"); - - b.HasIndex("EmployeeId", "AttendanceDate"); - - b.ToTable("hr_attendance_records", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AttendanceUploadBatch", b => - { - b.Property("AttendanceUploadBatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AttendanceUploadBatchId")); - - b.Property("ConfirmedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ConfirmedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("OriginalFileName") - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("PeriodEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("PeriodStart") - .HasColumnType("timestamp with time zone"); - - b.Property("RowCountDuplicate") - .HasColumnType("integer"); - - b.Property("RowCountError") - .HasColumnType("integer"); - - b.Property("RowCountTotal") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SourceType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UploadedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UploadedBy") - .HasColumnType("integer"); - - b.HasKey("AttendanceUploadBatchId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("PeriodStart", "PeriodEnd"); - - b.ToTable("hr_attendance_upload_batches", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AuditLog", b => - { - b.Property("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("BinId"); - - b.HasIndex("WarehouseId", "Code") - .IsUnique(); - - b.ToTable("bins", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Branch", b => - { - b.Property("BranchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BranchId")); - - b.Property("Address") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BranchId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_branches", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Brand", b => - { - b.Property("BrandId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BrandId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BrandId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("brands", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CategoryId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Department", b => - { - b.Property("DepartmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DepartmentId")); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("HeadEmployeeId") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("ParentDepartmentId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("DepartmentId"); - - b.HasIndex("BranchId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("HeadEmployeeId"); - - b.HasIndex("ParentDepartmentId"); - - b.HasIndex("Status"); - - b.ToTable("hr_departments", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Designation", b => - { - b.Property("DesignationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DesignationId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("DesignationId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_designations", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Employee", b => - { - b.Property("EmployeeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeId")); - - b.Property("AddressLine1") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("AddressLine2") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("City") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("ConfirmationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Country") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DateOfBirth") - .HasColumnType("timestamp with time zone"); - - b.Property("DepartmentId") - .HasColumnType("integer"); - - b.Property("DesignationId") - .HasColumnType("integer"); - - b.Property("Email") - .HasMaxLength(320) - .HasColumnType("character varying(320)"); - - b.Property("EmergencyContactName") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("EmergencyContactPhone") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmergencyContactRelationship") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("EmployeeCode") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmploymentTypeId") - .HasColumnType("integer"); - - b.Property("EpfNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EtfNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("FullName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Gender") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("HireDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LastWorkingDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Nationality") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("Nic") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PersonalMobile") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PostalCode") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ProfilePhotoPath") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("ReportingManagerId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxIdentificationNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("WorkShiftId") - .HasColumnType("integer"); - - b.HasKey("EmployeeId"); - - b.HasIndex("BranchId"); - - b.HasIndex("DepartmentId"); - - b.HasIndex("DesignationId"); - - b.HasIndex("Email"); - - b.HasIndex("EmployeeCode") - .IsUnique(); - - b.HasIndex("EmploymentTypeId"); - - b.HasIndex("ReportingManagerId"); - - b.HasIndex("Status"); - - b.HasIndex("UserId") - .IsUnique(); - - b.HasIndex("WorkShiftId"); - - b.ToTable("hr_employees", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeBankDetail", b => - { - b.Property("EmployeeBankDetailId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeBankDetailId")); - - b.Property("AccountHolderName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("AccountNumber") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("BankName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("BranchName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("IsPrimary") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("SwiftCode") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("EmployeeBankDetailId"); - - b.HasIndex("EmployeeId"); - - b.ToTable("hr_employee_bank_details", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeDocument", b => - { - b.Property("EmployeeDocumentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeDocumentId")); - - b.Property("ContentType") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("ExpiryDate") - .HasColumnType("timestamp with time zone"); - - b.Property("HrDocumentTypeId") - .HasColumnType("integer"); - - b.Property("IssueDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Notes") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("OriginalFileName") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("RelativePath") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SizeBytes") - .HasColumnType("bigint"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StoredFileName") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("UploadedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UploadedBy") - .HasColumnType("integer"); - - b.Property("VerifiedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("VerifiedBy") - .HasColumnType("integer"); - - b.HasKey("EmployeeDocumentId"); - - b.HasIndex("EmployeeId"); - - b.HasIndex("ExpiryDate"); - - b.HasIndex("HrDocumentTypeId"); - - b.ToTable("hr_employee_documents", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.Property("EmployeeLoanId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeLoanId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("InstallmentAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("InterestRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("LoanKind") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("NumberOfInstallments") - .HasColumnType("integer"); - - b.Property("OutstandingBalance") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("PrincipalAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StartMonth") - .HasColumnType("integer"); - - b.Property("StartYear") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("EmployeeLoanId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("EmployeeId"); - - b.HasIndex("Status"); - - b.ToTable("hr_employee_loans", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.Property("EmployeeSalaryStructureId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeSalaryStructureId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("BasicSalary") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("Currency") - .IsRequired() - .HasMaxLength(3) - .HasColumnType("character varying(3)"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("EmployeeSalaryStructureId"); - - b.HasIndex("EmployeeId", "EffectiveTo"); - - b.ToTable("hr_employee_salary_structures", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructureLine", b => - { - b.Property("EmployeeSalaryStructureLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeSalaryStructureLineId")); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("EmployeeSalaryStructureId") - .HasColumnType("integer"); - - b.Property("SalaryComponentId") - .HasColumnType("integer"); - - b.HasKey("EmployeeSalaryStructureLineId"); - - b.HasIndex("EmployeeSalaryStructureId"); - - b.HasIndex("SalaryComponentId"); - - b.ToTable("hr_employee_salary_structure_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmploymentType", b => - { - b.Property("EmploymentTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmploymentTypeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("EmploymentTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_employment_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("DiscountPct") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LineTotal") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("NetUnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("PoUnitPrice") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("VatAmount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("VatPct") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - 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.HrDocumentType", b => - { - b.Property("HrDocumentTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("HrDocumentTypeId")); - - b.Property("Category") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ExpiryTracked") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RequiredAtOnboarding") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("HrDocumentTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_document_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Item", b => - { - b.Property("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("BrandId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SalePrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StockNature") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SubCategoryId") - .HasColumnType("integer"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemId"); - - b.HasIndex("BaseUomId"); - - b.HasIndex("BrandId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("DefaultVendorId"); - - b.HasIndex("Sku") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("SubCategoryId"); - - b.ToTable("items", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b => - { - b.Property("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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.ItemType", b => - { - b.Property("ItemTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemTypeId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemTypeId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("item_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b => - { - b.Property("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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.LeaveBalance", b => - { - b.Property("LeaveBalanceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveBalanceId")); - - b.Property("AdjustmentDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("CarriedForwardDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EntitledDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("LeaveTypeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("TakenDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Year") - .HasColumnType("integer"); - - b.HasKey("LeaveBalanceId"); - - b.HasIndex("LeaveTypeId"); - - b.HasIndex("EmployeeId", "LeaveTypeId", "Year") - .IsUnique(); - - b.ToTable("hr_leave_balances", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveRequest", b => - { - b.Property("LeaveRequestId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveRequestId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DaysCount") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EndDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LeaveTypeId") - .HasColumnType("integer"); - - b.Property("Reason") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("RejectionReason") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StartDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("LeaveRequestId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("EmployeeId"); - - b.HasIndex("LeaveTypeId"); - - b.HasIndex("Status"); - - b.HasIndex("StartDate", "EndDate"); - - b.ToTable("hr_leave_requests", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveType", b => - { - b.Property("LeaveTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveTypeId")); - - b.Property("AccrualPerYear") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("CarryForwardAllowed") - .HasColumnType("boolean"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CountsAsNoPay") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsPaid") - .HasColumnType("boolean"); - - b.Property("MaxCarryForwardDays") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RequiresApproval") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("LeaveTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_leave_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LoanInstallment", b => - { - b.Property("LoanInstallmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LoanInstallmentId")); - - b.Property("DueMonth") - .HasColumnType("integer"); - - b.Property("DueYear") - .HasColumnType("integer"); - - b.Property("EmployeeLoanId") - .HasColumnType("integer"); - - b.Property("InstallmentNumber") - .HasColumnType("integer"); - - b.Property("PaidAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("PayrollRunId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("ScheduledAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("LoanInstallmentId"); - - b.HasIndex("EmployeeLoanId"); - - b.HasIndex("PayrollRunId"); - - b.HasIndex("DueYear", "DueMonth"); - - b.ToTable("hr_loan_installments", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NavItem", b => - { - b.Property("NavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("NavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("nav_items", (string)null); - - b.HasData( - new - { - NavItemId = 1, - Code = "dashboard", - Href = "/dashboard", - Label = "Dashboard", - SortOrder = 1, - Status = "Active" - }, - new - { - NavItemId = 2, - Code = "products", - Href = "/dashboard/products", - Label = "Products", - SortOrder = 2, - Status = "Active" - }, - new - { - NavItemId = 3, - Code = "vendors", - Href = "/dashboard/vendors", - Label = "Vendors", - SortOrder = 3, - Status = "Active" - }, - new - { - NavItemId = 4, - Code = "procurement", - Href = "/dashboard/procurement", - Label = "Procurement", - SortOrder = 4, - Status = "Active" - }, - new - { - NavItemId = 5, - Code = "receiving", - Href = "/dashboard/receiving/grn", - Label = "Receiving", - SortOrder = 5, - Status = "Active" - }, - new - { - NavItemId = 6, - Code = "stock", - Href = "/dashboard/stock", - Label = "Stock", - SortOrder = 6, - Status = "Active" - }, - new - { - NavItemId = 7, - Code = "warehouses", - Href = "/dashboard/warehouse", - Label = "Warehouses", - SortOrder = 7, - Status = "Active" - }, - new - { - NavItemId = 8, - Code = "orders", - Href = "/dashboard/orders", - Label = "Orders", - SortOrder = 8, - Status = "Active" - }, - new - { - NavItemId = 9, - Code = "settings", - Href = "/dashboard/settings", - Label = "Settings", - SortOrder = 9, - Status = "Active" - }, - new - { - NavItemId = 10, - Code = "help", - Href = "/dashboard/help", - Label = "Help", - SortOrder = 10, - Status = "Active" - }, - new - { - NavItemId = 11, - Code = "ledgers", - Href = "/dashboard/ledgers", - Label = "Ledgers", - SortOrder = 11, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NumberSequence", b => - { - b.Property("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("Year") - .HasColumnType("integer") - .HasColumnName("year"); - - b.HasKey("SequenceId"); - - b.HasIndex("DocType", "Year") - .IsUnique(); - - b.ToTable("number_sequences", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.Property("PayrollLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollLineId")); - - b.Property("AbsentDays") - .HasColumnType("integer"); - - b.Property("BasicSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EpfEmployeeAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("EpfEmployerAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("EtfEmployerAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("GrossSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("LateDeductionAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("LateMinutesTotal") - .HasColumnType("integer"); - - b.Property("LeaveDays") - .HasColumnType("integer"); - - b.Property("LoanDeductionAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("NetSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("NoPayAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("OtMinutesTotal") - .HasColumnType("integer"); - - b.Property("OtherDeductionsAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("OvertimeAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("PayrollRunId") - .HasColumnType("integer"); - - b.Property("PresentDays") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("TaxAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("TotalAllowances") - .HasColumnType("numeric(18,2)"); - - b.Property("WorkingDays") - .HasColumnType("integer"); - - b.HasKey("PayrollLineId"); - - b.HasIndex("EmployeeId"); - - b.HasIndex("PayrollRunId", "EmployeeId") - .IsUnique(); - - b.ToTable("hr_payroll_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLineComponent", b => - { - b.Property("PayrollLineComponentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollLineComponentId")); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("ComponentCategory") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("PayrollLineId") - .HasColumnType("integer"); - - b.Property("SalaryComponentId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.HasKey("PayrollLineComponentId"); - - b.HasIndex("PayrollLineId"); - - b.HasIndex("SalaryComponentId"); - - b.ToTable("hr_payroll_line_components", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.Property("PayrollRunId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollRunId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("GeneratedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("GeneratedBy") - .HasColumnType("integer"); - - b.Property("LockedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("LockedBy") - .HasColumnType("integer"); - - b.Property("PeriodMonth") - .HasColumnType("integer"); - - b.Property("PeriodYear") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UnlockReason") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("UnlockedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UnlockedBy") - .HasColumnType("integer"); - - b.HasKey("PayrollRunId"); - - b.HasIndex("BranchId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("PeriodYear", "PeriodMonth", "BranchId"); - - b.ToTable("hr_payroll_runs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollStatutorySetting", b => - { - b.Property("PayrollStatutorySettingId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollStatutorySettingId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("EpfEmployeeRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("EpfEmployerRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("EtfEmployerRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("OtMultiplierDefault") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.HasKey("PayrollStatutorySettingId"); - - b.HasIndex("EffectiveFrom"); - - b.ToTable("hr_payroll_statutory_settings", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Payslip", b => - { - b.Property("PayslipId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayslipId")); - - b.Property("GeneratedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("PayrollLineId") - .HasColumnType("integer"); - - b.Property("ReleasedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ReleasedBy") - .HasColumnType("integer"); - - b.HasKey("PayslipId"); - - b.HasIndex("PayrollLineId") - .IsUnique(); - - b.ToTable("hr_payslips", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.Property("PermissionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PermissionId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SubNavItemId") - .HasColumnType("integer"); - - b.HasKey("PermissionId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.HasIndex("SubNavItemId"); - - b.ToTable("permissions", (string)null); - - b.HasData( - new - { - PermissionId = 1, - Code = "NAV:dashboard", - NavItemId = 1 - }, - new - { - PermissionId = 2, - Code = "NAV:products", - NavItemId = 2 - }, - new - { - PermissionId = 3, - Code = "NAV:vendors", - NavItemId = 3 - }, - new - { - PermissionId = 4, - Code = "NAV:procurement", - NavItemId = 4 - }, - new - { - PermissionId = 5, - Code = "NAV:receiving", - NavItemId = 5 - }, - new - { - PermissionId = 6, - Code = "NAV:stock", - NavItemId = 6 - }, - new - { - PermissionId = 7, - Code = "NAV:warehouses", - NavItemId = 7 - }, - new - { - PermissionId = 8, - Code = "NAV:orders", - NavItemId = 8 - }, - new - { - PermissionId = 9, - Code = "NAV:settings", - NavItemId = 9 - }, - new - { - PermissionId = 10, - Code = "NAV:help", - NavItemId = 10 - }, - new - { - PermissionId = 11, - Code = "NAV:products.item", - SubNavItemId = 1 - }, - new - { - PermissionId = 12, - Code = "NAV:products.category", - SubNavItemId = 2 - }, - new - { - PermissionId = 13, - Code = "NAV:products.brand", - SubNavItemId = 3 - }, - new - { - PermissionId = 14, - Code = "NAV:products.item-type", - SubNavItemId = 4 - }, - new - { - PermissionId = 15, - Code = "NAV:products.uom", - SubNavItemId = 5 - }, - new - { - PermissionId = 16, - Code = "NAV:products.configuration", - SubNavItemId = 6 - }, - new - { - PermissionId = 17, - Code = "NAV:settings.roles", - SubNavItemId = 7 - }, - new - { - PermissionId = 18, - Code = "NAV:settings.users", - SubNavItemId = 8 - }, - new - { - PermissionId = 28, - Code = "NAV:procurement.requisitions", - SubNavItemId = 17 - }, - new - { - PermissionId = 29, - Code = "NAV:procurement.rfqs", - SubNavItemId = 18 - }, - new - { - PermissionId = 30, - Code = "NAV:procurement.purchase-orders", - SubNavItemId = 19 - }, - new - { - PermissionId = 31, - Code = "NAV:procurement.purchase-returns", - SubNavItemId = 20 - }, - new - { - PermissionId = 19, - Code = "NAV:ledgers", - NavItemId = 11 - }, - new - { - PermissionId = 20, - Code = "NAV:ledgers.trial-balance", - SubNavItemId = 9 - }, - new - { - PermissionId = 21, - Code = "NAV:ledgers.balance-sheet", - SubNavItemId = 10 - }, - new - { - PermissionId = 22, - Code = "NAV:ledgers.general-ledger", - SubNavItemId = 11 - }, - new - { - PermissionId = 23, - Code = "NAV:ledgers.profit-and-loss", - SubNavItemId = 12 - }, - new - { - PermissionId = 24, - Code = "NAV:ledgers.cash-flow", - SubNavItemId = 13 - }, - new - { - PermissionId = 25, - Code = "NAV:ledgers.budget-vs-actual", - SubNavItemId = 14 - }, - new - { - PermissionId = 26, - Code = "NAV:ledgers.bank-accounts", - SubNavItemId = 15 - }, - new - { - PermissionId = 27, - Code = "NAV:ledgers.tax-report", - SubNavItemId = 16 - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b => - { - b.Property("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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.ProductConfig", b => - { - b.Property("ConfigId") - .HasColumnType("integer"); - - b.Property("BrandsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("ItemTypesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SubcategoriesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.HasKey("ConfigId"); - - b.HasIndex("UpdatedBy"); - - b.ToTable("product_config", null, t => - { - t.HasCheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b => - { - b.Property("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.HasKey("RfqLineId"); - - b.HasIndex("ItemId"); - - b.HasIndex("RfqId"); - - b.ToTable("rfq_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Role", b => - { - b.Property("RoleId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RoleId")); - - b.Property("AuthRoleId") - .HasColumnType("uuid") - .HasColumnName("auth_role_id"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsSystemRole") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(false); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("RoleId"); - - b.HasIndex("AuthRoleId") - .IsUnique(); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("roles", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RolePermission", b => - { - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("PermissionId") - .HasColumnType("integer"); - - b.HasKey("RoleId", "PermissionId"); - - b.HasIndex("PermissionId"); - - b.ToTable("role_permissions", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SalaryComponent", b => - { - b.Property("SalaryComponentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SalaryComponentId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ComponentType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsEpfEtfApplicable") - .HasColumnType("boolean"); - - b.Property("IsTaxable") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SalaryComponentId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_salary_components", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b => - { - b.Property("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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.SubCategory", b => - { - b.Property("SubCategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubCategoryId")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SubCategoryId"); - - b.HasIndex("Status"); - - b.HasIndex("CategoryId", "Name") - .IsUnique(); - - b.ToTable("subcategories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.Property("SubNavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubNavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("SubNavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.ToTable("sub_nav_items", (string)null); - - b.HasData( - new - { - SubNavItemId = 1, - Code = "products.item", - Href = "/dashboard/products", - Label = "Item", - NavItemId = 2, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 2, - Code = "products.category", - Href = "/dashboard/products/categories", - Label = "Category", - NavItemId = 2, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 3, - Code = "products.brand", - Href = "/dashboard/products/brands", - Label = "Brand", - NavItemId = 2, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 4, - Code = "products.item-type", - Href = "/dashboard/products/item-types", - Label = "Item Type", - NavItemId = 2, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 5, - Code = "products.uom", - Href = "/dashboard/products/uoms", - Label = "UOM", - NavItemId = 2, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 6, - Code = "products.configuration", - Href = "/dashboard/products/settings", - Label = "Configuration", - NavItemId = 2, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 7, - Code = "settings.roles", - Href = "/dashboard/settings/roles", - Label = "Roles", - NavItemId = 9, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 8, - Code = "settings.users", - Href = "/dashboard/settings/users", - Label = "Users", - NavItemId = 9, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 17, - Code = "procurement.requisitions", - Href = "/dashboard/procurement/requisitions", - Label = "Requisitions", - NavItemId = 4, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 18, - Code = "procurement.rfqs", - Href = "/dashboard/procurement/rfqs", - Label = "RFQs", - NavItemId = 4, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 19, - Code = "procurement.purchase-orders", - Href = "/dashboard/procurement/purchase-orders", - Label = "Purchase Orders", - NavItemId = 4, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 20, - Code = "procurement.purchase-returns", - Href = "/dashboard/procurement/purchase-returns", - Label = "Purchase Returns", - NavItemId = 4, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 9, - Code = "ledgers.trial-balance", - Href = "/dashboard/ledgers/trial-balance", - Label = "Trial Balance", - NavItemId = 11, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 10, - Code = "ledgers.balance-sheet", - Href = "/dashboard/ledgers/balance-sheet", - Label = "Balance Sheet", - NavItemId = 11, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 11, - Code = "ledgers.general-ledger", - Href = "/dashboard/ledgers/general-ledger", - Label = "General Ledger", - NavItemId = 11, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 12, - Code = "ledgers.profit-and-loss", - Href = "/dashboard/ledgers/profit-and-loss", - Label = "Profit & Loss", - NavItemId = 11, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 13, - Code = "ledgers.cash-flow", - Href = "/dashboard/ledgers/cash-flow", - Label = "Cash Flow", - NavItemId = 11, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 14, - Code = "ledgers.budget-vs-actual", - Href = "/dashboard/ledgers/budget-vs-actual", - Label = "Budget vs Actual", - NavItemId = 11, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 15, - Code = "ledgers.bank-accounts", - Href = "/dashboard/ledgers/bank-accounts", - Label = "Cash / Bank Accounts", - NavItemId = 11, - SortOrder = 8, - Status = "Active" - }, - new - { - SubNavItemId = 16, - Code = "ledgers.tax-report", - Href = "/dashboard/ledgers/tax-report", - Label = "Tax Report", - NavItemId = 11, - SortOrder = 7, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.TaxSlab", b => - { - b.Property("TaxSlabId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TaxSlabId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("LowerBound") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("Rate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("UpperBound") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.HasKey("TaxSlabId"); - - b.HasIndex("EffectiveFrom"); - - b.ToTable("hr_tax_slabs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b => - { - b.Property("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Email") - .HasMaxLength(320) - .HasColumnType("character varying(320)"); - - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.HasKey("UserId"); - - b.HasIndex("AuthUserId") - .IsUnique(); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("RoleId"); - - 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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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.WorkShift", b => - { - b.Property("WorkShiftId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WorkShiftId")); - - b.Property("BreakMinutes") - .HasColumnType("integer"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EndTime") - .HasColumnType("interval"); - - b.Property("GraceMinutes") - .HasColumnType("integer"); - - b.Property("IsOvernight") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("OtMultiplier") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StandardWorkingMinutes") - .HasColumnType("integer"); - - b.Property("StartTime") - .HasColumnType("interval"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("WorkingDaysMask") - .HasColumnType("integer"); - - b.HasKey("WorkShiftId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_work_shifts", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AttendanceRecord", b => - { - b.HasOne("ERPCore.Domain.Entities.AttendanceUploadBatch", "AttendanceUploadBatch") - .WithMany() - .HasForeignKey("AttendanceUploadBatchId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.WorkShift", "WorkShift") - .WithMany() - .HasForeignKey("WorkShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("AttendanceUploadBatch"); - - b.Navigation("Employee"); - - b.Navigation("WorkShift"); - }); - - 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.Department", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Employee", "HeadEmployee") - .WithMany() - .HasForeignKey("HeadEmployeeId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Department", "ParentDepartment") - .WithMany() - .HasForeignKey("ParentDepartmentId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Branch"); - - b.Navigation("HeadEmployee"); - - b.Navigation("ParentDepartment"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Employee", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Department", "Department") - .WithMany() - .HasForeignKey("DepartmentId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Designation", "Designation") - .WithMany() - .HasForeignKey("DesignationId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.EmploymentType", "EmploymentType") - .WithMany() - .HasForeignKey("EmploymentTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Employee", "ReportingManager") - .WithMany() - .HasForeignKey("ReportingManagerId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.User", "User") - .WithOne() - .HasForeignKey("ERPCore.Domain.Entities.Employee", "UserId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.WorkShift", "WorkShift") - .WithMany() - .HasForeignKey("WorkShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Branch"); - - b.Navigation("Department"); - - b.Navigation("Designation"); - - b.Navigation("EmploymentType"); - - b.Navigation("ReportingManager"); - - b.Navigation("User"); - - b.Navigation("WorkShift"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeBankDetail", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeDocument", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.HrDocumentType", "HrDocumentType") - .WithMany() - .HasForeignKey("HrDocumentTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("HrDocumentType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructureLine", b => - { - b.HasOne("ERPCore.Domain.Entities.EmployeeSalaryStructure", "EmployeeSalaryStructure") - .WithMany("Lines") - .HasForeignKey("EmployeeSalaryStructureId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.SalaryComponent", "SalaryComponent") - .WithMany() - .HasForeignKey("SalaryComponentId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("EmployeeSalaryStructure"); - - b.Navigation("SalaryComponent"); - }); - - 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.Brand", "Brand") - .WithMany() - .HasForeignKey("BrandId") - .OnDelete(DeleteBehavior.Restrict); - - 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.HasOne("ERPCore.Domain.Entities.SubCategory", "SubCategory") - .WithMany() - .HasForeignKey("SubCategoryId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("BaseUom"); - - b.Navigation("Brand"); - - b.Navigation("Category"); - - b.Navigation("DefaultVendor"); - - b.Navigation("SubCategory"); - }); - - 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.LeaveBalance", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.LeaveType", "LeaveType") - .WithMany() - .HasForeignKey("LeaveTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("LeaveType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveRequest", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.LeaveType", "LeaveType") - .WithMany() - .HasForeignKey("LeaveTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("LeaveType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LoanInstallment", b => - { - b.HasOne("ERPCore.Domain.Entities.EmployeeLoan", "EmployeeLoan") - .WithMany("Installments") - .HasForeignKey("EmployeeLoanId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.PayrollRun", "PayrollRun") - .WithMany() - .HasForeignKey("PayrollRunId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EmployeeLoan"); - - b.Navigation("PayrollRun"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.PayrollRun", "PayrollRun") - .WithMany("Lines") - .HasForeignKey("PayrollRunId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("PayrollRun"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLineComponent", b => - { - b.HasOne("ERPCore.Domain.Entities.PayrollLine", "PayrollLine") - .WithMany("Components") - .HasForeignKey("PayrollLineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.SalaryComponent", "SalaryComponent") - .WithMany() - .HasForeignKey("SalaryComponentId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("PayrollLine"); - - b.Navigation("SalaryComponent"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Branch"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Payslip", b => - { - b.HasOne("ERPCore.Domain.Entities.PayrollLine", "PayrollLine") - .WithOne() - .HasForeignKey("ERPCore.Domain.Entities.Payslip", "PayrollLineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("PayrollLine"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany() - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.SubNavItem", "SubNavItem") - .WithMany() - .HasForeignKey("SubNavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("NavItem"); - - b.Navigation("SubNavItem"); - }); - - 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.ProductConfig", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser") - .WithMany() - .HasForeignKey("UpdatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("UpdatedByUser"); - }); - - 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.RolePermission", b => - { - b.HasOne("ERPCore.Domain.Entities.Permission", "Permission") - .WithMany() - .HasForeignKey("PermissionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Permission"); - - b.Navigation("Role"); - }); - - 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.SubCategory", b => - { - b.HasOne("ERPCore.Domain.Entities.Category", "Category") - .WithMany("SubCategories") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany("Children") - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NavItem"); - }); - - 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.User", b => - { - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Role"); - }); - - 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("SubCategories"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.Navigation("Installments"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.Navigation("Lines"); - }); - - 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.NavItem", b => - { - b.Navigation("Children"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.Navigation("Components"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.Navigation("Lines"); - }); - - 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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260730105356_FixProcurementNavIdCollision.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260730105356_FixProcurementNavIdCollision.cs deleted file mode 100644 index 6062f5d..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260730105356_FixProcurementNavIdCollision.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class FixProcurementNavIdCollision : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.InsertData( - table: "sub_nav_items", - columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" }, - values: new object[,] - { - { 17, "procurement.requisitions", "/dashboard/procurement/requisitions", null, "Requisitions", 4, 1 }, - { 18, "procurement.rfqs", "/dashboard/procurement/rfqs", null, "RFQs", 4, 2 }, - { 19, "procurement.purchase-orders", "/dashboard/procurement/purchase-orders", null, "Purchase Orders", 4, 3 }, - { 20, "procurement.purchase-returns", "/dashboard/procurement/purchase-returns", null, "Purchase Returns", 4, 4 } - }); - - migrationBuilder.InsertData( - table: "permissions", - columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, - values: new object[,] - { - { 28, "NAV:procurement.requisitions", null, 17 }, - { 29, "NAV:procurement.rfqs", null, 18 }, - { 30, "NAV:procurement.purchase-orders", null, 19 }, - { 31, "NAV:procurement.purchase-returns", null, 20 } - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 28); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 29); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 30); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 31); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 17); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 18); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 19); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 20); - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260731113219_AddAccountsNavSeed.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260731113219_AddAccountsNavSeed.Designer.cs deleted file mode 100644 index cbbf80d..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260731113219_AddAccountsNavSeed.Designer.cs +++ /dev/null @@ -1,5199 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260731113219_AddAccountsNavSeed")] - partial class AddAccountsNavSeed - { - /// - protected override void BuildTargetModel(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.AttendanceRecord", b => - { - b.Property("AttendanceRecordId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AttendanceRecordId")); - - b.Property("AttendanceDate") - .HasColumnType("timestamp with time zone"); - - b.Property("AttendanceStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("AttendanceUploadBatchId") - .HasColumnType("integer"); - - b.Property("CheckIn") - .HasColumnType("interval"); - - b.Property("CheckOut") - .HasColumnType("interval"); - - b.Property("DuplicateOfAttendanceRecordId") - .HasColumnType("integer"); - - b.Property("EarlyLeaveMinutes") - .HasColumnType("integer"); - - b.Property("EditedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EditedBy") - .HasColumnType("integer"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("IsManualOverride") - .HasColumnType("boolean"); - - b.Property("LateMinutes") - .HasColumnType("integer"); - - b.Property("Notes") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("OvertimeMinutes") - .HasColumnType("integer"); - - b.Property("RowValidationStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("WorkShiftId") - .HasColumnType("integer"); - - b.Property("WorkingMinutes") - .HasColumnType("integer"); - - b.HasKey("AttendanceRecordId"); - - b.HasIndex("AttendanceUploadBatchId"); - - b.HasIndex("WorkShiftId"); - - b.HasIndex("EmployeeId", "AttendanceDate"); - - b.ToTable("hr_attendance_records", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AttendanceUploadBatch", b => - { - b.Property("AttendanceUploadBatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AttendanceUploadBatchId")); - - b.Property("ConfirmedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ConfirmedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("OriginalFileName") - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("PeriodEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("PeriodStart") - .HasColumnType("timestamp with time zone"); - - b.Property("RowCountDuplicate") - .HasColumnType("integer"); - - b.Property("RowCountError") - .HasColumnType("integer"); - - b.Property("RowCountTotal") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SourceType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UploadedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UploadedBy") - .HasColumnType("integer"); - - b.HasKey("AttendanceUploadBatchId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("PeriodStart", "PeriodEnd"); - - b.ToTable("hr_attendance_upload_batches", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AuditLog", b => - { - b.Property("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("BinId"); - - b.HasIndex("WarehouseId", "Code") - .IsUnique(); - - b.ToTable("bins", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Branch", b => - { - b.Property("BranchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BranchId")); - - b.Property("Address") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BranchId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_branches", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Brand", b => - { - b.Property("BrandId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BrandId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BrandId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("brands", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CategoryId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Department", b => - { - b.Property("DepartmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DepartmentId")); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("HeadEmployeeId") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("ParentDepartmentId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("DepartmentId"); - - b.HasIndex("BranchId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("HeadEmployeeId"); - - b.HasIndex("ParentDepartmentId"); - - b.HasIndex("Status"); - - b.ToTable("hr_departments", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Designation", b => - { - b.Property("DesignationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DesignationId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("DesignationId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_designations", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Employee", b => - { - b.Property("EmployeeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeId")); - - b.Property("AddressLine1") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("AddressLine2") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("City") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("ConfirmationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Country") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DateOfBirth") - .HasColumnType("timestamp with time zone"); - - b.Property("DepartmentId") - .HasColumnType("integer"); - - b.Property("DesignationId") - .HasColumnType("integer"); - - b.Property("Email") - .HasMaxLength(320) - .HasColumnType("character varying(320)"); - - b.Property("EmergencyContactName") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("EmergencyContactPhone") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmergencyContactRelationship") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("EmployeeCode") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmploymentTypeId") - .HasColumnType("integer"); - - b.Property("EpfNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EtfNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("FullName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Gender") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("HireDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LastWorkingDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Nationality") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("Nic") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PersonalMobile") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PostalCode") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ProfilePhotoPath") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("ReportingManagerId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxIdentificationNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("WorkShiftId") - .HasColumnType("integer"); - - b.HasKey("EmployeeId"); - - b.HasIndex("BranchId"); - - b.HasIndex("DepartmentId"); - - b.HasIndex("DesignationId"); - - b.HasIndex("Email"); - - b.HasIndex("EmployeeCode") - .IsUnique(); - - b.HasIndex("EmploymentTypeId"); - - b.HasIndex("ReportingManagerId"); - - b.HasIndex("Status"); - - b.HasIndex("UserId") - .IsUnique(); - - b.HasIndex("WorkShiftId"); - - b.ToTable("hr_employees", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeBankDetail", b => - { - b.Property("EmployeeBankDetailId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeBankDetailId")); - - b.Property("AccountHolderName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("AccountNumber") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("BankName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("BranchName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("IsPrimary") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("SwiftCode") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("EmployeeBankDetailId"); - - b.HasIndex("EmployeeId"); - - b.ToTable("hr_employee_bank_details", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeDocument", b => - { - b.Property("EmployeeDocumentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeDocumentId")); - - b.Property("ContentType") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("ExpiryDate") - .HasColumnType("timestamp with time zone"); - - b.Property("HrDocumentTypeId") - .HasColumnType("integer"); - - b.Property("IssueDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Notes") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("OriginalFileName") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("RelativePath") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SizeBytes") - .HasColumnType("bigint"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StoredFileName") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("UploadedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UploadedBy") - .HasColumnType("integer"); - - b.Property("VerifiedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("VerifiedBy") - .HasColumnType("integer"); - - b.HasKey("EmployeeDocumentId"); - - b.HasIndex("EmployeeId"); - - b.HasIndex("ExpiryDate"); - - b.HasIndex("HrDocumentTypeId"); - - b.ToTable("hr_employee_documents", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.Property("EmployeeLoanId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeLoanId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("InstallmentAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("InterestRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("LoanKind") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("NumberOfInstallments") - .HasColumnType("integer"); - - b.Property("OutstandingBalance") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("PrincipalAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StartMonth") - .HasColumnType("integer"); - - b.Property("StartYear") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("EmployeeLoanId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("EmployeeId"); - - b.HasIndex("Status"); - - b.ToTable("hr_employee_loans", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.Property("EmployeeSalaryStructureId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeSalaryStructureId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("BasicSalary") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("Currency") - .IsRequired() - .HasMaxLength(3) - .HasColumnType("character varying(3)"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("EmployeeSalaryStructureId"); - - b.HasIndex("EmployeeId", "EffectiveTo"); - - b.ToTable("hr_employee_salary_structures", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructureLine", b => - { - b.Property("EmployeeSalaryStructureLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeSalaryStructureLineId")); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("EmployeeSalaryStructureId") - .HasColumnType("integer"); - - b.Property("SalaryComponentId") - .HasColumnType("integer"); - - b.HasKey("EmployeeSalaryStructureLineId"); - - b.HasIndex("EmployeeSalaryStructureId"); - - b.HasIndex("SalaryComponentId"); - - b.ToTable("hr_employee_salary_structure_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmploymentType", b => - { - b.Property("EmploymentTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmploymentTypeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("EmploymentTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_employment_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("DiscountPct") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LineTotal") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("NetUnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("PoUnitPrice") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("VatAmount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("VatPct") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - 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.HrDocumentType", b => - { - b.Property("HrDocumentTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("HrDocumentTypeId")); - - b.Property("Category") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ExpiryTracked") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RequiredAtOnboarding") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("HrDocumentTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_document_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Item", b => - { - b.Property("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("BrandId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SalePrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StockNature") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SubCategoryId") - .HasColumnType("integer"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemId"); - - b.HasIndex("BaseUomId"); - - b.HasIndex("BrandId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("DefaultVendorId"); - - b.HasIndex("Sku") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("SubCategoryId"); - - b.ToTable("items", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b => - { - b.Property("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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.ItemType", b => - { - b.Property("ItemTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemTypeId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemTypeId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("item_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b => - { - b.Property("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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.LeaveBalance", b => - { - b.Property("LeaveBalanceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveBalanceId")); - - b.Property("AdjustmentDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("CarriedForwardDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EntitledDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("LeaveTypeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("TakenDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Year") - .HasColumnType("integer"); - - b.HasKey("LeaveBalanceId"); - - b.HasIndex("LeaveTypeId"); - - b.HasIndex("EmployeeId", "LeaveTypeId", "Year") - .IsUnique(); - - b.ToTable("hr_leave_balances", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveRequest", b => - { - b.Property("LeaveRequestId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveRequestId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DaysCount") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EndDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LeaveTypeId") - .HasColumnType("integer"); - - b.Property("Reason") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("RejectionReason") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StartDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("LeaveRequestId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("EmployeeId"); - - b.HasIndex("LeaveTypeId"); - - b.HasIndex("Status"); - - b.HasIndex("StartDate", "EndDate"); - - b.ToTable("hr_leave_requests", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveType", b => - { - b.Property("LeaveTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveTypeId")); - - b.Property("AccrualPerYear") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("CarryForwardAllowed") - .HasColumnType("boolean"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CountsAsNoPay") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsPaid") - .HasColumnType("boolean"); - - b.Property("MaxCarryForwardDays") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RequiresApproval") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("LeaveTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_leave_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LoanInstallment", b => - { - b.Property("LoanInstallmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LoanInstallmentId")); - - b.Property("DueMonth") - .HasColumnType("integer"); - - b.Property("DueYear") - .HasColumnType("integer"); - - b.Property("EmployeeLoanId") - .HasColumnType("integer"); - - b.Property("InstallmentNumber") - .HasColumnType("integer"); - - b.Property("PaidAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("PayrollRunId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("ScheduledAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("LoanInstallmentId"); - - b.HasIndex("EmployeeLoanId"); - - b.HasIndex("PayrollRunId"); - - b.HasIndex("DueYear", "DueMonth"); - - b.ToTable("hr_loan_installments", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NavItem", b => - { - b.Property("NavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("NavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("nav_items", (string)null); - - b.HasData( - new - { - NavItemId = 1, - Code = "dashboard", - Href = "/dashboard", - Label = "Dashboard", - SortOrder = 1, - Status = "Active" - }, - new - { - NavItemId = 2, - Code = "products", - Href = "/dashboard/products", - Label = "Products", - SortOrder = 2, - Status = "Active" - }, - new - { - NavItemId = 3, - Code = "vendors", - Href = "/dashboard/vendors", - Label = "Vendors", - SortOrder = 3, - Status = "Active" - }, - new - { - NavItemId = 4, - Code = "procurement", - Href = "/dashboard/procurement", - Label = "Procurement", - SortOrder = 4, - Status = "Active" - }, - new - { - NavItemId = 5, - Code = "receiving", - Href = "/dashboard/receiving/grn", - Label = "Receiving", - SortOrder = 5, - Status = "Active" - }, - new - { - NavItemId = 6, - Code = "stock", - Href = "/dashboard/stock", - Label = "Stock", - SortOrder = 6, - Status = "Active" - }, - new - { - NavItemId = 7, - Code = "warehouses", - Href = "/dashboard/warehouse", - Label = "Warehouses", - SortOrder = 7, - Status = "Active" - }, - new - { - NavItemId = 8, - Code = "orders", - Href = "/dashboard/orders", - Label = "Orders", - SortOrder = 8, - Status = "Active" - }, - new - { - NavItemId = 9, - Code = "settings", - Href = "/dashboard/settings", - Label = "Settings", - SortOrder = 9, - Status = "Active" - }, - new - { - NavItemId = 10, - Code = "help", - Href = "/dashboard/help", - Label = "Help", - SortOrder = 10, - Status = "Active" - }, - new - { - NavItemId = 11, - Code = "ledgers", - Href = "/dashboard/ledgers", - Label = "Ledgers", - SortOrder = 11, - Status = "Active" - }, - new - { - NavItemId = 12, - Code = "accounts", - Href = "/dashboard/accounts", - Label = "Accounts", - SortOrder = 12, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NumberSequence", b => - { - b.Property("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("Year") - .HasColumnType("integer") - .HasColumnName("year"); - - b.HasKey("SequenceId"); - - b.HasIndex("DocType", "Year") - .IsUnique(); - - b.ToTable("number_sequences", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.Property("PayrollLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollLineId")); - - b.Property("AbsentDays") - .HasColumnType("integer"); - - b.Property("BasicSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EpfEmployeeAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("EpfEmployerAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("EtfEmployerAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("GrossSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("LateDeductionAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("LateMinutesTotal") - .HasColumnType("integer"); - - b.Property("LeaveDays") - .HasColumnType("integer"); - - b.Property("LoanDeductionAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("NetSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("NoPayAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("OtMinutesTotal") - .HasColumnType("integer"); - - b.Property("OtherDeductionsAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("OvertimeAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("PayrollRunId") - .HasColumnType("integer"); - - b.Property("PresentDays") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("TaxAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("TotalAllowances") - .HasColumnType("numeric(18,2)"); - - b.Property("WorkingDays") - .HasColumnType("integer"); - - b.HasKey("PayrollLineId"); - - b.HasIndex("EmployeeId"); - - b.HasIndex("PayrollRunId", "EmployeeId") - .IsUnique(); - - b.ToTable("hr_payroll_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLineComponent", b => - { - b.Property("PayrollLineComponentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollLineComponentId")); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("ComponentCategory") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("PayrollLineId") - .HasColumnType("integer"); - - b.Property("SalaryComponentId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.HasKey("PayrollLineComponentId"); - - b.HasIndex("PayrollLineId"); - - b.HasIndex("SalaryComponentId"); - - b.ToTable("hr_payroll_line_components", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.Property("PayrollRunId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollRunId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("GeneratedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("GeneratedBy") - .HasColumnType("integer"); - - b.Property("LockedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("LockedBy") - .HasColumnType("integer"); - - b.Property("PeriodMonth") - .HasColumnType("integer"); - - b.Property("PeriodYear") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UnlockReason") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("UnlockedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UnlockedBy") - .HasColumnType("integer"); - - b.HasKey("PayrollRunId"); - - b.HasIndex("BranchId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("PeriodYear", "PeriodMonth", "BranchId"); - - b.ToTable("hr_payroll_runs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollStatutorySetting", b => - { - b.Property("PayrollStatutorySettingId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollStatutorySettingId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("EpfEmployeeRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("EpfEmployerRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("EtfEmployerRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("OtMultiplierDefault") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.HasKey("PayrollStatutorySettingId"); - - b.HasIndex("EffectiveFrom"); - - b.ToTable("hr_payroll_statutory_settings", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Payslip", b => - { - b.Property("PayslipId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayslipId")); - - b.Property("GeneratedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("PayrollLineId") - .HasColumnType("integer"); - - b.Property("ReleasedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ReleasedBy") - .HasColumnType("integer"); - - b.HasKey("PayslipId"); - - b.HasIndex("PayrollLineId") - .IsUnique(); - - b.ToTable("hr_payslips", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.Property("PermissionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PermissionId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SubNavItemId") - .HasColumnType("integer"); - - b.HasKey("PermissionId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.HasIndex("SubNavItemId"); - - b.ToTable("permissions", (string)null); - - b.HasData( - new - { - PermissionId = 1, - Code = "NAV:dashboard", - NavItemId = 1 - }, - new - { - PermissionId = 2, - Code = "NAV:products", - NavItemId = 2 - }, - new - { - PermissionId = 3, - Code = "NAV:vendors", - NavItemId = 3 - }, - new - { - PermissionId = 4, - Code = "NAV:procurement", - NavItemId = 4 - }, - new - { - PermissionId = 5, - Code = "NAV:receiving", - NavItemId = 5 - }, - new - { - PermissionId = 6, - Code = "NAV:stock", - NavItemId = 6 - }, - new - { - PermissionId = 7, - Code = "NAV:warehouses", - NavItemId = 7 - }, - new - { - PermissionId = 8, - Code = "NAV:orders", - NavItemId = 8 - }, - new - { - PermissionId = 9, - Code = "NAV:settings", - NavItemId = 9 - }, - new - { - PermissionId = 10, - Code = "NAV:help", - NavItemId = 10 - }, - new - { - PermissionId = 11, - Code = "NAV:products.item", - SubNavItemId = 1 - }, - new - { - PermissionId = 12, - Code = "NAV:products.category", - SubNavItemId = 2 - }, - new - { - PermissionId = 13, - Code = "NAV:products.brand", - SubNavItemId = 3 - }, - new - { - PermissionId = 14, - Code = "NAV:products.item-type", - SubNavItemId = 4 - }, - new - { - PermissionId = 15, - Code = "NAV:products.uom", - SubNavItemId = 5 - }, - new - { - PermissionId = 16, - Code = "NAV:products.configuration", - SubNavItemId = 6 - }, - new - { - PermissionId = 17, - Code = "NAV:settings.roles", - SubNavItemId = 7 - }, - new - { - PermissionId = 18, - Code = "NAV:settings.users", - SubNavItemId = 8 - }, - new - { - PermissionId = 28, - Code = "NAV:procurement.requisitions", - SubNavItemId = 17 - }, - new - { - PermissionId = 29, - Code = "NAV:procurement.rfqs", - SubNavItemId = 18 - }, - new - { - PermissionId = 30, - Code = "NAV:procurement.purchase-orders", - SubNavItemId = 19 - }, - new - { - PermissionId = 31, - Code = "NAV:procurement.purchase-returns", - SubNavItemId = 20 - }, - new - { - PermissionId = 19, - Code = "NAV:ledgers", - NavItemId = 11 - }, - new - { - PermissionId = 20, - Code = "NAV:ledgers.trial-balance", - SubNavItemId = 9 - }, - new - { - PermissionId = 21, - Code = "NAV:ledgers.balance-sheet", - SubNavItemId = 10 - }, - new - { - PermissionId = 22, - Code = "NAV:ledgers.general-ledger", - SubNavItemId = 11 - }, - new - { - PermissionId = 23, - Code = "NAV:ledgers.profit-and-loss", - SubNavItemId = 12 - }, - new - { - PermissionId = 24, - Code = "NAV:ledgers.cash-flow", - SubNavItemId = 13 - }, - new - { - PermissionId = 25, - Code = "NAV:ledgers.budget-vs-actual", - SubNavItemId = 14 - }, - new - { - PermissionId = 27, - Code = "NAV:ledgers.tax-report", - SubNavItemId = 16 - }, - new - { - PermissionId = 26, - Code = "NAV:accounts.bank-accounts", - SubNavItemId = 15 - }, - new - { - PermissionId = 32, - Code = "NAV:accounts", - NavItemId = 12 - }, - new - { - PermissionId = 33, - Code = "NAV:accounts.cheque-books", - SubNavItemId = 21 - }, - new - { - PermissionId = 34, - Code = "NAV:accounts.received-cheques", - SubNavItemId = 22 - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b => - { - b.Property("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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.ProductConfig", b => - { - b.Property("ConfigId") - .HasColumnType("integer"); - - b.Property("BrandsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("ItemTypesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SubcategoriesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.HasKey("ConfigId"); - - b.HasIndex("UpdatedBy"); - - b.ToTable("product_config", null, t => - { - t.HasCheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b => - { - b.Property("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.HasKey("RfqLineId"); - - b.HasIndex("ItemId"); - - b.HasIndex("RfqId"); - - b.ToTable("rfq_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Role", b => - { - b.Property("RoleId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RoleId")); - - b.Property("AuthRoleId") - .HasColumnType("uuid") - .HasColumnName("auth_role_id"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsSystemRole") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(false); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("RoleId"); - - b.HasIndex("AuthRoleId") - .IsUnique(); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("roles", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RolePermission", b => - { - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("PermissionId") - .HasColumnType("integer"); - - b.HasKey("RoleId", "PermissionId"); - - b.HasIndex("PermissionId"); - - b.ToTable("role_permissions", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SalaryComponent", b => - { - b.Property("SalaryComponentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SalaryComponentId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ComponentType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsEpfEtfApplicable") - .HasColumnType("boolean"); - - b.Property("IsTaxable") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SalaryComponentId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_salary_components", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b => - { - b.Property("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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.SubCategory", b => - { - b.Property("SubCategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubCategoryId")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SubCategoryId"); - - b.HasIndex("Status"); - - b.HasIndex("CategoryId", "Name") - .IsUnique(); - - b.ToTable("subcategories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.Property("SubNavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubNavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("SubNavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.ToTable("sub_nav_items", (string)null); - - b.HasData( - new - { - SubNavItemId = 1, - Code = "products.item", - Href = "/dashboard/products", - Label = "Item", - NavItemId = 2, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 2, - Code = "products.category", - Href = "/dashboard/products/categories", - Label = "Category", - NavItemId = 2, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 3, - Code = "products.brand", - Href = "/dashboard/products/brands", - Label = "Brand", - NavItemId = 2, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 4, - Code = "products.item-type", - Href = "/dashboard/products/item-types", - Label = "Item Type", - NavItemId = 2, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 5, - Code = "products.uom", - Href = "/dashboard/products/uoms", - Label = "UOM", - NavItemId = 2, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 6, - Code = "products.configuration", - Href = "/dashboard/products/settings", - Label = "Configuration", - NavItemId = 2, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 7, - Code = "settings.roles", - Href = "/dashboard/settings/roles", - Label = "Roles", - NavItemId = 9, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 8, - Code = "settings.users", - Href = "/dashboard/settings/users", - Label = "Users", - NavItemId = 9, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 17, - Code = "procurement.requisitions", - Href = "/dashboard/procurement/requisitions", - Label = "Requisitions", - NavItemId = 4, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 18, - Code = "procurement.rfqs", - Href = "/dashboard/procurement/rfqs", - Label = "RFQs", - NavItemId = 4, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 19, - Code = "procurement.purchase-orders", - Href = "/dashboard/procurement/purchase-orders", - Label = "Purchase Orders", - NavItemId = 4, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 20, - Code = "procurement.purchase-returns", - Href = "/dashboard/procurement/purchase-returns", - Label = "Purchase Returns", - NavItemId = 4, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 9, - Code = "ledgers.trial-balance", - Href = "/dashboard/ledgers/trial-balance", - Label = "Trial Balance", - NavItemId = 11, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 10, - Code = "ledgers.balance-sheet", - Href = "/dashboard/ledgers/balance-sheet", - Label = "Balance Sheet", - NavItemId = 11, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 11, - Code = "ledgers.general-ledger", - Href = "/dashboard/ledgers/general-ledger", - Label = "General Ledger", - NavItemId = 11, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 12, - Code = "ledgers.profit-and-loss", - Href = "/dashboard/ledgers/profit-and-loss", - Label = "Profit & Loss", - NavItemId = 11, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 13, - Code = "ledgers.cash-flow", - Href = "/dashboard/ledgers/cash-flow", - Label = "Cash Flow", - NavItemId = 11, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 14, - Code = "ledgers.budget-vs-actual", - Href = "/dashboard/ledgers/budget-vs-actual", - Label = "Budget vs Actual", - NavItemId = 11, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 16, - Code = "ledgers.tax-report", - Href = "/dashboard/ledgers/tax-report", - Label = "Tax Report", - NavItemId = 11, - SortOrder = 7, - Status = "Active" - }, - new - { - SubNavItemId = 15, - Code = "accounts.bank-accounts", - Href = "/dashboard/accounts/bank-accounts", - Label = "Cash / Bank Accounts", - NavItemId = 12, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 21, - Code = "accounts.cheque-books", - Href = "/dashboard/accounts/cheque-books", - Label = "Cheque Books", - NavItemId = 12, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 22, - Code = "accounts.received-cheques", - Href = "/dashboard/accounts/received-cheques", - Label = "Received Cheques", - NavItemId = 12, - SortOrder = 3, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.TaxSlab", b => - { - b.Property("TaxSlabId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TaxSlabId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("LowerBound") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("Rate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("UpperBound") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.HasKey("TaxSlabId"); - - b.HasIndex("EffectiveFrom"); - - b.ToTable("hr_tax_slabs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b => - { - b.Property("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Email") - .HasMaxLength(320) - .HasColumnType("character varying(320)"); - - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.HasKey("UserId"); - - b.HasIndex("AuthUserId") - .IsUnique(); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("RoleId"); - - 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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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.WorkShift", b => - { - b.Property("WorkShiftId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WorkShiftId")); - - b.Property("BreakMinutes") - .HasColumnType("integer"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EndTime") - .HasColumnType("interval"); - - b.Property("GraceMinutes") - .HasColumnType("integer"); - - b.Property("IsOvernight") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("OtMultiplier") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StandardWorkingMinutes") - .HasColumnType("integer"); - - b.Property("StartTime") - .HasColumnType("interval"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("WorkingDaysMask") - .HasColumnType("integer"); - - b.HasKey("WorkShiftId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_work_shifts", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AttendanceRecord", b => - { - b.HasOne("ERPCore.Domain.Entities.AttendanceUploadBatch", "AttendanceUploadBatch") - .WithMany() - .HasForeignKey("AttendanceUploadBatchId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.WorkShift", "WorkShift") - .WithMany() - .HasForeignKey("WorkShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("AttendanceUploadBatch"); - - b.Navigation("Employee"); - - b.Navigation("WorkShift"); - }); - - 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.Department", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Employee", "HeadEmployee") - .WithMany() - .HasForeignKey("HeadEmployeeId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Department", "ParentDepartment") - .WithMany() - .HasForeignKey("ParentDepartmentId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Branch"); - - b.Navigation("HeadEmployee"); - - b.Navigation("ParentDepartment"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Employee", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Department", "Department") - .WithMany() - .HasForeignKey("DepartmentId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Designation", "Designation") - .WithMany() - .HasForeignKey("DesignationId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.EmploymentType", "EmploymentType") - .WithMany() - .HasForeignKey("EmploymentTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Employee", "ReportingManager") - .WithMany() - .HasForeignKey("ReportingManagerId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.User", "User") - .WithOne() - .HasForeignKey("ERPCore.Domain.Entities.Employee", "UserId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.WorkShift", "WorkShift") - .WithMany() - .HasForeignKey("WorkShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Branch"); - - b.Navigation("Department"); - - b.Navigation("Designation"); - - b.Navigation("EmploymentType"); - - b.Navigation("ReportingManager"); - - b.Navigation("User"); - - b.Navigation("WorkShift"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeBankDetail", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeDocument", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.HrDocumentType", "HrDocumentType") - .WithMany() - .HasForeignKey("HrDocumentTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("HrDocumentType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructureLine", b => - { - b.HasOne("ERPCore.Domain.Entities.EmployeeSalaryStructure", "EmployeeSalaryStructure") - .WithMany("Lines") - .HasForeignKey("EmployeeSalaryStructureId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.SalaryComponent", "SalaryComponent") - .WithMany() - .HasForeignKey("SalaryComponentId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("EmployeeSalaryStructure"); - - b.Navigation("SalaryComponent"); - }); - - 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.Brand", "Brand") - .WithMany() - .HasForeignKey("BrandId") - .OnDelete(DeleteBehavior.Restrict); - - 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.HasOne("ERPCore.Domain.Entities.SubCategory", "SubCategory") - .WithMany() - .HasForeignKey("SubCategoryId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("BaseUom"); - - b.Navigation("Brand"); - - b.Navigation("Category"); - - b.Navigation("DefaultVendor"); - - b.Navigation("SubCategory"); - }); - - 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.LeaveBalance", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.LeaveType", "LeaveType") - .WithMany() - .HasForeignKey("LeaveTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("LeaveType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveRequest", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.LeaveType", "LeaveType") - .WithMany() - .HasForeignKey("LeaveTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("LeaveType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LoanInstallment", b => - { - b.HasOne("ERPCore.Domain.Entities.EmployeeLoan", "EmployeeLoan") - .WithMany("Installments") - .HasForeignKey("EmployeeLoanId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.PayrollRun", "PayrollRun") - .WithMany() - .HasForeignKey("PayrollRunId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EmployeeLoan"); - - b.Navigation("PayrollRun"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.PayrollRun", "PayrollRun") - .WithMany("Lines") - .HasForeignKey("PayrollRunId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("PayrollRun"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLineComponent", b => - { - b.HasOne("ERPCore.Domain.Entities.PayrollLine", "PayrollLine") - .WithMany("Components") - .HasForeignKey("PayrollLineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.SalaryComponent", "SalaryComponent") - .WithMany() - .HasForeignKey("SalaryComponentId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("PayrollLine"); - - b.Navigation("SalaryComponent"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Branch"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Payslip", b => - { - b.HasOne("ERPCore.Domain.Entities.PayrollLine", "PayrollLine") - .WithOne() - .HasForeignKey("ERPCore.Domain.Entities.Payslip", "PayrollLineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("PayrollLine"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany() - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.SubNavItem", "SubNavItem") - .WithMany() - .HasForeignKey("SubNavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("NavItem"); - - b.Navigation("SubNavItem"); - }); - - 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.ProductConfig", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser") - .WithMany() - .HasForeignKey("UpdatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("UpdatedByUser"); - }); - - 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.RolePermission", b => - { - b.HasOne("ERPCore.Domain.Entities.Permission", "Permission") - .WithMany() - .HasForeignKey("PermissionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Permission"); - - b.Navigation("Role"); - }); - - 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.SubCategory", b => - { - b.HasOne("ERPCore.Domain.Entities.Category", "Category") - .WithMany("SubCategories") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany("Children") - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NavItem"); - }); - - 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.User", b => - { - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Role"); - }); - - 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("SubCategories"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.Navigation("Installments"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.Navigation("Lines"); - }); - - 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.NavItem", b => - { - b.Navigation("Children"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.Navigation("Components"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.Navigation("Lines"); - }); - - 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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260731113219_AddAccountsNavSeed.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260731113219_AddAccountsNavSeed.cs deleted file mode 100644 index a92f7dc..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260731113219_AddAccountsNavSeed.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class AddAccountsNavSeed : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.InsertData( - table: "nav_items", - columns: new[] { "NavItemId", "Code", "Href", "Icon", "Label", "SortOrder" }, - values: new object[] { 12, "accounts", "/dashboard/accounts", null, "Accounts", 12 }); - - migrationBuilder.UpdateData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 26, - column: "Code", - value: "NAV:accounts.bank-accounts"); - - migrationBuilder.UpdateData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 15, - columns: new[] { "Code", "Href", "NavItemId", "SortOrder" }, - values: new object[] { "accounts.bank-accounts", "/dashboard/accounts/bank-accounts", 12, 1 }); - - migrationBuilder.InsertData( - table: "permissions", - columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, - values: new object[] { 32, "NAV:accounts", 12, null }); - - migrationBuilder.InsertData( - table: "sub_nav_items", - columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" }, - values: new object[,] - { - { 21, "accounts.cheque-books", "/dashboard/accounts/cheque-books", null, "Cheque Books", 12, 2 }, - { 22, "accounts.received-cheques", "/dashboard/accounts/received-cheques", null, "Received Cheques", 12, 3 } - }); - - migrationBuilder.InsertData( - table: "permissions", - columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, - values: new object[,] - { - { 33, "NAV:accounts.cheque-books", null, 21 }, - { 34, "NAV:accounts.received-cheques", null, 22 } - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 32); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 33); - - migrationBuilder.DeleteData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 34); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 21); - - migrationBuilder.DeleteData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 22); - - migrationBuilder.DeleteData( - table: "nav_items", - keyColumn: "NavItemId", - keyValue: 12); - - migrationBuilder.UpdateData( - table: "permissions", - keyColumn: "PermissionId", - keyValue: 26, - column: "Code", - value: "NAV:ledgers.bank-accounts"); - - migrationBuilder.UpdateData( - table: "sub_nav_items", - keyColumn: "SubNavItemId", - keyValue: 15, - columns: new[] { "Code", "Href", "NavItemId", "SortOrder" }, - values: new object[] { "ledgers.bank-accounts", "/dashboard/ledgers/bank-accounts", 11, 8 }); - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260731123720_production.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260731123720_production.cs deleted file mode 100644 index 88bc1a8..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260731123720_production.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class production : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260731131856_AddMissingHrmAndManufacturingTables.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260731131856_AddMissingHrmAndManufacturingTables.Designer.cs deleted file mode 100644 index b2f7353..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260731131856_AddMissingHrmAndManufacturingTables.Designer.cs +++ /dev/null @@ -1,6054 +0,0 @@ -// -using System; -using ERPCore.Infra.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - [DbContext(typeof(ErpDbContext))] - [Migration("20260731131856_AddMissingHrmAndManufacturingTables")] - partial class AddMissingHrmAndManufacturingTables - { - /// - protected override void BuildTargetModel(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.AttendanceRecord", b => - { - b.Property("AttendanceRecordId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AttendanceRecordId")); - - b.Property("AttendanceDate") - .HasColumnType("timestamp with time zone"); - - b.Property("AttendanceStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("AttendanceUploadBatchId") - .HasColumnType("integer"); - - b.Property("CheckIn") - .HasColumnType("interval"); - - b.Property("CheckOut") - .HasColumnType("interval"); - - b.Property("DuplicateOfAttendanceRecordId") - .HasColumnType("integer"); - - b.Property("EarlyLeaveMinutes") - .HasColumnType("integer"); - - b.Property("EditedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EditedBy") - .HasColumnType("integer"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("IsManualOverride") - .HasColumnType("boolean"); - - b.Property("LateMinutes") - .HasColumnType("integer"); - - b.Property("Notes") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("OvertimeMinutes") - .HasColumnType("integer"); - - b.Property("RowValidationStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("WorkShiftId") - .HasColumnType("integer"); - - b.Property("WorkingMinutes") - .HasColumnType("integer"); - - b.HasKey("AttendanceRecordId"); - - b.HasIndex("AttendanceUploadBatchId"); - - b.HasIndex("WorkShiftId"); - - b.HasIndex("EmployeeId", "AttendanceDate"); - - b.ToTable("hr_attendance_records", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AttendanceUploadBatch", b => - { - b.Property("AttendanceUploadBatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AttendanceUploadBatchId")); - - b.Property("ConfirmedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ConfirmedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("OriginalFileName") - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("PeriodEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("PeriodStart") - .HasColumnType("timestamp with time zone"); - - b.Property("RowCountDuplicate") - .HasColumnType("integer"); - - b.Property("RowCountError") - .HasColumnType("integer"); - - b.Property("RowCountTotal") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SourceType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UploadedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UploadedBy") - .HasColumnType("integer"); - - b.HasKey("AttendanceUploadBatchId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("PeriodStart", "PeriodEnd"); - - b.ToTable("hr_attendance_upload_batches", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AuditLog", b => - { - b.Property("AuditId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AuditId")); - - b.Property("Action") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("ChangeSet") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EntityId") - .HasColumnType("integer"); - - b.Property("EntityType") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("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("BatchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BatchId")); - - b.Property("BatchNo") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ExpiryDate") - .HasColumnType("date"); - - b.Property("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("BinId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BinId")); - - b.Property("BinType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("BinId"); - - b.HasIndex("WarehouseId", "Code") - .IsUnique(); - - b.ToTable("bins", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Branch", b => - { - b.Property("BranchId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BranchId")); - - b.Property("Address") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BranchId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_branches", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Brand", b => - { - b.Property("BrandId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BrandId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("BrandId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("brands", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CategoryId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("categories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Department", b => - { - b.Property("DepartmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DepartmentId")); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("HeadEmployeeId") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("ParentDepartmentId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("DepartmentId"); - - b.HasIndex("BranchId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("HeadEmployeeId"); - - b.HasIndex("ParentDepartmentId"); - - b.HasIndex("Status"); - - b.ToTable("hr_departments", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Designation", b => - { - b.Property("DesignationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DesignationId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("DesignationId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_designations", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Employee", b => - { - b.Property("EmployeeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeId")); - - b.Property("AddressLine1") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("AddressLine2") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("City") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("ConfirmationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Country") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DateOfBirth") - .HasColumnType("timestamp with time zone"); - - b.Property("DepartmentId") - .HasColumnType("integer"); - - b.Property("DesignationId") - .HasColumnType("integer"); - - b.Property("Email") - .HasMaxLength(320) - .HasColumnType("character varying(320)"); - - b.Property("EmergencyContactName") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("EmergencyContactPhone") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmergencyContactRelationship") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("EmployeeCode") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmploymentTypeId") - .HasColumnType("integer"); - - b.Property("EpfNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EtfNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("FullName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Gender") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("HireDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LastWorkingDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Nationality") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("Nic") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PersonalMobile") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PostalCode") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ProfilePhotoPath") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("ReportingManagerId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxIdentificationNumber") - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("WorkShiftId") - .HasColumnType("integer"); - - b.HasKey("EmployeeId"); - - b.HasIndex("BranchId"); - - b.HasIndex("DepartmentId"); - - b.HasIndex("DesignationId"); - - b.HasIndex("Email"); - - b.HasIndex("EmployeeCode") - .IsUnique(); - - b.HasIndex("EmploymentTypeId"); - - b.HasIndex("ReportingManagerId"); - - b.HasIndex("Status"); - - b.HasIndex("UserId") - .IsUnique(); - - b.HasIndex("WorkShiftId"); - - b.ToTable("hr_employees", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeBankDetail", b => - { - b.Property("EmployeeBankDetailId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeBankDetailId")); - - b.Property("AccountHolderName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("AccountNumber") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("BankName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("BranchName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("IsPrimary") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("SwiftCode") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("EmployeeBankDetailId"); - - b.HasIndex("EmployeeId"); - - b.ToTable("hr_employee_bank_details", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeDocument", b => - { - b.Property("EmployeeDocumentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeDocumentId")); - - b.Property("ContentType") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("ExpiryDate") - .HasColumnType("timestamp with time zone"); - - b.Property("HrDocumentTypeId") - .HasColumnType("integer"); - - b.Property("IssueDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Notes") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("OriginalFileName") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("RelativePath") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SizeBytes") - .HasColumnType("bigint"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StoredFileName") - .IsRequired() - .HasMaxLength(260) - .HasColumnType("character varying(260)"); - - b.Property("UploadedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UploadedBy") - .HasColumnType("integer"); - - b.Property("VerifiedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("VerifiedBy") - .HasColumnType("integer"); - - b.HasKey("EmployeeDocumentId"); - - b.HasIndex("EmployeeId"); - - b.HasIndex("ExpiryDate"); - - b.HasIndex("HrDocumentTypeId"); - - b.ToTable("hr_employee_documents", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.Property("EmployeeLoanId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeLoanId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("InstallmentAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("InterestRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("LoanKind") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("NumberOfInstallments") - .HasColumnType("integer"); - - b.Property("OutstandingBalance") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("PrincipalAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StartMonth") - .HasColumnType("integer"); - - b.Property("StartYear") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("EmployeeLoanId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("EmployeeId"); - - b.HasIndex("Status"); - - b.ToTable("hr_employee_loans", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.Property("EmployeeSalaryStructureId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeSalaryStructureId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("BasicSalary") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("Currency") - .IsRequired() - .HasMaxLength(3) - .HasColumnType("character varying(3)"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("EmployeeSalaryStructureId"); - - b.HasIndex("EmployeeId", "EffectiveTo"); - - b.ToTable("hr_employee_salary_structures", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructureLine", b => - { - b.Property("EmployeeSalaryStructureLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmployeeSalaryStructureLineId")); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("EmployeeSalaryStructureId") - .HasColumnType("integer"); - - b.Property("SalaryComponentId") - .HasColumnType("integer"); - - b.HasKey("EmployeeSalaryStructureLineId"); - - b.HasIndex("EmployeeSalaryStructureId"); - - b.HasIndex("SalaryComponentId"); - - b.ToTable("hr_employee_salary_structure_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmploymentType", b => - { - b.Property("EmploymentTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EmploymentTypeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("EmploymentTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_employment_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Grn", b => - { - b.Property("GrnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("PostedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("GrnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GrnLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("DiscountPct") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("GrnId") - .HasColumnType("integer"); - - b.Property("HoldStatus") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LineTotal") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("NetUnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("PoLineId") - .HasColumnType("integer"); - - b.Property("PoUnitPrice") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceivedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("VatAmount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("VatPct") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - 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.HrDocumentType", b => - { - b.Property("HrDocumentTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("HrDocumentTypeId")); - - b.Property("Category") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ExpiryTracked") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RequiredAtOnboarding") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("HrDocumentTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_document_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Item", b => - { - b.Property("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("BaseUomId") - .HasColumnType("integer"); - - b.Property("BrandId") - .HasColumnType("integer"); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DefaultVendorId") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SalePrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Sku") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("StockNature") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SubCategoryId") - .HasColumnType("integer"); - - b.Property("TaxClass") - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TrackingMode") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemId"); - - b.HasIndex("BaseUomId"); - - b.HasIndex("BrandId"); - - b.HasIndex("CategoryId"); - - b.HasIndex("DefaultVendorId"); - - b.HasIndex("Sku") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("SubCategoryId"); - - b.ToTable("items", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b => - { - b.Property("ReorderId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReorderId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("ReorderPoint") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReorderQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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.ItemType", b => - { - b.Property("ItemTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemTypeId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ItemTypeId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("item_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.JournalEntryStub", b => - { - b.Property("JournalId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("JournalId")); - - b.Property("Amount") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("CreditAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("DebitAccount") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("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.LeaveBalance", b => - { - b.Property("LeaveBalanceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveBalanceId")); - - b.Property("AdjustmentDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("CarriedForwardDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EntitledDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("LeaveTypeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("TakenDays") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Year") - .HasColumnType("integer"); - - b.HasKey("LeaveBalanceId"); - - b.HasIndex("LeaveTypeId"); - - b.HasIndex("EmployeeId", "LeaveTypeId", "Year") - .IsUnique(); - - b.ToTable("hr_leave_balances", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveRequest", b => - { - b.Property("LeaveRequestId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveRequestId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DaysCount") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EndDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LeaveTypeId") - .HasColumnType("integer"); - - b.Property("Reason") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("RejectionReason") - .HasMaxLength(1000) - .HasColumnType("character varying(1000)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StartDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("LeaveRequestId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("EmployeeId"); - - b.HasIndex("LeaveTypeId"); - - b.HasIndex("Status"); - - b.HasIndex("StartDate", "EndDate"); - - b.ToTable("hr_leave_requests", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveType", b => - { - b.Property("LeaveTypeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LeaveTypeId")); - - b.Property("AccrualPerYear") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("CarryForwardAllowed") - .HasColumnType("boolean"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CountsAsNoPay") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsPaid") - .HasColumnType("boolean"); - - b.Property("MaxCarryForwardDays") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RequiresApproval") - .HasColumnType("boolean"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("LeaveTypeId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_leave_types", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LoanInstallment", b => - { - b.Property("LoanInstallmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LoanInstallmentId")); - - b.Property("DueMonth") - .HasColumnType("integer"); - - b.Property("DueYear") - .HasColumnType("integer"); - - b.Property("EmployeeLoanId") - .HasColumnType("integer"); - - b.Property("InstallmentNumber") - .HasColumnType("integer"); - - b.Property("PaidAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("PayrollRunId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("ScheduledAmount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("LoanInstallmentId"); - - b.HasIndex("EmployeeLoanId"); - - b.HasIndex("PayrollRunId"); - - b.HasIndex("DueYear", "DueMonth"); - - b.ToTable("hr_loan_installments", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NavItem", b => - { - b.Property("NavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("NavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("nav_items", (string)null); - - b.HasData( - new - { - NavItemId = 1, - Code = "dashboard", - Href = "/dashboard", - Label = "Dashboard", - SortOrder = 1, - Status = "Active" - }, - new - { - NavItemId = 2, - Code = "products", - Href = "/dashboard/products", - Label = "Products", - SortOrder = 2, - Status = "Active" - }, - new - { - NavItemId = 3, - Code = "vendors", - Href = "/dashboard/vendors", - Label = "Vendors", - SortOrder = 3, - Status = "Active" - }, - new - { - NavItemId = 4, - Code = "procurement", - Href = "/dashboard/procurement", - Label = "Procurement", - SortOrder = 4, - Status = "Active" - }, - new - { - NavItemId = 5, - Code = "receiving", - Href = "/dashboard/receiving/grn", - Label = "Receiving", - SortOrder = 5, - Status = "Active" - }, - new - { - NavItemId = 6, - Code = "stock", - Href = "/dashboard/stock", - Label = "Stock", - SortOrder = 6, - Status = "Active" - }, - new - { - NavItemId = 7, - Code = "warehouses", - Href = "/dashboard/warehouse", - Label = "Warehouses", - SortOrder = 7, - Status = "Active" - }, - new - { - NavItemId = 8, - Code = "orders", - Href = "/dashboard/orders", - Label = "Orders", - SortOrder = 8, - Status = "Active" - }, - new - { - NavItemId = 9, - Code = "settings", - Href = "/dashboard/settings", - Label = "Settings", - SortOrder = 9, - Status = "Active" - }, - new - { - NavItemId = 10, - Code = "help", - Href = "/dashboard/help", - Label = "Help", - SortOrder = 10, - Status = "Active" - }, - new - { - NavItemId = 11, - Code = "ledgers", - Href = "/dashboard/ledgers", - Label = "Ledgers", - SortOrder = 11, - Status = "Active" - }, - new - { - NavItemId = 12, - Code = "accounts", - Href = "/dashboard/accounts", - Label = "Accounts", - SortOrder = 12, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.NumberSequence", b => - { - b.Property("SequenceId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceId")); - - b.Property("DocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("doc_type"); - - b.Property("LastNumber") - .HasColumnType("integer") - .HasColumnName("last_number"); - - b.Property("Year") - .HasColumnType("integer") - .HasColumnName("year"); - - b.HasKey("SequenceId"); - - b.HasIndex("DocType", "Year") - .IsUnique(); - - b.ToTable("number_sequences", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.Property("PayrollLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollLineId")); - - b.Property("AbsentDays") - .HasColumnType("integer"); - - b.Property("BasicSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("EmployeeId") - .HasColumnType("integer"); - - b.Property("EpfEmployeeAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("EpfEmployerAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("EtfEmployerAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("GrossSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("LateDeductionAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("LateMinutesTotal") - .HasColumnType("integer"); - - b.Property("LeaveDays") - .HasColumnType("integer"); - - b.Property("LoanDeductionAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("NetSalary") - .HasColumnType("numeric(18,2)"); - - b.Property("NoPayAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("OtMinutesTotal") - .HasColumnType("integer"); - - b.Property("OtherDeductionsAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("OvertimeAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("PayrollRunId") - .HasColumnType("integer"); - - b.Property("PresentDays") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("TaxAmount") - .HasColumnType("numeric(18,2)"); - - b.Property("TotalAllowances") - .HasColumnType("numeric(18,2)"); - - b.Property("WorkingDays") - .HasColumnType("integer"); - - b.HasKey("PayrollLineId"); - - b.HasIndex("EmployeeId"); - - b.HasIndex("PayrollRunId", "EmployeeId") - .IsUnique(); - - b.ToTable("hr_payroll_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLineComponent", b => - { - b.Property("PayrollLineComponentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollLineComponentId")); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("ComponentCategory") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("PayrollLineId") - .HasColumnType("integer"); - - b.Property("SalaryComponentId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.HasKey("PayrollLineComponentId"); - - b.HasIndex("PayrollLineId"); - - b.HasIndex("SalaryComponentId"); - - b.ToTable("hr_payroll_line_components", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.Property("PayrollRunId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollRunId")); - - b.Property("ApprovedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ApprovedBy") - .HasColumnType("integer"); - - b.Property("BranchId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("GeneratedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("GeneratedBy") - .HasColumnType("integer"); - - b.Property("LockedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("LockedBy") - .HasColumnType("integer"); - - b.Property("PeriodMonth") - .HasColumnType("integer"); - - b.Property("PeriodYear") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UnlockReason") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("UnlockedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UnlockedBy") - .HasColumnType("integer"); - - b.HasKey("PayrollRunId"); - - b.HasIndex("BranchId"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("Status"); - - b.HasIndex("PeriodYear", "PeriodMonth", "BranchId"); - - b.ToTable("hr_payroll_runs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollStatutorySetting", b => - { - b.Property("PayrollStatutorySettingId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayrollStatutorySettingId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("EpfEmployeeRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("EpfEmployerRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("EtfEmployerRate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("OtMultiplierDefault") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.HasKey("PayrollStatutorySettingId"); - - b.HasIndex("EffectiveFrom"); - - b.ToTable("hr_payroll_statutory_settings", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Payslip", b => - { - b.Property("PayslipId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PayslipId")); - - b.Property("GeneratedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("PayrollLineId") - .HasColumnType("integer"); - - b.Property("ReleasedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ReleasedBy") - .HasColumnType("integer"); - - b.HasKey("PayslipId"); - - b.HasIndex("PayrollLineId") - .IsUnique(); - - b.ToTable("hr_payslips", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.Property("PermissionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PermissionId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("character varying(80)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SubNavItemId") - .HasColumnType("integer"); - - b.HasKey("PermissionId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.HasIndex("SubNavItemId"); - - b.ToTable("permissions", (string)null); - - b.HasData( - new - { - PermissionId = 1, - Code = "NAV:dashboard", - NavItemId = 1 - }, - new - { - PermissionId = 2, - Code = "NAV:products", - NavItemId = 2 - }, - new - { - PermissionId = 3, - Code = "NAV:vendors", - NavItemId = 3 - }, - new - { - PermissionId = 4, - Code = "NAV:procurement", - NavItemId = 4 - }, - new - { - PermissionId = 5, - Code = "NAV:receiving", - NavItemId = 5 - }, - new - { - PermissionId = 6, - Code = "NAV:stock", - NavItemId = 6 - }, - new - { - PermissionId = 7, - Code = "NAV:warehouses", - NavItemId = 7 - }, - new - { - PermissionId = 8, - Code = "NAV:orders", - NavItemId = 8 - }, - new - { - PermissionId = 9, - Code = "NAV:settings", - NavItemId = 9 - }, - new - { - PermissionId = 10, - Code = "NAV:help", - NavItemId = 10 - }, - new - { - PermissionId = 11, - Code = "NAV:products.item", - SubNavItemId = 1 - }, - new - { - PermissionId = 12, - Code = "NAV:products.category", - SubNavItemId = 2 - }, - new - { - PermissionId = 13, - Code = "NAV:products.brand", - SubNavItemId = 3 - }, - new - { - PermissionId = 14, - Code = "NAV:products.item-type", - SubNavItemId = 4 - }, - new - { - PermissionId = 15, - Code = "NAV:products.uom", - SubNavItemId = 5 - }, - new - { - PermissionId = 16, - Code = "NAV:products.configuration", - SubNavItemId = 6 - }, - new - { - PermissionId = 17, - Code = "NAV:settings.roles", - SubNavItemId = 7 - }, - new - { - PermissionId = 18, - Code = "NAV:settings.users", - SubNavItemId = 8 - }, - new - { - PermissionId = 28, - Code = "NAV:procurement.requisitions", - SubNavItemId = 17 - }, - new - { - PermissionId = 29, - Code = "NAV:procurement.rfqs", - SubNavItemId = 18 - }, - new - { - PermissionId = 30, - Code = "NAV:procurement.purchase-orders", - SubNavItemId = 19 - }, - new - { - PermissionId = 31, - Code = "NAV:procurement.purchase-returns", - SubNavItemId = 20 - }, - new - { - PermissionId = 19, - Code = "NAV:ledgers", - NavItemId = 11 - }, - new - { - PermissionId = 20, - Code = "NAV:ledgers.trial-balance", - SubNavItemId = 9 - }, - new - { - PermissionId = 21, - Code = "NAV:ledgers.balance-sheet", - SubNavItemId = 10 - }, - new - { - PermissionId = 22, - Code = "NAV:ledgers.general-ledger", - SubNavItemId = 11 - }, - new - { - PermissionId = 23, - Code = "NAV:ledgers.profit-and-loss", - SubNavItemId = 12 - }, - new - { - PermissionId = 24, - Code = "NAV:ledgers.cash-flow", - SubNavItemId = 13 - }, - new - { - PermissionId = 25, - Code = "NAV:ledgers.budget-vs-actual", - SubNavItemId = 14 - }, - new - { - PermissionId = 27, - Code = "NAV:ledgers.tax-report", - SubNavItemId = 16 - }, - new - { - PermissionId = 26, - Code = "NAV:accounts.bank-accounts", - SubNavItemId = 15 - }, - new - { - PermissionId = 32, - Code = "NAV:accounts", - NavItemId = 12 - }, - new - { - PermissionId = 33, - Code = "NAV:accounts.cheque-books", - SubNavItemId = 21 - }, - new - { - PermissionId = 34, - Code = "NAV:accounts.received-cheques", - SubNavItemId = 22 - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b => - { - b.Property("PoLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PoId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Tax") - .HasPrecision(9, 4) - .HasColumnType("numeric(9,4)"); - - b.Property("UnitPrice") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.Property("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.ProductConfig", b => - { - b.Property("ConfigId") - .HasColumnType("integer"); - - b.Property("BrandsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("ItemTypesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SubcategoriesEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("UpdatedBy") - .HasColumnType("integer"); - - b.HasKey("ConfigId"); - - b.HasIndex("UpdatedBy"); - - b.ToTable("product_config", null, t => - { - t.HasCheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ProductionRun", b => - { - b.Property("RunId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RunId")); - - b.Property("CancelReasonCodeId") - .HasColumnType("integer"); - - b.Property("CompletedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("OutputBinId") - .HasColumnType("integer"); - - b.Property("ReworkCount") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("ScaleFactor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TargetQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("TemplateId") - .HasColumnType("integer"); - - b.Property("WarehouseId") - .HasColumnType("integer"); - - b.HasKey("RunId"); - - b.HasIndex("CancelReasonCodeId"); - - b.HasIndex("CreatedBy"); - - b.HasIndex("DocNo") - .IsUnique(); - - b.HasIndex("OutputBinId"); - - b.HasIndex("Status"); - - b.HasIndex("WarehouseId"); - - b.HasIndex("TemplateId", "Status"); - - b.ToTable("production_runs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ProductionTemplate", b => - { - b.Property("TemplateId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TemplateId")); - - b.Property("Annotations") - .HasColumnType("jsonb"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("character varying(150)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.HasKey("TemplateId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("CreatedBy"); - - b.HasIndex("Status"); - - b.ToTable("production_templates", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b => - { - b.Property("PoId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("PoId")); - - b.Property("ApprovalRequired") - .HasColumnType("boolean"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("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("ReturnId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("VendorId") - .HasColumnType("integer"); - - b.Property("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("ReturnLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReturnLineId")); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("ReasonCodeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReasonCodeId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Context") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("RequisitionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RequisitionId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequestedBy") - .HasColumnType("integer"); - - b.Property("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("ReqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RequiredBy") - .HasColumnType("date"); - - b.Property("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("RfqId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RequisitionId") - .HasColumnType("integer"); - - b.Property("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("RfqLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RfqLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.HasKey("RfqLineId"); - - b.HasIndex("ItemId"); - - b.HasIndex("RfqId"); - - b.ToTable("rfq_lines", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Role", b => - { - b.Property("RoleId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RoleId")); - - b.Property("AuthRoleId") - .HasColumnType("uuid") - .HasColumnName("auth_role_id"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsSystemRole") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(false); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("RoleId"); - - b.HasIndex("AuthRoleId") - .IsUnique(); - - b.HasIndex("Code") - .IsUnique(); - - b.ToTable("roles", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RolePermission", b => - { - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("PermissionId") - .HasColumnType("integer"); - - b.HasKey("RoleId", "PermissionId"); - - b.HasIndex("PermissionId"); - - b.ToTable("role_permissions", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunEdge", b => - { - b.Property("RunEdgeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RunEdgeId")); - - b.Property("ChildRunStageId") - .HasColumnType("integer"); - - b.Property("ParentRunStageId") - .HasColumnType("integer"); - - b.Property("RunId") - .HasColumnType("integer"); - - b.HasKey("RunEdgeId"); - - b.HasIndex("ChildRunStageId"); - - b.HasIndex("RunId"); - - b.HasIndex("ParentRunStageId", "ChildRunStageId") - .IsUnique(); - - b.ToTable("run_edges", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunStage", b => - { - b.Property("RunStageId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RunStageId")); - - b.Property("ActualEndAt") - .HasColumnType("timestamp with time zone"); - - b.Property("ActualStartAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EstimatedMinutes") - .HasColumnType("integer"); - - b.Property("FieldDefs") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("FieldValues") - .HasColumnType("jsonb"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("character varying(150)"); - - b.Property("PosX") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("PosY") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RoleLabel") - .HasMaxLength(60) - .HasColumnType("character varying(60)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("RunId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("TemplateStageId") - .HasColumnType("integer"); - - b.HasKey("RunStageId"); - - b.HasIndex("TemplateStageId"); - - b.HasIndex("RunId", "Status"); - - b.ToTable("run_stages", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunStageEvent", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EventId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EventType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Note") - .HasMaxLength(500) - .HasColumnType("character varying(500)"); - - b.Property("Payload") - .HasColumnType("jsonb"); - - b.Property("RunId") - .HasColumnType("integer"); - - b.Property("RunStageId") - .HasColumnType("integer"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.HasKey("EventId"); - - b.HasIndex("RunStageId"); - - b.HasIndex("UserId"); - - b.HasIndex("RunId", "EventId"); - - b.ToTable("run_stage_events", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunStageInput", b => - { - b.Property("RunInputId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RunInputId")); - - b.Property("ConsumedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ConsumedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("DeliveredQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("FromRunOutputId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("PlannedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReturnedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReturnedValue") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunStageId") - .HasColumnType("integer"); - - b.Property("Source") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.HasKey("RunInputId"); - - b.HasIndex("FromRunOutputId"); - - b.HasIndex("ItemId"); - - b.HasIndex("RunStageId"); - - b.HasIndex("UomId"); - - b.ToTable("run_stage_inputs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunStageOutput", b => - { - b.Property("RunOutputId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("RunOutputId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("character varying(150)"); - - b.Property("PlannedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ProducedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunStageId") - .HasColumnType("integer"); - - b.Property("ScrapReasonCodeId") - .HasColumnType("integer"); - - b.Property("ScrappedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("TransferredQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.HasKey("RunOutputId"); - - b.HasIndex("ItemId"); - - b.HasIndex("RunStageId"); - - b.HasIndex("ScrapReasonCodeId"); - - b.HasIndex("UomId"); - - b.ToTable("run_stage_outputs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SalaryComponent", b => - { - b.Property("SalaryComponentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SalaryComponentId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("ComponentType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("IsEpfEtfApplicable") - .HasColumnType("boolean"); - - b.Property("IsTaxable") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SalaryComponentId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_salary_components", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b => - { - b.Property("SerialId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SerialId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SerialNo") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("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.StageEdge", b => - { - b.Property("EdgeId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EdgeId")); - - b.Property("ChildStageId") - .HasColumnType("integer"); - - b.Property("ParentStageId") - .HasColumnType("integer"); - - b.Property("TemplateId") - .HasColumnType("integer"); - - b.HasKey("EdgeId"); - - b.HasIndex("ChildStageId"); - - b.HasIndex("TemplateId"); - - b.HasIndex("ParentStageId", "ChildStageId") - .IsUnique(); - - b.ToTable("stage_edges", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.StageInput", b => - { - b.Property("InputId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("InputId")); - - b.Property("FromOutputId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyPerBatch") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("Source") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("StageId") - .HasColumnType("integer"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.HasKey("InputId"); - - b.HasIndex("FromOutputId"); - - b.HasIndex("ItemId"); - - b.HasIndex("StageId"); - - b.HasIndex("UomId"); - - b.ToTable("stage_inputs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.StageOutput", b => - { - b.Property("OutputId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("OutputId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("character varying(150)"); - - b.Property("QtyPerBatch") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("StageId") - .HasColumnType("integer"); - - b.Property("UomId") - .HasColumnType("integer"); - - b.HasKey("OutputId"); - - b.HasIndex("ItemId"); - - b.HasIndex("StageId"); - - b.HasIndex("UomId"); - - b.ToTable("stage_outputs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.StockAdjustment", b => - { - b.Property("AdjustmentId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjustmentId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("ReasonCodeId") - .HasColumnType("integer"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("AdjLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AdjLineId")); - - b.Property("AdjustmentId") - .HasColumnType("integer"); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyDelta") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("CountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountId")); - - b.Property("CountType") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("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("CountLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CountLineId")); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CountId") - .HasColumnType("integer"); - - b.Property("CountedQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SystemQty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("LayerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LayerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("GrnLineId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyRemaining") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("ReceiptDate") - .HasColumnType("timestamp with time zone"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("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("LedgerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("LedgerId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("BinId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Direction") - .IsRequired() - .HasMaxLength(5) - .HasColumnType("character varying(5)"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("QtyBase") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RunningBalance") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SourceDocId") - .HasColumnType("integer"); - - b.Property("SourceDocType") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)"); - - b.Property("UnitCost") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.Property("Value") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("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("TransferId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("integer"); - - b.Property("DestWarehouseId") - .HasColumnType("integer"); - - b.Property("DocNo") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("character varying(30)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("SrcWarehouseId") - .HasColumnType("integer"); - - b.Property("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("TransferLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransferLineId")); - - b.Property("BatchId") - .HasColumnType("integer"); - - b.Property("DestBinId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("Qty") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("QtyReceived") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("SerialId") - .HasColumnType("integer"); - - b.Property("SrcBinId") - .HasColumnType("integer"); - - b.Property("TransferId") - .HasColumnType("integer"); - - b.Property("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.SubCategory", b => - { - b.Property("SubCategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubCategoryId")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("SubCategoryId"); - - b.HasIndex("Status"); - - b.HasIndex("CategoryId", "Name") - .IsUnique(); - - b.ToTable("subcategories", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.Property("SubNavItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SubNavItemId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Href") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Icon") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("NavItemId") - .HasColumnType("integer"); - - b.Property("SortOrder") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.HasKey("SubNavItemId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("NavItemId"); - - b.ToTable("sub_nav_items", (string)null); - - b.HasData( - new - { - SubNavItemId = 1, - Code = "products.item", - Href = "/dashboard/products", - Label = "Item", - NavItemId = 2, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 2, - Code = "products.category", - Href = "/dashboard/products/categories", - Label = "Category", - NavItemId = 2, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 3, - Code = "products.brand", - Href = "/dashboard/products/brands", - Label = "Brand", - NavItemId = 2, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 4, - Code = "products.item-type", - Href = "/dashboard/products/item-types", - Label = "Item Type", - NavItemId = 2, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 5, - Code = "products.uom", - Href = "/dashboard/products/uoms", - Label = "UOM", - NavItemId = 2, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 6, - Code = "products.configuration", - Href = "/dashboard/products/settings", - Label = "Configuration", - NavItemId = 2, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 7, - Code = "settings.roles", - Href = "/dashboard/settings/roles", - Label = "Roles", - NavItemId = 9, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 8, - Code = "settings.users", - Href = "/dashboard/settings/users", - Label = "Users", - NavItemId = 9, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 17, - Code = "procurement.requisitions", - Href = "/dashboard/procurement/requisitions", - Label = "Requisitions", - NavItemId = 4, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 18, - Code = "procurement.rfqs", - Href = "/dashboard/procurement/rfqs", - Label = "RFQs", - NavItemId = 4, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 19, - Code = "procurement.purchase-orders", - Href = "/dashboard/procurement/purchase-orders", - Label = "Purchase Orders", - NavItemId = 4, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 20, - Code = "procurement.purchase-returns", - Href = "/dashboard/procurement/purchase-returns", - Label = "Purchase Returns", - NavItemId = 4, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 9, - Code = "ledgers.trial-balance", - Href = "/dashboard/ledgers/trial-balance", - Label = "Trial Balance", - NavItemId = 11, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 10, - Code = "ledgers.balance-sheet", - Href = "/dashboard/ledgers/balance-sheet", - Label = "Balance Sheet", - NavItemId = 11, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 11, - Code = "ledgers.general-ledger", - Href = "/dashboard/ledgers/general-ledger", - Label = "General Ledger", - NavItemId = 11, - SortOrder = 3, - Status = "Active" - }, - new - { - SubNavItemId = 12, - Code = "ledgers.profit-and-loss", - Href = "/dashboard/ledgers/profit-and-loss", - Label = "Profit & Loss", - NavItemId = 11, - SortOrder = 4, - Status = "Active" - }, - new - { - SubNavItemId = 13, - Code = "ledgers.cash-flow", - Href = "/dashboard/ledgers/cash-flow", - Label = "Cash Flow", - NavItemId = 11, - SortOrder = 5, - Status = "Active" - }, - new - { - SubNavItemId = 14, - Code = "ledgers.budget-vs-actual", - Href = "/dashboard/ledgers/budget-vs-actual", - Label = "Budget vs Actual", - NavItemId = 11, - SortOrder = 6, - Status = "Active" - }, - new - { - SubNavItemId = 16, - Code = "ledgers.tax-report", - Href = "/dashboard/ledgers/tax-report", - Label = "Tax Report", - NavItemId = 11, - SortOrder = 7, - Status = "Active" - }, - new - { - SubNavItemId = 15, - Code = "accounts.bank-accounts", - Href = "/dashboard/accounts/bank-accounts", - Label = "Cash / Bank Accounts", - NavItemId = 12, - SortOrder = 1, - Status = "Active" - }, - new - { - SubNavItemId = 21, - Code = "accounts.cheque-books", - Href = "/dashboard/accounts/cheque-books", - Label = "Cheque Books", - NavItemId = 12, - SortOrder = 2, - Status = "Active" - }, - new - { - SubNavItemId = 22, - Code = "accounts.received-cheques", - Href = "/dashboard/accounts/received-cheques", - Label = "Received Cheques", - NavItemId = 12, - SortOrder = 3, - Status = "Active" - }); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.TaxSlab", b => - { - b.Property("TaxSlabId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TaxSlabId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveFrom") - .HasColumnType("timestamp with time zone"); - - b.Property("EffectiveTo") - .HasColumnType("timestamp with time zone"); - - b.Property("LowerBound") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.Property("Rate") - .HasPrecision(6, 4) - .HasColumnType("numeric(6,4)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("UpperBound") - .HasPrecision(18, 2) - .HasColumnType("numeric(18,2)"); - - b.HasKey("TaxSlabId"); - - b.HasIndex("EffectiveFrom"); - - b.ToTable("hr_tax_slabs", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.TemplateStage", b => - { - b.Property("StageId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("StageId")); - - b.Property("EstimatedMinutes") - .HasColumnType("integer"); - - b.Property("FieldDefs") - .IsRequired() - .HasColumnType("jsonb"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("character varying(150)"); - - b.Property("PosX") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("PosY") - .HasPrecision(18, 4) - .HasColumnType("numeric(18,4)"); - - b.Property("RoleLabel") - .HasMaxLength(60) - .HasColumnType("character varying(60)"); - - b.Property("TemplateId") - .HasColumnType("integer"); - - b.HasKey("StageId"); - - b.HasIndex("TemplateId"); - - b.ToTable("template_stages", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b => - { - b.Property("UomId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UomId")); - - b.Property("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("ConversionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ConversionId")); - - b.Property("Factor") - .HasPrecision(18, 6) - .HasColumnType("numeric(18,6)"); - - b.Property("FromUomId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("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("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); - - b.Property("AuthUserId") - .HasColumnType("uuid") - .HasColumnName("auth_user_id"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Email") - .HasMaxLength(320) - .HasColumnType("character varying(320)"); - - b.Property("RoleId") - .HasColumnType("integer"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.HasKey("UserId"); - - b.HasIndex("AuthUserId") - .IsUnique(); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("RoleId"); - - 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("VendorId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VendorId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Currency") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(3) - .HasColumnType("character varying(3)") - .HasDefaultValue("LKR"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("TaxReg") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Terms") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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("QuotationId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationId")); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("RfqId") - .HasColumnType("integer"); - - b.Property("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("QuotationLineId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("QuotationLineId")); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("LeadDays") - .HasColumnType("integer"); - - b.Property("QuotationId") - .HasColumnType("integer"); - - b.Property("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("WarehouseId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WarehouseId")); - - b.Property("Code") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("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.WorkShift", b => - { - b.Property("WorkShiftId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("WorkShiftId")); - - b.Property("BreakMinutes") - .HasColumnType("integer"); - - b.Property("Code") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("character varying(20)"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("EndTime") - .HasColumnType("interval"); - - b.Property("GraceMinutes") - .HasColumnType("integer"); - - b.Property("IsOvernight") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("OtMultiplier") - .HasPrecision(6, 2) - .HasColumnType("numeric(6,2)"); - - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.Property("StandardWorkingMinutes") - .HasColumnType("integer"); - - b.Property("StartTime") - .HasColumnType("interval"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasDefaultValue("Active"); - - b.Property("UpdatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("WorkingDaysMask") - .HasColumnType("integer"); - - b.HasKey("WorkShiftId"); - - b.HasIndex("Code") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("hr_work_shifts", (string)null); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.AttendanceRecord", b => - { - b.HasOne("ERPCore.Domain.Entities.AttendanceUploadBatch", "AttendanceUploadBatch") - .WithMany() - .HasForeignKey("AttendanceUploadBatchId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.WorkShift", "WorkShift") - .WithMany() - .HasForeignKey("WorkShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("AttendanceUploadBatch"); - - b.Navigation("Employee"); - - b.Navigation("WorkShift"); - }); - - 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.Department", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Employee", "HeadEmployee") - .WithMany() - .HasForeignKey("HeadEmployeeId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Department", "ParentDepartment") - .WithMany() - .HasForeignKey("ParentDepartmentId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Branch"); - - b.Navigation("HeadEmployee"); - - b.Navigation("ParentDepartment"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Employee", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Department", "Department") - .WithMany() - .HasForeignKey("DepartmentId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Designation", "Designation") - .WithMany() - .HasForeignKey("DesignationId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.EmploymentType", "EmploymentType") - .WithMany() - .HasForeignKey("EmploymentTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Employee", "ReportingManager") - .WithMany() - .HasForeignKey("ReportingManagerId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.User", "User") - .WithOne() - .HasForeignKey("ERPCore.Domain.Entities.Employee", "UserId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.WorkShift", "WorkShift") - .WithMany() - .HasForeignKey("WorkShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Branch"); - - b.Navigation("Department"); - - b.Navigation("Designation"); - - b.Navigation("EmploymentType"); - - b.Navigation("ReportingManager"); - - b.Navigation("User"); - - b.Navigation("WorkShift"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeBankDetail", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeDocument", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.HrDocumentType", "HrDocumentType") - .WithMany() - .HasForeignKey("HrDocumentTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("HrDocumentType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructureLine", b => - { - b.HasOne("ERPCore.Domain.Entities.EmployeeSalaryStructure", "EmployeeSalaryStructure") - .WithMany("Lines") - .HasForeignKey("EmployeeSalaryStructureId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.SalaryComponent", "SalaryComponent") - .WithMany() - .HasForeignKey("SalaryComponentId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("EmployeeSalaryStructure"); - - b.Navigation("SalaryComponent"); - }); - - 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.Brand", "Brand") - .WithMany() - .HasForeignKey("BrandId") - .OnDelete(DeleteBehavior.Restrict); - - 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.HasOne("ERPCore.Domain.Entities.SubCategory", "SubCategory") - .WithMany() - .HasForeignKey("SubCategoryId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("BaseUom"); - - b.Navigation("Brand"); - - b.Navigation("Category"); - - b.Navigation("DefaultVendor"); - - b.Navigation("SubCategory"); - }); - - 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.LeaveBalance", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.LeaveType", "LeaveType") - .WithMany() - .HasForeignKey("LeaveTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("LeaveType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LeaveRequest", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.LeaveType", "LeaveType") - .WithMany() - .HasForeignKey("LeaveTypeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("LeaveType"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.LoanInstallment", b => - { - b.HasOne("ERPCore.Domain.Entities.EmployeeLoan", "EmployeeLoan") - .WithMany("Installments") - .HasForeignKey("EmployeeLoanId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.PayrollRun", "PayrollRun") - .WithMany() - .HasForeignKey("PayrollRunId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EmployeeLoan"); - - b.Navigation("PayrollRun"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.HasOne("ERPCore.Domain.Entities.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.PayrollRun", "PayrollRun") - .WithMany("Lines") - .HasForeignKey("PayrollRunId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Employee"); - - b.Navigation("PayrollRun"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLineComponent", b => - { - b.HasOne("ERPCore.Domain.Entities.PayrollLine", "PayrollLine") - .WithMany("Components") - .HasForeignKey("PayrollLineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.SalaryComponent", "SalaryComponent") - .WithMany() - .HasForeignKey("SalaryComponentId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("PayrollLine"); - - b.Navigation("SalaryComponent"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") - .WithMany() - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Branch"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Payslip", b => - { - b.HasOne("ERPCore.Domain.Entities.PayrollLine", "PayrollLine") - .WithOne() - .HasForeignKey("ERPCore.Domain.Entities.Payslip", "PayrollLineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("PayrollLine"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.Permission", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany() - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("ERPCore.Domain.Entities.SubNavItem", "SubNavItem") - .WithMany() - .HasForeignKey("SubNavItemId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("NavItem"); - - b.Navigation("SubNavItem"); - }); - - 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.ProductConfig", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser") - .WithMany() - .HasForeignKey("UpdatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("UpdatedByUser"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ProductionRun", b => - { - b.HasOne("ERPCore.Domain.Entities.ReasonCode", "CancelReason") - .WithMany() - .HasForeignKey("CancelReasonCodeId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.User", "Creator") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Bin", "OutputBin") - .WithMany() - .HasForeignKey("OutputBinId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.ProductionTemplate", "Template") - .WithMany("Runs") - .HasForeignKey("TemplateId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse") - .WithMany() - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("CancelReason"); - - b.Navigation("Creator"); - - b.Navigation("OutputBin"); - - b.Navigation("Template"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ProductionTemplate", b => - { - b.HasOne("ERPCore.Domain.Entities.User", "Creator") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Creator"); - }); - - 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.RolePermission", b => - { - b.HasOne("ERPCore.Domain.Entities.Permission", "Permission") - .WithMany() - .HasForeignKey("PermissionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Permission"); - - b.Navigation("Role"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunEdge", b => - { - b.HasOne("ERPCore.Domain.Entities.RunStage", "ChildRunStage") - .WithMany() - .HasForeignKey("ChildRunStageId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.RunStage", "ParentRunStage") - .WithMany() - .HasForeignKey("ParentRunStageId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.ProductionRun", "Run") - .WithMany("Edges") - .HasForeignKey("RunId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ChildRunStage"); - - b.Navigation("ParentRunStage"); - - b.Navigation("Run"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunStage", b => - { - b.HasOne("ERPCore.Domain.Entities.ProductionRun", "Run") - .WithMany("Stages") - .HasForeignKey("RunId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.TemplateStage", "TemplateStage") - .WithMany() - .HasForeignKey("TemplateStageId") - .OnDelete(DeleteBehavior.SetNull); - - b.Navigation("Run"); - - b.Navigation("TemplateStage"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunStageEvent", b => - { - b.HasOne("ERPCore.Domain.Entities.ProductionRun", "Run") - .WithMany("Events") - .HasForeignKey("RunId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.RunStage", "RunStage") - .WithMany("Events") - .HasForeignKey("RunStageId") - .OnDelete(DeleteBehavior.SetNull); - - b.HasOne("ERPCore.Domain.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Run"); - - b.Navigation("RunStage"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunStageInput", b => - { - b.HasOne("ERPCore.Domain.Entities.RunStageOutput", "FromRunOutput") - .WithMany() - .HasForeignKey("FromRunOutputId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Item", "Item") - .WithMany() - .HasForeignKey("ItemId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.RunStage", "RunStage") - .WithMany("Inputs") - .HasForeignKey("RunStageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Uom", "Uom") - .WithMany() - .HasForeignKey("UomId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("FromRunOutput"); - - b.Navigation("Item"); - - b.Navigation("RunStage"); - - b.Navigation("Uom"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.RunStageOutput", b => - { - b.HasOne("ERPCore.Domain.Entities.Item", "Item") - .WithMany() - .HasForeignKey("ItemId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.RunStage", "RunStage") - .WithMany("Outputs") - .HasForeignKey("RunStageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.ReasonCode", "ScrapReason") - .WithMany() - .HasForeignKey("ScrapReasonCodeId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Uom", "Uom") - .WithMany() - .HasForeignKey("UomId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Item"); - - b.Navigation("RunStage"); - - b.Navigation("ScrapReason"); - - b.Navigation("Uom"); - }); - - 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.StageEdge", b => - { - b.HasOne("ERPCore.Domain.Entities.TemplateStage", "ChildStage") - .WithMany() - .HasForeignKey("ChildStageId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.TemplateStage", "ParentStage") - .WithMany() - .HasForeignKey("ParentStageId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.ProductionTemplate", "Template") - .WithMany("Edges") - .HasForeignKey("TemplateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ChildStage"); - - b.Navigation("ParentStage"); - - b.Navigation("Template"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.StageInput", b => - { - b.HasOne("ERPCore.Domain.Entities.StageOutput", "FromOutput") - .WithMany() - .HasForeignKey("FromOutputId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.Item", "Item") - .WithMany() - .HasForeignKey("ItemId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.TemplateStage", "Stage") - .WithMany("Inputs") - .HasForeignKey("StageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Uom", "Uom") - .WithMany() - .HasForeignKey("UomId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("FromOutput"); - - b.Navigation("Item"); - - b.Navigation("Stage"); - - b.Navigation("Uom"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.StageOutput", b => - { - b.HasOne("ERPCore.Domain.Entities.Item", "Item") - .WithMany() - .HasForeignKey("ItemId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("ERPCore.Domain.Entities.TemplateStage", "Stage") - .WithMany("Outputs") - .HasForeignKey("StageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ERPCore.Domain.Entities.Uom", "Uom") - .WithMany() - .HasForeignKey("UomId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Item"); - - b.Navigation("Stage"); - - b.Navigation("Uom"); - }); - - 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.SubCategory", b => - { - b.HasOne("ERPCore.Domain.Entities.Category", "Category") - .WithMany("SubCategories") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.SubNavItem", b => - { - b.HasOne("ERPCore.Domain.Entities.NavItem", "NavItem") - .WithMany("Children") - .HasForeignKey("NavItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NavItem"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.TemplateStage", b => - { - b.HasOne("ERPCore.Domain.Entities.ProductionTemplate", "Template") - .WithMany("Stages") - .HasForeignKey("TemplateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Template"); - }); - - 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.User", b => - { - b.HasOne("ERPCore.Domain.Entities.Role", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Role"); - }); - - 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("SubCategories"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeLoan", b => - { - b.Navigation("Installments"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.EmployeeSalaryStructure", b => - { - b.Navigation("Lines"); - }); - - 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.NavItem", b => - { - b.Navigation("Children"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b => - { - b.Navigation("Components"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.PayrollRun", b => - { - b.Navigation("Lines"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ProductionRun", b => - { - b.Navigation("Edges"); - - b.Navigation("Events"); - - b.Navigation("Stages"); - }); - - modelBuilder.Entity("ERPCore.Domain.Entities.ProductionTemplate", b => - { - b.Navigation("Edges"); - - b.Navigation("Runs"); - - b.Navigation("Stages"); - }); - - 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.RunStage", b => - { - b.Navigation("Events"); - - b.Navigation("Inputs"); - - b.Navigation("Outputs"); - }); - - 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.TemplateStage", b => - { - b.Navigation("Inputs"); - - b.Navigation("Outputs"); - }); - - 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 - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260731131856_AddMissingHrmAndManufacturingTables.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260731131856_AddMissingHrmAndManufacturingTables.cs deleted file mode 100644 index 755d721..0000000 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260731131856_AddMissingHrmAndManufacturingTables.cs +++ /dev/null @@ -1,1871 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ERPCore.Infra.Persistence.Migrations -{ - /// - public partial class AddMissingHrmAndManufacturingTables : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "hr_attendance_upload_batches", - columns: table => new - { - AttendanceUploadBatchId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - PeriodStart = table.Column(type: "timestamp with time zone", nullable: false), - PeriodEnd = table.Column(type: "timestamp with time zone", nullable: false), - SourceType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - OriginalFileName = table.Column(type: "character varying(260)", maxLength: 260, nullable: true), - UploadedBy = table.Column(type: "integer", nullable: false), - UploadedAt = table.Column(type: "timestamp with time zone", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ConfirmedBy = table.Column(type: "integer", nullable: true), - ConfirmedAt = table.Column(type: "timestamp with time zone", nullable: true), - RowCountTotal = table.Column(type: "integer", nullable: false), - RowCountDuplicate = table.Column(type: "integer", nullable: false), - RowCountError = table.Column(type: "integer", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_attendance_upload_batches", x => x.AttendanceUploadBatchId); - }); - - migrationBuilder.CreateTable( - name: "hr_branches", - columns: table => new - { - BranchId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Address = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_branches", x => x.BranchId); - }); - - migrationBuilder.CreateTable( - name: "hr_designations", - columns: table => new - { - DesignationId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_designations", x => x.DesignationId); - }); - - migrationBuilder.CreateTable( - name: "hr_document_types", - columns: table => new - { - HrDocumentTypeId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Category = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - RequiredAtOnboarding = table.Column(type: "boolean", nullable: false), - ExpiryTracked = table.Column(type: "boolean", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_document_types", x => x.HrDocumentTypeId); - }); - - migrationBuilder.CreateTable( - name: "hr_employment_types", - columns: table => new - { - EmploymentTypeId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_employment_types", x => x.EmploymentTypeId); - }); - - migrationBuilder.CreateTable( - name: "hr_leave_types", - columns: table => new - { - LeaveTypeId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - IsPaid = table.Column(type: "boolean", nullable: false), - CountsAsNoPay = table.Column(type: "boolean", nullable: false), - AccrualPerYear = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), - CarryForwardAllowed = table.Column(type: "boolean", nullable: false), - MaxCarryForwardDays = table.Column(type: "integer", nullable: true), - RequiresApproval = table.Column(type: "boolean", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_leave_types", x => x.LeaveTypeId); - }); - - migrationBuilder.CreateTable( - name: "hr_payroll_statutory_settings", - columns: table => new - { - PayrollStatutorySettingId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EpfEmployeeRate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), - EpfEmployerRate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), - EtfEmployerRate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), - OtMultiplierDefault = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), - EffectiveFrom = table.Column(type: "timestamp with time zone", nullable: false), - EffectiveTo = table.Column(type: "timestamp with time zone", nullable: true), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_payroll_statutory_settings", x => x.PayrollStatutorySettingId); - }); - - migrationBuilder.CreateTable( - name: "hr_salary_components", - columns: table => new - { - SalaryComponentId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - ComponentType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - IsTaxable = table.Column(type: "boolean", nullable: false), - IsEpfEtfApplicable = table.Column(type: "boolean", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_salary_components", x => x.SalaryComponentId); - }); - - migrationBuilder.CreateTable( - name: "hr_tax_slabs", - columns: table => new - { - TaxSlabId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EffectiveFrom = table.Column(type: "timestamp with time zone", nullable: false), - EffectiveTo = table.Column(type: "timestamp with time zone", nullable: true), - LowerBound = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), - UpperBound = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), - Rate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_tax_slabs", x => x.TaxSlabId); - }); - - migrationBuilder.CreateTable( - name: "hr_work_shifts", - columns: table => new - { - WorkShiftId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - StartTime = table.Column(type: "interval", nullable: false), - EndTime = table.Column(type: "interval", nullable: false), - IsOvernight = table.Column(type: "boolean", nullable: false), - GraceMinutes = table.Column(type: "integer", nullable: false), - BreakMinutes = table.Column(type: "integer", nullable: false), - StandardWorkingMinutes = table.Column(type: "integer", nullable: false), - OtMultiplier = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), - WorkingDaysMask = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_work_shifts", x => x.WorkShiftId); - }); - - migrationBuilder.CreateTable( - name: "production_templates", - columns: table => new - { - TemplateId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), - Description = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Annotations = table.Column(type: "jsonb", nullable: true), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_production_templates", x => x.TemplateId); - table.ForeignKey( - name: "FK_production_templates_users_CreatedBy", - column: x => x.CreatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_payroll_runs", - columns: table => new - { - PayrollRunId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - PeriodYear = table.Column(type: "integer", nullable: false), - PeriodMonth = table.Column(type: "integer", nullable: false), - BranchId = table.Column(type: "integer", nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - GeneratedBy = table.Column(type: "integer", nullable: false), - GeneratedAt = table.Column(type: "timestamp with time zone", nullable: false), - ApprovedBy = table.Column(type: "integer", nullable: true), - ApprovedAt = table.Column(type: "timestamp with time zone", nullable: true), - LockedBy = table.Column(type: "integer", nullable: true), - LockedAt = table.Column(type: "timestamp with time zone", nullable: true), - UnlockedBy = table.Column(type: "integer", nullable: true), - UnlockedAt = table.Column(type: "timestamp with time zone", nullable: true), - UnlockReason = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_payroll_runs", x => x.PayrollRunId); - table.ForeignKey( - name: "FK_hr_payroll_runs_hr_branches_BranchId", - column: x => x.BranchId, - principalTable: "hr_branches", - principalColumn: "BranchId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "production_runs", - columns: table => new - { - RunId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - TemplateId = table.Column(type: "integer", nullable: false), - WarehouseId = table.Column(type: "integer", nullable: false), - OutputBinId = table.Column(type: "integer", nullable: true), - TargetQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ScaleFactor = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ReworkCount = table.Column(type: "integer", nullable: false), - CancelReasonCodeId = table.Column(type: "integer", nullable: true), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - CompletedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_production_runs", x => x.RunId); - table.ForeignKey( - name: "FK_production_runs_bins_OutputBinId", - column: x => x.OutputBinId, - principalTable: "bins", - principalColumn: "BinId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_production_runs_production_templates_TemplateId", - column: x => x.TemplateId, - principalTable: "production_templates", - principalColumn: "TemplateId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_production_runs_reason_codes_CancelReasonCodeId", - column: x => x.CancelReasonCodeId, - principalTable: "reason_codes", - principalColumn: "ReasonCodeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_production_runs_users_CreatedBy", - column: x => x.CreatedBy, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_production_runs_warehouses_WarehouseId", - column: x => x.WarehouseId, - principalTable: "warehouses", - principalColumn: "WarehouseId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "template_stages", - columns: table => new - { - StageId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TemplateId = table.Column(type: "integer", nullable: false), - Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), - RoleLabel = table.Column(type: "character varying(60)", maxLength: 60, nullable: true), - EstimatedMinutes = table.Column(type: "integer", nullable: false), - PosX = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - PosY = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - FieldDefs = table.Column(type: "jsonb", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_template_stages", x => x.StageId); - table.ForeignKey( - name: "FK_template_stages_production_templates_TemplateId", - column: x => x.TemplateId, - principalTable: "production_templates", - principalColumn: "TemplateId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "run_stages", - columns: table => new - { - RunStageId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RunId = table.Column(type: "integer", nullable: false), - TemplateStageId = table.Column(type: "integer", nullable: true), - Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), - RoleLabel = table.Column(type: "character varying(60)", maxLength: 60, nullable: true), - EstimatedMinutes = table.Column(type: "integer", nullable: false), - PosX = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - PosY = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ActualStartAt = table.Column(type: "timestamp with time zone", nullable: true), - ActualEndAt = table.Column(type: "timestamp with time zone", nullable: true), - FieldDefs = table.Column(type: "jsonb", nullable: false), - FieldValues = table.Column(type: "jsonb", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_run_stages", x => x.RunStageId); - table.ForeignKey( - name: "FK_run_stages_production_runs_RunId", - column: x => x.RunId, - principalTable: "production_runs", - principalColumn: "RunId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_run_stages_template_stages_TemplateStageId", - column: x => x.TemplateStageId, - principalTable: "template_stages", - principalColumn: "StageId", - onDelete: ReferentialAction.SetNull); - }); - - migrationBuilder.CreateTable( - name: "stage_edges", - columns: table => new - { - EdgeId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TemplateId = table.Column(type: "integer", nullable: false), - ParentStageId = table.Column(type: "integer", nullable: false), - ChildStageId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stage_edges", x => x.EdgeId); - table.ForeignKey( - name: "FK_stage_edges_production_templates_TemplateId", - column: x => x.TemplateId, - principalTable: "production_templates", - principalColumn: "TemplateId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_stage_edges_template_stages_ChildStageId", - column: x => x.ChildStageId, - principalTable: "template_stages", - principalColumn: "StageId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stage_edges_template_stages_ParentStageId", - column: x => x.ParentStageId, - principalTable: "template_stages", - principalColumn: "StageId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "stage_outputs", - columns: table => new - { - OutputId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - StageId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: true), - Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), - UomId = table.Column(type: "integer", nullable: false), - QtyPerBatch = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stage_outputs", x => x.OutputId); - table.ForeignKey( - name: "FK_stage_outputs_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stage_outputs_template_stages_StageId", - column: x => x.StageId, - principalTable: "template_stages", - principalColumn: "StageId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_stage_outputs_uoms_UomId", - column: x => x.UomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "run_edges", - columns: table => new - { - RunEdgeId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RunId = table.Column(type: "integer", nullable: false), - ParentRunStageId = table.Column(type: "integer", nullable: false), - ChildRunStageId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_run_edges", x => x.RunEdgeId); - table.ForeignKey( - name: "FK_run_edges_production_runs_RunId", - column: x => x.RunId, - principalTable: "production_runs", - principalColumn: "RunId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_run_edges_run_stages_ChildRunStageId", - column: x => x.ChildRunStageId, - principalTable: "run_stages", - principalColumn: "RunStageId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_run_edges_run_stages_ParentRunStageId", - column: x => x.ParentRunStageId, - principalTable: "run_stages", - principalColumn: "RunStageId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "run_stage_events", - columns: table => new - { - EventId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RunId = table.Column(type: "integer", nullable: false), - RunStageId = table.Column(type: "integer", nullable: true), - EventType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Note = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), - Payload = table.Column(type: "jsonb", nullable: true), - UserId = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_run_stage_events", x => x.EventId); - table.ForeignKey( - name: "FK_run_stage_events_production_runs_RunId", - column: x => x.RunId, - principalTable: "production_runs", - principalColumn: "RunId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_run_stage_events_run_stages_RunStageId", - column: x => x.RunStageId, - principalTable: "run_stages", - principalColumn: "RunStageId", - onDelete: ReferentialAction.SetNull); - table.ForeignKey( - name: "FK_run_stage_events_users_UserId", - column: x => x.UserId, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "run_stage_outputs", - columns: table => new - { - RunOutputId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RunStageId = table.Column(type: "integer", nullable: false), - ItemId = table.Column(type: "integer", nullable: true), - Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), - UomId = table.Column(type: "integer", nullable: false), - PlannedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ProducedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ScrappedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ScrapReasonCodeId = table.Column(type: "integer", nullable: true), - TransferredQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_run_stage_outputs", x => x.RunOutputId); - table.ForeignKey( - name: "FK_run_stage_outputs_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_run_stage_outputs_reason_codes_ScrapReasonCodeId", - column: x => x.ScrapReasonCodeId, - principalTable: "reason_codes", - principalColumn: "ReasonCodeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_run_stage_outputs_run_stages_RunStageId", - column: x => x.RunStageId, - principalTable: "run_stages", - principalColumn: "RunStageId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_run_stage_outputs_uoms_UomId", - column: x => x.UomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "stage_inputs", - columns: table => new - { - InputId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - StageId = table.Column(type: "integer", nullable: false), - Source = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ItemId = table.Column(type: "integer", nullable: true), - FromOutputId = table.Column(type: "integer", nullable: true), - UomId = table.Column(type: "integer", nullable: false), - QtyPerBatch = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_stage_inputs", x => x.InputId); - table.ForeignKey( - name: "FK_stage_inputs_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stage_inputs_stage_outputs_FromOutputId", - column: x => x.FromOutputId, - principalTable: "stage_outputs", - principalColumn: "OutputId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_stage_inputs_template_stages_StageId", - column: x => x.StageId, - principalTable: "template_stages", - principalColumn: "StageId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_stage_inputs_uoms_UomId", - column: x => x.UomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "run_stage_inputs", - columns: table => new - { - RunInputId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RunStageId = table.Column(type: "integer", nullable: false), - Source = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ItemId = table.Column(type: "integer", nullable: true), - FromRunOutputId = table.Column(type: "integer", nullable: true), - UomId = table.Column(type: "integer", nullable: false), - PlannedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ConsumedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ConsumedValue = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - DeliveredQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ReturnedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), - ReturnedValue = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_run_stage_inputs", x => x.RunInputId); - table.ForeignKey( - name: "FK_run_stage_inputs_items_ItemId", - column: x => x.ItemId, - principalTable: "items", - principalColumn: "ItemId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_run_stage_inputs_run_stage_outputs_FromRunOutputId", - column: x => x.FromRunOutputId, - principalTable: "run_stage_outputs", - principalColumn: "RunOutputId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_run_stage_inputs_run_stages_RunStageId", - column: x => x.RunStageId, - principalTable: "run_stages", - principalColumn: "RunStageId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_run_stage_inputs_uoms_UomId", - column: x => x.UomId, - principalTable: "uoms", - principalColumn: "UomId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_attendance_records", - columns: table => new - { - AttendanceRecordId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - AttendanceUploadBatchId = table.Column(type: "integer", nullable: true), - EmployeeId = table.Column(type: "integer", nullable: false), - AttendanceDate = table.Column(type: "timestamp with time zone", nullable: false), - CheckIn = table.Column(type: "interval", nullable: true), - CheckOut = table.Column(type: "interval", nullable: true), - WorkShiftId = table.Column(type: "integer", nullable: false), - WorkingMinutes = table.Column(type: "integer", nullable: false), - LateMinutes = table.Column(type: "integer", nullable: false), - EarlyLeaveMinutes = table.Column(type: "integer", nullable: false), - OvertimeMinutes = table.Column(type: "integer", nullable: false), - AttendanceStatus = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - RowValidationStatus = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - DuplicateOfAttendanceRecordId = table.Column(type: "integer", nullable: true), - Notes = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), - IsManualOverride = table.Column(type: "boolean", nullable: false), - EditedBy = table.Column(type: "integer", nullable: true), - EditedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_attendance_records", x => x.AttendanceRecordId); - table.ForeignKey( - name: "FK_hr_attendance_records_hr_attendance_upload_batches_Attendan~", - column: x => x.AttendanceUploadBatchId, - principalTable: "hr_attendance_upload_batches", - principalColumn: "AttendanceUploadBatchId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_hr_attendance_records_hr_work_shifts_WorkShiftId", - column: x => x.WorkShiftId, - principalTable: "hr_work_shifts", - principalColumn: "WorkShiftId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_departments", - columns: table => new - { - DepartmentId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - ParentDepartmentId = table.Column(type: "integer", nullable: true), - HeadEmployeeId = table.Column(type: "integer", nullable: true), - BranchId = table.Column(type: "integer", nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_departments", x => x.DepartmentId); - table.ForeignKey( - name: "FK_hr_departments_hr_branches_BranchId", - column: x => x.BranchId, - principalTable: "hr_branches", - principalColumn: "BranchId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_departments_hr_departments_ParentDepartmentId", - column: x => x.ParentDepartmentId, - principalTable: "hr_departments", - principalColumn: "DepartmentId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_employees", - columns: table => new - { - EmployeeId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EmployeeCode = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - FullName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Nic = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), - DateOfBirth = table.Column(type: "timestamp with time zone", nullable: true), - Gender = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), - Nationality = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), - ProfilePhotoPath = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), - Email = table.Column(type: "character varying(320)", maxLength: 320, nullable: true), - PersonalMobile = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), - AddressLine1 = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), - AddressLine2 = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), - City = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), - PostalCode = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), - Country = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), - EmergencyContactName = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), - EmergencyContactRelationship = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), - EmergencyContactPhone = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), - HireDate = table.Column(type: "timestamp with time zone", nullable: false), - ConfirmationDate = table.Column(type: "timestamp with time zone", nullable: true), - LastWorkingDate = table.Column(type: "timestamp with time zone", nullable: true), - DepartmentId = table.Column(type: "integer", nullable: false), - DesignationId = table.Column(type: "integer", nullable: false), - EmploymentTypeId = table.Column(type: "integer", nullable: false), - BranchId = table.Column(type: "integer", nullable: true), - WorkShiftId = table.Column(type: "integer", nullable: false), - ReportingManagerId = table.Column(type: "integer", nullable: true), - EpfNumber = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), - EtfNumber = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), - TaxIdentificationNumber = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), - UserId = table.Column(type: "integer", nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedBy = table.Column(type: "integer", nullable: true), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_employees", x => x.EmployeeId); - table.ForeignKey( - name: "FK_hr_employees_hr_branches_BranchId", - column: x => x.BranchId, - principalTable: "hr_branches", - principalColumn: "BranchId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_employees_hr_departments_DepartmentId", - column: x => x.DepartmentId, - principalTable: "hr_departments", - principalColumn: "DepartmentId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_employees_hr_designations_DesignationId", - column: x => x.DesignationId, - principalTable: "hr_designations", - principalColumn: "DesignationId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_employees_hr_employees_ReportingManagerId", - column: x => x.ReportingManagerId, - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_employees_hr_employment_types_EmploymentTypeId", - column: x => x.EmploymentTypeId, - principalTable: "hr_employment_types", - principalColumn: "EmploymentTypeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_employees_hr_work_shifts_WorkShiftId", - column: x => x.WorkShiftId, - principalTable: "hr_work_shifts", - principalColumn: "WorkShiftId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_employees_users_UserId", - column: x => x.UserId, - principalTable: "users", - principalColumn: "UserId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_employee_bank_details", - columns: table => new - { - EmployeeBankDetailId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EmployeeId = table.Column(type: "integer", nullable: false), - BankName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - BranchName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - AccountNumber = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - AccountHolderName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - SwiftCode = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), - IsPrimary = table.Column(type: "boolean", nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_employee_bank_details", x => x.EmployeeBankDetailId); - table.ForeignKey( - name: "FK_hr_employee_bank_details_hr_employees_EmployeeId", - column: x => x.EmployeeId, - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "hr_employee_documents", - columns: table => new - { - EmployeeDocumentId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EmployeeId = table.Column(type: "integer", nullable: false), - HrDocumentTypeId = table.Column(type: "integer", nullable: false), - OriginalFileName = table.Column(type: "character varying(260)", maxLength: 260, nullable: false), - StoredFileName = table.Column(type: "character varying(260)", maxLength: 260, nullable: false), - RelativePath = table.Column(type: "character varying(500)", maxLength: 500, nullable: false), - ContentType = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - SizeBytes = table.Column(type: "bigint", nullable: false), - IssueDate = table.Column(type: "timestamp with time zone", nullable: true), - ExpiryDate = table.Column(type: "timestamp with time zone", nullable: true), - Notes = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), - UploadedBy = table.Column(type: "integer", nullable: false), - UploadedAt = table.Column(type: "timestamp with time zone", nullable: false), - VerifiedBy = table.Column(type: "integer", nullable: true), - VerifiedAt = table.Column(type: "timestamp with time zone", nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_employee_documents", x => x.EmployeeDocumentId); - table.ForeignKey( - name: "FK_hr_employee_documents_hr_document_types_HrDocumentTypeId", - column: x => x.HrDocumentTypeId, - principalTable: "hr_document_types", - principalColumn: "HrDocumentTypeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_employee_documents_hr_employees_EmployeeId", - column: x => x.EmployeeId, - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "hr_employee_loans", - columns: table => new - { - EmployeeLoanId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - EmployeeId = table.Column(type: "integer", nullable: false), - LoanKind = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - PrincipalAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), - InterestRate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), - InstallmentAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), - NumberOfInstallments = table.Column(type: "integer", nullable: false), - StartYear = table.Column(type: "integer", nullable: false), - StartMonth = table.Column(type: "integer", nullable: false), - OutstandingBalance = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ApprovedBy = table.Column(type: "integer", nullable: false), - ApprovedAt = table.Column(type: "timestamp with time zone", nullable: false), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_employee_loans", x => x.EmployeeLoanId); - table.ForeignKey( - name: "FK_hr_employee_loans_hr_employees_EmployeeId", - column: x => x.EmployeeId, - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_employee_salary_structures", - columns: table => new - { - EmployeeSalaryStructureId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EmployeeId = table.Column(type: "integer", nullable: false), - EffectiveFrom = table.Column(type: "timestamp with time zone", nullable: false), - EffectiveTo = table.Column(type: "timestamp with time zone", nullable: true), - BasicSalary = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), - Currency = table.Column(type: "character varying(3)", maxLength: 3, nullable: false), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ApprovedBy = table.Column(type: "integer", nullable: false), - ApprovedAt = table.Column(type: "timestamp with time zone", nullable: false), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_employee_salary_structures", x => x.EmployeeSalaryStructureId); - table.ForeignKey( - name: "FK_hr_employee_salary_structures_hr_employees_EmployeeId", - column: x => x.EmployeeId, - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_leave_balances", - columns: table => new - { - LeaveBalanceId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EmployeeId = table.Column(type: "integer", nullable: false), - LeaveTypeId = table.Column(type: "integer", nullable: false), - Year = table.Column(type: "integer", nullable: false), - EntitledDays = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), - TakenDays = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), - CarriedForwardDays = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), - AdjustmentDays = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false), - UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_leave_balances", x => x.LeaveBalanceId); - table.ForeignKey( - name: "FK_hr_leave_balances_hr_employees_EmployeeId", - column: x => x.EmployeeId, - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_leave_balances_hr_leave_types_LeaveTypeId", - column: x => x.LeaveTypeId, - principalTable: "hr_leave_types", - principalColumn: "LeaveTypeId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_leave_requests", - columns: table => new - { - LeaveRequestId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), - EmployeeId = table.Column(type: "integer", nullable: false), - LeaveTypeId = table.Column(type: "integer", nullable: false), - StartDate = table.Column(type: "timestamp with time zone", nullable: false), - EndDate = table.Column(type: "timestamp with time zone", nullable: false), - DaysCount = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), - Reason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - ApprovedBy = table.Column(type: "integer", nullable: true), - ApprovedAt = table.Column(type: "timestamp with time zone", nullable: true), - RejectionReason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), - CreatedBy = table.Column(type: "integer", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_leave_requests", x => x.LeaveRequestId); - table.ForeignKey( - name: "FK_hr_leave_requests_hr_employees_EmployeeId", - column: x => x.EmployeeId, - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_leave_requests_hr_leave_types_LeaveTypeId", - column: x => x.LeaveTypeId, - principalTable: "hr_leave_types", - principalColumn: "LeaveTypeId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_payroll_lines", - columns: table => new - { - PayrollLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - PayrollRunId = table.Column(type: "integer", nullable: false), - EmployeeId = table.Column(type: "integer", nullable: false), - BasicSalary = table.Column(type: "numeric(18,2)", nullable: false), - TotalAllowances = table.Column(type: "numeric(18,2)", nullable: false), - OvertimeAmount = table.Column(type: "numeric(18,2)", nullable: false), - GrossSalary = table.Column(type: "numeric(18,2)", nullable: false), - LateDeductionAmount = table.Column(type: "numeric(18,2)", nullable: false), - NoPayAmount = table.Column(type: "numeric(18,2)", nullable: false), - LoanDeductionAmount = table.Column(type: "numeric(18,2)", nullable: false), - EpfEmployeeAmount = table.Column(type: "numeric(18,2)", nullable: false), - EpfEmployerAmount = table.Column(type: "numeric(18,2)", nullable: false), - EtfEmployerAmount = table.Column(type: "numeric(18,2)", nullable: false), - TaxAmount = table.Column(type: "numeric(18,2)", nullable: false), - OtherDeductionsAmount = table.Column(type: "numeric(18,2)", nullable: false), - NetSalary = table.Column(type: "numeric(18,2)", nullable: false), - WorkingDays = table.Column(type: "integer", nullable: false), - PresentDays = table.Column(type: "integer", nullable: false), - AbsentDays = table.Column(type: "integer", nullable: false), - LeaveDays = table.Column(type: "integer", nullable: false), - OtMinutesTotal = table.Column(type: "integer", nullable: false), - LateMinutesTotal = table.Column(type: "integer", nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_payroll_lines", x => x.PayrollLineId); - table.ForeignKey( - name: "FK_hr_payroll_lines_hr_employees_EmployeeId", - column: x => x.EmployeeId, - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_hr_payroll_lines_hr_payroll_runs_PayrollRunId", - column: x => x.PayrollRunId, - principalTable: "hr_payroll_runs", - principalColumn: "PayrollRunId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "hr_loan_installments", - columns: table => new - { - LoanInstallmentId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EmployeeLoanId = table.Column(type: "integer", nullable: false), - InstallmentNumber = table.Column(type: "integer", nullable: false), - DueYear = table.Column(type: "integer", nullable: false), - DueMonth = table.Column(type: "integer", nullable: false), - ScheduledAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), - PaidAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), - PayrollRunId = table.Column(type: "integer", nullable: true), - Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - xmin = table.Column(type: "xid", rowVersion: true, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_loan_installments", x => x.LoanInstallmentId); - table.ForeignKey( - name: "FK_hr_loan_installments_hr_employee_loans_EmployeeLoanId", - column: x => x.EmployeeLoanId, - principalTable: "hr_employee_loans", - principalColumn: "EmployeeLoanId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_hr_loan_installments_hr_payroll_runs_PayrollRunId", - column: x => x.PayrollRunId, - principalTable: "hr_payroll_runs", - principalColumn: "PayrollRunId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_employee_salary_structure_lines", - columns: table => new - { - EmployeeSalaryStructureLineId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - EmployeeSalaryStructureId = table.Column(type: "integer", nullable: false), - SalaryComponentId = table.Column(type: "integer", nullable: false), - Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_employee_salary_structure_lines", x => x.EmployeeSalaryStructureLineId); - table.ForeignKey( - name: "FK_hr_employee_salary_structure_lines_hr_employee_salary_struc~", - column: x => x.EmployeeSalaryStructureId, - principalTable: "hr_employee_salary_structures", - principalColumn: "EmployeeSalaryStructureId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_hr_employee_salary_structure_lines_hr_salary_components_Sal~", - column: x => x.SalaryComponentId, - principalTable: "hr_salary_components", - principalColumn: "SalaryComponentId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_payroll_line_components", - columns: table => new - { - PayrollLineComponentId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - PayrollLineId = table.Column(type: "integer", nullable: false), - ComponentCategory = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), - SalaryComponentId = table.Column(type: "integer", nullable: true), - Label = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), - SortOrder = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_payroll_line_components", x => x.PayrollLineComponentId); - table.ForeignKey( - name: "FK_hr_payroll_line_components_hr_payroll_lines_PayrollLineId", - column: x => x.PayrollLineId, - principalTable: "hr_payroll_lines", - principalColumn: "PayrollLineId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_hr_payroll_line_components_hr_salary_components_SalaryCompo~", - column: x => x.SalaryComponentId, - principalTable: "hr_salary_components", - principalColumn: "SalaryComponentId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "hr_payslips", - columns: table => new - { - PayslipId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - PayrollLineId = table.Column(type: "integer", nullable: false), - GeneratedAt = table.Column(type: "timestamp with time zone", nullable: false), - ReleasedAt = table.Column(type: "timestamp with time zone", nullable: true), - ReleasedBy = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_hr_payslips", x => x.PayslipId); - table.ForeignKey( - name: "FK_hr_payslips_hr_payroll_lines_PayrollLineId", - column: x => x.PayrollLineId, - principalTable: "hr_payroll_lines", - principalColumn: "PayrollLineId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_hr_attendance_records_AttendanceUploadBatchId", - table: "hr_attendance_records", - column: "AttendanceUploadBatchId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_attendance_records_EmployeeId_AttendanceDate", - table: "hr_attendance_records", - columns: new[] { "EmployeeId", "AttendanceDate" }); - - migrationBuilder.CreateIndex( - name: "IX_hr_attendance_records_WorkShiftId", - table: "hr_attendance_records", - column: "WorkShiftId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_attendance_upload_batches_DocNo", - table: "hr_attendance_upload_batches", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_attendance_upload_batches_PeriodStart_PeriodEnd", - table: "hr_attendance_upload_batches", - columns: new[] { "PeriodStart", "PeriodEnd" }); - - migrationBuilder.CreateIndex( - name: "IX_hr_attendance_upload_batches_Status", - table: "hr_attendance_upload_batches", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_branches_Code", - table: "hr_branches", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_branches_Status", - table: "hr_branches", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_departments_BranchId", - table: "hr_departments", - column: "BranchId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_departments_Code", - table: "hr_departments", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_departments_HeadEmployeeId", - table: "hr_departments", - column: "HeadEmployeeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_departments_ParentDepartmentId", - table: "hr_departments", - column: "ParentDepartmentId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_departments_Status", - table: "hr_departments", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_designations_Code", - table: "hr_designations", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_designations_Status", - table: "hr_designations", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_document_types_Code", - table: "hr_document_types", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_document_types_Status", - table: "hr_document_types", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_bank_details_EmployeeId", - table: "hr_employee_bank_details", - column: "EmployeeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_documents_EmployeeId", - table: "hr_employee_documents", - column: "EmployeeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_documents_ExpiryDate", - table: "hr_employee_documents", - column: "ExpiryDate"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_documents_HrDocumentTypeId", - table: "hr_employee_documents", - column: "HrDocumentTypeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_loans_DocNo", - table: "hr_employee_loans", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_loans_EmployeeId", - table: "hr_employee_loans", - column: "EmployeeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_loans_Status", - table: "hr_employee_loans", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_salary_structure_lines_EmployeeSalaryStructureId", - table: "hr_employee_salary_structure_lines", - column: "EmployeeSalaryStructureId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_salary_structure_lines_SalaryComponentId", - table: "hr_employee_salary_structure_lines", - column: "SalaryComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employee_salary_structures_EmployeeId_EffectiveTo", - table: "hr_employee_salary_structures", - columns: new[] { "EmployeeId", "EffectiveTo" }); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_BranchId", - table: "hr_employees", - column: "BranchId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_DepartmentId", - table: "hr_employees", - column: "DepartmentId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_DesignationId", - table: "hr_employees", - column: "DesignationId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_Email", - table: "hr_employees", - column: "Email"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_EmployeeCode", - table: "hr_employees", - column: "EmployeeCode", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_EmploymentTypeId", - table: "hr_employees", - column: "EmploymentTypeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_ReportingManagerId", - table: "hr_employees", - column: "ReportingManagerId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_Status", - table: "hr_employees", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_UserId", - table: "hr_employees", - column: "UserId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_employees_WorkShiftId", - table: "hr_employees", - column: "WorkShiftId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_employment_types_Code", - table: "hr_employment_types", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_employment_types_Status", - table: "hr_employment_types", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_balances_EmployeeId_LeaveTypeId_Year", - table: "hr_leave_balances", - columns: new[] { "EmployeeId", "LeaveTypeId", "Year" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_balances_LeaveTypeId", - table: "hr_leave_balances", - column: "LeaveTypeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_requests_DocNo", - table: "hr_leave_requests", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_requests_EmployeeId", - table: "hr_leave_requests", - column: "EmployeeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_requests_LeaveTypeId", - table: "hr_leave_requests", - column: "LeaveTypeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_requests_StartDate_EndDate", - table: "hr_leave_requests", - columns: new[] { "StartDate", "EndDate" }); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_requests_Status", - table: "hr_leave_requests", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_types_Code", - table: "hr_leave_types", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_leave_types_Status", - table: "hr_leave_types", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_loan_installments_DueYear_DueMonth", - table: "hr_loan_installments", - columns: new[] { "DueYear", "DueMonth" }); - - migrationBuilder.CreateIndex( - name: "IX_hr_loan_installments_EmployeeLoanId", - table: "hr_loan_installments", - column: "EmployeeLoanId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_loan_installments_PayrollRunId", - table: "hr_loan_installments", - column: "PayrollRunId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_line_components_PayrollLineId", - table: "hr_payroll_line_components", - column: "PayrollLineId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_line_components_SalaryComponentId", - table: "hr_payroll_line_components", - column: "SalaryComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_lines_EmployeeId", - table: "hr_payroll_lines", - column: "EmployeeId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_lines_PayrollRunId_EmployeeId", - table: "hr_payroll_lines", - columns: new[] { "PayrollRunId", "EmployeeId" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_runs_BranchId", - table: "hr_payroll_runs", - column: "BranchId"); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_runs_DocNo", - table: "hr_payroll_runs", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_runs_PeriodYear_PeriodMonth_BranchId", - table: "hr_payroll_runs", - columns: new[] { "PeriodYear", "PeriodMonth", "BranchId" }); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_runs_Status", - table: "hr_payroll_runs", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_payroll_statutory_settings_EffectiveFrom", - table: "hr_payroll_statutory_settings", - column: "EffectiveFrom"); - - migrationBuilder.CreateIndex( - name: "IX_hr_payslips_PayrollLineId", - table: "hr_payslips", - column: "PayrollLineId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_salary_components_Code", - table: "hr_salary_components", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_salary_components_Status", - table: "hr_salary_components", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_hr_tax_slabs_EffectiveFrom", - table: "hr_tax_slabs", - column: "EffectiveFrom"); - - migrationBuilder.CreateIndex( - name: "IX_hr_work_shifts_Code", - table: "hr_work_shifts", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_hr_work_shifts_Status", - table: "hr_work_shifts", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_production_runs_CancelReasonCodeId", - table: "production_runs", - column: "CancelReasonCodeId"); - - migrationBuilder.CreateIndex( - name: "IX_production_runs_CreatedBy", - table: "production_runs", - column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_production_runs_DocNo", - table: "production_runs", - column: "DocNo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_production_runs_OutputBinId", - table: "production_runs", - column: "OutputBinId"); - - migrationBuilder.CreateIndex( - name: "IX_production_runs_Status", - table: "production_runs", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_production_runs_TemplateId_Status", - table: "production_runs", - columns: new[] { "TemplateId", "Status" }); - - migrationBuilder.CreateIndex( - name: "IX_production_runs_WarehouseId", - table: "production_runs", - column: "WarehouseId"); - - migrationBuilder.CreateIndex( - name: "IX_production_templates_Code", - table: "production_templates", - column: "Code", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_production_templates_CreatedBy", - table: "production_templates", - column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_production_templates_Status", - table: "production_templates", - column: "Status"); - - migrationBuilder.CreateIndex( - name: "IX_run_edges_ChildRunStageId", - table: "run_edges", - column: "ChildRunStageId"); - - migrationBuilder.CreateIndex( - name: "IX_run_edges_ParentRunStageId_ChildRunStageId", - table: "run_edges", - columns: new[] { "ParentRunStageId", "ChildRunStageId" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_run_edges_RunId", - table: "run_edges", - column: "RunId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_events_RunId_EventId", - table: "run_stage_events", - columns: new[] { "RunId", "EventId" }); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_events_RunStageId", - table: "run_stage_events", - column: "RunStageId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_events_UserId", - table: "run_stage_events", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_inputs_FromRunOutputId", - table: "run_stage_inputs", - column: "FromRunOutputId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_inputs_ItemId", - table: "run_stage_inputs", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_inputs_RunStageId", - table: "run_stage_inputs", - column: "RunStageId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_inputs_UomId", - table: "run_stage_inputs", - column: "UomId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_outputs_ItemId", - table: "run_stage_outputs", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_outputs_RunStageId", - table: "run_stage_outputs", - column: "RunStageId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_outputs_ScrapReasonCodeId", - table: "run_stage_outputs", - column: "ScrapReasonCodeId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stage_outputs_UomId", - table: "run_stage_outputs", - column: "UomId"); - - migrationBuilder.CreateIndex( - name: "IX_run_stages_RunId_Status", - table: "run_stages", - columns: new[] { "RunId", "Status" }); - - migrationBuilder.CreateIndex( - name: "IX_run_stages_TemplateStageId", - table: "run_stages", - column: "TemplateStageId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_edges_ChildStageId", - table: "stage_edges", - column: "ChildStageId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_edges_ParentStageId_ChildStageId", - table: "stage_edges", - columns: new[] { "ParentStageId", "ChildStageId" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_stage_edges_TemplateId", - table: "stage_edges", - column: "TemplateId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_inputs_FromOutputId", - table: "stage_inputs", - column: "FromOutputId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_inputs_ItemId", - table: "stage_inputs", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_inputs_StageId", - table: "stage_inputs", - column: "StageId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_inputs_UomId", - table: "stage_inputs", - column: "UomId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_outputs_ItemId", - table: "stage_outputs", - column: "ItemId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_outputs_StageId", - table: "stage_outputs", - column: "StageId"); - - migrationBuilder.CreateIndex( - name: "IX_stage_outputs_UomId", - table: "stage_outputs", - column: "UomId"); - - migrationBuilder.CreateIndex( - name: "IX_template_stages_TemplateId", - table: "template_stages", - column: "TemplateId"); - - migrationBuilder.AddForeignKey( - name: "FK_hr_attendance_records_hr_employees_EmployeeId", - table: "hr_attendance_records", - column: "EmployeeId", - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_hr_departments_hr_employees_HeadEmployeeId", - table: "hr_departments", - column: "HeadEmployeeId", - principalTable: "hr_employees", - principalColumn: "EmployeeId", - onDelete: ReferentialAction.Restrict); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_hr_departments_hr_employees_HeadEmployeeId", - table: "hr_departments"); - - migrationBuilder.DropTable( - name: "hr_attendance_records"); - - migrationBuilder.DropTable( - name: "hr_employee_bank_details"); - - migrationBuilder.DropTable( - name: "hr_employee_documents"); - - migrationBuilder.DropTable( - name: "hr_employee_salary_structure_lines"); - - migrationBuilder.DropTable( - name: "hr_leave_balances"); - - migrationBuilder.DropTable( - name: "hr_leave_requests"); - - migrationBuilder.DropTable( - name: "hr_loan_installments"); - - migrationBuilder.DropTable( - name: "hr_payroll_line_components"); - - migrationBuilder.DropTable( - name: "hr_payroll_statutory_settings"); - - migrationBuilder.DropTable( - name: "hr_payslips"); - - migrationBuilder.DropTable( - name: "hr_tax_slabs"); - - migrationBuilder.DropTable( - name: "run_edges"); - - migrationBuilder.DropTable( - name: "run_stage_events"); - - migrationBuilder.DropTable( - name: "run_stage_inputs"); - - migrationBuilder.DropTable( - name: "stage_edges"); - - migrationBuilder.DropTable( - name: "stage_inputs"); - - migrationBuilder.DropTable( - name: "hr_attendance_upload_batches"); - - migrationBuilder.DropTable( - name: "hr_document_types"); - - migrationBuilder.DropTable( - name: "hr_employee_salary_structures"); - - migrationBuilder.DropTable( - name: "hr_leave_types"); - - migrationBuilder.DropTable( - name: "hr_employee_loans"); - - migrationBuilder.DropTable( - name: "hr_salary_components"); - - migrationBuilder.DropTable( - name: "hr_payroll_lines"); - - migrationBuilder.DropTable( - name: "run_stage_outputs"); - - migrationBuilder.DropTable( - name: "stage_outputs"); - - migrationBuilder.DropTable( - name: "hr_payroll_runs"); - - migrationBuilder.DropTable( - name: "run_stages"); - - migrationBuilder.DropTable( - name: "production_runs"); - - migrationBuilder.DropTable( - name: "template_stages"); - - migrationBuilder.DropTable( - name: "production_templates"); - - migrationBuilder.DropTable( - name: "hr_employees"); - - migrationBuilder.DropTable( - name: "hr_departments"); - - migrationBuilder.DropTable( - name: "hr_designations"); - - migrationBuilder.DropTable( - name: "hr_employment_types"); - - migrationBuilder.DropTable( - name: "hr_work_shifts"); - - migrationBuilder.DropTable( - name: "hr_branches"); - } - } -} diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260731123720_production.Designer.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260801025920_InitialCreate.Designer.cs similarity index 90% rename from Backend/ERPCore/Infra/Persistence/Migrations/20260731123720_production.Designer.cs rename to Backend/ERPCore/Infra/Persistence/Migrations/20260801025920_InitialCreate.Designer.cs index bce3695..dc6674d 100644 --- a/Backend/ERPCore/Infra/Persistence/Migrations/20260731123720_production.Designer.cs +++ b/Backend/ERPCore/Infra/Persistence/Migrations/20260801025920_InitialCreate.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace ERPCore.Infra.Persistence.Migrations { [DbContext(typeof(ErpDbContext))] - [Migration("20260731123720_production")] - partial class production + [Migration("20260801025920_InitialCreate")] + partial class InitialCreate { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -410,6 +410,106 @@ namespace ERPCore.Infra.Persistence.Migrations b.ToTable("categories", (string)null); }); + modelBuilder.Entity("ERPCore.Domain.Entities.Customer", b => + { + b.Property("CustomerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CustomerId")); + + b.Property("AddressLine1") + .HasMaxLength(250) + .HasColumnType("character varying(250)"); + + b.Property("AddressLine2") + .HasMaxLength(250) + .HasColumnType("character varying(250)"); + + b.Property("City") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Country") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreditDays") + .HasColumnType("integer"); + + b.Property("CreditLimit") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("CustomerCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CustomerType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("B2C"); + + b.Property("DefaultWarehouseId") + .HasColumnType("integer"); + + b.Property("DisplayName") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Email") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Phone") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.Property("Status") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Active"); + + b.Property("TaxRegistrationNo") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("CustomerId"); + + b.HasIndex("CustomerCode") + .IsUnique(); + + b.HasIndex("CustomerType"); + + b.HasIndex("DefaultWarehouseId"); + + b.HasIndex("Status"); + + b.ToTable("customers", (string)null); + }); + modelBuilder.Entity("ERPCore.Domain.Entities.Department", b => { b.Property("DepartmentId") @@ -3305,6 +3405,406 @@ namespace ERPCore.Infra.Persistence.Migrations b.ToTable("hr_salary_components", (string)null); }); + modelBuilder.Entity("ERPCore.Domain.Entities.SalesInvoice", b => + { + b.Property("SalesInvoiceId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SalesInvoiceId")); + + b.Property("BalanceAmount") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("integer"); + + b.Property("CreatorUserId") + .HasColumnType("integer"); + + b.Property("CustomerId") + .HasColumnType("integer"); + + b.Property("CustomerSnapshotName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("CustomerSnapshotTaxNo") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("DiscountTotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("GrandTotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("InvoiceDate") + .HasColumnType("timestamp with time zone"); + + b.Property("InvoiceNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("InvoiceType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("B2C"); + + b.Property("NetPayable") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("PaidAmount") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("RoundOff") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.Property("Status") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Draft"); + + b.Property("Subtotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("TaxTotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("WarehouseId") + .HasColumnType("integer"); + + b.HasKey("SalesInvoiceId"); + + b.HasIndex("CreatorUserId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("InvoiceDate"); + + b.HasIndex("InvoiceNo") + .IsUnique(); + + b.HasIndex("Status"); + + b.HasIndex("WarehouseId"); + + b.ToTable("sales_invoices", (string)null); + }); + + modelBuilder.Entity("ERPCore.Domain.Entities.SalesInvoiceLine", b => + { + b.Property("SalesInvoiceLineId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SalesInvoiceLineId")); + + b.Property("BaseCost") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("DiscountAmount") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("DiscountMode") + .HasColumnType("integer"); + + b.Property("DiscountPct") + .HasPrecision(9, 4) + .HasColumnType("numeric(9,4)"); + + b.Property("FreeQty") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("IsFreeIssue") + .HasColumnType("boolean"); + + b.Property("ItemId") + .HasColumnType("integer"); + + b.Property("LineTotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("NetUnitPrice") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("ParentLineId") + .HasColumnType("integer"); + + b.Property("PriceSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Qty") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.Property("SalesInvoiceId") + .HasColumnType("integer"); + + b.Property("TaxAmount") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("TaxPct") + .HasPrecision(9, 4) + .HasColumnType("numeric(9,4)"); + + b.Property("UnitPrice") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("UomId") + .HasColumnType("integer"); + + b.Property("WarehouseId") + .HasColumnType("integer"); + + b.HasKey("SalesInvoiceLineId"); + + b.HasIndex("ItemId"); + + b.HasIndex("SalesInvoiceId"); + + b.HasIndex("UomId"); + + b.HasIndex("WarehouseId"); + + b.ToTable("sales_invoice_lines", (string)null); + }); + + modelBuilder.Entity("ERPCore.Domain.Entities.SalesSlip", b => + { + b.Property("SalesSlipId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SalesSlipId")); + + b.Property("BalanceAmount") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("CashierUserId") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CustomerId") + .HasColumnType("integer"); + + b.Property("CustomerSnapshotName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("DiscountTotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("GrandTotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("PaidAmount") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.Property("SlipDate") + .HasColumnType("timestamp with time zone"); + + b.Property("SlipNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Status") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Draft"); + + b.Property("Subtotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("TaxTotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("WarehouseId") + .HasColumnType("integer"); + + b.HasKey("SalesSlipId"); + + b.HasIndex("CashierUserId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("SlipDate"); + + b.HasIndex("SlipNo") + .IsUnique(); + + b.HasIndex("Status"); + + b.HasIndex("WarehouseId"); + + b.ToTable("sales_slips", (string)null); + }); + + modelBuilder.Entity("ERPCore.Domain.Entities.SalesSlipLine", b => + { + b.Property("SalesSlipLineId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SalesSlipLineId")); + + b.Property("BaseCost") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("DiscountAmount") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("DiscountMode") + .HasColumnType("integer"); + + b.Property("DiscountPct") + .HasPrecision(9, 4) + .HasColumnType("numeric(9,4)"); + + b.Property("FreeQty") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("IsFreeIssue") + .HasColumnType("boolean"); + + b.Property("ItemId") + .HasColumnType("integer"); + + b.Property("LineTotal") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("NetUnitPrice") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("ParentLineId") + .HasColumnType("integer"); + + b.Property("PriceSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Qty") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.Property("SalesSlipId") + .HasColumnType("integer"); + + b.Property("TaxAmount") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("TaxPct") + .HasPrecision(9, 4) + .HasColumnType("numeric(9,4)"); + + b.Property("UnitPrice") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("UomId") + .HasColumnType("integer"); + + b.Property("WarehouseId") + .HasColumnType("integer"); + + b.HasKey("SalesSlipLineId"); + + b.HasIndex("ItemId"); + + b.HasIndex("SalesSlipId"); + + b.HasIndex("UomId"); + + b.HasIndex("WarehouseId"); + + b.ToTable("sales_slip_lines", (string)null); + }); + modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b => { b.Property("SerialId") @@ -4652,6 +5152,16 @@ namespace ERPCore.Infra.Persistence.Migrations b.Navigation("Warehouse"); }); + modelBuilder.Entity("ERPCore.Domain.Entities.Customer", b => + { + b.HasOne("ERPCore.Domain.Entities.Warehouse", "DefaultWarehouse") + .WithMany() + .HasForeignKey("DefaultWarehouseId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("DefaultWarehouse"); + }); + modelBuilder.Entity("ERPCore.Domain.Entities.Department", b => { b.HasOne("ERPCore.Domain.Entities.Branch", "Branch") @@ -5475,6 +5985,128 @@ namespace ERPCore.Infra.Persistence.Migrations b.Navigation("Uom"); }); + modelBuilder.Entity("ERPCore.Domain.Entities.SalesInvoice", b => + { + b.HasOne("ERPCore.Domain.Entities.User", "Creator") + .WithMany() + .HasForeignKey("CreatorUserId"); + + b.HasOne("ERPCore.Domain.Entities.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse") + .WithMany() + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Creator"); + + b.Navigation("Customer"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("ERPCore.Domain.Entities.SalesInvoiceLine", b => + { + b.HasOne("ERPCore.Domain.Entities.Item", "Item") + .WithMany() + .HasForeignKey("ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("ERPCore.Domain.Entities.SalesInvoice", "SalesInvoice") + .WithMany("Lines") + .HasForeignKey("SalesInvoiceId") + .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("SalesInvoice"); + + b.Navigation("Uom"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("ERPCore.Domain.Entities.SalesSlip", b => + { + b.HasOne("ERPCore.Domain.Entities.User", "CashierUser") + .WithMany() + .HasForeignKey("CashierUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("ERPCore.Domain.Entities.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse") + .WithMany() + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CashierUser"); + + b.Navigation("Customer"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("ERPCore.Domain.Entities.SalesSlipLine", b => + { + b.HasOne("ERPCore.Domain.Entities.Item", "Item") + .WithMany() + .HasForeignKey("ItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("ERPCore.Domain.Entities.SalesSlip", "SalesSlip") + .WithMany("Lines") + .HasForeignKey("SalesSlipId") + .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("SalesSlip"); + + b.Navigation("Uom"); + + b.Navigation("Warehouse"); + }); + modelBuilder.Entity("ERPCore.Domain.Entities.Serial", b => { b.HasOne("ERPCore.Domain.Entities.Item", "Item") @@ -6017,6 +6649,16 @@ namespace ERPCore.Infra.Persistence.Migrations b.Navigation("Outputs"); }); + modelBuilder.Entity("ERPCore.Domain.Entities.SalesInvoice", b => + { + b.Navigation("Lines"); + }); + + modelBuilder.Entity("ERPCore.Domain.Entities.SalesSlip", b => + { + b.Navigation("Lines"); + }); + modelBuilder.Entity("ERPCore.Domain.Entities.StockAdjustment", b => { b.Navigation("Lines"); diff --git a/Backend/ERPCore/Infra/Persistence/Migrations/20260801025920_InitialCreate.cs b/Backend/ERPCore/Infra/Persistence/Migrations/20260801025920_InitialCreate.cs new file mode 100644 index 0000000..4b464cf --- /dev/null +++ b/Backend/ERPCore/Infra/Persistence/Migrations/20260801025920_InitialCreate.cs @@ -0,0 +1,4490 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace ERPCore.Infra.Persistence.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "brands", + columns: table => new + { + BrandId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_brands", x => x.BrandId); + }); + + migrationBuilder.CreateTable( + name: "categories", + columns: table => new + { + CategoryId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_categories", x => x.CategoryId); + }); + + migrationBuilder.CreateTable( + name: "hr_attendance_upload_batches", + columns: table => new + { + AttendanceUploadBatchId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + PeriodStart = table.Column(type: "timestamp with time zone", nullable: false), + PeriodEnd = table.Column(type: "timestamp with time zone", nullable: false), + SourceType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + OriginalFileName = table.Column(type: "character varying(260)", maxLength: 260, nullable: true), + UploadedBy = table.Column(type: "integer", nullable: false), + UploadedAt = table.Column(type: "timestamp with time zone", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ConfirmedBy = table.Column(type: "integer", nullable: true), + ConfirmedAt = table.Column(type: "timestamp with time zone", nullable: true), + RowCountTotal = table.Column(type: "integer", nullable: false), + RowCountDuplicate = table.Column(type: "integer", nullable: false), + RowCountError = table.Column(type: "integer", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_attendance_upload_batches", x => x.AttendanceUploadBatchId); + }); + + migrationBuilder.CreateTable( + name: "hr_branches", + columns: table => new + { + BranchId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Address = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_branches", x => x.BranchId); + }); + + migrationBuilder.CreateTable( + name: "hr_designations", + columns: table => new + { + DesignationId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_designations", x => x.DesignationId); + }); + + migrationBuilder.CreateTable( + name: "hr_document_types", + columns: table => new + { + HrDocumentTypeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Category = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + RequiredAtOnboarding = table.Column(type: "boolean", nullable: false), + ExpiryTracked = table.Column(type: "boolean", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_document_types", x => x.HrDocumentTypeId); + }); + + migrationBuilder.CreateTable( + name: "hr_employment_types", + columns: table => new + { + EmploymentTypeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_employment_types", x => x.EmploymentTypeId); + }); + + migrationBuilder.CreateTable( + name: "hr_leave_types", + columns: table => new + { + LeaveTypeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + IsPaid = table.Column(type: "boolean", nullable: false), + CountsAsNoPay = table.Column(type: "boolean", nullable: false), + AccrualPerYear = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), + CarryForwardAllowed = table.Column(type: "boolean", nullable: false), + MaxCarryForwardDays = table.Column(type: "integer", nullable: true), + RequiresApproval = table.Column(type: "boolean", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_leave_types", x => x.LeaveTypeId); + }); + + migrationBuilder.CreateTable( + name: "hr_payroll_statutory_settings", + columns: table => new + { + PayrollStatutorySettingId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EpfEmployeeRate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), + EpfEmployerRate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), + EtfEmployerRate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), + OtMultiplierDefault = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), + EffectiveFrom = table.Column(type: "timestamp with time zone", nullable: false), + EffectiveTo = table.Column(type: "timestamp with time zone", nullable: true), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_payroll_statutory_settings", x => x.PayrollStatutorySettingId); + }); + + migrationBuilder.CreateTable( + name: "hr_salary_components", + columns: table => new + { + SalaryComponentId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + ComponentType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + IsTaxable = table.Column(type: "boolean", nullable: false), + IsEpfEtfApplicable = table.Column(type: "boolean", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_salary_components", x => x.SalaryComponentId); + }); + + migrationBuilder.CreateTable( + name: "hr_tax_slabs", + columns: table => new + { + TaxSlabId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EffectiveFrom = table.Column(type: "timestamp with time zone", nullable: false), + EffectiveTo = table.Column(type: "timestamp with time zone", nullable: true), + LowerBound = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + UpperBound = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), + Rate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_tax_slabs", x => x.TaxSlabId); + }); + + migrationBuilder.CreateTable( + name: "hr_work_shifts", + columns: table => new + { + WorkShiftId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + StartTime = table.Column(type: "interval", nullable: false), + EndTime = table.Column(type: "interval", nullable: false), + IsOvernight = table.Column(type: "boolean", nullable: false), + GraceMinutes = table.Column(type: "integer", nullable: false), + BreakMinutes = table.Column(type: "integer", nullable: false), + StandardWorkingMinutes = table.Column(type: "integer", nullable: false), + OtMultiplier = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), + WorkingDaysMask = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_work_shifts", x => x.WorkShiftId); + }); + + migrationBuilder.CreateTable( + name: "item_types", + columns: table => new + { + ItemTypeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_item_types", x => x.ItemTypeId); + }); + + migrationBuilder.CreateTable( + name: "journal_entry_stubs", + columns: table => new + { + JournalId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SourceDocType = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + SourceDocId = table.Column(type: "integer", nullable: false), + DebitAccount = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + CreditAccount = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Amount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_journal_entry_stubs", x => x.JournalId); + }); + + migrationBuilder.CreateTable( + name: "nav_items", + columns: table => new + { + NavItemId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Label = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), + Icon = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), + Href = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + SortOrder = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active") + }, + constraints: table => + { + table.PrimaryKey("PK_nav_items", x => x.NavItemId); + }); + + migrationBuilder.CreateTable( + name: "number_sequences", + columns: table => new + { + SequenceId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + doc_type = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + year = table.Column(type: "integer", nullable: false), + last_number = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_number_sequences", x => x.SequenceId); + }); + + migrationBuilder.CreateTable( + name: "reason_codes", + columns: table => new + { + ReasonCodeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Description = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Context = table.Column(type: "character varying(20)", maxLength: 20, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_reason_codes", x => x.ReasonCodeId); + }); + + migrationBuilder.CreateTable( + name: "roles", + columns: table => new + { + RoleId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + auth_role_id = table.Column(type: "uuid", nullable: false), + Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + IsSystemRole = table.Column(type: "boolean", nullable: false, defaultValue: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_roles", x => x.RoleId); + }); + + migrationBuilder.CreateTable( + name: "uoms", + columns: table => new + { + UomId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_uoms", x => x.UomId); + }); + + migrationBuilder.CreateTable( + name: "vendors", + columns: table => new + { + VendorId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Terms = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), + TaxReg = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), + Currency = table.Column(type: "character varying(3)", maxLength: 3, nullable: false, defaultValue: "LKR"), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_vendors", x => x.VendorId); + }); + + migrationBuilder.CreateTable( + name: "warehouses", + columns: table => new + { + WarehouseId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_warehouses", x => x.WarehouseId); + }); + + migrationBuilder.CreateTable( + name: "subcategories", + columns: table => new + { + SubCategoryId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + CategoryId = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_subcategories", x => x.SubCategoryId); + table.ForeignKey( + name: "FK_subcategories_categories_CategoryId", + column: x => x.CategoryId, + principalTable: "categories", + principalColumn: "CategoryId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_payroll_runs", + columns: table => new + { + PayrollRunId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + PeriodYear = table.Column(type: "integer", nullable: false), + PeriodMonth = table.Column(type: "integer", nullable: false), + BranchId = table.Column(type: "integer", nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + GeneratedBy = table.Column(type: "integer", nullable: false), + GeneratedAt = table.Column(type: "timestamp with time zone", nullable: false), + ApprovedBy = table.Column(type: "integer", nullable: true), + ApprovedAt = table.Column(type: "timestamp with time zone", nullable: true), + LockedBy = table.Column(type: "integer", nullable: true), + LockedAt = table.Column(type: "timestamp with time zone", nullable: true), + UnlockedBy = table.Column(type: "integer", nullable: true), + UnlockedAt = table.Column(type: "timestamp with time zone", nullable: true), + UnlockReason = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_payroll_runs", x => x.PayrollRunId); + table.ForeignKey( + name: "FK_hr_payroll_runs_hr_branches_BranchId", + column: x => x.BranchId, + principalTable: "hr_branches", + principalColumn: "BranchId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "sub_nav_items", + columns: table => new + { + SubNavItemId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NavItemId = table.Column(type: "integer", nullable: false), + Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Label = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), + Icon = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), + Href = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + SortOrder = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active") + }, + constraints: table => + { + table.PrimaryKey("PK_sub_nav_items", x => x.SubNavItemId); + table.ForeignKey( + name: "FK_sub_nav_items_nav_items_NavItemId", + column: x => x.NavItemId, + principalTable: "nav_items", + principalColumn: "NavItemId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "users", + columns: table => new + { + UserId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Username = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), + DisplayName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + auth_user_id = table.Column(type: "uuid", nullable: true), + Email = table.Column(type: "character varying(320)", maxLength: 320, nullable: true), + RoleId = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_users", x => x.UserId); + table.ForeignKey( + name: "FK_users_roles_RoleId", + column: x => x.RoleId, + principalTable: "roles", + principalColumn: "RoleId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "bins", + columns: table => new + { + BinId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + WarehouseId = table.Column(type: "integer", nullable: false), + Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + BinType = table.Column(type: "character varying(50)", maxLength: 50, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_bins", x => x.BinId); + table.ForeignKey( + name: "FK_bins_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "customers", + columns: table => new + { + CustomerId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CustomerCode = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + CustomerType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "B2C"), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + Phone = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), + Email = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + AddressLine1 = table.Column(type: "character varying(250)", maxLength: 250, nullable: true), + AddressLine2 = table.Column(type: "character varying(250)", maxLength: 250, nullable: true), + City = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + Country = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + TaxRegistrationNo = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), + CreditLimit = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + CreditDays = table.Column(type: "integer", nullable: false), + DefaultWarehouseId = table.Column(type: "integer", nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_customers", x => x.CustomerId); + table.ForeignKey( + name: "FK_customers_warehouses_DefaultWarehouseId", + column: x => x.DefaultWarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.CreateTable( + name: "items", + columns: table => new + { + ItemId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Sku = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Description = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + CategoryId = table.Column(type: "integer", nullable: false), + SubCategoryId = table.Column(type: "integer", nullable: true), + BrandId = table.Column(type: "integer", nullable: true), + BaseUomId = table.Column(type: "integer", nullable: false), + DefaultVendorId = table.Column(type: "integer", nullable: true), + StockNature = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + TrackingMode = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + TaxClass = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), + SalePrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_items", x => x.ItemId); + table.ForeignKey( + name: "FK_items_brands_BrandId", + column: x => x.BrandId, + principalTable: "brands", + principalColumn: "BrandId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_items_categories_CategoryId", + column: x => x.CategoryId, + principalTable: "categories", + principalColumn: "CategoryId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_items_subcategories_SubCategoryId", + column: x => x.SubCategoryId, + principalTable: "subcategories", + principalColumn: "SubCategoryId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_items_uoms_BaseUomId", + column: x => x.BaseUomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_items_vendors_DefaultVendorId", + column: x => x.DefaultVendorId, + principalTable: "vendors", + principalColumn: "VendorId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "permissions", + columns: table => new + { + PermissionId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(80)", maxLength: 80, nullable: false), + NavItemId = table.Column(type: "integer", nullable: true), + SubNavItemId = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_permissions", x => x.PermissionId); + table.ForeignKey( + name: "FK_permissions_nav_items_NavItemId", + column: x => x.NavItemId, + principalTable: "nav_items", + principalColumn: "NavItemId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_permissions_sub_nav_items_SubNavItemId", + column: x => x.SubNavItemId, + principalTable: "sub_nav_items", + principalColumn: "SubNavItemId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "audit_logs", + columns: table => new + { + AuditId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + EntityType = table.Column(type: "character varying(80)", maxLength: 80, nullable: false), + EntityId = table.Column(type: "integer", nullable: false), + Action = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + ChangeSet = table.Column(type: "jsonb", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_audit_logs", x => x.AuditId); + table.ForeignKey( + name: "FK_audit_logs_users_UserId", + column: x => x.UserId, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "product_config", + columns: table => new + { + ConfigId = table.Column(type: "integer", nullable: false), + SubcategoriesEnabled = table.Column(type: "boolean", nullable: false, defaultValue: true), + BrandsEnabled = table.Column(type: "boolean", nullable: false, defaultValue: true), + ItemTypesEnabled = table.Column(type: "boolean", nullable: false, defaultValue: true), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + UpdatedBy = table.Column(type: "integer", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_product_config", x => x.ConfigId); + table.CheckConstraint("ck_product_config_singleton", "\"ConfigId\" = 1"); + table.ForeignKey( + name: "FK_product_config_users_UpdatedBy", + column: x => x.UpdatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "production_templates", + columns: table => new + { + TemplateId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), + Description = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Annotations = table.Column(type: "jsonb", nullable: true), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_production_templates", x => x.TemplateId); + table.ForeignKey( + name: "FK_production_templates_users_CreatedBy", + column: x => x.CreatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "purchase_returns", + columns: table => new + { + ReturnId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + VendorId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + ReasonCodeId = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_purchase_returns", x => x.ReturnId); + table.ForeignKey( + name: "FK_purchase_returns_reason_codes_ReasonCodeId", + column: x => x.ReasonCodeId, + principalTable: "reason_codes", + principalColumn: "ReasonCodeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_purchase_returns_users_CreatedBy", + column: x => x.CreatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_purchase_returns_vendors_VendorId", + column: x => x.VendorId, + principalTable: "vendors", + principalColumn: "VendorId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_purchase_returns_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "requisitions", + columns: table => new + { + RequisitionId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + RequestedBy = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_requisitions", x => x.RequisitionId); + table.ForeignKey( + name: "FK_requisitions_users_RequestedBy", + column: x => x.RequestedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "stock_adjustments", + columns: table => new + { + AdjustmentId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + ReasonCodeId = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stock_adjustments", x => x.AdjustmentId); + table.ForeignKey( + name: "FK_stock_adjustments_reason_codes_ReasonCodeId", + column: x => x.ReasonCodeId, + principalTable: "reason_codes", + principalColumn: "ReasonCodeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_adjustments_users_CreatedBy", + column: x => x.CreatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_adjustments_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "stock_counts", + columns: table => new + { + CountId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + CountType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stock_counts", x => x.CountId); + table.ForeignKey( + name: "FK_stock_counts_users_CreatedBy", + column: x => x.CreatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_counts_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "stock_transfers", + columns: table => new + { + TransferId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + SrcWarehouseId = table.Column(type: "integer", nullable: false), + DestWarehouseId = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stock_transfers", x => x.TransferId); + table.ForeignKey( + name: "FK_stock_transfers_users_CreatedBy", + column: x => x.CreatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_transfers_warehouses_DestWarehouseId", + column: x => x.DestWarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_transfers_warehouses_SrcWarehouseId", + column: x => x.SrcWarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "sales_invoices", + columns: table => new + { + SalesInvoiceId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + InvoiceNo = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + InvoiceDate = table.Column(type: "timestamp with time zone", nullable: false), + CustomerId = table.Column(type: "integer", nullable: false), + CustomerSnapshotName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + CustomerSnapshotTaxNo = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), + WarehouseId = table.Column(type: "integer", nullable: false), + InvoiceType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "B2C"), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Draft"), + Subtotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + DiscountTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + TaxTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + GrandTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + RoundOff = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + NetPayable = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + PaidAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + BalanceAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatorUserId = table.Column(type: "integer", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_sales_invoices", x => x.SalesInvoiceId); + table.ForeignKey( + name: "FK_sales_invoices_customers_CustomerId", + column: x => x.CustomerId, + principalTable: "customers", + principalColumn: "CustomerId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_sales_invoices_users_CreatorUserId", + column: x => x.CreatorUserId, + principalTable: "users", + principalColumn: "UserId"); + table.ForeignKey( + name: "FK_sales_invoices_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "sales_slips", + columns: table => new + { + SalesSlipId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SlipNo = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + SlipDate = table.Column(type: "timestamp with time zone", nullable: false), + CustomerId = table.Column(type: "integer", nullable: false), + CustomerSnapshotName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + CashierUserId = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Draft"), + Subtotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + DiscountTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + TaxTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + GrandTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + PaidAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + BalanceAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_sales_slips", x => x.SalesSlipId); + table.ForeignKey( + name: "FK_sales_slips_customers_CustomerId", + column: x => x.CustomerId, + principalTable: "customers", + principalColumn: "CustomerId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_sales_slips_users_CashierUserId", + column: x => x.CashierUserId, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_sales_slips_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "batches", + columns: table => new + { + BatchId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ItemId = table.Column(type: "integer", nullable: false), + BatchNo = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + ExpiryDate = table.Column(type: "date", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_batches", x => x.BatchId); + table.ForeignKey( + name: "FK_batches_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "item_reorders", + columns: table => new + { + ReorderId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ItemId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + ReorderPoint = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ReorderQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_item_reorders", x => x.ReorderId); + table.ForeignKey( + name: "FK_item_reorders_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_item_reorders_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "serials", + columns: table => new + { + SerialId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ItemId = table.Column(type: "integer", nullable: false), + SerialNo = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_serials", x => x.SerialId); + table.ForeignKey( + name: "FK_serials_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "uom_conversions", + columns: table => new + { + ConversionId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ItemId = table.Column(type: "integer", nullable: false), + FromUomId = table.Column(type: "integer", nullable: false), + ToUomId = table.Column(type: "integer", nullable: false), + Factor = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_uom_conversions", x => x.ConversionId); + table.ForeignKey( + name: "FK_uom_conversions_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_uom_conversions_uoms_FromUomId", + column: x => x.FromUomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_uom_conversions_uoms_ToUomId", + column: x => x.ToUomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "role_permissions", + columns: table => new + { + RoleId = table.Column(type: "integer", nullable: false), + PermissionId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_role_permissions", x => new { x.RoleId, x.PermissionId }); + table.ForeignKey( + name: "FK_role_permissions_permissions_PermissionId", + column: x => x.PermissionId, + principalTable: "permissions", + principalColumn: "PermissionId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_role_permissions_roles_RoleId", + column: x => x.RoleId, + principalTable: "roles", + principalColumn: "RoleId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "production_runs", + columns: table => new + { + RunId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + TemplateId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + OutputBinId = table.Column(type: "integer", nullable: true), + TargetQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ScaleFactor = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ReworkCount = table.Column(type: "integer", nullable: false), + CancelReasonCodeId = table.Column(type: "integer", nullable: true), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + CompletedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_production_runs", x => x.RunId); + table.ForeignKey( + name: "FK_production_runs_bins_OutputBinId", + column: x => x.OutputBinId, + principalTable: "bins", + principalColumn: "BinId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_production_runs_production_templates_TemplateId", + column: x => x.TemplateId, + principalTable: "production_templates", + principalColumn: "TemplateId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_production_runs_reason_codes_CancelReasonCodeId", + column: x => x.CancelReasonCodeId, + principalTable: "reason_codes", + principalColumn: "ReasonCodeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_production_runs_users_CreatedBy", + column: x => x.CreatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_production_runs_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "template_stages", + columns: table => new + { + StageId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TemplateId = table.Column(type: "integer", nullable: false), + Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), + RoleLabel = table.Column(type: "character varying(60)", maxLength: 60, nullable: true), + EstimatedMinutes = table.Column(type: "integer", nullable: false), + PosX = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + PosY = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + FieldDefs = table.Column(type: "jsonb", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_template_stages", x => x.StageId); + table.ForeignKey( + name: "FK_template_stages_production_templates_TemplateId", + column: x => x.TemplateId, + principalTable: "production_templates", + principalColumn: "TemplateId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "purchase_orders", + columns: table => new + { + PoId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + VendorId = table.Column(type: "integer", nullable: false), + RequisitionId = table.Column(type: "integer", nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ApprovalRequired = table.Column(type: "boolean", nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_purchase_orders", x => x.PoId); + table.ForeignKey( + name: "FK_purchase_orders_requisitions_RequisitionId", + column: x => x.RequisitionId, + principalTable: "requisitions", + principalColumn: "RequisitionId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_purchase_orders_users_CreatedBy", + column: x => x.CreatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_purchase_orders_vendors_VendorId", + column: x => x.VendorId, + principalTable: "vendors", + principalColumn: "VendorId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "requisition_lines", + columns: table => new + { + ReqLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RequisitionId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + RequiredBy = table.Column(type: "date", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_requisition_lines", x => x.ReqLineId); + table.ForeignKey( + name: "FK_requisition_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_requisition_lines_requisitions_RequisitionId", + column: x => x.RequisitionId, + principalTable: "requisitions", + principalColumn: "RequisitionId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "rfqs", + columns: table => new + { + RfqId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + RequisitionId = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_rfqs", x => x.RfqId); + table.ForeignKey( + name: "FK_rfqs_requisitions_RequisitionId", + column: x => x.RequisitionId, + principalTable: "requisitions", + principalColumn: "RequisitionId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "stock_count_lines", + columns: table => new + { + CountLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CountId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + BinId = table.Column(type: "integer", nullable: true), + SystemQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + CountedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: true), + Variance = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_stock_count_lines", x => x.CountLineId); + table.ForeignKey( + name: "FK_stock_count_lines_bins_BinId", + column: x => x.BinId, + principalTable: "bins", + principalColumn: "BinId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_count_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_count_lines_stock_counts_CountId", + column: x => x.CountId, + principalTable: "stock_counts", + principalColumn: "CountId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "sales_invoice_lines", + columns: table => new + { + SalesInvoiceLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SalesInvoiceId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + Description = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + FreeQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + UomId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + UnitPrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + BaseCost = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + PriceSource = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + DiscountMode = table.Column(type: "integer", nullable: false), + DiscountPct = table.Column(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false), + DiscountAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + NetUnitPrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + LineTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + TaxPct = table.Column(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false), + TaxAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + IsFreeIssue = table.Column(type: "boolean", nullable: false), + ParentLineId = table.Column(type: "integer", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_sales_invoice_lines", x => x.SalesInvoiceLineId); + table.ForeignKey( + name: "FK_sales_invoice_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_sales_invoice_lines_sales_invoices_SalesInvoiceId", + column: x => x.SalesInvoiceId, + principalTable: "sales_invoices", + principalColumn: "SalesInvoiceId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_sales_invoice_lines_uoms_UomId", + column: x => x.UomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_sales_invoice_lines_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "sales_slip_lines", + columns: table => new + { + SalesSlipLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SalesSlipId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + Description = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + FreeQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + UomId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + UnitPrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + BaseCost = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + PriceSource = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + DiscountMode = table.Column(type: "integer", nullable: false), + DiscountPct = table.Column(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false), + DiscountAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + NetUnitPrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + LineTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + TaxPct = table.Column(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false), + TaxAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + IsFreeIssue = table.Column(type: "boolean", nullable: false), + ParentLineId = table.Column(type: "integer", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_sales_slip_lines", x => x.SalesSlipLineId); + table.ForeignKey( + name: "FK_sales_slip_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_sales_slip_lines_sales_slips_SalesSlipId", + column: x => x.SalesSlipId, + principalTable: "sales_slips", + principalColumn: "SalesSlipId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_sales_slip_lines_uoms_UomId", + column: x => x.UomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_sales_slip_lines_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "stock_adjustment_lines", + columns: table => new + { + AdjLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AdjustmentId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + BinId = table.Column(type: "integer", nullable: true), + BatchId = table.Column(type: "integer", nullable: true), + SerialId = table.Column(type: "integer", nullable: true), + QtyDelta = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stock_adjustment_lines", x => x.AdjLineId); + table.ForeignKey( + name: "FK_stock_adjustment_lines_batches_BatchId", + column: x => x.BatchId, + principalTable: "batches", + principalColumn: "BatchId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_adjustment_lines_bins_BinId", + column: x => x.BinId, + principalTable: "bins", + principalColumn: "BinId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_adjustment_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_adjustment_lines_serials_SerialId", + column: x => x.SerialId, + principalTable: "serials", + principalColumn: "SerialId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_adjustment_lines_stock_adjustments_AdjustmentId", + column: x => x.AdjustmentId, + principalTable: "stock_adjustments", + principalColumn: "AdjustmentId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "stock_ledger", + columns: table => new + { + LedgerId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ItemId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + BinId = table.Column(type: "integer", nullable: true), + BatchId = table.Column(type: "integer", nullable: true), + SerialId = table.Column(type: "integer", nullable: true), + UserId = table.Column(type: "integer", nullable: false), + Direction = table.Column(type: "character varying(5)", maxLength: 5, nullable: false), + QtyBase = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + UnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), + Value = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + RunningBalance = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + SourceDocType = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + SourceDocId = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stock_ledger", x => x.LedgerId); + table.ForeignKey( + name: "FK_stock_ledger_batches_BatchId", + column: x => x.BatchId, + principalTable: "batches", + principalColumn: "BatchId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_ledger_bins_BinId", + column: x => x.BinId, + principalTable: "bins", + principalColumn: "BinId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_ledger_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_ledger_serials_SerialId", + column: x => x.SerialId, + principalTable: "serials", + principalColumn: "SerialId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_ledger_users_UserId", + column: x => x.UserId, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_ledger_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "stock_transfer_lines", + columns: table => new + { + TransferLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TransferId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + SrcBinId = table.Column(type: "integer", nullable: true), + DestBinId = table.Column(type: "integer", nullable: true), + BatchId = table.Column(type: "integer", nullable: true), + SerialId = table.Column(type: "integer", nullable: true), + Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + UnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: true), + QtyReceived = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stock_transfer_lines", x => x.TransferLineId); + table.ForeignKey( + name: "FK_stock_transfer_lines_batches_BatchId", + column: x => x.BatchId, + principalTable: "batches", + principalColumn: "BatchId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_transfer_lines_bins_DestBinId", + column: x => x.DestBinId, + principalTable: "bins", + principalColumn: "BinId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_transfer_lines_bins_SrcBinId", + column: x => x.SrcBinId, + principalTable: "bins", + principalColumn: "BinId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_transfer_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_transfer_lines_serials_SerialId", + column: x => x.SerialId, + principalTable: "serials", + principalColumn: "SerialId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_transfer_lines_stock_transfers_TransferId", + column: x => x.TransferId, + principalTable: "stock_transfers", + principalColumn: "TransferId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "run_stages", + columns: table => new + { + RunStageId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RunId = table.Column(type: "integer", nullable: false), + TemplateStageId = table.Column(type: "integer", nullable: true), + Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), + RoleLabel = table.Column(type: "character varying(60)", maxLength: 60, nullable: true), + EstimatedMinutes = table.Column(type: "integer", nullable: false), + PosX = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + PosY = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ActualStartAt = table.Column(type: "timestamp with time zone", nullable: true), + ActualEndAt = table.Column(type: "timestamp with time zone", nullable: true), + FieldDefs = table.Column(type: "jsonb", nullable: false), + FieldValues = table.Column(type: "jsonb", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_run_stages", x => x.RunStageId); + table.ForeignKey( + name: "FK_run_stages_production_runs_RunId", + column: x => x.RunId, + principalTable: "production_runs", + principalColumn: "RunId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_run_stages_template_stages_TemplateStageId", + column: x => x.TemplateStageId, + principalTable: "template_stages", + principalColumn: "StageId", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.CreateTable( + name: "stage_edges", + columns: table => new + { + EdgeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TemplateId = table.Column(type: "integer", nullable: false), + ParentStageId = table.Column(type: "integer", nullable: false), + ChildStageId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stage_edges", x => x.EdgeId); + table.ForeignKey( + name: "FK_stage_edges_production_templates_TemplateId", + column: x => x.TemplateId, + principalTable: "production_templates", + principalColumn: "TemplateId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_stage_edges_template_stages_ChildStageId", + column: x => x.ChildStageId, + principalTable: "template_stages", + principalColumn: "StageId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stage_edges_template_stages_ParentStageId", + column: x => x.ParentStageId, + principalTable: "template_stages", + principalColumn: "StageId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "stage_outputs", + columns: table => new + { + OutputId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StageId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: true), + Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), + UomId = table.Column(type: "integer", nullable: false), + QtyPerBatch = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stage_outputs", x => x.OutputId); + table.ForeignKey( + name: "FK_stage_outputs_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stage_outputs_template_stages_StageId", + column: x => x.StageId, + principalTable: "template_stages", + principalColumn: "StageId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_stage_outputs_uoms_UomId", + column: x => x.UomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "grns", + columns: table => new + { + GrnId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + PoId = table.Column(type: "integer", nullable: true), + VendorId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + PostedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_grns", x => x.GrnId); + table.ForeignKey( + name: "FK_grns_purchase_orders_PoId", + column: x => x.PoId, + principalTable: "purchase_orders", + principalColumn: "PoId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_grns_users_CreatedBy", + column: x => x.CreatedBy, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_grns_vendors_VendorId", + column: x => x.VendorId, + principalTable: "vendors", + principalColumn: "VendorId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_grns_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "po_lines", + columns: table => new + { + PoLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PoId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + UomId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + UnitPrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + Tax = table.Column(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false), + QtyReceived = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_po_lines", x => x.PoLineId); + table.ForeignKey( + name: "FK_po_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_po_lines_purchase_orders_PoId", + column: x => x.PoId, + principalTable: "purchase_orders", + principalColumn: "PoId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_po_lines_uoms_UomId", + column: x => x.UomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_po_lines_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "rfq_lines", + columns: table => new + { + RfqLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RfqId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_rfq_lines", x => x.RfqLineId); + table.ForeignKey( + name: "FK_rfq_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_rfq_lines_rfqs_RfqId", + column: x => x.RfqId, + principalTable: "rfqs", + principalColumn: "RfqId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "vendor_quotations", + columns: table => new + { + QuotationId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RfqId = table.Column(type: "integer", nullable: false), + VendorId = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_vendor_quotations", x => x.QuotationId); + table.ForeignKey( + name: "FK_vendor_quotations_rfqs_RfqId", + column: x => x.RfqId, + principalTable: "rfqs", + principalColumn: "RfqId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_vendor_quotations_vendors_VendorId", + column: x => x.VendorId, + principalTable: "vendors", + principalColumn: "VendorId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "run_edges", + columns: table => new + { + RunEdgeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RunId = table.Column(type: "integer", nullable: false), + ParentRunStageId = table.Column(type: "integer", nullable: false), + ChildRunStageId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_run_edges", x => x.RunEdgeId); + table.ForeignKey( + name: "FK_run_edges_production_runs_RunId", + column: x => x.RunId, + principalTable: "production_runs", + principalColumn: "RunId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_run_edges_run_stages_ChildRunStageId", + column: x => x.ChildRunStageId, + principalTable: "run_stages", + principalColumn: "RunStageId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_run_edges_run_stages_ParentRunStageId", + column: x => x.ParentRunStageId, + principalTable: "run_stages", + principalColumn: "RunStageId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "run_stage_events", + columns: table => new + { + EventId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RunId = table.Column(type: "integer", nullable: false), + RunStageId = table.Column(type: "integer", nullable: true), + EventType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Note = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), + Payload = table.Column(type: "jsonb", nullable: true), + UserId = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_run_stage_events", x => x.EventId); + table.ForeignKey( + name: "FK_run_stage_events_production_runs_RunId", + column: x => x.RunId, + principalTable: "production_runs", + principalColumn: "RunId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_run_stage_events_run_stages_RunStageId", + column: x => x.RunStageId, + principalTable: "run_stages", + principalColumn: "RunStageId", + onDelete: ReferentialAction.SetNull); + table.ForeignKey( + name: "FK_run_stage_events_users_UserId", + column: x => x.UserId, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "run_stage_outputs", + columns: table => new + { + RunOutputId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RunStageId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: true), + Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), + UomId = table.Column(type: "integer", nullable: false), + PlannedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ProducedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ScrappedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ScrapReasonCodeId = table.Column(type: "integer", nullable: true), + TransferredQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_run_stage_outputs", x => x.RunOutputId); + table.ForeignKey( + name: "FK_run_stage_outputs_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_run_stage_outputs_reason_codes_ScrapReasonCodeId", + column: x => x.ScrapReasonCodeId, + principalTable: "reason_codes", + principalColumn: "ReasonCodeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_run_stage_outputs_run_stages_RunStageId", + column: x => x.RunStageId, + principalTable: "run_stages", + principalColumn: "RunStageId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_run_stage_outputs_uoms_UomId", + column: x => x.UomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "stage_inputs", + columns: table => new + { + InputId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StageId = table.Column(type: "integer", nullable: false), + Source = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ItemId = table.Column(type: "integer", nullable: true), + FromOutputId = table.Column(type: "integer", nullable: true), + UomId = table.Column(type: "integer", nullable: false), + QtyPerBatch = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stage_inputs", x => x.InputId); + table.ForeignKey( + name: "FK_stage_inputs_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stage_inputs_stage_outputs_FromOutputId", + column: x => x.FromOutputId, + principalTable: "stage_outputs", + principalColumn: "OutputId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stage_inputs_template_stages_StageId", + column: x => x.StageId, + principalTable: "template_stages", + principalColumn: "StageId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_stage_inputs_uoms_UomId", + column: x => x.UomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "grn_lines", + columns: table => new + { + GrnLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + GrnId = table.Column(type: "integer", nullable: false), + PoLineId = table.Column(type: "integer", nullable: true), + ItemId = table.Column(type: "integer", nullable: false), + UomId = table.Column(type: "integer", nullable: false), + BinId = table.Column(type: "integer", nullable: true), + BatchId = table.Column(type: "integer", nullable: true), + Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + UnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), + PoUnitPrice = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: true), + DiscountPct = table.Column(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false), + NetUnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), + VatPct = table.Column(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false), + VatAmount = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ReceivedValue = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + LineTotal = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + HoldStatus = table.Column(type: "character varying(20)", maxLength: 20, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_grn_lines", x => x.GrnLineId); + table.ForeignKey( + name: "FK_grn_lines_batches_BatchId", + column: x => x.BatchId, + principalTable: "batches", + principalColumn: "BatchId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_grn_lines_bins_BinId", + column: x => x.BinId, + principalTable: "bins", + principalColumn: "BinId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_grn_lines_grns_GrnId", + column: x => x.GrnId, + principalTable: "grns", + principalColumn: "GrnId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_grn_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_grn_lines_po_lines_PoLineId", + column: x => x.PoLineId, + principalTable: "po_lines", + principalColumn: "PoLineId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_grn_lines_uoms_UomId", + column: x => x.UomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "vendor_quotation_lines", + columns: table => new + { + QuotationLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + QuotationId = table.Column(type: "integer", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), + UnitPrice = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + LeadDays = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_vendor_quotation_lines", x => x.QuotationLineId); + table.ForeignKey( + name: "FK_vendor_quotation_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_vendor_quotation_lines_vendor_quotations_QuotationId", + column: x => x.QuotationId, + principalTable: "vendor_quotations", + principalColumn: "QuotationId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "run_stage_inputs", + columns: table => new + { + RunInputId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RunStageId = table.Column(type: "integer", nullable: false), + Source = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ItemId = table.Column(type: "integer", nullable: true), + FromRunOutputId = table.Column(type: "integer", nullable: true), + UomId = table.Column(type: "integer", nullable: false), + PlannedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ConsumedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ConsumedValue = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + DeliveredQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ReturnedQty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + ReturnedValue = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_run_stage_inputs", x => x.RunInputId); + table.ForeignKey( + name: "FK_run_stage_inputs_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_run_stage_inputs_run_stage_outputs_FromRunOutputId", + column: x => x.FromRunOutputId, + principalTable: "run_stage_outputs", + principalColumn: "RunOutputId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_run_stage_inputs_run_stages_RunStageId", + column: x => x.RunStageId, + principalTable: "run_stages", + principalColumn: "RunStageId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_run_stage_inputs_uoms_UomId", + column: x => x.UomId, + principalTable: "uoms", + principalColumn: "UomId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "purchase_return_lines", + columns: table => new + { + ReturnLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ReturnId = table.Column(type: "integer", nullable: false), + GrnLineId = table.Column(type: "integer", nullable: true), + ItemId = table.Column(type: "integer", nullable: false), + Qty = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_purchase_return_lines", x => x.ReturnLineId); + table.ForeignKey( + name: "FK_purchase_return_lines_grn_lines_GrnLineId", + column: x => x.GrnLineId, + principalTable: "grn_lines", + principalColumn: "GrnLineId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_purchase_return_lines_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_purchase_return_lines_purchase_returns_ReturnId", + column: x => x.ReturnId, + principalTable: "purchase_returns", + principalColumn: "ReturnId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "stock_layers", + columns: table => new + { + LayerId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ItemId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + BatchId = table.Column(type: "integer", nullable: true), + SerialId = table.Column(type: "integer", nullable: true), + GrnLineId = table.Column(type: "integer", nullable: true), + QtyReceived = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + QtyRemaining = table.Column(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false), + UnitCost = table.Column(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false), + ReceiptDate = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stock_layers", x => x.LayerId); + table.ForeignKey( + name: "FK_stock_layers_batches_BatchId", + column: x => x.BatchId, + principalTable: "batches", + principalColumn: "BatchId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_layers_grn_lines_GrnLineId", + column: x => x.GrnLineId, + principalTable: "grn_lines", + principalColumn: "GrnLineId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_layers_items_ItemId", + column: x => x.ItemId, + principalTable: "items", + principalColumn: "ItemId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_layers_serials_SerialId", + column: x => x.SerialId, + principalTable: "serials", + principalColumn: "SerialId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_stock_layers_warehouses_WarehouseId", + column: x => x.WarehouseId, + principalTable: "warehouses", + principalColumn: "WarehouseId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_attendance_records", + columns: table => new + { + AttendanceRecordId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AttendanceUploadBatchId = table.Column(type: "integer", nullable: true), + EmployeeId = table.Column(type: "integer", nullable: false), + AttendanceDate = table.Column(type: "timestamp with time zone", nullable: false), + CheckIn = table.Column(type: "interval", nullable: true), + CheckOut = table.Column(type: "interval", nullable: true), + WorkShiftId = table.Column(type: "integer", nullable: false), + WorkingMinutes = table.Column(type: "integer", nullable: false), + LateMinutes = table.Column(type: "integer", nullable: false), + EarlyLeaveMinutes = table.Column(type: "integer", nullable: false), + OvertimeMinutes = table.Column(type: "integer", nullable: false), + AttendanceStatus = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + RowValidationStatus = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + DuplicateOfAttendanceRecordId = table.Column(type: "integer", nullable: true), + Notes = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + IsManualOverride = table.Column(type: "boolean", nullable: false), + EditedBy = table.Column(type: "integer", nullable: true), + EditedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_attendance_records", x => x.AttendanceRecordId); + table.ForeignKey( + name: "FK_hr_attendance_records_hr_attendance_upload_batches_Attendan~", + column: x => x.AttendanceUploadBatchId, + principalTable: "hr_attendance_upload_batches", + principalColumn: "AttendanceUploadBatchId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_hr_attendance_records_hr_work_shifts_WorkShiftId", + column: x => x.WorkShiftId, + principalTable: "hr_work_shifts", + principalColumn: "WorkShiftId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_departments", + columns: table => new + { + DepartmentId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Code = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + ParentDepartmentId = table.Column(type: "integer", nullable: true), + HeadEmployeeId = table.Column(type: "integer", nullable: true), + BranchId = table.Column(type: "integer", nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_departments", x => x.DepartmentId); + table.ForeignKey( + name: "FK_hr_departments_hr_branches_BranchId", + column: x => x.BranchId, + principalTable: "hr_branches", + principalColumn: "BranchId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_departments_hr_departments_ParentDepartmentId", + column: x => x.ParentDepartmentId, + principalTable: "hr_departments", + principalColumn: "DepartmentId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_employees", + columns: table => new + { + EmployeeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EmployeeCode = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + FullName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Nic = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), + DateOfBirth = table.Column(type: "timestamp with time zone", nullable: true), + Gender = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), + Nationality = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + ProfilePhotoPath = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), + Email = table.Column(type: "character varying(320)", maxLength: 320, nullable: true), + PersonalMobile = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), + AddressLine1 = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + AddressLine2 = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + City = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + PostalCode = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), + Country = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + EmergencyContactName = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + EmergencyContactRelationship = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + EmergencyContactPhone = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), + HireDate = table.Column(type: "timestamp with time zone", nullable: false), + ConfirmationDate = table.Column(type: "timestamp with time zone", nullable: true), + LastWorkingDate = table.Column(type: "timestamp with time zone", nullable: true), + DepartmentId = table.Column(type: "integer", nullable: false), + DesignationId = table.Column(type: "integer", nullable: false), + EmploymentTypeId = table.Column(type: "integer", nullable: false), + BranchId = table.Column(type: "integer", nullable: true), + WorkShiftId = table.Column(type: "integer", nullable: false), + ReportingManagerId = table.Column(type: "integer", nullable: true), + EpfNumber = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), + EtfNumber = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), + TaxIdentificationNumber = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), + UserId = table.Column(type: "integer", nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedBy = table.Column(type: "integer", nullable: true), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_employees", x => x.EmployeeId); + table.ForeignKey( + name: "FK_hr_employees_hr_branches_BranchId", + column: x => x.BranchId, + principalTable: "hr_branches", + principalColumn: "BranchId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_employees_hr_departments_DepartmentId", + column: x => x.DepartmentId, + principalTable: "hr_departments", + principalColumn: "DepartmentId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_employees_hr_designations_DesignationId", + column: x => x.DesignationId, + principalTable: "hr_designations", + principalColumn: "DesignationId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_employees_hr_employees_ReportingManagerId", + column: x => x.ReportingManagerId, + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_employees_hr_employment_types_EmploymentTypeId", + column: x => x.EmploymentTypeId, + principalTable: "hr_employment_types", + principalColumn: "EmploymentTypeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_employees_hr_work_shifts_WorkShiftId", + column: x => x.WorkShiftId, + principalTable: "hr_work_shifts", + principalColumn: "WorkShiftId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_employees_users_UserId", + column: x => x.UserId, + principalTable: "users", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_employee_bank_details", + columns: table => new + { + EmployeeBankDetailId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EmployeeId = table.Column(type: "integer", nullable: false), + BankName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + BranchName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + AccountNumber = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + AccountHolderName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + SwiftCode = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), + IsPrimary = table.Column(type: "boolean", nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_employee_bank_details", x => x.EmployeeBankDetailId); + table.ForeignKey( + name: "FK_hr_employee_bank_details_hr_employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "hr_employee_documents", + columns: table => new + { + EmployeeDocumentId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EmployeeId = table.Column(type: "integer", nullable: false), + HrDocumentTypeId = table.Column(type: "integer", nullable: false), + OriginalFileName = table.Column(type: "character varying(260)", maxLength: 260, nullable: false), + StoredFileName = table.Column(type: "character varying(260)", maxLength: 260, nullable: false), + RelativePath = table.Column(type: "character varying(500)", maxLength: 500, nullable: false), + ContentType = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + SizeBytes = table.Column(type: "bigint", nullable: false), + IssueDate = table.Column(type: "timestamp with time zone", nullable: true), + ExpiryDate = table.Column(type: "timestamp with time zone", nullable: true), + Notes = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + UploadedBy = table.Column(type: "integer", nullable: false), + UploadedAt = table.Column(type: "timestamp with time zone", nullable: false), + VerifiedBy = table.Column(type: "integer", nullable: true), + VerifiedAt = table.Column(type: "timestamp with time zone", nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_employee_documents", x => x.EmployeeDocumentId); + table.ForeignKey( + name: "FK_hr_employee_documents_hr_document_types_HrDocumentTypeId", + column: x => x.HrDocumentTypeId, + principalTable: "hr_document_types", + principalColumn: "HrDocumentTypeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_employee_documents_hr_employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "hr_employee_loans", + columns: table => new + { + EmployeeLoanId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + EmployeeId = table.Column(type: "integer", nullable: false), + LoanKind = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + PrincipalAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + InterestRate = table.Column(type: "numeric(6,4)", precision: 6, scale: 4, nullable: false), + InstallmentAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + NumberOfInstallments = table.Column(type: "integer", nullable: false), + StartYear = table.Column(type: "integer", nullable: false), + StartMonth = table.Column(type: "integer", nullable: false), + OutstandingBalance = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ApprovedBy = table.Column(type: "integer", nullable: false), + ApprovedAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_employee_loans", x => x.EmployeeLoanId); + table.ForeignKey( + name: "FK_hr_employee_loans_hr_employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_employee_salary_structures", + columns: table => new + { + EmployeeSalaryStructureId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EmployeeId = table.Column(type: "integer", nullable: false), + EffectiveFrom = table.Column(type: "timestamp with time zone", nullable: false), + EffectiveTo = table.Column(type: "timestamp with time zone", nullable: true), + BasicSalary = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + Currency = table.Column(type: "character varying(3)", maxLength: 3, nullable: false), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ApprovedBy = table.Column(type: "integer", nullable: false), + ApprovedAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_employee_salary_structures", x => x.EmployeeSalaryStructureId); + table.ForeignKey( + name: "FK_hr_employee_salary_structures_hr_employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_leave_balances", + columns: table => new + { + LeaveBalanceId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EmployeeId = table.Column(type: "integer", nullable: false), + LeaveTypeId = table.Column(type: "integer", nullable: false), + Year = table.Column(type: "integer", nullable: false), + EntitledDays = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), + TakenDays = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), + CarriedForwardDays = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), + AdjustmentDays = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_leave_balances", x => x.LeaveBalanceId); + table.ForeignKey( + name: "FK_hr_leave_balances_hr_employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_leave_balances_hr_leave_types_LeaveTypeId", + column: x => x.LeaveTypeId, + principalTable: "hr_leave_types", + principalColumn: "LeaveTypeId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_leave_requests", + columns: table => new + { + LeaveRequestId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DocNo = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), + EmployeeId = table.Column(type: "integer", nullable: false), + LeaveTypeId = table.Column(type: "integer", nullable: false), + StartDate = table.Column(type: "timestamp with time zone", nullable: false), + EndDate = table.Column(type: "timestamp with time zone", nullable: false), + DaysCount = table.Column(type: "numeric(6,2)", precision: 6, scale: 2, nullable: false), + Reason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + ApprovedBy = table.Column(type: "integer", nullable: true), + ApprovedAt = table.Column(type: "timestamp with time zone", nullable: true), + RejectionReason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + CreatedBy = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_leave_requests", x => x.LeaveRequestId); + table.ForeignKey( + name: "FK_hr_leave_requests_hr_employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_leave_requests_hr_leave_types_LeaveTypeId", + column: x => x.LeaveTypeId, + principalTable: "hr_leave_types", + principalColumn: "LeaveTypeId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_payroll_lines", + columns: table => new + { + PayrollLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PayrollRunId = table.Column(type: "integer", nullable: false), + EmployeeId = table.Column(type: "integer", nullable: false), + BasicSalary = table.Column(type: "numeric(18,2)", nullable: false), + TotalAllowances = table.Column(type: "numeric(18,2)", nullable: false), + OvertimeAmount = table.Column(type: "numeric(18,2)", nullable: false), + GrossSalary = table.Column(type: "numeric(18,2)", nullable: false), + LateDeductionAmount = table.Column(type: "numeric(18,2)", nullable: false), + NoPayAmount = table.Column(type: "numeric(18,2)", nullable: false), + LoanDeductionAmount = table.Column(type: "numeric(18,2)", nullable: false), + EpfEmployeeAmount = table.Column(type: "numeric(18,2)", nullable: false), + EpfEmployerAmount = table.Column(type: "numeric(18,2)", nullable: false), + EtfEmployerAmount = table.Column(type: "numeric(18,2)", nullable: false), + TaxAmount = table.Column(type: "numeric(18,2)", nullable: false), + OtherDeductionsAmount = table.Column(type: "numeric(18,2)", nullable: false), + NetSalary = table.Column(type: "numeric(18,2)", nullable: false), + WorkingDays = table.Column(type: "integer", nullable: false), + PresentDays = table.Column(type: "integer", nullable: false), + AbsentDays = table.Column(type: "integer", nullable: false), + LeaveDays = table.Column(type: "integer", nullable: false), + OtMinutesTotal = table.Column(type: "integer", nullable: false), + LateMinutesTotal = table.Column(type: "integer", nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_payroll_lines", x => x.PayrollLineId); + table.ForeignKey( + name: "FK_hr_payroll_lines_hr_employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_hr_payroll_lines_hr_payroll_runs_PayrollRunId", + column: x => x.PayrollRunId, + principalTable: "hr_payroll_runs", + principalColumn: "PayrollRunId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "hr_loan_installments", + columns: table => new + { + LoanInstallmentId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EmployeeLoanId = table.Column(type: "integer", nullable: false), + InstallmentNumber = table.Column(type: "integer", nullable: false), + DueYear = table.Column(type: "integer", nullable: false), + DueMonth = table.Column(type: "integer", nullable: false), + ScheduledAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + PaidAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), + PayrollRunId = table.Column(type: "integer", nullable: true), + Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + xmin = table.Column(type: "xid", rowVersion: true, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_loan_installments", x => x.LoanInstallmentId); + table.ForeignKey( + name: "FK_hr_loan_installments_hr_employee_loans_EmployeeLoanId", + column: x => x.EmployeeLoanId, + principalTable: "hr_employee_loans", + principalColumn: "EmployeeLoanId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_hr_loan_installments_hr_payroll_runs_PayrollRunId", + column: x => x.PayrollRunId, + principalTable: "hr_payroll_runs", + principalColumn: "PayrollRunId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_employee_salary_structure_lines", + columns: table => new + { + EmployeeSalaryStructureLineId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EmployeeSalaryStructureId = table.Column(type: "integer", nullable: false), + SalaryComponentId = table.Column(type: "integer", nullable: false), + Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_employee_salary_structure_lines", x => x.EmployeeSalaryStructureLineId); + table.ForeignKey( + name: "FK_hr_employee_salary_structure_lines_hr_employee_salary_struc~", + column: x => x.EmployeeSalaryStructureId, + principalTable: "hr_employee_salary_structures", + principalColumn: "EmployeeSalaryStructureId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_hr_employee_salary_structure_lines_hr_salary_components_Sal~", + column: x => x.SalaryComponentId, + principalTable: "hr_salary_components", + principalColumn: "SalaryComponentId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_payroll_line_components", + columns: table => new + { + PayrollLineComponentId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PayrollLineId = table.Column(type: "integer", nullable: false), + ComponentCategory = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + SalaryComponentId = table.Column(type: "integer", nullable: true), + Label = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), + SortOrder = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_payroll_line_components", x => x.PayrollLineComponentId); + table.ForeignKey( + name: "FK_hr_payroll_line_components_hr_payroll_lines_PayrollLineId", + column: x => x.PayrollLineId, + principalTable: "hr_payroll_lines", + principalColumn: "PayrollLineId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_hr_payroll_line_components_hr_salary_components_SalaryCompo~", + column: x => x.SalaryComponentId, + principalTable: "hr_salary_components", + principalColumn: "SalaryComponentId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "hr_payslips", + columns: table => new + { + PayslipId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PayrollLineId = table.Column(type: "integer", nullable: false), + GeneratedAt = table.Column(type: "timestamp with time zone", nullable: false), + ReleasedAt = table.Column(type: "timestamp with time zone", nullable: true), + ReleasedBy = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_hr_payslips", x => x.PayslipId); + table.ForeignKey( + name: "FK_hr_payslips_hr_payroll_lines_PayrollLineId", + column: x => x.PayrollLineId, + principalTable: "hr_payroll_lines", + principalColumn: "PayrollLineId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "nav_items", + columns: new[] { "NavItemId", "Code", "Href", "Icon", "Label", "SortOrder" }, + values: new object[,] + { + { 1, "dashboard", "/dashboard", null, "Dashboard", 1 }, + { 2, "products", "/dashboard/products", null, "Products", 2 }, + { 3, "vendors", "/dashboard/vendors", null, "Vendors", 3 }, + { 4, "procurement", "/dashboard/procurement", null, "Procurement", 4 }, + { 5, "receiving", "/dashboard/receiving/grn", null, "Receiving", 5 }, + { 6, "stock", "/dashboard/stock", null, "Stock", 6 }, + { 7, "warehouses", "/dashboard/warehouse", null, "Warehouses", 7 }, + { 8, "orders", "/dashboard/orders", null, "Orders", 8 }, + { 9, "settings", "/dashboard/settings", null, "Settings", 9 }, + { 10, "help", "/dashboard/help", null, "Help", 10 }, + { 11, "ledgers", "/dashboard/ledgers", null, "Ledgers", 11 }, + { 12, "accounts", "/dashboard/accounts", null, "Accounts", 12 } + }); + + migrationBuilder.InsertData( + table: "users", + columns: new[] { "UserId", "auth_user_id", "DisplayName", "Email", "RoleId", "Status", "Username" }, + values: new object[] { 1, null, "System", null, null, "Active", "system" }); + + migrationBuilder.InsertData( + table: "permissions", + columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, + values: new object[,] + { + { 1, "NAV:dashboard", 1, null }, + { 2, "NAV:products", 2, null }, + { 3, "NAV:vendors", 3, null }, + { 4, "NAV:procurement", 4, null }, + { 5, "NAV:receiving", 5, null }, + { 6, "NAV:stock", 6, null }, + { 7, "NAV:warehouses", 7, null }, + { 8, "NAV:orders", 8, null }, + { 9, "NAV:settings", 9, null }, + { 10, "NAV:help", 10, null }, + { 19, "NAV:ledgers", 11, null }, + { 32, "NAV:accounts", 12, null } + }); + + migrationBuilder.InsertData( + table: "sub_nav_items", + columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" }, + values: new object[,] + { + { 1, "products.item", "/dashboard/products", null, "Item", 2, 1 }, + { 2, "products.category", "/dashboard/products/categories", null, "Category", 2, 2 }, + { 3, "products.brand", "/dashboard/products/brands", null, "Brand", 2, 3 }, + { 4, "products.item-type", "/dashboard/products/item-types", null, "Item Type", 2, 4 }, + { 5, "products.uom", "/dashboard/products/uoms", null, "UOM", 2, 5 }, + { 6, "products.configuration", "/dashboard/products/settings", null, "Configuration", 2, 6 }, + { 7, "settings.roles", "/dashboard/settings/roles", null, "Roles", 9, 1 }, + { 8, "settings.users", "/dashboard/settings/users", null, "Users", 9, 2 }, + { 9, "ledgers.trial-balance", "/dashboard/ledgers/trial-balance", null, "Trial Balance", 11, 1 }, + { 10, "ledgers.balance-sheet", "/dashboard/ledgers/balance-sheet", null, "Balance Sheet", 11, 2 }, + { 11, "ledgers.general-ledger", "/dashboard/ledgers/general-ledger", null, "General Ledger", 11, 3 }, + { 12, "ledgers.profit-and-loss", "/dashboard/ledgers/profit-and-loss", null, "Profit & Loss", 11, 4 }, + { 13, "ledgers.cash-flow", "/dashboard/ledgers/cash-flow", null, "Cash Flow", 11, 5 }, + { 14, "ledgers.budget-vs-actual", "/dashboard/ledgers/budget-vs-actual", null, "Budget vs Actual", 11, 6 }, + { 15, "accounts.bank-accounts", "/dashboard/accounts/bank-accounts", null, "Cash / Bank Accounts", 12, 1 }, + { 16, "ledgers.tax-report", "/dashboard/ledgers/tax-report", null, "Tax Report", 11, 7 }, + { 17, "procurement.requisitions", "/dashboard/procurement/requisitions", null, "Requisitions", 4, 1 }, + { 18, "procurement.rfqs", "/dashboard/procurement/rfqs", null, "RFQs", 4, 2 }, + { 19, "procurement.purchase-orders", "/dashboard/procurement/purchase-orders", null, "Purchase Orders", 4, 3 }, + { 20, "procurement.purchase-returns", "/dashboard/procurement/purchase-returns", null, "Purchase Returns", 4, 4 }, + { 21, "accounts.cheque-books", "/dashboard/accounts/cheque-books", null, "Cheque Books", 12, 2 }, + { 22, "accounts.received-cheques", "/dashboard/accounts/received-cheques", null, "Received Cheques", 12, 3 } + }); + + migrationBuilder.InsertData( + table: "permissions", + columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" }, + values: new object[,] + { + { 11, "NAV:products.item", null, 1 }, + { 12, "NAV:products.category", null, 2 }, + { 13, "NAV:products.brand", null, 3 }, + { 14, "NAV:products.item-type", null, 4 }, + { 15, "NAV:products.uom", null, 5 }, + { 16, "NAV:products.configuration", null, 6 }, + { 17, "NAV:settings.roles", null, 7 }, + { 18, "NAV:settings.users", null, 8 }, + { 20, "NAV:ledgers.trial-balance", null, 9 }, + { 21, "NAV:ledgers.balance-sheet", null, 10 }, + { 22, "NAV:ledgers.general-ledger", null, 11 }, + { 23, "NAV:ledgers.profit-and-loss", null, 12 }, + { 24, "NAV:ledgers.cash-flow", null, 13 }, + { 25, "NAV:ledgers.budget-vs-actual", null, 14 }, + { 26, "NAV:accounts.bank-accounts", null, 15 }, + { 27, "NAV:ledgers.tax-report", null, 16 }, + { 28, "NAV:procurement.requisitions", null, 17 }, + { 29, "NAV:procurement.rfqs", null, 18 }, + { 30, "NAV:procurement.purchase-orders", null, 19 }, + { 31, "NAV:procurement.purchase-returns", null, 20 }, + { 33, "NAV:accounts.cheque-books", null, 21 }, + { 34, "NAV:accounts.received-cheques", null, 22 } + }); + + migrationBuilder.CreateIndex( + name: "IX_audit_logs_CreatedAt", + table: "audit_logs", + column: "CreatedAt"); + + migrationBuilder.CreateIndex( + name: "IX_audit_logs_EntityType_EntityId", + table: "audit_logs", + columns: new[] { "EntityType", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_audit_logs_UserId", + table: "audit_logs", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_batches_ItemId_BatchNo", + table: "batches", + columns: new[] { "ItemId", "BatchNo" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_bins_WarehouseId_Code", + table: "bins", + columns: new[] { "WarehouseId", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_brands_Name", + table: "brands", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_brands_Status", + table: "brands", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_categories_Name", + table: "categories", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_categories_Status", + table: "categories", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_customers_CustomerCode", + table: "customers", + column: "CustomerCode", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_customers_CustomerType", + table: "customers", + column: "CustomerType"); + + migrationBuilder.CreateIndex( + name: "IX_customers_DefaultWarehouseId", + table: "customers", + column: "DefaultWarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_customers_Status", + table: "customers", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_grn_lines_BatchId", + table: "grn_lines", + column: "BatchId"); + + migrationBuilder.CreateIndex( + name: "IX_grn_lines_BinId", + table: "grn_lines", + column: "BinId"); + + migrationBuilder.CreateIndex( + name: "IX_grn_lines_GrnId", + table: "grn_lines", + column: "GrnId"); + + migrationBuilder.CreateIndex( + name: "IX_grn_lines_ItemId", + table: "grn_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_grn_lines_PoLineId", + table: "grn_lines", + column: "PoLineId"); + + migrationBuilder.CreateIndex( + name: "IX_grn_lines_UomId", + table: "grn_lines", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_grns_CreatedBy", + table: "grns", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_grns_DocNo", + table: "grns", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_grns_PoId", + table: "grns", + column: "PoId"); + + migrationBuilder.CreateIndex( + name: "IX_grns_Status", + table: "grns", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_grns_VendorId", + table: "grns", + column: "VendorId"); + + migrationBuilder.CreateIndex( + name: "IX_grns_WarehouseId", + table: "grns", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_attendance_records_AttendanceUploadBatchId", + table: "hr_attendance_records", + column: "AttendanceUploadBatchId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_attendance_records_EmployeeId_AttendanceDate", + table: "hr_attendance_records", + columns: new[] { "EmployeeId", "AttendanceDate" }); + + migrationBuilder.CreateIndex( + name: "IX_hr_attendance_records_WorkShiftId", + table: "hr_attendance_records", + column: "WorkShiftId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_attendance_upload_batches_DocNo", + table: "hr_attendance_upload_batches", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_attendance_upload_batches_PeriodStart_PeriodEnd", + table: "hr_attendance_upload_batches", + columns: new[] { "PeriodStart", "PeriodEnd" }); + + migrationBuilder.CreateIndex( + name: "IX_hr_attendance_upload_batches_Status", + table: "hr_attendance_upload_batches", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_branches_Code", + table: "hr_branches", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_branches_Status", + table: "hr_branches", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_departments_BranchId", + table: "hr_departments", + column: "BranchId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_departments_Code", + table: "hr_departments", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_departments_HeadEmployeeId", + table: "hr_departments", + column: "HeadEmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_departments_ParentDepartmentId", + table: "hr_departments", + column: "ParentDepartmentId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_departments_Status", + table: "hr_departments", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_designations_Code", + table: "hr_designations", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_designations_Status", + table: "hr_designations", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_document_types_Code", + table: "hr_document_types", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_document_types_Status", + table: "hr_document_types", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_bank_details_EmployeeId", + table: "hr_employee_bank_details", + column: "EmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_documents_EmployeeId", + table: "hr_employee_documents", + column: "EmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_documents_ExpiryDate", + table: "hr_employee_documents", + column: "ExpiryDate"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_documents_HrDocumentTypeId", + table: "hr_employee_documents", + column: "HrDocumentTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_loans_DocNo", + table: "hr_employee_loans", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_loans_EmployeeId", + table: "hr_employee_loans", + column: "EmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_loans_Status", + table: "hr_employee_loans", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_salary_structure_lines_EmployeeSalaryStructureId", + table: "hr_employee_salary_structure_lines", + column: "EmployeeSalaryStructureId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_salary_structure_lines_SalaryComponentId", + table: "hr_employee_salary_structure_lines", + column: "SalaryComponentId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employee_salary_structures_EmployeeId_EffectiveTo", + table: "hr_employee_salary_structures", + columns: new[] { "EmployeeId", "EffectiveTo" }); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_BranchId", + table: "hr_employees", + column: "BranchId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_DepartmentId", + table: "hr_employees", + column: "DepartmentId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_DesignationId", + table: "hr_employees", + column: "DesignationId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_Email", + table: "hr_employees", + column: "Email"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_EmployeeCode", + table: "hr_employees", + column: "EmployeeCode", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_EmploymentTypeId", + table: "hr_employees", + column: "EmploymentTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_ReportingManagerId", + table: "hr_employees", + column: "ReportingManagerId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_Status", + table: "hr_employees", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_UserId", + table: "hr_employees", + column: "UserId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_employees_WorkShiftId", + table: "hr_employees", + column: "WorkShiftId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_employment_types_Code", + table: "hr_employment_types", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_employment_types_Status", + table: "hr_employment_types", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_balances_EmployeeId_LeaveTypeId_Year", + table: "hr_leave_balances", + columns: new[] { "EmployeeId", "LeaveTypeId", "Year" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_balances_LeaveTypeId", + table: "hr_leave_balances", + column: "LeaveTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_requests_DocNo", + table: "hr_leave_requests", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_requests_EmployeeId", + table: "hr_leave_requests", + column: "EmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_requests_LeaveTypeId", + table: "hr_leave_requests", + column: "LeaveTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_requests_StartDate_EndDate", + table: "hr_leave_requests", + columns: new[] { "StartDate", "EndDate" }); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_requests_Status", + table: "hr_leave_requests", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_types_Code", + table: "hr_leave_types", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_leave_types_Status", + table: "hr_leave_types", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_loan_installments_DueYear_DueMonth", + table: "hr_loan_installments", + columns: new[] { "DueYear", "DueMonth" }); + + migrationBuilder.CreateIndex( + name: "IX_hr_loan_installments_EmployeeLoanId", + table: "hr_loan_installments", + column: "EmployeeLoanId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_loan_installments_PayrollRunId", + table: "hr_loan_installments", + column: "PayrollRunId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_line_components_PayrollLineId", + table: "hr_payroll_line_components", + column: "PayrollLineId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_line_components_SalaryComponentId", + table: "hr_payroll_line_components", + column: "SalaryComponentId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_lines_EmployeeId", + table: "hr_payroll_lines", + column: "EmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_lines_PayrollRunId_EmployeeId", + table: "hr_payroll_lines", + columns: new[] { "PayrollRunId", "EmployeeId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_runs_BranchId", + table: "hr_payroll_runs", + column: "BranchId"); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_runs_DocNo", + table: "hr_payroll_runs", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_runs_PeriodYear_PeriodMonth_BranchId", + table: "hr_payroll_runs", + columns: new[] { "PeriodYear", "PeriodMonth", "BranchId" }); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_runs_Status", + table: "hr_payroll_runs", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_payroll_statutory_settings_EffectiveFrom", + table: "hr_payroll_statutory_settings", + column: "EffectiveFrom"); + + migrationBuilder.CreateIndex( + name: "IX_hr_payslips_PayrollLineId", + table: "hr_payslips", + column: "PayrollLineId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_salary_components_Code", + table: "hr_salary_components", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_salary_components_Status", + table: "hr_salary_components", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_hr_tax_slabs_EffectiveFrom", + table: "hr_tax_slabs", + column: "EffectiveFrom"); + + migrationBuilder.CreateIndex( + name: "IX_hr_work_shifts_Code", + table: "hr_work_shifts", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hr_work_shifts_Status", + table: "hr_work_shifts", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_item_reorders_ItemId_WarehouseId", + table: "item_reorders", + columns: new[] { "ItemId", "WarehouseId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_item_reorders_WarehouseId", + table: "item_reorders", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_item_types_Name", + table: "item_types", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_item_types_Status", + table: "item_types", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_items_BaseUomId", + table: "items", + column: "BaseUomId"); + + migrationBuilder.CreateIndex( + name: "IX_items_BrandId", + table: "items", + column: "BrandId"); + + migrationBuilder.CreateIndex( + name: "IX_items_CategoryId", + table: "items", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_items_DefaultVendorId", + table: "items", + column: "DefaultVendorId"); + + migrationBuilder.CreateIndex( + name: "IX_items_Sku", + table: "items", + column: "Sku", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_items_Status", + table: "items", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_items_SubCategoryId", + table: "items", + column: "SubCategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_journal_entry_stubs_SourceDocType_SourceDocId", + table: "journal_entry_stubs", + columns: new[] { "SourceDocType", "SourceDocId" }); + + migrationBuilder.CreateIndex( + name: "IX_nav_items_Code", + table: "nav_items", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_number_sequences_doc_type_year", + table: "number_sequences", + columns: new[] { "doc_type", "year" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_permissions_Code", + table: "permissions", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_permissions_NavItemId", + table: "permissions", + column: "NavItemId"); + + migrationBuilder.CreateIndex( + name: "IX_permissions_SubNavItemId", + table: "permissions", + column: "SubNavItemId"); + + migrationBuilder.CreateIndex( + name: "IX_po_lines_ItemId", + table: "po_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_po_lines_PoId", + table: "po_lines", + column: "PoId"); + + migrationBuilder.CreateIndex( + name: "IX_po_lines_UomId", + table: "po_lines", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_po_lines_WarehouseId", + table: "po_lines", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_product_config_UpdatedBy", + table: "product_config", + column: "UpdatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_production_runs_CancelReasonCodeId", + table: "production_runs", + column: "CancelReasonCodeId"); + + migrationBuilder.CreateIndex( + name: "IX_production_runs_CreatedBy", + table: "production_runs", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_production_runs_DocNo", + table: "production_runs", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_production_runs_OutputBinId", + table: "production_runs", + column: "OutputBinId"); + + migrationBuilder.CreateIndex( + name: "IX_production_runs_Status", + table: "production_runs", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_production_runs_TemplateId_Status", + table: "production_runs", + columns: new[] { "TemplateId", "Status" }); + + migrationBuilder.CreateIndex( + name: "IX_production_runs_WarehouseId", + table: "production_runs", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_production_templates_Code", + table: "production_templates", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_production_templates_CreatedBy", + table: "production_templates", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_production_templates_Status", + table: "production_templates", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_orders_CreatedBy", + table: "purchase_orders", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_orders_DocNo", + table: "purchase_orders", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_purchase_orders_RequisitionId", + table: "purchase_orders", + column: "RequisitionId"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_orders_Status", + table: "purchase_orders", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_orders_VendorId", + table: "purchase_orders", + column: "VendorId"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_return_lines_GrnLineId", + table: "purchase_return_lines", + column: "GrnLineId"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_return_lines_ItemId", + table: "purchase_return_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_return_lines_ReturnId", + table: "purchase_return_lines", + column: "ReturnId"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_returns_CreatedBy", + table: "purchase_returns", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_returns_DocNo", + table: "purchase_returns", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_purchase_returns_ReasonCodeId", + table: "purchase_returns", + column: "ReasonCodeId"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_returns_VendorId", + table: "purchase_returns", + column: "VendorId"); + + migrationBuilder.CreateIndex( + name: "IX_purchase_returns_WarehouseId", + table: "purchase_returns", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_reason_codes_Context_Code", + table: "reason_codes", + columns: new[] { "Context", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_requisition_lines_ItemId", + table: "requisition_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_requisition_lines_RequisitionId", + table: "requisition_lines", + column: "RequisitionId"); + + migrationBuilder.CreateIndex( + name: "IX_requisitions_DocNo", + table: "requisitions", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_requisitions_RequestedBy", + table: "requisitions", + column: "RequestedBy"); + + migrationBuilder.CreateIndex( + name: "IX_requisitions_Status", + table: "requisitions", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_rfq_lines_ItemId", + table: "rfq_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_rfq_lines_RfqId", + table: "rfq_lines", + column: "RfqId"); + + migrationBuilder.CreateIndex( + name: "IX_rfqs_DocNo", + table: "rfqs", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_rfqs_RequisitionId", + table: "rfqs", + column: "RequisitionId"); + + migrationBuilder.CreateIndex( + name: "IX_role_permissions_PermissionId", + table: "role_permissions", + column: "PermissionId"); + + migrationBuilder.CreateIndex( + name: "IX_roles_auth_role_id", + table: "roles", + column: "auth_role_id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_roles_Code", + table: "roles", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_run_edges_ChildRunStageId", + table: "run_edges", + column: "ChildRunStageId"); + + migrationBuilder.CreateIndex( + name: "IX_run_edges_ParentRunStageId_ChildRunStageId", + table: "run_edges", + columns: new[] { "ParentRunStageId", "ChildRunStageId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_run_edges_RunId", + table: "run_edges", + column: "RunId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_events_RunId_EventId", + table: "run_stage_events", + columns: new[] { "RunId", "EventId" }); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_events_RunStageId", + table: "run_stage_events", + column: "RunStageId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_events_UserId", + table: "run_stage_events", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_inputs_FromRunOutputId", + table: "run_stage_inputs", + column: "FromRunOutputId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_inputs_ItemId", + table: "run_stage_inputs", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_inputs_RunStageId", + table: "run_stage_inputs", + column: "RunStageId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_inputs_UomId", + table: "run_stage_inputs", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_outputs_ItemId", + table: "run_stage_outputs", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_outputs_RunStageId", + table: "run_stage_outputs", + column: "RunStageId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_outputs_ScrapReasonCodeId", + table: "run_stage_outputs", + column: "ScrapReasonCodeId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stage_outputs_UomId", + table: "run_stage_outputs", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_run_stages_RunId_Status", + table: "run_stages", + columns: new[] { "RunId", "Status" }); + + migrationBuilder.CreateIndex( + name: "IX_run_stages_TemplateStageId", + table: "run_stages", + column: "TemplateStageId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoice_lines_ItemId", + table: "sales_invoice_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoice_lines_SalesInvoiceId", + table: "sales_invoice_lines", + column: "SalesInvoiceId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoice_lines_UomId", + table: "sales_invoice_lines", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoice_lines_WarehouseId", + table: "sales_invoice_lines", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoices_CreatorUserId", + table: "sales_invoices", + column: "CreatorUserId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoices_CustomerId", + table: "sales_invoices", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoices_InvoiceDate", + table: "sales_invoices", + column: "InvoiceDate"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoices_InvoiceNo", + table: "sales_invoices", + column: "InvoiceNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoices_Status", + table: "sales_invoices", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_sales_invoices_WarehouseId", + table: "sales_invoices", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slip_lines_ItemId", + table: "sales_slip_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slip_lines_SalesSlipId", + table: "sales_slip_lines", + column: "SalesSlipId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slip_lines_UomId", + table: "sales_slip_lines", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slip_lines_WarehouseId", + table: "sales_slip_lines", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slips_CashierUserId", + table: "sales_slips", + column: "CashierUserId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slips_CustomerId", + table: "sales_slips", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slips_SlipDate", + table: "sales_slips", + column: "SlipDate"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slips_SlipNo", + table: "sales_slips", + column: "SlipNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_sales_slips_Status", + table: "sales_slips", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_sales_slips_WarehouseId", + table: "sales_slips", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_serials_ItemId_SerialNo", + table: "serials", + columns: new[] { "ItemId", "SerialNo" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_stage_edges_ChildStageId", + table: "stage_edges", + column: "ChildStageId"); + + migrationBuilder.CreateIndex( + name: "IX_stage_edges_ParentStageId_ChildStageId", + table: "stage_edges", + columns: new[] { "ParentStageId", "ChildStageId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_stage_edges_TemplateId", + table: "stage_edges", + column: "TemplateId"); + + migrationBuilder.CreateIndex( + name: "IX_stage_inputs_FromOutputId", + table: "stage_inputs", + column: "FromOutputId"); + + migrationBuilder.CreateIndex( + name: "IX_stage_inputs_ItemId", + table: "stage_inputs", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_stage_inputs_StageId", + table: "stage_inputs", + column: "StageId"); + + migrationBuilder.CreateIndex( + name: "IX_stage_inputs_UomId", + table: "stage_inputs", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_stage_outputs_ItemId", + table: "stage_outputs", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_stage_outputs_StageId", + table: "stage_outputs", + column: "StageId"); + + migrationBuilder.CreateIndex( + name: "IX_stage_outputs_UomId", + table: "stage_outputs", + column: "UomId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustment_lines_AdjustmentId", + table: "stock_adjustment_lines", + column: "AdjustmentId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustment_lines_BatchId", + table: "stock_adjustment_lines", + column: "BatchId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustment_lines_BinId", + table: "stock_adjustment_lines", + column: "BinId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustment_lines_ItemId", + table: "stock_adjustment_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustment_lines_SerialId", + table: "stock_adjustment_lines", + column: "SerialId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustments_CreatedBy", + table: "stock_adjustments", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustments_DocNo", + table: "stock_adjustments", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustments_ReasonCodeId", + table: "stock_adjustments", + column: "ReasonCodeId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_adjustments_WarehouseId", + table: "stock_adjustments", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_count_lines_BinId", + table: "stock_count_lines", + column: "BinId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_count_lines_CountId", + table: "stock_count_lines", + column: "CountId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_count_lines_ItemId", + table: "stock_count_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_counts_CreatedBy", + table: "stock_counts", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_stock_counts_DocNo", + table: "stock_counts", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_stock_counts_Status", + table: "stock_counts", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_stock_counts_WarehouseId", + table: "stock_counts", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_layers_BatchId", + table: "stock_layers", + column: "BatchId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_layers_GrnLineId", + table: "stock_layers", + column: "GrnLineId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_layers_ItemId_WarehouseId_ReceiptDate_LayerId", + table: "stock_layers", + columns: new[] { "ItemId", "WarehouseId", "ReceiptDate", "LayerId" }); + + migrationBuilder.CreateIndex( + name: "IX_stock_layers_SerialId", + table: "stock_layers", + column: "SerialId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_layers_WarehouseId", + table: "stock_layers", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_ledger_BatchId", + table: "stock_ledger", + column: "BatchId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_ledger_BinId", + table: "stock_ledger", + column: "BinId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_ledger_ItemId_WarehouseId_CreatedAt", + table: "stock_ledger", + columns: new[] { "ItemId", "WarehouseId", "CreatedAt" }); + + migrationBuilder.CreateIndex( + name: "IX_stock_ledger_ItemId_WarehouseId_LedgerId", + table: "stock_ledger", + columns: new[] { "ItemId", "WarehouseId", "LedgerId" }); + + migrationBuilder.CreateIndex( + name: "IX_stock_ledger_SerialId", + table: "stock_ledger", + column: "SerialId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_ledger_SourceDocType_SourceDocId", + table: "stock_ledger", + columns: new[] { "SourceDocType", "SourceDocId" }); + + migrationBuilder.CreateIndex( + name: "IX_stock_ledger_UserId", + table: "stock_ledger", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_ledger_WarehouseId", + table: "stock_ledger", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfer_lines_BatchId", + table: "stock_transfer_lines", + column: "BatchId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfer_lines_DestBinId", + table: "stock_transfer_lines", + column: "DestBinId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfer_lines_ItemId", + table: "stock_transfer_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfer_lines_SerialId", + table: "stock_transfer_lines", + column: "SerialId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfer_lines_SrcBinId", + table: "stock_transfer_lines", + column: "SrcBinId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfer_lines_TransferId", + table: "stock_transfer_lines", + column: "TransferId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfers_CreatedBy", + table: "stock_transfers", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfers_DestWarehouseId", + table: "stock_transfers", + column: "DestWarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfers_DocNo", + table: "stock_transfers", + column: "DocNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfers_SrcWarehouseId", + table: "stock_transfers", + column: "SrcWarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_stock_transfers_Status", + table: "stock_transfers", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_sub_nav_items_Code", + table: "sub_nav_items", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_sub_nav_items_NavItemId", + table: "sub_nav_items", + column: "NavItemId"); + + migrationBuilder.CreateIndex( + name: "IX_subcategories_CategoryId_Name", + table: "subcategories", + columns: new[] { "CategoryId", "Name" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_subcategories_Status", + table: "subcategories", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_template_stages_TemplateId", + table: "template_stages", + column: "TemplateId"); + + migrationBuilder.CreateIndex( + name: "IX_uom_conversions_FromUomId", + table: "uom_conversions", + column: "FromUomId"); + + migrationBuilder.CreateIndex( + name: "IX_uom_conversions_ItemId_FromUomId_ToUomId", + table: "uom_conversions", + columns: new[] { "ItemId", "FromUomId", "ToUomId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_uom_conversions_ToUomId", + table: "uom_conversions", + column: "ToUomId"); + + migrationBuilder.CreateIndex( + name: "IX_uoms_Name", + table: "uoms", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_users_auth_user_id", + table: "users", + column: "auth_user_id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_users_Email", + table: "users", + column: "Email", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_users_RoleId", + table: "users", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_users_Username", + table: "users", + column: "Username", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_vendor_quotation_lines_ItemId", + table: "vendor_quotation_lines", + column: "ItemId"); + + migrationBuilder.CreateIndex( + name: "IX_vendor_quotation_lines_QuotationId", + table: "vendor_quotation_lines", + column: "QuotationId"); + + migrationBuilder.CreateIndex( + name: "IX_vendor_quotations_RfqId_VendorId", + table: "vendor_quotations", + columns: new[] { "RfqId", "VendorId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_vendor_quotations_VendorId", + table: "vendor_quotations", + column: "VendorId"); + + migrationBuilder.CreateIndex( + name: "IX_vendors_Code", + table: "vendors", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_vendors_Status", + table: "vendors", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_warehouses_Code", + table: "warehouses", + column: "Code", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_hr_attendance_records_hr_employees_EmployeeId", + table: "hr_attendance_records", + column: "EmployeeId", + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_hr_departments_hr_employees_HeadEmployeeId", + table: "hr_departments", + column: "HeadEmployeeId", + principalTable: "hr_employees", + principalColumn: "EmployeeId", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_hr_employees_users_UserId", + table: "hr_employees"); + + migrationBuilder.DropForeignKey( + name: "FK_hr_departments_hr_employees_HeadEmployeeId", + table: "hr_departments"); + + migrationBuilder.DropTable( + name: "audit_logs"); + + migrationBuilder.DropTable( + name: "hr_attendance_records"); + + migrationBuilder.DropTable( + name: "hr_employee_bank_details"); + + migrationBuilder.DropTable( + name: "hr_employee_documents"); + + migrationBuilder.DropTable( + name: "hr_employee_salary_structure_lines"); + + migrationBuilder.DropTable( + name: "hr_leave_balances"); + + migrationBuilder.DropTable( + name: "hr_leave_requests"); + + migrationBuilder.DropTable( + name: "hr_loan_installments"); + + migrationBuilder.DropTable( + name: "hr_payroll_line_components"); + + migrationBuilder.DropTable( + name: "hr_payroll_statutory_settings"); + + migrationBuilder.DropTable( + name: "hr_payslips"); + + migrationBuilder.DropTable( + name: "hr_tax_slabs"); + + migrationBuilder.DropTable( + name: "item_reorders"); + + migrationBuilder.DropTable( + name: "item_types"); + + migrationBuilder.DropTable( + name: "journal_entry_stubs"); + + migrationBuilder.DropTable( + name: "number_sequences"); + + migrationBuilder.DropTable( + name: "product_config"); + + migrationBuilder.DropTable( + name: "purchase_return_lines"); + + migrationBuilder.DropTable( + name: "requisition_lines"); + + migrationBuilder.DropTable( + name: "rfq_lines"); + + migrationBuilder.DropTable( + name: "role_permissions"); + + migrationBuilder.DropTable( + name: "run_edges"); + + migrationBuilder.DropTable( + name: "run_stage_events"); + + migrationBuilder.DropTable( + name: "run_stage_inputs"); + + migrationBuilder.DropTable( + name: "sales_invoice_lines"); + + migrationBuilder.DropTable( + name: "sales_slip_lines"); + + migrationBuilder.DropTable( + name: "stage_edges"); + + migrationBuilder.DropTable( + name: "stage_inputs"); + + migrationBuilder.DropTable( + name: "stock_adjustment_lines"); + + migrationBuilder.DropTable( + name: "stock_count_lines"); + + migrationBuilder.DropTable( + name: "stock_layers"); + + migrationBuilder.DropTable( + name: "stock_ledger"); + + migrationBuilder.DropTable( + name: "stock_transfer_lines"); + + migrationBuilder.DropTable( + name: "uom_conversions"); + + migrationBuilder.DropTable( + name: "vendor_quotation_lines"); + + migrationBuilder.DropTable( + name: "hr_attendance_upload_batches"); + + migrationBuilder.DropTable( + name: "hr_document_types"); + + migrationBuilder.DropTable( + name: "hr_employee_salary_structures"); + + migrationBuilder.DropTable( + name: "hr_leave_types"); + + migrationBuilder.DropTable( + name: "hr_employee_loans"); + + migrationBuilder.DropTable( + name: "hr_salary_components"); + + migrationBuilder.DropTable( + name: "hr_payroll_lines"); + + migrationBuilder.DropTable( + name: "purchase_returns"); + + migrationBuilder.DropTable( + name: "permissions"); + + migrationBuilder.DropTable( + name: "run_stage_outputs"); + + migrationBuilder.DropTable( + name: "sales_invoices"); + + migrationBuilder.DropTable( + name: "sales_slips"); + + migrationBuilder.DropTable( + name: "stage_outputs"); + + migrationBuilder.DropTable( + name: "stock_adjustments"); + + migrationBuilder.DropTable( + name: "stock_counts"); + + migrationBuilder.DropTable( + name: "grn_lines"); + + migrationBuilder.DropTable( + name: "serials"); + + migrationBuilder.DropTable( + name: "stock_transfers"); + + migrationBuilder.DropTable( + name: "vendor_quotations"); + + migrationBuilder.DropTable( + name: "hr_payroll_runs"); + + migrationBuilder.DropTable( + name: "sub_nav_items"); + + migrationBuilder.DropTable( + name: "run_stages"); + + migrationBuilder.DropTable( + name: "customers"); + + migrationBuilder.DropTable( + name: "batches"); + + migrationBuilder.DropTable( + name: "grns"); + + migrationBuilder.DropTable( + name: "po_lines"); + + migrationBuilder.DropTable( + name: "rfqs"); + + migrationBuilder.DropTable( + name: "nav_items"); + + migrationBuilder.DropTable( + name: "production_runs"); + + migrationBuilder.DropTable( + name: "template_stages"); + + migrationBuilder.DropTable( + name: "items"); + + migrationBuilder.DropTable( + name: "purchase_orders"); + + migrationBuilder.DropTable( + name: "bins"); + + migrationBuilder.DropTable( + name: "reason_codes"); + + migrationBuilder.DropTable( + name: "production_templates"); + + migrationBuilder.DropTable( + name: "brands"); + + migrationBuilder.DropTable( + name: "subcategories"); + + migrationBuilder.DropTable( + name: "uoms"); + + migrationBuilder.DropTable( + name: "requisitions"); + + migrationBuilder.DropTable( + name: "vendors"); + + migrationBuilder.DropTable( + name: "warehouses"); + + migrationBuilder.DropTable( + name: "categories"); + + migrationBuilder.DropTable( + name: "users"); + + migrationBuilder.DropTable( + name: "roles"); + + migrationBuilder.DropTable( + name: "hr_employees"); + + migrationBuilder.DropTable( + name: "hr_departments"); + + migrationBuilder.DropTable( + name: "hr_designations"); + + migrationBuilder.DropTable( + name: "hr_employment_types"); + + migrationBuilder.DropTable( + name: "hr_work_shifts"); + + migrationBuilder.DropTable( + name: "hr_branches"); + } + } +} diff --git a/Backend/ERPCore/appsettings.Development.json b/Backend/ERPCore/appsettings.Development.json index 6d40007..f09d44e 100644 --- a/Backend/ERPCore/appsettings.Development.json +++ b/Backend/ERPCore/appsettings.Development.json @@ -6,7 +6,7 @@ } }, "ConnectionStrings": { - "DefaultConnection": "Host=localhost;Port=5432;Database=ERPCore;Username=postgres;Password=dbuser" + "DefaultConnection": "Host=localhost;Port=5432;Database=ERPCoreDev;Username=postgres;Password=root" }, "AuthHex": { "BaseUrl": "http://localhost:5011"