fix: Update sorting and calculation of available quantity in GetLowStockItems query
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m46s

This commit is contained in:
masoodafar-web
2026-01-04 22:22:42 +03:30
parent 389568af2b
commit 16ba2fa6fb
@@ -26,7 +26,7 @@ public class GetLowStockItemsQueryHandler : IRequestHandler<GetLowStockItemsQuer
var totalCount = await query.CountAsync(cancellationToken); var totalCount = await query.CountAsync(cancellationToken);
var items = await query var items = await query
.OrderBy(i => i.AvailableQuantity) .OrderBy(i => i.Quantity - i.ReservedQuantity)
.Take(request.Count) .Take(request.Count)
.Select(i => new LowStockItemDto .Select(i => new LowStockItemDto
{ {
@@ -39,7 +39,7 @@ public class GetLowStockItemsQueryHandler : IRequestHandler<GetLowStockItemsQuer
ProductTitle = i.Product != null ? i.Product.Title : (i.DiscountProduct != null ? i.DiscountProduct.Title : null), ProductTitle = i.Product != null ? i.Product.Title : (i.DiscountProduct != null ? i.DiscountProduct.Title : null),
Quantity = i.Quantity, Quantity = i.Quantity,
ReservedQuantity = i.ReservedQuantity, ReservedQuantity = i.ReservedQuantity,
AvailableQuantity = i.AvailableQuantity, AvailableQuantity = i.Quantity - i.ReservedQuantity,
LowStockThreshold = i.LowStockThreshold LowStockThreshold = i.LowStockThreshold
}) })
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);