<?php

function fi_tool_usage_charges($batch_no, $cutoff_date_){
    $cutoff_date = date2sql($cutoff_date_);
    $trans_type = ST_TOOL_USAGE_CHARGE;
    $result_h = get_fi_calculate_tool_usage_charges($cutoff_date);
    
    while($h = db_fetch($result_h)){
        
        $tran_date = $h['tran_date'];
        $tran_date_ = sql2date($tran_date);
        $trans_no = $h['trans_no'];
        
        $currency_code = get_company_pref('curr_default');
        
        $amount = $h['no_of_units'] * $h['rate tucd_rate'];
        
        $cgfit_msg = can_generate_fi_transaction($trans_type, $trans_no, $tran_date);
        if($cgfit_msg['success'] !== true){ 
            return $cgfit_msg;
        }

        begin_global_transaction();
        

        
//        add_fi_trans($batch_no, $trans_type, $trans_no, $tran_date_, $h['asset_account'], "", "", $h['comments'], $amount, $currency_code, "", "", "", $h['rate tucd_rate']);
       
    
        commit_transaction();
    }
    
}

?>