From 25bac082e16ba396d013945e81f4b64d2ee8a347 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 5 Dec 2013 00:17:05 +0100 Subject: [PATCH] Inventory Items Movements always starts with 0 qty. Fixed. --- inventory/includes/db/movement_types_db.inc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inventory/includes/db/movement_types_db.inc b/inventory/includes/db/movement_types_db.inc index 47164191..e3e476fc 100644 --- a/inventory/includes/db/movement_types_db.inc +++ b/inventory/includes/db/movement_types_db.inc @@ -75,9 +75,10 @@ function get_stock_movements($stock_id, $StockLocation, $BeforeDate, $AfterDate) function get_stock_movements_before($stock_id, $StockLocation, $AfterDate) { $after_date = date2sql($AfterDate); - $sql = "SELECT SUM(qty) FROM ".TB_PREF."stock_moves WHERE stock_id=".db_escape($stock_id) . " - AND loc_code=".db_escape( $StockLocation) . " - AND tran_date < '" . $after_date . "'"; + $sql = "SELECT SUM(qty) FROM ".TB_PREF."stock_moves WHERE stock_id=".db_escape($stock_id); + if ($StockLocation) + $sql .= " AND loc_code=".db_escape( $StockLocation); + $sql .= " AND tran_date < '" . $after_date . "'"; $before_qty = db_query($sql, "The starting quantity on hand could not be calculated"); $before_qty_row = db_fetch_row($before_qty); -- 2.30.2