From: Pak R. <pak...@gm...> - 2015-07-23 01:24:59
|
Hi all: I've getting wrong results with DailySalesInquiry.php, as in an employee entered the same sales order twice (by error) and we cancelled it later on (by deleteting its items), in the DailySalesInquiry it was still showed as twice the sales. I changed the SQL to read salesorderdetails instead of stockmoves strating at line 96 $sql = "SELECT orddate AS trandate, SUM(unitprice*(1-discountpercent)* (qtyinvoiced)) as salesvalue, SUM(CASE WHEN mbflag='A' THEN 0 ELSE ((materialcost+labourcost+overheadcost) * qtyinvoiced) END) as cost FROM salesorders INNER JOIN salesorderdetails ON salesorders.orderno=salesorderdetails.orderno INNER JOIN stockmaster ON stockmaster.stockid=salesorderdetails.stkcode WHERE orddate>='" . $StartDateSQL . "' AND orddate<='" . $EndDateSQL . "'"; $sql .= " GROUP BY salesorders.orddate ORDER BY salesorders.orddate"; BTW, why did we check the sales via a table related to stock movements? Not sure if this change will seem reasonable to the community, so before I upload to SVN would like your votes on this. Regards, Ricard |