X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=manufacturing%2Fincludes%2Fdb%2Fwork_order_costing_db.inc;h=418eacd962386ab4e111dc595524cde158d9afef;hb=7561718ee5113232ce917f63085d272884b0929c;hp=e6d1e123c33a9229d62e441341d2a2b4dd9b0cfd;hpb=fa43a9c974d05b77517a0d8e3e510ef4a088632e;p=fa-stable.git diff --git a/manufacturing/includes/db/work_order_costing_db.inc b/manufacturing/includes/db/work_order_costing_db.inc index e6d1e123..418eacd9 100644 --- a/manufacturing/includes/db/work_order_costing_db.inc +++ b/manufacturing/includes/db/work_order_costing_db.inc @@ -67,9 +67,14 @@ function add_material_cost($stock_id, $qty, $date_, $advanced=false) if ($qoh + $qty >= 0) $cost_adjust = true; $qoh = 0; - } - if ($qoh + $qty != 0) - $material_cost = ($qoh * $material_cost + $qty * $m_cost) / ($qoh + $qty); + } + if ($qoh + $qty != 0) + { + if ($qoh == 0) + $material_cost += $m_cost; + else + $material_cost = ($qoh * $material_cost + $qty * $m_cost) / ($qoh + $qty); + } if ($advanced && $cost_adjust) // new 2010-02-10 adjust_deliveries($stock_id, $bom_cost, $date_); @@ -120,6 +125,8 @@ function add_overhead_cost($stock_id, $qty, $date_, $costs, $adj_only=false) add_audit_trail(ST_JOURNAL, $id, $date_); add_comments(ST_JOURNAL, $id, $date_, $memo); $Refs->save(ST_JOURNAL, $id, $ref); + if ($qty != 0) + $overhead_cost = ($qoh * $overhead_cost + $costs) / $qty; } } else @@ -173,6 +180,8 @@ function add_labour_cost($stock_id, $qty, $date_, $costs, $adj_only=false) add_audit_trail(ST_JOURNAL, $id, $date_); add_comments(ST_JOURNAL, $id, $date_, $memo); $Refs->save(ST_JOURNAL, $id, $ref); + if ($qty != 0) + $labour_cost = ($qoh * $labour_cost + $costs) / $qty; } } else @@ -226,6 +235,8 @@ function add_issue_cost($stock_id, $qty, $date_, $costs, $adj_only=false) add_audit_trail(ST_JOURNAL, $id, $date_); add_comments(ST_JOURNAL, $id, $date_, $memo); $Refs->save(ST_JOURNAL, $id, $ref); + if ($qty != 0) + $material_cost = $costs / $qty; } } else