new order fix
This commit is contained in:
parent
11651e4946
commit
16cd9ccd73
|
|
@ -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<object>();
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -763,7 +763,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Product</th>
|
||||
<th style="width: 100px;">Mennyisség</th>
|
||||
<th style="width: 100px;">Mennyiség</th>
|
||||
<th style="width: 120px;">Egységár</th>
|
||||
<th style="width: 50px;"></th>
|
||||
</tr>
|
||||
|
|
@ -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 = $('<td>').html(
|
||||
'<input type="number" class="form-control form-control-sm" min="1" max="' + product.stockQuantity + '" value="' + product.quantity + '" data-index="' + index + '" />'
|
||||
'<input type="number" class="form-control form-control-sm" min="1" max="' + (product.stockQuantity + product.incomingQuantity) + '" value="' + product.quantity + '" data-index="' + index + '" />'
|
||||
);
|
||||
|
||||
var priceCell = $('<td>').html(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue