From: Joe Date: Wed, 4 Dec 2013 23:17:05 +0000 (+0100) Subject: Inventory Items Movements always starts with 0 qty. Fixed. X-Git-Tag: 2.3-final~166 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=25bac082e16ba396d013945e81f4b64d2ee8a347;p=fa-stable.git Inventory Items Movements always starts with 0 qty. Fixed. --- 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);