X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fdb%2Fmanufacturing_db.inc;h=1153010d725e78cb92f1b7592c999c6c6f7ba435;hb=31c79a2d7cc29c18ac1bfa92cf070857a5b9fe98;hp=9592fdaa172efee0a5fd8afd7bbe8847fa5e7ed9;hpb=0910660ff9783e5954e553b91bfe98c336dc4afd;p=fa-stable.git diff --git a/includes/db/manufacturing_db.inc b/includes/db/manufacturing_db.inc index 9592fdaa..1153010d 100644 --- a/includes/db/manufacturing_db.inc +++ b/includes/db/manufacturing_db.inc @@ -22,6 +22,8 @@ function get_demand_qty($stock_id, $location) $result = db_query($sql,"No transactions were returned"); $row = db_fetch($result); + if ($row === false) + return 0; return $row['QtyDemand']; } @@ -34,7 +36,7 @@ function load_stock_levels($location) $date = date2sql(Today()); $sql = "SELECT stock_id, SUM(qty) FROM ".TB_PREF."stock_moves WHERE tran_date <= '$date'"; - if ($location != null) $sql .= " AND loc_code = '$location'"; + if ($location != '') $sql .= " AND loc_code = '$location'"; $sql .= " GROUP BY stock_id"; $result = db_query($sql, "QOH calulcation failed"); while ($row = db_fetch($result)) { @@ -58,11 +60,11 @@ function stock_demand_manufacture($stock_id, $qty, $demand_id, $location, $level } $stock_qty = $qoh_stock[$stock_id]; if ($stock_qty == NULL) $stock_qty = 0; - if ($qty < $stock_qty) return $demand; + if ($qty <= $stock_qty) return $demand; $bom = $bom_list[$stock_id]; if ($bom == NULL) { $sql = "SELECT parent, component, quantity FROM ".TB_PREF."bom WHERE parent = '$stock_id'"; - if ($location != '') $sql .= " AND loc_code = '$location'"; + if ($location != "") $sql .= " AND loc_code = '$location'"; $result = db_query($sql, "Could not search bom"); $bom = array(); // Even if we get no results, remember that fact