Topic: Deleting fiscal year stock_mov doesn't delete data's
Here is the code of deleting the things on stock mov table.
$sql = "SELECT loc_code, stock_id, SUM(qty) AS qty, SUM(qty*standard_cost) AS std_cost FROM ".TB_PREF."stock_moves WHERE tran_date <= '$to' GROUP by
loc_code, stock_id";
$result = db_query($sql, "Could not retrieve supp trans");
while ($row = db_fetch($result))
{
$sql = "DELETE FROM ".TB_PREF."stock_moves WHERE tran_date <= '$to' AND loc_code = '{$row['loc_code']}' AND stock_id = '{$row['stock_id']}'";
db_query($sql, "Could not delete stock moves");
$qty = $row['qty'];
$std_cost = ($qty == 0 ? 0 : round2($row['std_cost'] / $qty, user_price_dec()));
$sql = "INSERT INTO ".TB_PREF."stock_moves (stock_id, loc_code, tran_date, reference, qty, standard_cost) VALUES
('{$row['stock_id']}', '{$row['loc_code']}', '$to', '$ref', $qty, $std_cost)";
db_query($sql, "Could not insert stock move");
}
Here each row inserted again with the end date of fiscal year. How its working?
and Are we need to keep the stock mov datas for next year?
shall we check this data's again after closing the previous year.
HRM CRM POS batch Themes