Compare commits
3 Commits
ffa4e2cc31
...
343fb818c7
| Author | SHA1 | Date |
|---|---|---|
|
|
343fb818c7 | |
|
|
71f2eab412 | |
|
|
b00bd0508d |
|
|
@ -168,12 +168,11 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
return RedirectToAction("List");
|
||||
|
||||
//prepare model
|
||||
var model = await _orderModelFactory.PrepareOrderModelAsync(null, order);
|
||||
var model = await _orderModelFactory.PrepareOrderModelExtendedAsync(null, order);
|
||||
|
||||
return View("~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/Edit.cshtml", model);
|
||||
}
|
||||
|
||||
|
||||
public async Task<OrderListModelExtended> GetOrderListModelByFilter(OrderSearchModel searchModel)
|
||||
{
|
||||
//return _customOrderService.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@model OrderModel
|
||||
@model Nop.Plugin.Misc.FruitBankPlugin.Models.Orders.OrderModelExtended
|
||||
|
||||
|
||||
@{
|
||||
|
|
|
|||
|
|
@ -307,6 +307,8 @@
|
|||
Name = "orders-grid",
|
||||
UrlRead = new DataUrl("OrderList", "CustomOrder", null),
|
||||
SearchButtonId = "search-orders",
|
||||
Ordering = true,
|
||||
ServerSide = false,
|
||||
Length = Model.PageSize,
|
||||
LengthMenu = Model.AvailablePageSizes,
|
||||
FooterCallback = !Model.IsLoggedInAsVendor ? "ordersfootercallback" : null,
|
||||
|
|
@ -348,27 +350,28 @@
|
|||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModelExtended.CustomerCompany))
|
||||
{
|
||||
Title = T("Admin.Orders.Fields.Customer").Text,
|
||||
Width = "150"
|
||||
//Render = new RenderCustom("renderColumnCustomer")
|
||||
});
|
||||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModelExtended.IsMeasurable))
|
||||
{
|
||||
Title = T("Admin.Orders.Fields.IsMeasurable").Text,
|
||||
Width = "100",
|
||||
Title = T($"FruitBank.{nameof(OrderModelExtended.IsMeasurable)}").Text,
|
||||
Width = "80",
|
||||
Render = new RenderCustom("renderColumnIsMeasurable"),
|
||||
ClassName = NopColumnClassDefaults.CenterAll
|
||||
});
|
||||
|
||||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModelExtended.IsMeasured))
|
||||
{
|
||||
Title = T("Admin.Orders.Fields.IsMeasured").Text,
|
||||
Width = "100",
|
||||
Title = T($"FruitBank.{nameof(OrderModelExtended.IsMeasured)}").Text,
|
||||
Width = "80",
|
||||
Render = new RenderCustom("renderColumnIsMeasurable"),
|
||||
ClassName = NopColumnClassDefaults.CenterAll
|
||||
});
|
||||
|
||||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(IOrderDto.DateOfReceipt))
|
||||
{
|
||||
Title = T("Admin.Orders.Fields.PickupDate").Text,
|
||||
Title = T($"FruitBank.{nameof(IOrderDto.DateOfReceipt)}").Text,
|
||||
Width = "100",
|
||||
Render = new RenderCustom("renderColumnPickupDateAndTime"),
|
||||
ClassName = NopColumnClassDefaults.CenterAll
|
||||
|
|
@ -387,7 +390,7 @@
|
|||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModel.PaymentStatus))
|
||||
{
|
||||
Title = T("Admin.Orders.Fields.PaymentStatus").Text,
|
||||
Width = "150"
|
||||
Width = "130"
|
||||
});
|
||||
//a vendor does not have access to this functionality
|
||||
if (!Model.IsLoggedInAsVendor)
|
||||
|
|
@ -395,10 +398,9 @@
|
|||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModel.ShippingStatus))
|
||||
{
|
||||
Title = T("Admin.Orders.Fields.ShippingStatus").Text,
|
||||
Width = "150"
|
||||
Width = "130"
|
||||
});
|
||||
}
|
||||
|
||||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModel.StoreName))
|
||||
{
|
||||
Title = T("Admin.Orders.Fields.Store").Text,
|
||||
|
|
@ -408,7 +410,7 @@
|
|||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModel.CreatedOn))
|
||||
{
|
||||
Title = T("Admin.Orders.Fields.CreatedOn").Text,
|
||||
Width = "120",
|
||||
Width = "100",
|
||||
Render = new RenderDate()
|
||||
});
|
||||
//a vendor does not have access to this functionality
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
@model OrderModel
|
||||
@model Nop.Plugin.Misc.FruitBankPlugin.Models.Orders.OrderModelExtended
|
||||
|
||||
@using Nop.Core.Domain.Tax;
|
||||
@using Nop.Core.Domain.Catalog;
|
||||
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<div class="col-md-12" style="overflow-x: auto;">ANYÁD!!!!!
|
||||
<div class="col-md-12" style="overflow-x: auto;">
|
||||
@foreach (var item in Model.Items)
|
||||
{
|
||||
<script>
|
||||
|
|
@ -20,6 +20,18 @@
|
|||
// Function to automatically calculate and update total price
|
||||
function calculateTotal@(item.Id)() {
|
||||
// Get values
|
||||
|
||||
@* var isMeasurable = ($('#pvIsMeasurable@(item.Id)').val()).toLowerCase() === "true"; *@
|
||||
|
||||
var isMeasurable = $($('#pvIsMeasurable@(item.Id)')).is(':checked');
|
||||
console.log(isMeasurable);
|
||||
console.log(($('#pvIsMeasurable@(item.Id)')));
|
||||
console.log(($('#pvIsMeasurable@(item.Id)').val()));
|
||||
console.log(($('#pvIsMeasurable@(item.Id)').val()).toLowerCase());
|
||||
|
||||
|
||||
var netWeight = parseFloat($('#pvNetWeight@(item.Id)').val()) || 0;
|
||||
|
||||
var unitPriceInclTax = parseFloat($('#pvUnitPriceInclTax@(item.Id)').val()) || 0;
|
||||
var unitPriceExclTax = parseFloat($('#pvUnitPriceExclTax@(item.Id)').val()) || 0;
|
||||
var quantity = parseFloat($('#pvQuantity@(item.Id)').val()) || 0;
|
||||
|
|
@ -27,8 +39,8 @@
|
|||
var discountExclTax = parseFloat($('#pvDiscountExclTax@(item.Id)').val()) || 0;
|
||||
|
||||
// Calculate totals
|
||||
var totalInclTax = (unitPriceInclTax * quantity) - discountInclTax;
|
||||
var totalExclTax = (unitPriceExclTax * quantity) - discountExclTax;
|
||||
var totalInclTax = (unitPriceInclTax * (isMeasurable ? netWeight : quantity)) - discountInclTax;
|
||||
var totalExclTax = (unitPriceExclTax * (isMeasurable ? netWeight : quantity)) - discountExclTax;
|
||||
|
||||
// Update total price fields
|
||||
$('#pvPriceInclTax@(item.Id)').val(totalInclTax.toFixed(0));
|
||||
|
|
@ -117,12 +129,21 @@
|
|||
<th>
|
||||
@T("Admin.Orders.Products.Price")
|
||||
</th>
|
||||
<th>
|
||||
@T("FruitBank.IsMeasurable")
|
||||
</th>
|
||||
<th>
|
||||
@T("FruitBank.StockQuantity")
|
||||
</th>
|
||||
<th>
|
||||
@T("Admin.Orders.Products.Quantity")
|
||||
</th>
|
||||
<th>
|
||||
@T("Admin.Orders.Products.Discount")
|
||||
@T("FruitBank.NetWeight")
|
||||
</th>
|
||||
@* <th>
|
||||
@T("Admin.Orders.Products.Discount")
|
||||
</th> *@
|
||||
<th>
|
||||
@T("Admin.Orders.Products.Total")
|
||||
</th>
|
||||
|
|
@ -135,7 +156,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Items)
|
||||
@foreach (var item in Model.ItemExtendeds)
|
||||
{
|
||||
<tr>
|
||||
<td class="text-center preview">
|
||||
|
|
@ -240,7 +261,7 @@
|
|||
<input name="pvUnitPriceInclTax@(item.Id)" type="text" value="@item.UnitPriceInclTaxValue" id="pvUnitPriceInclTax@(item.Id)" class="form-control input-sm" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
@* <div class="form-group row">
|
||||
<div class="col-md-5">
|
||||
@T("Admin.Orders.Products.Edit.ExclTax")
|
||||
</div>
|
||||
|
|
@ -248,19 +269,35 @@
|
|||
<input name="pvUnitPriceExclTax@(item.Id)" type="text" value="@item.UnitPriceExclTaxValue" id="pvUnitPriceExclTax@(item.Id)" class="form-control input-sm" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
*@ </div>
|
||||
</td>
|
||||
|
||||
<td style="width: 80px;" class="text-center">
|
||||
<div><input type="checkbox" name="pvIsMeasurable@(item.Id)" id="pvIsMeasurable@(item.Id)" @(item.IsMeasurable ? " checked" : "") disabled /></div>
|
||||
</td>
|
||||
|
||||
<td style="width: 80px;" class="text-center">
|
||||
<div>@($"{item.ProductStockQuantity}{(item.ProductIncomingQuantity > 0 ? " (+"+item.ProductIncomingQuantity + ")" : string.Empty)}")</div>
|
||||
</td>
|
||||
|
||||
<td style="width: 10%;" class="text-center">
|
||||
<div>@item.Quantity</div>
|
||||
<div id="pnlEditPvQuantity@(item.Id)">
|
||||
<div class="form-group row">
|
||||
<div class="col-md-8 offset-md-2">
|
||||
<input name="pvQuantity@(item.Id)" type="text" value="@item.Quantity" id="pvQuantity@(item.Id)" class="form-control input-sm" />
|
||||
</div>
|
||||
<input name="pvQuantity@(item.Id)" type="number" max="@(item.ProductStockQuantity + item.ProductIncomingQuantity)" min="0"
|
||||
value="@item.Quantity" id="pvQuantity@(item.Id)" class="form-control input-sm" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="width: 15%;" class="text-center">
|
||||
|
||||
<td style="width: 80px;" class="text-center">
|
||||
@* <div name="pvNetWeight@(item.Id)" id="pvNetWeight@(item.Id)">@item.NetWeight</div> *@
|
||||
<div><input name="pvNetWeight@(item.Id)" id="pvNetWeight@(item.Id)" value='@item.NetWeight' disabled /></div>
|
||||
</td>
|
||||
|
||||
@* <td style="width: 15%;" class="text-center">
|
||||
@if (Model.AllowCustomersToSelectTaxDisplayType)
|
||||
{
|
||||
<div>@Html.Raw(item.DiscountInclTax)</div>
|
||||
|
|
@ -302,8 +339,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="width: 15%;" class="text-center">
|
||||
</td> *@
|
||||
<td style="width: 15%;" class="text-center;">
|
||||
@if (Model.AllowCustomersToSelectTaxDisplayType)
|
||||
{
|
||||
<div>@Html.Raw(item.SubTotalInclTax)</div>
|
||||
|
|
@ -333,18 +370,18 @@
|
|||
@T("Admin.Orders.Products.Edit.InclTax")
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<input name="pvPriceInclTax@(item.Id)" type="text" value="@item.SubTotalInclTaxValue" id="pvPriceInclTax@(item.Id)" class="form-control input-sm" />
|
||||
<input name="pvPriceInclTax@(item.Id)" disabled type="text" value="@item.SubTotalInclTaxValue" id="pvPriceInclTax@(item.Id)" class="form-control input-sm" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
@* <div class="form-group row">
|
||||
<div class="col-md-5">
|
||||
@T("Admin.Orders.Products.Edit.ExclTax")
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<input name="pvPriceExclTax@(item.Id)" type="text" value="@item.SubTotalExclTaxValue" id="pvPriceExclTax@(item.Id)" class="form-control input-sm" />
|
||||
<input name="pvPriceExclTax@(item.Id)" disabled type="text" value="@item.SubTotalExclTaxValue" id="pvPriceExclTax@(item.Id)" class="form-control input-sm" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
</div>
|
||||
</td>
|
||||
@if (!Model.IsLoggedInAsVendor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ public class OrderItemDtoDbTable : MgDtoDbTableBase<OrderItemDto, OrderItem>
|
|||
.LoadWith(oi => oi.ProductDto).ThenLoad(prod => prod.GenericAttributes);
|
||||
}
|
||||
|
||||
public Task<OrderItemDto> GetByIdAsync(int orderItemId, bool loadRelations) => GetAll(loadRelations).Where(x => x.Id == orderItemId).FirstOrDefaultAsync(null);
|
||||
public Task<OrderItemDto> GetByIdAsync(int orderItemId, bool loadRelations) => GetAll(loadRelations).Where(oi => oi.Id == orderItemId).FirstOrDefaultAsync(null);
|
||||
|
||||
public IQueryable<OrderItemDto> GetAllByOrderId(int orderId, bool loadRelations = true)=> GetAll(loadRelations).Where(o => o.OrderId == orderId);
|
||||
public IQueryable<OrderItemDto> GetAllByOrderId(int orderId, bool loadRelations = true)=> GetAll(loadRelations).Where(oi => oi.OrderId == orderId);
|
||||
|
||||
public IQueryable<OrderItemDto> GetAllByIds(IEnumerable<int> orderItemIds, bool loadRelations = true) => GetAll(loadRelations).Where(oi => orderItemIds.Contains(oi.Id));
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ public class FruitBankEventConsumer :
|
|||
IConsumer<EntityInsertedEvent<OrderItem>>,
|
||||
IConsumer<EntityUpdatedEvent<OrderItem>>
|
||||
{
|
||||
private CustomPriceCalculationService _customPriceCalculationService;
|
||||
private readonly CustomPriceCalculationService _customPriceCalculationService;
|
||||
|
||||
private readonly FruitBankDbContext _ctx;
|
||||
private readonly FruitBankAttributeService _fruitBankAttributeService;
|
||||
|
|
@ -43,8 +43,7 @@ public class FruitBankEventConsumer :
|
|||
_fruitBankAttributeService = fruitBankAttributeService;
|
||||
_customPriceCalculationService = customPriceCalculationService as CustomPriceCalculationService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override async Task HandleEventAsync(EntityUpdatedEvent<Product> eventMessage)
|
||||
{
|
||||
var product = await CheckAndUpdateProductManageInventoryMethodToManageStock(eventMessage.Entity);
|
||||
|
|
@ -83,7 +82,6 @@ public class FruitBankEventConsumer :
|
|||
/// <param name="product"></param>
|
||||
/// <returns>IsMeasureable</returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
|
||||
private async Task<(bool IsMeasurableChanged, bool? IsMeasurable)> SaveProductCustomAttributesAsync(Product product)
|
||||
{
|
||||
if (product == null) return (false, null);
|
||||
|
|
|
|||
|
|
@ -167,21 +167,61 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Factories
|
|||
orderDtosById ??= await _ctx.OrderDtos.GetAllByIds(orderListModel.Data.Select(x => x.Id)).ToDictionaryAsync(k => k.Id, v => v);
|
||||
var orderDto = orderDtosById[orderModelExtended.Id];
|
||||
|
||||
orderModelExtended.IsMeasured = orderDto.IsMeasured;
|
||||
orderModelExtended.IsMeasurable = orderDto.IsMeasurable;
|
||||
orderModelExtended.DateOfReceipt = orderDto.DateOfReceipt;
|
||||
|
||||
orderModelExtended.CustomerCompany = orderDto.Customer.Company;
|
||||
|
||||
//orderModelExtended.IsMeasurable = await ShouldMarkAsNeedsMeasurementAsync(orderModel);
|
||||
//orderModelExtended.DateOfReceipt = await GetPickupDateTimeAsync(orderModel);
|
||||
|
||||
//Console.WriteLine(orderModelExtended.Id);
|
||||
PrepareOrderModelExtended(orderModelExtended, orderDto);
|
||||
});
|
||||
|
||||
return orderListModelExtended;
|
||||
}
|
||||
|
||||
private static void PrepareOrderModelExtended(OrderModelExtended orderModelExtended, OrderDto orderDto)
|
||||
{
|
||||
orderModelExtended.IsMeasured = orderDto.IsMeasured;
|
||||
orderModelExtended.IsMeasurable = orderDto.IsMeasurable;
|
||||
orderModelExtended.DateOfReceipt = orderDto.DateOfReceipt;
|
||||
orderModelExtended.OrderTotal = !orderDto.IsComplete && orderDto.IsMeasurable ? "Kalkuláció alatt..." : orderModelExtended.OrderTotal;
|
||||
orderModelExtended.CustomerCompany = orderDto.Customer.Company;
|
||||
}
|
||||
|
||||
public override async Task<OrderModel> PrepareOrderModelAsync(OrderModel model, Order order, bool excludeProperties = false)
|
||||
{
|
||||
return await base.PrepareOrderModelAsync(model, order, excludeProperties);
|
||||
}
|
||||
|
||||
public async Task<OrderModelExtended> PrepareOrderModelExtendedAsync(OrderModel model, Order order, bool excludeProperties = false)
|
||||
{
|
||||
var orderModel = await base.PrepareOrderModelAsync(model, order, excludeProperties);
|
||||
var orderModelExtended = new OrderModelExtended();
|
||||
|
||||
PropertyHelper.CopyPublicValueTypeProperties(orderModel, orderModelExtended);
|
||||
|
||||
var orderDto = await _ctx.OrderDtos.GetByIdAsync(order.Id, true);
|
||||
PrepareOrderModelExtended(orderModelExtended, orderDto);
|
||||
|
||||
var orderItemDtosById = await _ctx.OrderItemDtos.GetAllByIds(orderModelExtended.Items.Select(oi => oi.Id)).ToDictionaryAsync(k => k.Id, v => v);
|
||||
foreach (var orderItemModel in orderModelExtended.Items)
|
||||
{
|
||||
var orderItemModelExtended = new OrderItemModelExtended();
|
||||
PropertyHelper.CopyPublicValueTypeProperties(orderItemModel, orderItemModelExtended);
|
||||
|
||||
var orderItemDto = orderItemDtosById[orderItemModelExtended.Id];
|
||||
|
||||
orderItemModelExtended.IsMeasured = orderItemDto.IsMeasured;
|
||||
orderItemModelExtended.IsMeasurable = orderItemDto.IsMeasurable;
|
||||
orderItemModelExtended.NetWeight = (decimal)orderItemDto.NetWeight;
|
||||
orderItemModelExtended.ProductStockQuantity = orderItemDto.ProductDto!.StockQuantity;
|
||||
orderItemModelExtended.ProductIncomingQuantity = orderItemDto.ProductDto.IncomingQuantity;
|
||||
|
||||
orderModelExtended.ItemExtendeds ??= new List<OrderItemModelExtended>();
|
||||
orderModelExtended.ItemExtendeds.Add(orderItemModelExtended);
|
||||
|
||||
//var a = orderItemModelExtended;
|
||||
//var gf= $"{a.ProductStockQuantity} {(a.ProductIncomingQuantity > 0 ? a.ProductIncomingQuantity.ToString() : string.Empty)}";
|
||||
}
|
||||
|
||||
//orderModelExtended.Items.Clear();
|
||||
return orderModelExtended;
|
||||
}
|
||||
|
||||
// example async custom logic
|
||||
private async Task<bool> ShouldMarkAsNeedsMeasurementAsync(OrderModel order)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,15 @@ using Nop.Plugin.Misc.FruitBankPlugin.Models.MgBase.OrderModels;
|
|||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders;
|
||||
|
||||
public interface IOrderItemModelExtended //: IMgOrderItemModelExtended, IMeasurable, IMeasured
|
||||
{
|
||||
bool IsMeasured { get; set; }
|
||||
bool IsMeasurable { get; set; }
|
||||
decimal NetWeight { get; set; }
|
||||
int ProductStockQuantity { get; set; }
|
||||
int ProductIncomingQuantity { get; set; }
|
||||
}
|
||||
|
||||
public interface IOrderModelExtended : IMgOrderModelExtended, IMeasurable, IMeasured
|
||||
{
|
||||
DateTime? DateOfReceipt { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,17 @@
|
|||
using Nop.Plugin.Misc.FruitBankPlugin.Models.MgBase.OrderModels;
|
||||
using Nop.Web.Areas.Admin.Models.Orders;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
||||
{
|
||||
public partial record OrderItemModelExtended : /*MgOrderItemModelExtended*/ OrderItemModel, IOrderItemModelExtended
|
||||
{
|
||||
public bool IsMeasured { get; set; }
|
||||
public bool IsMeasurable { get; set; }
|
||||
public decimal NetWeight { get; set; }
|
||||
public int ProductStockQuantity { get; set; }
|
||||
public int ProductIncomingQuantity { get; set; }
|
||||
}
|
||||
|
||||
public partial record OrderModelExtended : MgOrderModelExtended, IOrderModelExtended
|
||||
{
|
||||
public bool IsMeasured { get; set; }
|
||||
|
|
@ -9,6 +19,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
|||
public DateTime? DateOfReceipt { get; set; }
|
||||
|
||||
public string CustomerCompany { get; set; }
|
||||
|
||||
public IList<OrderItemModelExtended> ItemExtendeds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@ public class CustomPriceCalculationService : PriceCalculationService
|
|||
return await CheckAndUpdateOrderItemFinalPricesAsync(orderItem, orderItemDto);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="orderItem"></param>
|
||||
/// <param name="orderItemDto"></param>
|
||||
/// <returns>true if has changes</returns>
|
||||
public async Task<bool> CheckAndUpdateOrderItemFinalPricesAsync(OrderItem orderItem, OrderItemDto orderItemDto)
|
||||
{
|
||||
_logger.Info($"CustomPriceCalculationService->CheckAndUpdateOrderItemFinalPricesAsync; orderItem.Id: {orderItem.Id}");
|
||||
|
|
@ -94,7 +100,12 @@ public class CustomPriceCalculationService : PriceCalculationService
|
|||
return true;
|
||||
}
|
||||
|
||||
public async Task CheckAndUpdateOrderTotalPrice(Order order)
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="order"></param>
|
||||
/// <returns>true if has changes</returns>
|
||||
public async Task<bool> CheckAndUpdateOrderTotalPrice(Order order)
|
||||
{
|
||||
var prevOrderTotal = order.OrderTotal;
|
||||
var orderItemDtos = await _dbContext.OrderItemDtos.GetAllByOrderId(order.Id).ToListAsync();
|
||||
|
|
@ -107,7 +118,7 @@ public class CustomPriceCalculationService : PriceCalculationService
|
|||
order.OrderTotal += itemDto.PriceInclTax;
|
||||
}
|
||||
|
||||
if (order.OrderTotal == prevOrderTotal) return;
|
||||
if (order.OrderTotal == prevOrderTotal) return false;
|
||||
|
||||
_logger.Error($"HandleEventAsync->CheckAndUpdateOrderItemFinalPrices; order.OrderTotal({order.OrderTotal}) == prevOrderTotal({prevOrderTotal})");
|
||||
|
||||
|
|
@ -117,6 +128,7 @@ public class CustomPriceCalculationService : PriceCalculationService
|
|||
order.OrderSubTotalDiscountExclTax = order.OrderTotal;
|
||||
|
||||
await _dbContext.Orders.UpdateAsync(order);
|
||||
return true;
|
||||
}
|
||||
|
||||
//public override async Task<(decimal priceWithoutDiscounts, decimal finalPrice, decimal appliedDiscountAmount, List<Discount> appliedDiscounts)> GetFinalPriceAsync(
|
||||
|
|
|
|||
Loading…
Reference in New Issue