HomeHome Product Discus... Product Discus...SmithCartSmithCartMath off in "Total Sales by Product" ReportMath off in "Total Sales by Product" Report
Previous
 
Next
New Post
12/30/2010 6:52 AM
 

Math seems wrong....

NewYearsEveTickets New Years Eve Gala Tickets (2) $75.00 45.00 $3,455.00
NL45 Nominate Someone for Santa's Naughty List - With T-Shirt $45.00 5.00 $315.00
NL25 Nominate Someone for Santa's Naughty List $25.00 11.00 $275.00
NewYearsTickets-1 New Years Eve Gala Ticket (1) $40.00 3.00 $270.00

$75 * 45 = 3375

$45 * 5 = 225

$40 * 3 = 120

.... what's going on with this one? Hopefully the "Daily Sales Reports" are correct... :(

 
New Post
12/30/2010 10:10 AM
 

The stored proc thats used for that report is "Smith_SR_TotalSalesByProduct". I took a look at it and it looks like the sum and group by is correct.

-Scott


Scott Kelly
Project Manager
DotNetNuke Consulting, DotNetNuke Store and DNN Ecommerce
 
New Post
12/30/2010 10:18 AM
 

I found it.

Please make the following minor adjustment to Smith_SR_TotalSalesByProduct

SELECT p.ModelNumber,p.ModelName, max(od.UnitCost) as "UnitCost", sum(od.Quantity) as "TotalQty", sum(ph.Amount)as "TotalSales"
FROM Smith_StoreOrders o
INNER JOIN Smith_StoreOrderDetails od
ON o.OrderID = od.OrderID
INNER JOIN Smith_PayHist ph
ON o.PayHistID = ph.PayHistID
INNER JOIN Smith_Products p
ON od.ProductID = p.ProductID
where o.deletedflag = 0 and o.portalid = @PortalId and o.orderdate >= @FromDate AND o.orderdate <= @ToDate
AND o.Status <> 'Cancelled'
group by p.ModelNumber,p.ModelName
order by totalsales desc

 
New Post
12/30/2010 10:33 AM
 

OK... that was PART of it. It's still not totaling correctly. I'll post my findings... when I find them. :)

 
New Post
12/30/2010 10:47 AM
 

OK. I found the problem. I'm re-writing the stored procedure from scratch.

You were aggregating the item sales off of the pay history table, which has the TOTAL amount, not the LINE amount per item. That's why it wasn't multiplying out correctly. I'll post the new SP as soon as I get it written.

 
New Post
12/30/2010 11:14 AM
 

OK. Here's a new SP. First off, I removed the link to the PayHist table, because that will only be the total sale. Then I made sure that the decimal was formatted correctly for the total amount. Additionally, MIN on the cost, as opposed to a MAX; this way the report represents the "Lowest" sell price, but the total will still show total sales. If you mark down items, this will help you see the current sell price. Here is the new SP. I have tested this on my system and checked the math. :)

ALTER PROCEDURE [dbo].[Smith_SR_TotalSalesByProduct]
@PortalId int,
@FromDate datetime,
@ToDate datetime

AS

SELECT p.ModelNumber,p.ModelName, min(od.UnitCost) as "UnitCost", sum(od.Quantity) as "TotalQty",
convert(money,sum(od.UnitCost * od.Quantity),1) as "TotalSales"
FROM Smith_StoreOrders o
INNER JOIN Smith_StoreOrderDetails od
ON o.OrderID = od.OrderID
INNER JOIN Smith_Products p
ON od.ProductID = p.ProductID
where o.deletedflag = 0 and o.portalid = @PortalId and o.orderdate >= @FromDate AND o.orderdate <= @ToDate
AND o.Status <> 'Cancelled'
group by p.ModelNumber,p.ModelName
order by totalsales desc

 
New Post
12/30/2010 11:57 AM
Accepted Answer 

Thanks Greg! We will test and update the main cart build.

-Scott


Scott Kelly
Project Manager
DotNetNuke Consulting, DotNetNuke Store and DNN Ecommerce
 
Previous
 
Next
HomeHome Product Discus... Product Discus...SmithCartSmithCartMath off in "Total Sales by Product" ReportMath off in "Total Sales by Product" Report