<?php

function get_fi_petty_cash_float_reimbursements($cutoff_date, $batch_size)
{
    $sql = "SELECT fr.id,
                fr.tran_date,
                fr.amount,
                fr.float_id,               
                pcf.account_code float_account,
                fr.from_float_id,
                ff.account_code from_float_account,
                fr.bank_account_id, 
                fr.bank_payment_id, 
                ba.account_code bank_account_gl_code,
                ft.id float_trans_id 
            FROM ".TB_PREF."i_owe_you_float_reimbursements  fr 
                JOIN ".TB_PREF."petty_cash_float_trans ft 
                    ON ft.float_id = fr.float_id 
                    AND ft.tran_type = ".db_escape(ST_PETTY_CASH_FLOAT_REIMBUR)."  
                    AND ft.type_no = fr.id 
                LEFT JOIN ".TB_PREF."petty_cash_floats pcf 
                    ON pcf.id = fr.float_id 
                LEFT JOIN ".TB_PREF."petty_cash_floats ff 
                    ON ff.id = fr.from_float_id 
                LEFT JOIN ".TB_PREF."bank_accounts ba 
                    ON ba.id = fr.bank_account_id 
            WHERE fr.tran_date <= ".db_escape($cutoff_date)."  
                    AND (fr.from_float_id > 0 OR fr.bank_payment_id > 0)   
                    AND fr.fi_batch_no = 0 
            ORDER BY fr.id 
            LIMIT ".$batch_size;
    
    return db_query($sql, "get_fi_petty_cash_float_reimbursements");
}

