Add logging for stock taking close operations
Added info logs to CloseStockTaking for invocation and item updates. Added error log in StockSignalREndpointServer when closing fails.
This commit is contained in:
parent
f5e356555c
commit
c5da19a3ee
|
|
@ -43,6 +43,8 @@ public class StockSignalREndpointServer(StockTakingDbContext ctx, SignalRSendToC
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result) return await ctx.StockTakings.GetByIdAsync(stockTakingId, false);
|
if (result) return await ctx.StockTakings.GetByIdAsync(stockTakingId, false);
|
||||||
|
|
||||||
|
_logger.Error($"StockTaking closing ERROR! stockTakingId: {stockTakingId}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,18 +83,24 @@ public class StockTakingDbContext : MgDbContextBase,
|
||||||
|
|
||||||
public async Task CloseStockTaking(int stockTakingId)
|
public async Task CloseStockTaking(int stockTakingId)
|
||||||
{
|
{
|
||||||
|
Logger.Info($"CloseStockTaking invoked! stockTakingId: {stockTakingId}");
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
var stockTaking = await StockTakings.GetByIdAsync(stockTakingId, true);
|
var stockTaking = await StockTakings.GetByIdAsync(stockTakingId, true);
|
||||||
|
|
||||||
if (!stockTaking.IsReadyForClose()) throw new Exception($"Not all IsRequiredForMeasuring items are IsMeasured! IsReadyForClose: false;");
|
if (!stockTaking.IsReadyForClose()) throw new Exception($"Not all IsRequiredForMeasuring items are IsMeasured! IsReadyForClose: false;");
|
||||||
|
|
||||||
var count = 0;
|
//TODO: Mi legyen az invalid item-ekkel? - J.
|
||||||
foreach (var stockTakingItem in stockTaking.StockTakingItems!.Where(stockTakingItem => stockTakingItem is { IsMeasured: true, IsInvalid: false }))
|
foreach (var stockTakingItem in stockTaking.StockTakingItems!.Where(stockTakingItem => stockTakingItem is { IsMeasured: true, IsInvalid: false }))
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
//await _fruitBankDbContext.UpdateStockQuantityAndWeightAsync(stockTakingItem.Product!, stockTakingItem.QuantityDiff,
|
//await _fruitBankDbContext.UpdateStockQuantityAndWeightAsync(stockTakingItem.Product!, stockTakingItem.QuantityDiff,
|
||||||
// $"Leltár által módosítva! stockTakingId: #{stockTaking.Id}, stockTakingItemId: #{stockTakingItem.Id}",
|
// $"Leltár által módosítva! stockTakingId: #{stockTaking.Id}, stockTakingItemId: #{stockTakingItem.Id}",
|
||||||
// stockTakingItem.NetWeightDiff);
|
// stockTakingItem.NetWeightDiff);
|
||||||
|
|
||||||
|
Logger.Info($"CloseStockTaking.UpdateStockQuantityAndWeightAsync; {stockTakingItem.Product}; qntDiff: {stockTakingItem.QuantityDiff} db; netWeightDiff: {stockTakingItem.NetWeightDiff} kg");
|
||||||
}
|
}
|
||||||
|
|
||||||
stockTaking.IsClosed = true;
|
stockTaking.IsClosed = true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue