$id = db_insert_id();
+ // -------------------------------------------------------------------------
+
+ work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, true);
+
+ // -------------------------------------------------------------------------
// insert a +ve stock move for the item being manufactured
// negative means "unproduce" or unassemble
add_stock_move(29, $details["stock_id"], $id,
$details["loc_code"], $date_, $memo_, $quantity, 0);
-
// update wo quantity and close wo if requested
work_order_update_finished_quantity($woid, $quantity, $close_wo);
- // -------------------------------------------------------------------------
- work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, true);
-
- // -------------------------------------------------------------------------
if ($memo_)
add_comments(29, $id, $date_, $memo_);
$myrow = db_fetch($result);
$material_cost = $myrow['material_cost'];
$qoh = get_qoh_on_date($stock_id, null, $date_);
- if ($qoh <= 0)
+ if ($qoh + $qty <= 0)
$material_cost = 0;
else
- $material_cost = ($qoh * $material_cost + $qty * $costs) / $qoh;
- $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=$material_cost
+ $material_cost = ($qty * $costs) / ($qoh + $qty);
+ $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=material_cost+$material_cost
WHERE stock_id='$stock_id'";
db_query($sql,"The cost details for the inventory item could not be updated");
}
null, -$issue_cost);
$issue_total += $issue_cost;
}
- add_issue_cost($stock_id, $units_reqd, $date_, $issue_total);
+ if ($issue_total != 0)
+ add_issue_cost($stock_id, $units_reqd, $date_, $issue_total);
$result = get_gl_wo_cost_trans($woid, WO_LABOUR);
$lcost = 0;
while ($row = db_fetch($result))
if (isset($_POST['process']) && can_process() == true)
{
+ begin_transaction();
add_gl_trans_std_cost(systypes::work_order(), $_POST['selected_id'], $_POST['date_'], $_POST['cr_acc'],
0, 0, $wo_cost_types[$_POST['PaymentType']], -input_num('costs'), payment_person_types::WorkOrder(), $_POST['PaymentType']);
$is_bank_to = is_bank_account($_POST['cr_acc']);
add_gl_trans_std_cost(systypes::work_order(), $_POST['selected_id'], $_POST['date_'], $_POST['db_acc'],
$_POST['dim1'], $_POST['dim2'], $wo_cost_types[$_POST['PaymentType']], input_num('costs'), payment_person_types::WorkOrder(),
$_POST['PaymentType']);
-
+ commit_transaction();
meta_forward($_SERVER['PHP_SELF'], "AddedID=".$_POST['selected_id']);
}
wo_types_list_row(_("Type:"), 'type', null);
}
-if ($_POST['released'] == true)
+if (get_post('released'))
{
hidden('stock_id', $_POST['stock_id']);
hidden('StockLocation', $_POST['StockLocation']);
}
-if ($_POST['released'])
+if (get_post('released'))
label_row(_("Released On:"),$_POST['released_date']);
textarea_row(_("Memo:"), 'memo_', null, 40, 5);
echo "<table align=center><tr>";
submit_cells('UPDATE_ITEM', _("Update"), '', _('Save changes to work order'), true);
- if (isset($_POST['released']))
+ if (get_post('released'))
{
submit_cells('close', _("Close This Work Order"),'','',true);
}