From: Joe Hunt Date: Wed, 3 Jun 2009 08:20:13 +0000 (+0000) Subject: Changed to present reference number in Print Invoices/Credit Notes if global $print_i... X-Git-Tag: 2.3-final~1235 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=83e9c286c92b366b482a0bffc6de8fe0fa5b390e;p=fa-stable.git Changed to present reference number in Print Invoices/Credit Notes if global $print_invoice_no = 0 Deleting of Locations was too easy. Implemented much more checks Report Stock Check Sheet and 'Inventory Item Status' was wrong when Locations were selected When producing advanced manufacture there should be errors when insuffient qoh in items (if 'Allow Negative Stock' is not marked) --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bcec0049..426d90f7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,19 @@ Legend: ! -> Note $ -> Affected files +03-Jun-2009 Joe Hunt +! Changed to present reference number in Print Invoices/Credit Notes if global $print_invoice_no = 0 +$ /reporting/includes/reports_classes.inc +# Deleting of Locations was too easy. Implemented much more checks +$ /inventory/manage/locations.php +! Report Stock Check Sheet and 'Inventory Item Status' was wrong when Locations were selected. +$ /reporting/rep302.php + /reporting/rep303.php + /includes/db/manufacturing_db.inc +# When producing advanced manufacture there should be errors when insuffient qoh in items (if 'Allow Negative Stock' is not marked). +$ /manufacturing/work_order_issue.php + /manufacturing/work_order_add_finished.php + 27-May-2009 Joe Hunt # After heavy testing a new set of nested subtypes in COA, Monthly Breakdown, Balance Sheet and P&L Statement. $ /gl/includes/db/gl_db_accounts.inc diff --git a/includes/db/manufacturing_db.inc b/includes/db/manufacturing_db.inc index 9592fdaa..c2f34d9b 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)) { @@ -62,7 +64,7 @@ function stock_demand_manufacture($stock_id, $qty, $demand_id, $location, $level $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 diff --git a/inventory/manage/locations.php b/inventory/manage/locations.php index e0c3b146..47eedc64 100644 --- a/inventory/manage/locations.php +++ b/inventory/manage/locations.php @@ -98,6 +98,46 @@ function can_delete($selected_id) return false; } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."bom WHERE loc_code='$selected_id'"; + $result = db_query($sql, "could not query bom"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."grn_batch WHERE loc_code='$selected_id'"; + $result = db_query($sql, "could not query grn batch"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."purch_orders WHERE into_stock_location='$selected_id'"; + $result = db_query($sql, "could not query purch orders"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_orders WHERE from_stk_loc='$selected_id'"; + $result = db_query($sql, "could not query sales orders"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_pos WHERE pos_location='$selected_id'"; + $result = db_query($sql, "could not query sales pos"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } return true; } diff --git a/manufacturing/work_order_add_finished.php b/manufacturing/work_order_add_finished.php index b8036c37..6248ed86 100644 --- a/manufacturing/work_order_add_finished.php +++ b/manufacturing/work_order_add_finished.php @@ -115,18 +115,38 @@ function can_process() } } + // if production we need to check the qoh of the wo requirements + if (($_POST['ProductionType'] == 1) && !sys_prefs::allow_negative_stock()) + { + $err = false; + $result = get_wo_requirements($_POST['selected_id']); + while ($row = db_fetch($result)) + { + if ($row['mb_flag'] == 'D') // service, non stock + continue; + $qoh = get_qoh_on_date($row["stock_id"], $row["loc_code"], $date_); + if ($qoh - $row['units_req'] * $_POST['quantity'] < 0) + { + display_error( _("The production cannot be processed because a required item would cause a negative inventory balance :") . + " " . $row['stock_id'] . " - " . $row['description']); + $err = true; + } + } + if ($err) + { + set_focus('quantity'); + return false; + } + } return true; } //-------------------------------------------------------------------------------------------------- -if (isset($_POST['Process']) || (isset($_POST['ProcessAndClose']) && can_process() == true)) +if (isset($_POST['ProcessAndClose']) && can_process() == true) { - $close_wo = 0; - if (isset($_POST['ProcessAndClose']) && ($_POST['ProcessAndClose']!="")) - $close_wo = 1; - + $close_wo = 1; // if unassembling, negate quantity if ($_POST['ProductionType'] == 0) $_POST['quantity'] = -$_POST['quantity']; @@ -171,8 +191,7 @@ textarea_row(_("Memo:"), 'memo_', null, 40, 3); end_table(1); -submit_center_first('Process', _("Process"), '', true); -submit_center_last('ProcessAndClose', _("Process And Close Order"), '', true); +submit_center('ProcessAndClose', _("Process And Close Order"), true, '', true); end_form(); diff --git a/manufacturing/work_order_issue.php b/manufacturing/work_order_issue.php index ee2b2950..452c8215 100644 --- a/manufacturing/work_order_issue.php +++ b/manufacturing/work_order_issue.php @@ -94,7 +94,7 @@ function can_process() } $failed_item = $_SESSION['issue_items']->check_qoh($_POST['Location'], $_POST['date_'], !$_POST['IssueType']); - if ($failed_item >= 0) + if ($failed_item != -1) { display_error( _("The issue cannot be processed because an entered item would cause a negative inventory balance :") . " " . $failed_item->stock_id . " - " . $failed_item->item_description); diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index d5e6afbe..4ff56b65 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -119,7 +119,7 @@ class Report function getDisplay() { - global $path_to_root, $use_date_picker, $pdf_debug; + global $path_to_root, $use_date_picker, $pdf_debug, $print_invoice_no; $st = ''; $dummy = ""; @@ -257,9 +257,14 @@ class Report case 'INVOICE': $IV = _("IV"); $CN = _("CN"); - $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', - ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName - FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; + if ($print_invoice_no == 1) + $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', + ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName + FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; + else + $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', + ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.reference, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName + FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy); break; case 'DELIVERY': diff --git a/reporting/rep302.php b/reporting/rep302.php index 6806e4c3..e92c27c5 100644 --- a/reporting/rep302.php +++ b/reporting/rep302.php @@ -46,7 +46,7 @@ function getTransactions($category, $location) if ($category != 0) $sql .= " AND ".TB_PREF."stock_master.category_id = '$category'"; if ($location != 'all') - $sql .= " AND ".TB_PREF."stock_moves.loc_code = '$location'"; + $sql .= " AND IF(".TB_PREF."stock_moves.stock_id IS NULL, '1=1',".TB_PREF."stock_moves.loc_code = '$location')"; $sql .= " GROUP BY ".TB_PREF."stock_master.category_id, ".TB_PREF."stock_category.description, ".TB_PREF."stock_master.stock_id, @@ -154,7 +154,7 @@ function print_inventory_planning() if ($location == 'all') $loc_code = ""; else - $loc_code = $trans['loc_code']; + $loc_code = $location; $custqty = get_demand_qty($trans['stock_id'], $loc_code); $custqty += get_demand_asm_qty($trans['stock_id'], $loc_code); $suppqty = get_on_porder_qty($trans['stock_id'], $loc_code); diff --git a/reporting/rep303.php b/reporting/rep303.php index 4b87d6b2..5cd68603 100644 --- a/reporting/rep303.php +++ b/reporting/rep303.php @@ -36,7 +36,7 @@ function getTransactions($category, $location) ".TB_PREF."stock_master.stock_id, ".TB_PREF."stock_master.description, IF(".TB_PREF."stock_moves.stock_id IS NULL, '', ".TB_PREF."stock_moves.loc_code) AS loc_code, - SUM(IF(".TB_PREF."stock_moves.stock_id IS NULL,0,".TB_PREF."stock_moves.qty)) AS QtyOnHand + SUM(IF(".TB_PREF."stock_moves.stock_id IS NULL,0,".TB_PREF."stock_moves.qty)) AS qty_on_hand FROM (".TB_PREF."stock_master, ".TB_PREF."stock_category) LEFT JOIN ".TB_PREF."stock_moves ON @@ -46,7 +46,7 @@ function getTransactions($category, $location) if ($category != 0) $sql .= " AND ".TB_PREF."stock_master.category_id = '$category'"; if ($location != 'all') - $sql .= " AND ".TB_PREF."stock_moves.loc_code = '$location'"; + $sql .= " AND IF(".TB_PREF."stock_moves.stock_id IS NULL, '1=1',".TB_PREF."stock_moves.loc_code = '$location')"; $sql .= " GROUP BY ".TB_PREF."stock_master.category_id, ".TB_PREF."stock_category.description, ".TB_PREF."stock_master.stock_id, @@ -132,6 +132,10 @@ function print_stock_check() $catt = ''; while ($trans=db_fetch($res)) { + if ($location == 'all') + $loc_code = ""; + else + $loc_code = $location; $demandqty = get_demand_qty($trans['stock_id'], $loc_code); $demandqty += get_demand_asm_qty($trans['stock_id'], $loc_code); $onorder = get_on_porder_qty($trans['stock_id'], $loc_code); @@ -150,10 +154,6 @@ function print_stock_check() $catt = $trans['cat_description']; $rep->NewLine(); } - if ($location == 'all') - $loc_code = ""; - else - $loc_code = $trans['loc_code']; $rep->NewLine(); $dec = get_qty_dec($trans['stock_id']); $rep->TextCol(0, 1, $trans['stock_id']); @@ -192,4 +192,4 @@ function print_stock_check() $rep->End(); } -?> \ No newline at end of file +?>