Implement Inventory Management Service with CRUD operations for warehouses and inventory items, stock operations, and bulk processing capabilities.
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m48s

This commit is contained in:
masoodafar-web
2026-01-02 00:45:37 +03:30
parent f0117eb1d5
commit 1cf501711f
50 changed files with 10699 additions and 101 deletions
@@ -1503,6 +1503,102 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.ToTable("NetworkMembershipHistories", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.InventoryItem", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<long?>("DiscountProductId")
.HasColumnType("bigint");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("LastRestockedAt")
.HasColumnType("datetime2");
b.Property<DateTime?>("LastSoldAt")
.HasColumnType("datetime2");
b.Property<int>("LowStockThreshold")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(10);
b.Property<int>("MaxStockLevel")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(1000);
b.Property<long?>("ProductId")
.HasColumnType("bigint");
b.Property<int>("ProductType")
.HasColumnType("int");
b.Property<int>("Quantity")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(0);
b.Property<int>("ReorderPoint")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(5);
b.Property<int>("ReservedQuantity")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(0);
b.Property<long>("WarehouseId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasDefaultValue(1L);
b.HasKey("Id");
b.HasIndex("DiscountProductId")
.HasDatabaseName("IX_InventoryItems_DiscountProductId");
b.HasIndex("ProductId")
.HasDatabaseName("IX_InventoryItems_ProductId");
b.HasIndex("WarehouseId")
.HasDatabaseName("IX_InventoryItems_WarehouseId");
b.HasIndex("ProductType", "Quantity")
.HasDatabaseName("IX_InventoryItems_ProductType_Quantity");
b.ToTable("InventoryItems", "CMS", t =>
{
t.HasCheckConstraint("CK_InventoryItem_ProductReference", "(ProductId IS NOT NULL AND DiscountProductId IS NULL) OR (ProductId IS NULL AND DiscountProductId IS NOT NULL)");
t.HasCheckConstraint("CK_InventoryItem_ProductType_Match", "(ProductType = 1 AND ProductId IS NOT NULL) OR (ProductType = 2 AND DiscountProductId IS NOT NULL)");
t.HasCheckConstraint("CK_InventoryItem_Quantity_NonNegative", "Quantity >= 0");
t.HasCheckConstraint("CK_InventoryItem_ReservedQuantity_LessOrEqualQuantity", "ReservedQuantity <= Quantity");
t.HasCheckConstraint("CK_InventoryItem_ReservedQuantity_NonNegative", "ReservedQuantity >= 0");
});
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b =>
{
b.Property<long>("Id")
@@ -2210,6 +2306,97 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.ToTable("Roles", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.StockMovement", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<long?>("DiscountOrderId")
.HasColumnType("bigint");
b.Property<long>("InventoryItemId")
.HasColumnType("bigint");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<int>("MovementType")
.HasColumnType("int");
b.Property<string>("Note")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<long?>("OrderId")
.HasColumnType("bigint");
b.Property<long?>("PerformedByUserId")
.HasColumnType("bigint");
b.Property<int>("Quantity")
.HasColumnType("int");
b.Property<int>("QuantityAfter")
.HasColumnType("int");
b.Property<int>("QuantityBefore")
.HasColumnType("int");
b.Property<string>("ReferenceNumber")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.HasKey("Id");
b.HasIndex("Created")
.HasDatabaseName("IX_StockMovements_Created");
b.HasIndex("DiscountOrderId")
.HasDatabaseName("IX_StockMovements_DiscountOrderId")
.HasFilter("[DiscountOrderId] IS NOT NULL");
b.HasIndex("InventoryItemId")
.HasDatabaseName("IX_StockMovements_InventoryItemId");
b.HasIndex("MovementType")
.HasDatabaseName("IX_StockMovements_MovementType");
b.HasIndex("OrderId")
.HasDatabaseName("IX_StockMovements_OrderId")
.HasFilter("[OrderId] IS NOT NULL");
b.HasIndex("ReferenceNumber")
.HasDatabaseName("IX_StockMovements_ReferenceNumber")
.HasFilter("[ReferenceNumber] IS NOT NULL");
b.HasIndex("InventoryItemId", "MovementType", "Created")
.HasDatabaseName("IX_StockMovements_Item_Type_Date");
b.ToTable("StockMovements", "CMS", t =>
{
t.HasCheckConstraint("CK_StockMovement_QuantityAfter_Calculation", "QuantityAfter = QuantityBefore + Quantity");
t.HasCheckConstraint("CK_StockMovement_QuantityAfter_NonNegative", "QuantityAfter >= 0");
t.HasCheckConstraint("CK_StockMovement_QuantityBefore_NonNegative", "QuantityBefore >= 0");
});
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b =>
{
b.Property<long>("Id")
@@ -2818,6 +3005,83 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.ToTable("UserWalletChangeLogs", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Warehouse", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<string>("Address")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsActive")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<bool>("IsDefault")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.HasKey("Id");
b.HasIndex("Code")
.IsUnique()
.HasDatabaseName("IX_Warehouses_Code_Unique");
b.HasIndex("IsActive")
.HasDatabaseName("IX_Warehouses_IsActive");
b.HasIndex("IsDefault")
.HasDatabaseName("IX_Warehouses_IsDefault")
.HasFilter("[IsDefault] = 1");
b.ToTable("Warehouses", "CMS");
b.HasData(
new
{
Id = 1L,
Address = "تهران - انبار مرکزی فروشگاه",
Code = "WH-001",
Created = new DateTime(2026, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc),
CreatedBy = "System",
IsActive = true,
IsDefault = true,
IsDeleted = false,
Name = "انبار اصلی"
});
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.WeekDefinition", b =>
{
b.Property<long>("Id")
@@ -3185,6 +3449,31 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("WeekDefinition");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.InventoryItem", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "DiscountProduct")
.WithMany()
.HasForeignKey("DiscountProductId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("CMSMicroservice.Domain.Entities.Warehouse", "Warehouse")
.WithMany("InventoryItems")
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("DiscountProduct");
b.Navigation("Product");
b.Navigation("Warehouse");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
@@ -3290,6 +3579,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("Tag");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.StockMovement", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.InventoryItem", "InventoryItem")
.WithMany("StockMovements")
.HasForeignKey("InventoryItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("InventoryItem");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent")
@@ -3527,6 +3827,11 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("Cities");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.InventoryItem", b =>
{
b.Navigation("StockMovements");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b =>
{
b.Navigation("UserOrders");
@@ -3611,6 +3916,11 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("UserWalletChangeLogs");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Warehouse", b =>
{
b.Navigation("InventoryItems");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.WeekDefinition", b =>
{
b.Navigation("CommissionPayoutHistories");