X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fdb%2Fmanufacturing_db.inc;h=93027b764b9f32e65beda3e463c4c6ba280ecfb8;hb=d63ba7b7819e07a73cd1999cec249fc6f0b009fb;hp=8adddc696142f8fe850a355c15396904d0eac473;hpb=f44132511cc91b83f20f91af0625d4b112b4c26e;p=fa-stable.git diff --git a/includes/db/manufacturing_db.inc b/includes/db/manufacturing_db.inc index 8adddc69..93027b76 100644 --- a/includes/db/manufacturing_db.inc +++ b/includes/db/manufacturing_db.inc @@ -50,7 +50,7 @@ function load_stock_levels($location) return $qoh_stock; } -// recursion fixed by Tom Moulton. Max 10 recursion levels. +// recursion fixed. Max 10 recursion levels. function stock_demand_manufacture($stock_id, $qty, $demand_id, $location, $level=0) { global $bom_list, $qoh_stock; @@ -149,29 +149,14 @@ function get_on_porder_qty($stock_id, $location) function get_on_worder_qty($stock_id, $location) { - $sql = "SELECT SUM((wo.units_reqd-wo.units_issued) * (req.units_req-req.units_issued)) AS qoo - FROM ".TB_PREF."wo_requirements req - INNER JOIN ".TB_PREF."workorders wo ON req.workorder_id=wo.id - WHERE req.stock_id=".db_escape($stock_id) - ." AND wo.released=1"; - if ($location != "") - $sql .= " AND req.loc_code=".db_escape($location); - - $qoo_result = db_query($sql,"could not receive quantity on order for item"); - if (db_num_rows($qoo_result) == 1) - { - $qoo_row = db_fetch_row($qoo_result); - $qoo = $qoo_row[0]; - } - else - $qoo = 0.0; + $qoo = 0.0; $flag = get_mb_flag($stock_id); if ($flag == 'M') { $sql = "SELECT SUM((units_reqd-units_issued)) AS qoo FROM ".TB_PREF."workorders WHERE stock_id=".db_escape($stock_id) - ." AND released=1"; + ." AND released AND NOT closed"; if ($location != "") $sql .= " AND loc_code=".db_escape($location); @@ -180,7 +165,7 @@ function get_on_worder_qty($stock_id, $location) if (db_num_rows($qoo_result) == 1) { $qoo_row = db_fetch_row($qoo_result); - $qoo += $qoo_row[0]; + $qoo = $qoo_row[0]; } } return $qoo; @@ -222,8 +207,8 @@ function get_bom($item) $sql = "SELECT bom.*, loc.location_name, centre.name AS WorkCentreDescription, item.description, item.mb_flag AS ResourceType, - item.material_cost+item.labour_cost+item.overhead_cost AS standard_cost, units, - bom.quantity * (item.material_cost+ item.labour_cost+ item.overhead_cost) AS ComponentCost + item.material_cost AS ProductCost, units, + bom.quantity * item.material_cost AS ComponentCost FROM ".TB_PREF."workcentres centre, ".TB_PREF."locations loc, ".TB_PREF."bom bom