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.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Deleting fiscal year stock_mov doesn't delete data's

All fiscal years store their data in the same database's tables, We can switch back and forth among the fiscal year of interest and hence the historical data of stock moves need to remain stored.

Re: Deleting fiscal year stock_mov doesn't delete data's

If it's so.  Than we don't need to change the stock move dates.  We can keep the stock moves table as since as it is.  And it's like the stock locations table.

Subscription service based on FA
HRM CRM POS batch Themes