From ab6fb3ab88682021df2809d67e4db7c0d0aff3a8 Mon Sep 17 00:00:00 2001 From: Loretta Date: Tue, 6 Jan 2026 15:15:57 +0100 Subject: [PATCH 1/4] Update DB to PROD; reformat GetAllByProductId method Switched connection string to use FruitBank_PROD database. Reformatted GetAllByProductId in OrderDtoDbTable.cs for clarity; no logic changes. --- Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs index c4583e0..a3eff9e 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs @@ -46,7 +46,8 @@ public class OrderDtoDbTable : MgDtoDbTableBase && o.OrderStatusId != (int)OrderStatus.Cancelled && o.GenericAttributes.Any(ga => ga.Key == nameof(OrderDto.DateOfReceipt) && DateTime.Parse(ga.Value) >= fromDate.Date)); - public IQueryable GetAllByProductId(int productId, bool loadRelations = true) => GetAll(loadRelations).Where(o => o.OrderItemDtos.Any(oi => oi.ProductId == productId)); + public IQueryable GetAllByProductId(int productId, bool loadRelations = true) + => GetAll(loadRelations).Where(o => o.OrderItemDtos.Any(oi => oi.ProductId == productId)); public IQueryable GetAllByProductIds(IEnumerable productIds, bool loadRelations = true) => GetAll(loadRelations).Where(o => o.OrderItemDtos.Any(oi => productIds.Contains(oi.ProductId))); From c5da19a3ee7694e40bb14db06a293aead21a4d68 Mon Sep 17 00:00:00 2001 From: Loretta Date: Fri, 6 Feb 2026 18:59:24 +0100 Subject: [PATCH 2/4] 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. --- .../Controllers/StockSignalREndpointServer.cs | 2 ++ .../Domains/DataLayer/StockTakingDbContext.cs | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs index 2b1c33c..093ed4d 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs @@ -43,6 +43,8 @@ public class StockSignalREndpointServer(StockTakingDbContext ctx, SignalRSendToC }); if (result) return await ctx.StockTakings.GetByIdAsync(stockTakingId, false); + + _logger.Error($"StockTaking closing ERROR! stockTakingId: {stockTakingId}"); return null; } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/StockTakingDbContext.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/StockTakingDbContext.cs index a57d217..c86e951 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/StockTakingDbContext.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/StockTakingDbContext.cs @@ -83,18 +83,24 @@ public class StockTakingDbContext : MgDbContextBase, public async Task CloseStockTaking(int stockTakingId) { + Logger.Info($"CloseStockTaking invoked! stockTakingId: {stockTakingId}"); + + var count = 0; + var stockTaking = await StockTakings.GetByIdAsync(stockTakingId, true); 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 })) { count++; - - //await _fruitBankDbContext.UpdateStockQuantityAndWeightAsync(stockTakingItem.Product!, stockTakingItem.QuantityDiff, - // $"Leltár által módosítva! stockTakingId: #{stockTaking.Id}, stockTakingItemId: #{stockTakingItem.Id}", + + //await _fruitBankDbContext.UpdateStockQuantityAndWeightAsync(stockTakingItem.Product!, stockTakingItem.QuantityDiff, + // $"Leltár által módosítva! stockTakingId: #{stockTaking.Id}, stockTakingItemId: #{stockTakingItem.Id}", // stockTakingItem.NetWeightDiff); + + Logger.Info($"CloseStockTaking.UpdateStockQuantityAndWeightAsync; {stockTakingItem.Product}; qntDiff: {stockTakingItem.QuantityDiff} db; netWeightDiff: {stockTakingItem.NetWeightDiff} kg"); } stockTaking.IsClosed = true; From 910a7aa852fa4f6ff72968832eb6ea29a08b2583 Mon Sep 17 00:00:00 2001 From: Loretta Date: Fri, 6 Feb 2026 22:14:43 +0100 Subject: [PATCH 3/4] Enable stock update on closure; adjust logging level Uncommented the stock quantity and weight update during stock taking closure, ensuring inventory is updated in the database. Changed the log level for this operation from Info to Debug. Added a new using directive and left a commented block for potential future handling of "virtual" stock items. --- .../Areas/Admin/Controllers/StockSignalREndpointServer.cs | 7 +++++++ .../Domains/DataLayer/StockTakingDbContext.cs | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs index 093ed4d..39d6250 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs @@ -4,6 +4,7 @@ using AyCode.Services.SignalRs; using DevExpress.Data.Helpers; using FruitBank.Common.Entities; using FruitBank.Common.Enums; +using FruitBank.Common.Interfaces; using FruitBank.Common.Server.Interfaces; using FruitBank.Common.Server.Services.SignalRs; using FruitBank.Common.SignalRs; @@ -66,6 +67,12 @@ public class StockSignalREndpointServer(StockTakingDbContext ctx, SignalRSendToC foreach (var productDto in productDtos) { + //if (productDto.StockQuantity < 0 && productDto.IncomingQuantity > 0) + //{ + // _logger.Info($"Beszállítás alatt lévő 'virtuális' készlet, nem leltározzuk! product: [#{productDto.Id}] {productDto.Name}; StockQuantity: {productDto.StockQuantity}; IncomingQuantity: {productDto.IncomingQuantity}"); + // continue; + //} + var stockTakingItem = new StockTakingItem { StockTakingId = stockTaking.Id, diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/StockTakingDbContext.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/StockTakingDbContext.cs index c86e951..bfc82e3 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/StockTakingDbContext.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/StockTakingDbContext.cs @@ -96,11 +96,11 @@ public class StockTakingDbContext : MgDbContextBase, { count++; - //await _fruitBankDbContext.UpdateStockQuantityAndWeightAsync(stockTakingItem.Product!, stockTakingItem.QuantityDiff, - // $"Leltár által módosítva! stockTakingId: #{stockTaking.Id}, stockTakingItemId: #{stockTakingItem.Id}", - // stockTakingItem.NetWeightDiff); + await _fruitBankDbContext.UpdateStockQuantityAndWeightAsync(stockTakingItem.Product!, stockTakingItem.QuantityDiff, + $"Leltár által módosítva! stockTakingId: #{stockTaking.Id}, stockTakingItemId: #{stockTakingItem.Id}", + stockTakingItem.NetWeightDiff); - Logger.Info($"CloseStockTaking.UpdateStockQuantityAndWeightAsync; {stockTakingItem.Product}; qntDiff: {stockTakingItem.QuantityDiff} db; netWeightDiff: {stockTakingItem.NetWeightDiff} kg"); + Logger.Debug($"CloseStockTaking.UpdateStockQuantityAndWeightAsync; {stockTakingItem.Product}; qntDiff: {stockTakingItem.QuantityDiff} db; netWeightDiff: {stockTakingItem.NetWeightDiff} kg"); } stockTaking.IsClosed = true; From 9bc7d4a27e666eb792d6ef8f4f14419eca091405 Mon Sep 17 00:00:00 2001 From: Loretta Date: Sat, 7 Feb 2026 08:54:40 +0100 Subject: [PATCH 4/4] Set IsMeasured=true in AddOrUpdateMeasuredStockTakingItemPallet Ensure all stock taking item pallets are marked as measured before adding or updating them via the SignalR endpoint. --- .../Areas/Admin/Controllers/StockSignalREndpointServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs index 39d6250..32940ef 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/StockSignalREndpointServer.cs @@ -162,6 +162,7 @@ public class StockSignalREndpointServer(StockTakingDbContext ctx, SignalRSendToC [SignalR(SignalRTags.AddOrUpdateMeasuredStockTakingItemPallet)] public async Task AddOrUpdateMeasuredStockTakingItemPallet(StockTakingItemPallet stockTakingItemPallet) { + stockTakingItemPallet.IsMeasured = true; return await ctx.AddOrUpdateMeasuredStockTakingItemPallet(stockTakingItemPallet); } } \ No newline at end of file