This commit is contained in:
Loretta 2025-11-26 10:16:49 +01:00
commit 805c5e2299
1 changed files with 28 additions and 7 deletions

View File

@ -587,7 +587,18 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
throw new Exception($"{errorText}");
}
var orderItem = await CreateOrderItem(product, order, orderProductItem, isMeasurable, unitPricesIncludeDiscounts, customer, store);
if(orderProductItem.Price != product.Price)
{
//manual price change
unitPricesIncludeDiscounts = false;
}
else
{
unitPricesIncludeDiscounts = true;
}
var orderItem = await CreateOrderItem(product, order, orderProductItem, isMeasurable, unitPricesIncludeDiscounts, customer, store);
await _orderService.InsertOrderItemAsync(orderItem);
await _productService.AdjustInventoryAsync(product, -orderItem.Quantity, orderItem.AttributesXml, string.Format(await _localizationService.GetResourceAsync("Admin.StockQuantityHistory.Messages.PlaceOrder"), order.Id));
@ -622,13 +633,23 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
store ??= await _storeContext.GetCurrentStoreAsync();
customer ??= await _workContext.GetCurrentCustomerAsync();
var priceCalculation = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: unitPricesIncludeDiscounts);
var unitPriceInclTaxValue = priceCalculation.finalPrice;
// Calculate tax
//var (unitPriceInclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, true, customer);
var (unitPriceExclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPriceInclTaxValue, false, customer);
decimal unitPriceInclTaxValue = 0;
if (unitPricesIncludeDiscounts)
{
var priceCalculation = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: unitPricesIncludeDiscounts);
unitPriceInclTaxValue = priceCalculation.finalPrice;
}
else
{
unitPriceInclTaxValue = orderProductItem.Price;
}
// Calculate tax
//var (unitPriceInclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, true, customer);
var (unitPriceExclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPriceInclTaxValue, false, customer);
return new OrderItem
{