fix: Update sorting and calculation of available quantity in GetLowStockItems query
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m46s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m46s
This commit is contained in:
+2
-2
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user