Add low stock endpoint
This commit is contained in:
@@ -41,6 +41,17 @@ public class StockRepository(AppDBContext db) : IStockRepository
|
||||
.Where(b => b.FK_ItemId == itemId)
|
||||
.ToListAsync();
|
||||
|
||||
public Task<List<StockBalance>> GetLowStockAsync(Guid? locationId)
|
||||
{
|
||||
var query = db.StockBalances
|
||||
.Include(b => b.Item)
|
||||
.Where(b => b.LocationType == LocationType.Warehouse
|
||||
&& b.Item.ReorderLevel != null
|
||||
&& b.Quantity < b.Item.ReorderLevel);
|
||||
if (locationId.HasValue) query = query.Where(b => b.LocationId == locationId.Value);
|
||||
return query.OrderBy(b => b.Quantity).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task AddBalanceAsync(StockBalance balance) =>
|
||||
await db.StockBalances.AddAsync(balance);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user