feat: Implement inventory and warehouse management features
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 2m33s
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 2m33s
- Add GetLowStockItemsResponseDto and LowStockItemDto for low stock item queries. - Create CreateStockMovementCommand and its handler for managing stock movements. - Implement CreateStockMovementCommandValidator for validating stock movement commands. - Add GetStockMovementsQuery and its handler to retrieve stock movement records. - Create GetStockMovementsResponseDto and StockMovementListDto for stock movement responses. - Implement GetStockMovementsByInventoryItemQuery and its handler for fetching movements by inventory item. - Add CreateWarehouseCommand and its handler for creating new warehouses. - Implement CreateWarehouseCommandValidator for warehouse creation validation. - Add DeleteWarehouseCommand and its handler for removing warehouses. - Implement SetDefaultWarehouseCommand and its handler for setting a default warehouse. - Create UpdateWarehouseCommand and its handler for updating warehouse details. - Implement GetAllWarehousesQuery and its handler to retrieve all warehouses. - Add GetWarehouseQuery and its handler for fetching a specific warehouse by ID. - Implement SearchWarehousesQuery and its handler for searching warehouses based on criteria.
This commit is contained in:
-152
@@ -1,152 +0,0 @@
|
||||
using CMSMicroservice.Domain.Entities;
|
||||
using CMSMicroservice.Domain.Enums;
|
||||
|
||||
namespace CMSMicroservice.Application.Common.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Repository interface برای مدیریت موجودی محصولات
|
||||
/// </summary>
|
||||
public interface IInventoryItemRepository
|
||||
{
|
||||
#region Read Operations
|
||||
|
||||
/// <summary>
|
||||
/// دریافت آیتم موجودی بر اساس شناسه
|
||||
/// </summary>
|
||||
Task<InventoryItem?> GetByIdAsync(long id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت آیتم موجودی بر اساس محصول معمولی
|
||||
/// </summary>
|
||||
Task<InventoryItem?> GetByProductIdAsync(long productId, long warehouseId = 1, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت آیتم موجودی بر اساس محصول تخفیفی
|
||||
/// </summary>
|
||||
Task<InventoryItem?> GetByDiscountProductIdAsync(long discountProductId, long warehouseId = 1, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت تمام آیتمهای موجودی یک انبار
|
||||
/// </summary>
|
||||
Task<List<InventoryItem>> GetByWarehouseIdAsync(long warehouseId, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت محصولات کمموجود
|
||||
/// </summary>
|
||||
Task<List<InventoryItem>> GetLowStockItemsAsync(ProductType? productType = null, long warehouseId = 1, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت محصولات با موجودی صفر
|
||||
/// </summary>
|
||||
Task<List<InventoryItem>> GetOutOfStockItemsAsync(ProductType? productType = null, long warehouseId = 1, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// جستجوی آیتمهای موجودی با فیلتر
|
||||
/// </summary>
|
||||
Task<List<InventoryItem>> SearchAsync(
|
||||
string? searchTerm = null,
|
||||
ProductType? productType = null,
|
||||
long? warehouseId = null,
|
||||
int? minQuantity = null,
|
||||
int? maxQuantity = null,
|
||||
int skip = 0,
|
||||
int take = 50,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// شمارش کل آیتمهای موجودی با فیلتر
|
||||
/// </summary>
|
||||
Task<int> CountAsync(
|
||||
string? searchTerm = null,
|
||||
ProductType? productType = null,
|
||||
long? warehouseId = null,
|
||||
int? minQuantity = null,
|
||||
int? maxQuantity = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Write Operations
|
||||
|
||||
/// <summary>
|
||||
/// افزودن آیتم موجودی جدید
|
||||
/// </summary>
|
||||
Task<InventoryItem> AddAsync(InventoryItem inventoryItem, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// بروزرسانی آیتم موجودی
|
||||
/// </summary>
|
||||
Task UpdateAsync(InventoryItem inventoryItem, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// حذف آیتم موجودی
|
||||
/// </summary>
|
||||
Task DeleteAsync(long id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// بروزرسانی موجودی (با ثبت حرکت)
|
||||
/// </summary>
|
||||
Task<bool> UpdateQuantityAsync(
|
||||
long inventoryItemId,
|
||||
int quantityChange,
|
||||
StockMovementType movementType,
|
||||
string? note = null,
|
||||
string? referenceNumber = null,
|
||||
long? orderId = null,
|
||||
long? discountOrderId = null,
|
||||
long? performedByUserId = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// رزرو موجودی
|
||||
/// </summary>
|
||||
Task<bool> ReserveQuantityAsync(
|
||||
long inventoryItemId,
|
||||
int quantity,
|
||||
string? note = null,
|
||||
string? referenceNumber = null,
|
||||
long? orderId = null,
|
||||
long? discountOrderId = null,
|
||||
long? performedByUserId = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// آزاد کردن موجودی رزرو شده
|
||||
/// </summary>
|
||||
Task<bool> ReleaseReservedQuantityAsync(
|
||||
long inventoryItemId,
|
||||
int quantity,
|
||||
string? note = null,
|
||||
string? referenceNumber = null,
|
||||
long? orderId = null,
|
||||
long? discountOrderId = null,
|
||||
long? performedByUserId = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bulk Operations
|
||||
|
||||
/// <summary>
|
||||
/// بروزرسانی انبوه موجودی چندین محصول
|
||||
/// </summary>
|
||||
Task<bool> BulkUpdateQuantityAsync(
|
||||
List<(long InventoryItemId, int QuantityChange, string? Note)> updates,
|
||||
StockMovementType movementType,
|
||||
string? referenceNumber = null,
|
||||
long? performedByUserId = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// رزرو انبوه موجودی چندین محصول
|
||||
/// </summary>
|
||||
Task<bool> BulkReserveQuantityAsync(
|
||||
List<(long InventoryItemId, int Quantity, string? Note)> reservations,
|
||||
string? referenceNumber = null,
|
||||
long? orderId = null,
|
||||
long? discountOrderId = null,
|
||||
long? performedByUserId = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
}
|
||||
-146
@@ -1,146 +0,0 @@
|
||||
using CMSMicroservice.Domain.Entities;
|
||||
using CMSMicroservice.Domain.Enums;
|
||||
|
||||
namespace CMSMicroservice.Application.Common.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Repository interface برای مدیریت حرکات موجودی
|
||||
/// </summary>
|
||||
public interface IStockMovementRepository
|
||||
{
|
||||
#region Read Operations
|
||||
|
||||
/// <summary>
|
||||
/// دریافت حرکت موجودی بر اساس شناسه
|
||||
/// </summary>
|
||||
Task<StockMovement?> GetByIdAsync(long id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت تاریخچه حرکات یک آیتم موجودی
|
||||
/// </summary>
|
||||
Task<List<StockMovement>> GetByInventoryItemIdAsync(
|
||||
long inventoryItemId,
|
||||
StockMovementType? movementType = null,
|
||||
DateTime? fromDate = null,
|
||||
DateTime? toDate = null,
|
||||
int skip = 0,
|
||||
int take = 100,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت حرکات مربوط به یک سفارش
|
||||
/// </summary>
|
||||
Task<List<StockMovement>> GetByOrderIdAsync(long orderId, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت حرکات مربوط به یک سفارش تخفیفی
|
||||
/// </summary>
|
||||
Task<List<StockMovement>> GetByDiscountOrderIdAsync(long discountOrderId, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت حرکات بر اساس شماره مرجع
|
||||
/// </summary>
|
||||
Task<List<StockMovement>> GetByReferenceNumberAsync(string referenceNumber, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت حرکات بر اساس نوع حرکت
|
||||
/// </summary>
|
||||
Task<List<StockMovement>> GetByMovementTypeAsync(
|
||||
StockMovementType movementType,
|
||||
DateTime? fromDate = null,
|
||||
DateTime? toDate = null,
|
||||
int skip = 0,
|
||||
int take = 100,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت آخرین حرکات موجودی
|
||||
/// </summary>
|
||||
Task<List<StockMovement>> GetRecentMovementsAsync(
|
||||
int count = 50,
|
||||
StockMovementType? movementType = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// جستجوی حرکات موجودی با فیلتر پیشرفته
|
||||
/// </summary>
|
||||
Task<List<StockMovement>> SearchAsync(
|
||||
long? inventoryItemId = null,
|
||||
StockMovementType? movementType = null,
|
||||
DateTime? fromDate = null,
|
||||
DateTime? toDate = null,
|
||||
string? referenceNumber = null,
|
||||
long? orderId = null,
|
||||
long? discountOrderId = null,
|
||||
long? performedByUserId = null,
|
||||
int skip = 0,
|
||||
int take = 100,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// شمارش حرکات موجودی با فیلتر
|
||||
/// </summary>
|
||||
Task<int> CountAsync(
|
||||
long? inventoryItemId = null,
|
||||
StockMovementType? movementType = null,
|
||||
DateTime? fromDate = null,
|
||||
DateTime? toDate = null,
|
||||
string? referenceNumber = null,
|
||||
long? orderId = null,
|
||||
long? discountOrderId = null,
|
||||
long? performedByUserId = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Write Operations
|
||||
|
||||
/// <summary>
|
||||
/// افزودن حرکت موجودی جدید
|
||||
/// </summary>
|
||||
Task<StockMovement> AddAsync(StockMovement stockMovement, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// حذف حرکت موجودی (نرمافزاری)
|
||||
/// </summary>
|
||||
Task DeleteAsync(long id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// افزودن انبوه حرکات موجودی
|
||||
/// </summary>
|
||||
Task<List<StockMovement>> BulkAddAsync(List<StockMovement> stockMovements, CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Analytics & Reports
|
||||
|
||||
/// <summary>
|
||||
/// گزارش خلاصه حرکات در بازه زمانی
|
||||
/// </summary>
|
||||
Task<Dictionary<StockMovementType, int>> GetMovementSummaryAsync(
|
||||
DateTime fromDate,
|
||||
DateTime toDate,
|
||||
long? inventoryItemId = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// گزارش حجم ورود و خروج روزانه
|
||||
/// </summary>
|
||||
Task<List<(DateTime Date, int InboundQuantity, int OutboundQuantity)>> GetDailyMovementVolumeAsync(
|
||||
DateTime fromDate,
|
||||
DateTime toDate,
|
||||
long? inventoryItemId = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// گزارش بیشترین حرکات محصولات
|
||||
/// </summary>
|
||||
Task<List<(long InventoryItemId, string ProductName, int MovementCount, int TotalQuantityChange)>> GetTopMovingProductsAsync(
|
||||
DateTime fromDate,
|
||||
DateTime toDate,
|
||||
int count = 10,
|
||||
StockMovementType? movementType = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
}
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
using CMSMicroservice.Domain.Entities;
|
||||
|
||||
namespace CMSMicroservice.Application.Common.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Repository interface برای مدیریت انبارها
|
||||
/// </summary>
|
||||
public interface IWarehouseRepository
|
||||
{
|
||||
#region Read Operations
|
||||
|
||||
/// <summary>
|
||||
/// دریافت انبار بر اساس شناسه
|
||||
/// </summary>
|
||||
Task<Warehouse?> GetByIdAsync(long id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت انبار بر اساس کد
|
||||
/// </summary>
|
||||
Task<Warehouse?> GetByCodeAsync(string code, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت انبار پیشفرض
|
||||
/// </summary>
|
||||
Task<Warehouse?> GetDefaultWarehouseAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت تمام انبارهای فعال
|
||||
/// </summary>
|
||||
Task<List<Warehouse>> GetActiveWarehousesAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت تمام انبارها
|
||||
/// </summary>
|
||||
Task<List<Warehouse>> GetAllAsync(bool includeInactive = false, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// جستجوی انبارها
|
||||
/// </summary>
|
||||
Task<List<Warehouse>> SearchAsync(
|
||||
string? searchTerm = null,
|
||||
bool? isActive = null,
|
||||
int skip = 0,
|
||||
int take = 50,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// شمارش انبارها
|
||||
/// </summary>
|
||||
Task<int> CountAsync(
|
||||
string? searchTerm = null,
|
||||
bool? isActive = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// بررسی وجود انبار با کد مشخص
|
||||
/// </summary>
|
||||
Task<bool> ExistsByCodeAsync(string code, long? excludeId = null, CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Write Operations
|
||||
|
||||
/// <summary>
|
||||
/// افزودن انبار جدید
|
||||
/// </summary>
|
||||
Task<Warehouse> AddAsync(Warehouse warehouse, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// بروزرسانی انبار
|
||||
/// </summary>
|
||||
Task UpdateAsync(Warehouse warehouse, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// حذف انبار (نرمافزاری)
|
||||
/// </summary>
|
||||
Task DeleteAsync(long id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// فعال/غیرفعال کردن انبار
|
||||
/// </summary>
|
||||
Task SetActiveStatusAsync(long id, bool isActive, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// تنظیم انبار پیشفرض
|
||||
/// </summary>
|
||||
Task SetAsDefaultAsync(long id, CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Analytics
|
||||
|
||||
/// <summary>
|
||||
/// گزارش آمار کلی انبار
|
||||
/// </summary>
|
||||
Task<(int TotalProducts, int LowStockProducts, int OutOfStockProducts, decimal TotalValue)> GetWarehouseStatisticsAsync(
|
||||
long warehouseId,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// گزارش محصولات پرفروش انبار
|
||||
/// </summary>
|
||||
Task<List<(long ProductId, string ProductName, int TotalSold, int CurrentStock)>> GetTopSellingProductsAsync(
|
||||
long warehouseId,
|
||||
DateTime fromDate,
|
||||
DateTime toDate,
|
||||
int count = 10,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user