<?php


function get_fi_stock_item_cost_updates($cutoff_date, $batch_size)
{
    $sql = "SELECT mov.id,
                    mov.trans_type,
                    mov.trans_no,
                    mov.trans_date,
                    mov.stock_id,
                    mov.total_quantity, 
                    mov.previous_material_cost,               
                    mov.new_material_cost,               
                    stk.inventory_account, 
                    stk.adjustment_account, 
                    stk.description 
            FROM ".TB_PREF."stock_item_cost_amendments mov  
                JOIN ".TB_PREF."stock_master stk ON 
                    stk.stock_id = mov.stock_id 
            WHERE mov.trans_type = ".db_escape(ST_ITEM_COSTUPDATE)." 
                    AND mov.trans_date <= ".db_escape($cutoff_date)."   
                    AND mov.fi_batch_no = 0 
            
            ORDER BY mov.id LIMIT ".$batch_size;
                    

    return db_query($sql, "get_fi_stock_item_cost_updates");
}
