Files
docs/archive/03-BACKEND/CMS/CHANGELOG-2026-01-01-INVENTORY-PHASE2.md
T
masoodafar-web 5965b98728 update
2026-01-03 18:27:49 +03:30

7.9 KiB

📦 CHANGELOG - سیستم انبارداری Phase 2

تاریخ: ۱۲ دی ۱۴۰۴ (1 January 2026)
نوع: Feature Implementation
وضعیت: Build Successful


🎯 خلاصه

پیاده‌سازی کامل Phase 2 سیستم انبارداری شامل:

  • Repository Pattern برای سه Entity اصلی
  • CQRS Commands و Queries کامل
  • Handlers برای تمام عملیات
  • DI Configuration

تغییرات انجام شده

1. Repository Interfaces (Application Layer)

فایل توضیح
IInventoryItemRepository.cs اینترفیس repository برای مدیریت موجودی
IStockMovementRepository.cs اینترفیس repository برای حرکات انبار
IWarehouseRepository.cs اینترفیس repository برای انبارها

متدهای کلیدی IInventoryItemRepository:

  • GetByIdAsync, GetByProductIdAsync, GetByDiscountProductIdAsync
  • GetLowStockItemsAsync, GetOutOfStockItemsAsync
  • UpdateQuantityAsync, ReserveQuantityAsync, ReleaseReservedQuantityAsync
  • BulkUpdateQuantityAsync, BulkReserveQuantityAsync

2. Repository Implementations (Infrastructure Layer)

فایل توضیح
InventoryItemRepository.cs پیاده‌سازی کامل با EF Core
StockMovementRepository.cs پیاده‌سازی با analytics queries
WarehouseRepository.cs پیاده‌سازی با statistics

ویژگی‌های خاص:

  • استفاده از BaseAuditableEntity.Created (نه CreatedAt)
  • پشتیبانی از ProductType.RegularProduct و ProductType.DiscountProduct
  • متدهای bulk operation برای عملکرد بهتر

3. CQRS Commands

InventoryItem Commands (8 عدد):

✅ CreateInventoryItemCommand
✅ UpdateInventoryItemCommand
✅ UpdateInventoryQuantityCommand
✅ ReserveInventoryCommand
✅ ReleaseReservedInventoryCommand
✅ ReduceInventoryCommand
✅ IncreaseInventoryCommand
✅ DeleteInventoryItemCommand

StockMovement Commands (3 عدد):

✅ CreateStockMovementCommand
✅ BulkCreateStockMovementCommand
✅ DeleteStockMovementCommand

Warehouse Commands (6 عدد):

✅ CreateWarehouseCommand
✅ UpdateWarehouseCommand
✅ DeleteWarehouseCommand
✅ SetDefaultWarehouseCommand
✅ ActivateWarehouseCommand
✅ BulkCreateWarehousesCommand

4. CQRS Queries

InventoryItem Queries (10 عدد):

✅ GetInventoryItemByIdQuery
✅ GetInventoryItemByProductIdQuery
✅ GetInventoryItemByDiscountProductIdQuery
✅ SearchInventoryItemsQuery
✅ GetInventoryItemsCountQuery
✅ GetLowStockItemsQuery
✅ GetOutOfStockItemsQuery
✅ CheckInventoryAvailabilityQuery
✅ GetAvailableQuantityQuery
✅ GetWarehouseInventoryItemsQuery

StockMovement Queries (12 عدد):

✅ GetStockMovementByIdQuery
✅ GetInventoryItemMovementHistoryQuery
✅ GetStockMovementsByOrderQuery
✅ GetStockMovementsByDiscountOrderQuery
✅ GetStockMovementsByReferenceQuery
✅ GetStockMovementsByTypeQuery
✅ GetRecentStockMovementsQuery
✅ SearchStockMovementsQuery
✅ GetStockMovementsCountQuery
✅ GetMovementSummaryQuery
✅ GetDailyMovementVolumeQuery
✅ GetTopMovingProductsQuery

Warehouse Queries (10 عدد):

✅ GetWarehouseByIdQuery
✅ GetWarehouseByCodeQuery
✅ GetDefaultWarehouseQuery
✅ GetActiveWarehousesQuery
✅ GetAllWarehousesQuery
✅ SearchWarehousesQuery
✅ GetWarehousesCountQuery
✅ WarehouseExistsQuery
✅ WarehouseExistsByCodeQuery
✅ GetWarehouseStatisticsQuery

