Try our conversational search powered by Generative AI!

IOrderSearchService Totals and Sub Totals Reporting - Commerce


using the IOrderSearchService we run reports for specific time periods and during some of those time periods we have sales and if the cart total is above 200 the customer gets free shipping.

We've noticed sometimes that the Total Revenue is sometimes less than the sub total.  Does anyone know how that's possible?

code snippet below

var orderFilter = new OrderSearchFilter
CreatedFrom = data.StartDate,
CreatedTo = data.EndDate.AddDays(1)

var orderSearchService = ServiceLocator.Current.GetInstance<IOrderSearchService>();
var searchResult = orderSearchService.FindPurchaseOrders(orderFilter);
completedTotalRev = searchResult.Orders.Sum(x => x.GetTotal()); //Sometimes lower than completedSubTotal
completedSubTotal = searchResult.Orders.Sum(x => x.GetSubTotal());

Thank you

Edited, Dec 23, 2022 0:36

bumping. anyone have any ideas? bug maybe?

Jan 16, 2023 22:54

I believe getTotal is calculated by:

Total = subTotal + handlingTotal + ShippingSubTotal - OrderDiscountTotal - ShippingDiscountTotal

Lets say you have 3 orders of $200 and shipping discount of $20.

200+200+200 = $600 subtotal

200+ 200 + 200 - 20 - 20 - 20 = 540 total?

So ShippingDiscountTotal is messing up with the calculations?

Feb 27, 2023 21:06

Yea the subtotal doesn't include discounts while the total does that's why it was showing like that.

Apr 10, 2023 15:40
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.