<?php
+
/**********************************************************************
Copyright (C) FrontAccounting, LLC.
Released under the terms of the GNU General Public License, GPL,
function add_wo_costing($workorder_id, $cost_type, $trans_type, $trans_no, $factor=1)
{
+ begin_transaction(__FUNCTION__, func_get_args());
$sql = "INSERT INTO ".TB_PREF."wo_costing (workorder_id, cost_type, trans_type, trans_no, factor)
VALUES (".db_escape($workorder_id).","
.db_escape($cost_type).",".db_escape($trans_type).","
.db_escape($trans_no).",".db_escape($factor).")";
db_query($sql, "could not add work order costing");
-
+ commit_transaction();
}
function get_wo_costing($workorder_id)
function delete_wo_costing($trans_type, $trans_no)
{
+ begin_transaction(__FUNCTION__, func_get_args());
$sql="DELETE FROM ".TB_PREF."wo_costing WHERE trans_type=".db_escape($trans_type)
." AND trans_no=".db_escape($trans_no);
db_query($sql, "could not delete work order costing");
+ commit_transaction();
}
/*
{
global $Refs;
- $product = get_item($stock_id);
- $avg_cost = $product['material_cost'];
+ $item = get_item($stock_id);
+ $avg_cost = $item['material_cost'];
$qoh = get_qoh_on_date($stock_id, null, $date);
write_journal_entries($cart);
}
- if ($qty > 0 && ($qoh != -$qty)) {
- if ($qoh == 0 && $avg_cost != 0)
- $avg_cost = ($avg_cost + ($unit_cost*$qty_new)/($qoh+$qty))/2;
- else
- $avg_cost = ($avg_cost*($qoh+$qty_delayed)+$unit_cost*$qty_new)/($qoh+$qty);
- }
+ if ($qty > 0 && ($qoh != -$qty))
+ $avg_cost = ($avg_cost*($qoh+$qty_delayed)+$unit_cost*$qty_new)/($qoh+$qty);
$sql = "UPDATE ".TB_PREF."stock_master SET material_cost=".db_escape($avg_cost)."
WHERE stock_id=".db_escape($stock_id);
//
global $Refs, $wo_cost_types;
- begin_transaction();
+ begin_transaction(__FUNCTION__, func_get_args());
$journal_id = get_next_trans_no(ST_JOURNAL);
if ($is_bank_to)
{
add_bank_trans(ST_JOURNAL, $journal_id, $is_bank_to, "",
- $date, -$amount, PT_WORKORDER, $wo_id, get_company_currency(),
- "Cannot insert a destination bank transaction");
+ $date, -$amount, PT_WORKORDER, $wo_id, get_company_currency());
}
add_journal(ST_JOURNAL, $journal_id, $amount, $date, get_company_currency(), $ref, '', 1, $date, $date);
{
global $Refs;
+ begin_transaction(__FUNCTION__, func_get_args());
$res = get_wo_costing($wo_id);
while($row = db_fetch($res))
$sql = "DELETE FROM ".TB_PREF."wo_costing WHERE workorder_id=".db_escape($wo_id);
db_query($sql, "could not delete work order costing");
+ commit_transaction();
}