diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs index 7960102..8e0b357 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs @@ -296,10 +296,9 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers foreach (var item in orderProducts) { var product = await _productService.GetProductByIdAsync(item.Id); - - if (product == null || product.StockQuantity - item.Quantity < 0) + if (product == null) { - var errorText = $"product == null || product.StockQuantity - item.Quantity < 0; productId: {product?.Id}; product?.StockQuantity - item.Quantity: {product?.StockQuantity - item.Quantity}"; + var errorText = $"product == null; productId: {item.Id};"; _logger.Error($"{errorText}"); throw new Exception($"{errorText}"); @@ -308,6 +307,14 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers var productDto = productDtosByOrderItemId[item.Id]; var isMeasurable = productDto.IsMeasurable; + if ((product.StockQuantity + productDto.IncomingQuantity) - item.Quantity < 0) + { + var errorText = $"((product.StockQuantity + productDto.IncomingQuantity) - item.Quantity < 0); productId: {product.Id}; (product.StockQuantity + productDto.IncomingQuantity) - item.Quantity: {(product.StockQuantity + productDto.IncomingQuantity) - item.Quantity}"; + + _logger.Error($"{errorText}"); + throw new Exception($"{errorText}"); + } + var orderItem = new OrderItem { OrderId = order.Id, @@ -522,15 +529,20 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers pageSize: maxResults); var result = new List(); + var productDtosById = await _dbContext.ProductDtos.GetAllByIds(products.Select(p => p.Id)).ToDictionaryAsync(k => k.Id, v => v); + foreach (var product in products) { + var productDto = productDtosById[product.Id]; + result.Add(new { - label = $"{product.Name} [KÉSZLET: {product.StockQuantity}] [ÁR: {product.Price}]", + label = $"{product.Name} [RENDELHETŐ: {(product.StockQuantity + productDto.IncomingQuantity)}] [ÁR: {product.Price}]", value = product.Id, sku = product.Sku, price = product.Price, - stockQuantity = product.StockQuantity + stockQuantity = product.StockQuantity, + incomingQuantity = productDto.IncomingQuantity, }); } diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Views/Order/List.cshtml b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Views/Order/List.cshtml index 031771d..a7814ef 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Views/Order/List.cshtml +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Views/Order/List.cshtml @@ -763,7 +763,7 @@ Product - Mennyisség + Mennyiség Egységár @@ -860,6 +860,7 @@ sku: product.sku || '', quantity: 1, stockQuantity : product.stockQuantity, + incomingQuantity : product.incomingQuantity, price: product.price || 0 }; @@ -889,7 +890,7 @@ ); var quantityCell = $('').html( - '' + '' ); var priceCell = $('').html( diff --git a/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs b/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs index bd144f5..1103af1 100644 --- a/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs +++ b/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs @@ -98,7 +98,7 @@ public class CustomPriceCalculationService : PriceCalculationService if (finalPrices.finalPriceInclTax == orderItem.PriceInclTax && finalPrices.finalPriceExclTax == orderItem.PriceExclTax) return false; - _logger.Error($"orderItem.PriceInclTax({orderItem.PriceInclTax}) != finalPriceInclTax({finalPrices.finalPriceInclTax}) || " + + _logger.Info($"orderItem.PriceInclTax({orderItem.PriceInclTax}) != finalPriceInclTax({finalPrices.finalPriceInclTax}) || " + $"orderItem.PriceExclTax({orderItem.PriceExclTax}) != finalPriceExclTax({finalPrices.finalPriceExclTax})"); orderItem.PriceInclTax = finalPrices.finalPriceInclTax;