X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=manufacturing%2Fwork_order_add_finished.php;h=fb2ae94ca33d6a21d706e0b4abb833c933448ba3;hb=ed8422cc500fa848a1e3a85bc0979ff76a802ca9;hp=acf67f73e197ef7e0621795772b40b17426a1893;hpb=46c5f7a65a7659a44ae8254c63152074363d3987;p=fa-stable.git diff --git a/manufacturing/work_order_add_finished.php b/manufacturing/work_order_add_finished.php index acf67f73..fb2ae94c 100644 --- a/manufacturing/work_order_add_finished.php +++ b/manufacturing/work_order_add_finished.php @@ -121,10 +121,7 @@ function can_process() // if unassembling we need to check the qoh if (($_POST['ProductionType'] == 0) && !$SysPrefs->allow_negative_stock()) { - $wo_details = get_work_order($_POST['selected_id']); - - $qoh = get_qoh_on_date($wo_details["stock_id"], $wo_details["loc_code"], $_POST['date_']); - if (-input_num('quantity') + $qoh < 0) + if (check_negative_stock($wo_details["stock_id"], -input_num('quantity'), $wo_details["loc_code"], $_POST['date_'])) { display_error(_("The unassembling cannot be processed because there is insufficient stock.")); set_focus('quantity'); @@ -141,13 +138,13 @@ function can_process() { if ($row['mb_flag'] == 'D') // service, non stock continue; - $qoh = get_qoh_on_date($row["stock_id"], $row["loc_code"], $_POST['date_']); - if ($qoh - $row['units_req'] * input_num('quantity') < 0) + + if (check_negative_stock($row["stock_id"], -$row['units_req'] * input_num('quantity'), $row["loc_code"], $_POST['date_'])) { display_error( _("The production cannot be processed because a required item would cause a negative inventory balance :") . " " . $row['stock_id'] . " - " . $row['description']); - $err = true; - } + $err = true; + } } if ($err) {