5. Handlers

فایل Handlers
InventoryItemCommandHandlers.cs 8 handler برای commands
InventoryItemQueryHandlers.cs 10 handler برای queries
StockMovementCommandHandlers.cs 3 handler برای commands
StockMovementQueryHandlers.cs 12 handler برای queries
WarehouseCommandHandlers.cs 6 handler برای commands
WarehouseQueryHandlers.cs 10 handler برای queries

6. DI Configuration

فایل DependencyInjection.cs آپدیت شد:

// Inventory Repositories
services.AddScoped<IInventoryItemRepository, InventoryItemRepository>();
services.AddScoped<IStockMovementRepository, StockMovementRepository>();
services.AddScoped<IWarehouseRepository, WarehouseRepository>();

🐛 باگ‌های رفع شده

مشکل راه‌حل
ProductType.Normal not found تغییر به ProductType.RegularProduct
ProductType.Discount not found تغییر به ProductType.DiscountProduct
.CreatedAt not found تغییر به .Created (BaseAuditableEntity)
Namespace Persistence.Context تغییر به Persistence
Interface mismatch errors بازنویسی کامل repositories

📊 آمار نهایی

متریک مقدار
Total Commands 17
Total Queries 32
Total Handlers 49
Repository Interfaces 3
Repository Implementations 3
Build Errors 0
Build Warnings 466

مراحل بعدی (باقی‌مانده از Plan)

Phase 3: Business Services (اولویت بالا)

  • IInventoryService interface
  • InventoryService implementation
  • InitializeInventoryAsync - ایجاد موجودی برای محصول جدید
  • ReserveStockAsync - رزرو برای سفارش
  • ReleaseReservationAsync - آزادسازی رزرو
  • ConfirmSaleAsync - تایید فروش
  • SyncRemainingCountAsync - همگام‌سازی با Product.RemainingCount

Phase 4: Integration

  • یکپارچه‌سازی با CreateProductCommandHandler
  • یکپارچه‌سازی با PlaceOrderCommandHandler
  • یکپارچه‌سازی با CompletePaymentHandler

Phase 5: Data Migration

  • Migration script برای Products موجود
  • Migration script برای DiscountProducts موجود

Phase 6: Proto/gRPC

  • inventory.proto
  • gRPC Service

Phase 7: Tests

  • Unit tests
  • Integration tests

📁 ساختار فایل‌ها

CMSMicroservice.Application/
├── Common/
│   └── Interfaces/
│       ├── IInventoryItemRepository.cs ✅
│       ├── IStockMovementRepository.cs ✅
│       └── IWarehouseRepository.cs ✅
└── Features/
    ├── InventoryItems/
    │   ├── Commands/
    │   │   └── InventoryItemCommands.cs ✅
    │   ├── Handlers/
    │   │   ├── InventoryItemCommandHandlers.cs ✅
    │   │   └── InventoryItemQueryHandlers.cs ✅
    │   └── Queries/
    │       └── InventoryItemQueries.cs ✅
    ├── StockMovements/
    │   ├── Commands/
    │   │   └── StockMovementCommands.cs ✅
    │   ├── Handlers/
    │   │   ├── StockMovementCommandHandlers.cs ✅
    │   │   └── StockMovementQueryHandlers.cs ✅
    │   └── Queries/
    │       └── StockMovementQueries.cs ✅
    └── Warehouses/
        ├── Commands/
        │   └── WarehouseCommands.cs ✅
        ├── Handlers/
        │   ├── WarehouseCommandHandlers.cs ✅
        │   └── WarehouseQueryHandlers.cs ✅
        └── Queries/
            └── WarehouseQueries.cs ✅

CMSMicroservice.Infrastructure/
├── DependencyInjection.cs ✅ (updated)
└── Persistence/
    └── Repositories/
        ├── InventoryItemRepository.cs ✅
        ├── StockMovementRepository.cs ✅
        └── WarehouseRepository.cs ✅

🔗 مستندات مرتبط


نویسنده: GitHub Copilot
تاریخ آخرین بروزرسانی: 1 January 2026