db_query($sql,"A work order manufacture could not be added");
$id = db_insert_id();
+ \r
+ // -------------------------------------------------------------------------\r
+ work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, $id);\r
+ \r
// -------------------------------------------------------------------------
- work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, $id);
+ // Chaitanya: stamp BOM cost to finished item\r
+ $m_cost = 0;\r
+ $result = get_bom($details["stock_id"]);\r
+ while ($bom_item = db_fetch($result))\r
+ {\r
+ $standard_cost = get_standard_cost($bom_item['component']);\r
+ $m_cost += ($bom_item['quantity'] * $standard_cost);\r
+ } \r
- // -------------------------------------------------------------------------
// insert a +ve stock move for the item being manufactured
// negative means "unproduce" or unassemble
add_stock_move(ST_MANURECEIVE, $details["stock_id"], $id,
- $details["loc_code"], $date_, $ref, $quantity, 0);
+ $details["loc_code"], $date_, $ref, $quantity, $m_cost);\r
// update wo quantity and close wo if requested
work_order_update_finished_quantity($woid, $quantity, $close_wo);
-
if ($memo_)
add_comments(ST_MANURECEIVE, $id, $date_, $memo_);
{
begin_transaction();
hook_db_prevoid(ST_MANURECEIVE, $type_no);
+ \r
+ //Chaitanya : Skip processing already voided entry i.e. explicitly voided\r
+ $void_entry = get_voided_entry(ST_MANURECEIVE, $type_no);\r
+ if ($void_entry)\r
+ return; \r
$row = get_work_order_produce($type_no);
// deduct the quantity of this production from the parent work order
work_order_update_finished_quantity($row["workorder_id"], -$row["quantity"]);
- work_order_quick_costs($row['workorder_id'], $row['stock_id'], -$row['quantity'], sql2date($row['date_']), $type_no);
-
+ //Chaitanya : skipped this step as BOM may have got changed\r
+ //work_order_quick_costs($row['workorder_id'], $row['stock_id'], -$row['quantity'], sql2date($row['date_']), $type_no);\r
+
+ // void any related gl trans\r
+ //Chaitanya : Nothing happens due to next statement as all gl postings are done against WO\r
+ //void_gl_trans(ST_MANURECEIVE, $type_no, true);\r
+ \r
+ $woid = $row["workorder_id"];\r
+ $date_ = sql2date($row["date_"]);\r
+ \r
+ $result = get_stock_moves(ST_MANURECEIVE, $type_no);\r
+ while ($myrow = db_fetch($result))\r
+ {\r
+ $issue_cost = $myrow["qty"]*$myrow["standard_cost"];\r
+ $issue = get_stock_gl_code($myrow["stock_id"]);\r
+ $stockitem = get_item($myrow["stock_id"]);\r
+ \r
+ //Chaitanya : Compatibility for Service Items\r
+ if (!is_service($issue["mb_flag"]))\r
+ $ivaccount = $issue["inventory_account"];\r
+ else\r
+ $ivaccount = $issue["cogs_account"]; \r
+ \r
+ if ($issue_cost != 0)\r
+ {\r
+ add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $ivaccount, 0, 0,\r
+ $date_.": "._("Reversed the production ")." ".$stockitem["description"],\r
+ -$issue_cost);\r
+ }\r
+ } \r
+ \r
// clear the production record
$sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".db_escape($type_no);
- db_query($sql, "Cannot void a wo production");
-
+ db_query($sql, "Cannot void a wo production"); \r
+ \r
+ //Chaitanya : Shifted below\r
// void all related stock moves
void_stock_move(ST_MANURECEIVE, $type_no);
- // void any related gl trans
- void_gl_trans(ST_MANURECEIVE, $type_no, true);
-
commit_transaction();
}