Rerun Items Summary Report fix
[fa-stable.git] / reporting / rep309.php
index bf6aebd4549b422145b418645ecd13cd811bef6e..2e3dfa6707028d4a24bacd98cbe05d5e6afba5c9 100644 (file)
@@ -37,8 +37,8 @@ function getTransactions($category, $from, $to)
                        category.description AS cat_description,
                        item.stock_id,
                        item.description,
-                       line.unit_price,
-                       SUM(line.quantity) as quantity
+                       line.unit_price * trans.rate AS unit_price,
+                       SUM(IF(line.debtor_trans_type = ".ST_CUSTCREDIT.", -line.quantity, line.quantity)) AS quantity
                FROM ".TB_PREF."stock_master item,
                        ".TB_PREF."stock_category category,
                        ".TB_PREF."debtor_trans trans,
@@ -50,7 +50,7 @@ function getTransactions($category, $from, $to)
                AND trans.tran_date>='$from'
                AND trans.tran_date<='$to'
                AND line.quantity<>0
-               AND line.debtor_trans_type = ".ST_SALESINVOICE;
+               AND (line.debtor_trans_type = ".ST_SALESINVOICE." OR line.debtor_trans_type = ".ST_CUSTCREDIT.")";
                if ($category != 0)
                        $sql .= " AND item.category_id = ".db_escape($category);
                $sql .= " GROUP BY item.category_id,
@@ -103,7 +103,7 @@ function print_inventory_sales()
                                    1 => array('text' => _('Period'),'from' => $from, 'to' => $to),
                                    2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''));
 
-    $rep = new FrontReport(_('Sales Summary Report, Detailed'), "SalesSummaryDetailedReport", user_pagesize(), 9, $orientation);
+    $rep = new FrontReport(_('Item Sales Summary Report'), "ItemSalesSummaryReport", user_pagesize(), 9, $orientation);
     if ($orientation == 'L')
        recalculate_cols($cols);