Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Remove ProfitReport from OrderReportService
KrzysztofPajak2ea09b46a0a7
diff --git a/src/Business/Grand.Business.System/Interfaces/Reports/IOrderReportService.cs b/src/Business/Grand.Business.System/Interfaces/Reports/IOrderReportService.csindex ae4fa902a..1fc634e2b 100644--- a/src/Business/Grand.Business.System/Interfaces/Reports/IOrderReportService.cs+++ b/src/Business/Grand.Business.System/Interfaces/Reports/IOrderReportService.cs@@ -141,29 +141,5 @@ namespace Grand.Business.System.Interfaces.ReportsDateTime? createdFromUtc = null, DateTime? createdToUtc = null,int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false);- /// <summary>- /// Get profit report- /// </summary>- /// <param name="storeId">Store identifier</param>- /// <param name="customerId">Customer identifier</param>- /// <param name="vendorId">Vendor identifier</param>- /// <param name="SalesEmployeeId">Sales employee identifier</param>- /// <param name="billingCountryId">Billing country identifier</param>- /// <param name="orderId">Order identifier; pass 0 to ignore this parameter</param>- /// <param name="paymentMethodSystemName">Payment method system name; null to load all records</param>- /// <param name="startTimeUtc">Start date</param>- /// <param name="endTimeUtc">End date</param>- /// <param name="os">Order status; null to load all records</param>- /// <param name="ps">Order payment status; null to load all records</param>- /// <param name="ss">Shipping status; null to load all records</param>- /// <param name="billingEmail">Billing email. Leave empty to load all records.</param>- /// <param name="billingLastName">Billing last name. Leave empty to load all records.</param>- /// <param name="tagid">tag ident</param>- /// <returns>Result</returns>- Task<double> ProfitReport(string storeId = "", string customerId = "", string vendorId = "", string salesEmployeeId = "",- string billingCountryId = "", string orderId = "", string paymentMethodSystemName = null,- int? os = null, PaymentStatus? ps = null, ShippingStatus? ss = null,- DateTime? startTimeUtc = null, DateTime? endTimeUtc = null,- string billingEmail = null, string billingLastName = "", string tagid = null);}}diff --git a/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs b/src/Business/Grand.Business.System/Services/Reports/OrderReportService.csindex 326625250..f00682e71 100644--- a/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs+++ b/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs@@ -527,107 +527,6 @@ namespace Grand.Business.System.Services.Reportsreturn await PagedList<Product>.Create(qproducts, pageIndex, pageSize);}- /// <summary>- /// Get profit report- /// </summary>- /// <param name="storeId">Store identifier</param>- /// <param name="CustomerId">Customer identifier</param>- /// <param name="vendorId">Vendor identifier</param>- /// <param name="salesEmployeeId">Sales employee identifier</param>- /// <param name="billingCountryId">Billing country identifier; 0 to load all orders</param>- /// <param name="orderId">Order identifier</param>- /// <param name="paymentMethodSystemName">Payment method system name; null to load all records</param>- /// <param name="startTimeUtc">Start date</param>- /// <param name="endTimeUtc">End date</param>- /// <param name="os">Order status; null to load all records</param>- /// <param name="ps">Order payment status; null to load all records</param>- /// <param name="ss">Shipping status; null to load all records</param>- /// <param name="billingEmail">Billing email. Leave empty to load all records.</param>- /// <param name="tagid">Tag ident.</param>- /// <returns>Result</returns>- public virtual async Task<double> ProfitReport(string storeId = "", string customerId = "", string vendorId = "", string salesEmployeeId = "",- string billingCountryId = "", string orderId = "", string paymentMethodSystemName = null,- int? os = null, PaymentStatus? ps = null, ShippingStatus? ss = null,- DateTime? startTimeUtc = null, DateTime? endTimeUtc = null,- string billingEmail = null, string billingLastName = "", string tagid = null)- {- var query = from p in _orderRepository.Table- select p;-- query = query.Where(o => !o.Deleted);-- if (!string.IsNullOrEmpty(storeId))- query = query.Where(o => o.StoreId == storeId);-- if (!string.IsNullOrEmpty(customerId))- query = query.Where(o => o.CustomerId == customerId);-- if (!string.IsNullOrEmpty(orderId))- query = query.Where(o => o.Id == orderId);-- if (!string.IsNullOrEmpty(vendorId))- {- query = query- .Where(o => o.OrderItems- .Any(orderItem => orderItem.VendorId == vendorId));- }-- if (!string.IsNullOrEmpty(salesEmployeeId))- query = query.Where(o => o.SeId == salesEmployeeId);-- if (!string.IsNullOrEmpty(billingCountryId))- query = query.Where(o => o.BillingAddress != null && o.BillingAddress.CountryId == billingCountryId);-- if (!string.IsNullOrEmpty(paymentMethodSystemName))- query = query.Where(o => o.PaymentMethodSystemName == paymentMethodSystemName);- if (os.HasValue)- query = query.Where(o => o.OrderStatusId == os.Value);- if (ps.HasValue)- query = query.Where(o => o.PaymentStatusId == ps.Value);- if (ss.HasValue)- query = query.Where(o => o.ShippingStatusId == ss.Value);- if (startTimeUtc.HasValue)- query = query.Where(o => startTimeUtc.Value <= o.CreatedOnUtc);- if (endTimeUtc.HasValue)- query = query.Where(o => endTimeUtc.Value >= o.CreatedOnUtc);-- if (!string.IsNullOrEmpty(billingEmail))- query = query.Where(o => o.BillingAddress != null && !string.IsNullOrEmpty(o.BillingAddress.Email) && o.BillingAddress.Email.Contains(billingEmail));-- if (!string.IsNullOrEmpty(billingLastName))- query = query.Where(o => o.BillingAddress != null && !string.IsNullOrEmpty(o.BillingAddress.LastName) && o.BillingAddress.LastName.Contains(billingLastName));-- //tag filtering- if (!string.IsNullOrEmpty(tagid))- query = query.Where(o => o.OrderTags.Any(y => y == tagid));-- var query2 = from o in query- from p in o.OrderItems- select p;--- var productCost = query2.Sum(orderItem => orderItem.OriginalProductCost * orderItem.Quantity);-- var reportSummary = await GetOrderAverageReportLine(- storeId: storeId,- vendorId: vendorId,- salesEmployeeId: salesEmployeeId,- customerId: customerId,- billingCountryId: billingCountryId,- orderId: orderId,- paymentMethodSystemName: paymentMethodSystemName,- os: os,- ps: ps,- ss: ss,- startTimeUtc: startTimeUtc,- endTimeUtc: endTimeUtc,- billingEmail: billingEmail,- tagid: tagid- );- var profit = Convert.ToDouble(reportSummary.SumOrders - reportSummary.SumShippingExclTax - reportSummary.SumTax - productCost);- return profit;- }-public class UnwindedOrderItem{public OrderItem OrderItems { get; set; }diff --git a/src/Web/Grand.Web.Admin/Interfaces/IOrderViewModelService.cs b/src/Web/Grand.Web.Admin/Interfaces/IOrderViewModelService.csindex 20fef5fe0..cbb888869 100644--- a/src/Web/Grand.Web.Admin/Interfaces/IOrderViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Interfaces/IOrderViewModelService.cs@@ -1,5 +1,4 @@-using Grand.Domain.Catalog;-using Grand.Domain.Common;+using Grand.Domain.Common;using Grand.Domain.Orders;using Grand.Web.Admin.Models.Orders;using Microsoft.AspNetCore.Http;@@ -22,7 +21,7 @@ namespace Grand.Web.Admin.InterfacesTask InsertOrderNote(Order order, string downloadId, bool displayToCustomer, string message);Task DeleteOrderNote(Order order, string id);Task<Address> UpdateOrderAddress(Order order, Address address, OrderAddressModel model, List<CustomAttribute> customAttributes);- Task<IList<string>> AddProductToOrderDetails(string orderId, string productId, IFormCollection form);+ Task<IList<string>> AddProductToOrderDetails(string orderId, string productId, IFormCollection form);Task<IList<Order>> PrepareOrders(OrderListModel model);Task SaveOrderTags(Order order, string tags);diff --git a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.csindex 8a0c75c9d..75667c090 100644--- a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs@@ -551,11 +551,15 @@ namespace Grand.Web.Admin.Services}}- //profit (hide for vendors)+ //profit (not for vendors)if (_workContext.CurrentVendor == null){- var profit = await _orderReportService.ProfitReport(orderId: order.Id);- model.Profit = await _priceFormatter.FormatPrice(profit, order.PrimaryCurrencyCode, false, _workContext.WorkingLanguage);+ var productCost = order.OrderItems.Sum(orderItem => orderItem.OriginalProductCost * orderItem.Quantity);+ if (order.CurrencyRate > 0)+ {+ var profit = Convert.ToDouble((order.OrderTotal / order.CurrencyRate) - (order.OrderShippingExclTax / order.CurrencyRate) - (order.OrderTax / order.CurrencyRate) - productCost);+ model.Profit = await _priceFormatter.FormatPrice(profit, order.PrimaryCurrencyCode, false, _workContext.WorkingLanguage);+ }}if (order.PrimaryCurrencyCode != order.CustomerCurrencyCode)