<?php

function get_fi_supplier_transport_invoices($cutoff_date, $batch_size)
{
    $sql = "SELECT st.trans_no, st.type, 
                    st.supplier_id, 
                    st.tran_date, 
                    st.due_date, 
                    st.ov_amount, 
                    st.ov_discount, 
                    st.ov_gst, 
                    st.rate, 
                    st.tax_included, 
                    st.reference,  
                    st.project_id,  
                    sup.purchase_account, sup.payable_account, 
                    sup.payment_discount_account, sup.curr_code 
                    
            FROM ".TB_PREF."supp_trans st  
                JOIN ".TB_PREF."suppliers sup 
                    ON st.supplier_id = sup.supplier_id 
                    
            WHERE st.tran_date <= ".db_escape($cutoff_date)."  
                    AND st.type = ".db_escape(ST_SUPPLIER_TRANSPORT_INVOICES)."  
                    AND st.fi_batch_no = 0 
                    
            ORDER BY st.trans_no LIMIT ".$batch_size;

    return db_query($sql, "get_fi_supplier_transport_invoices");

}



function get_fi_supplier_transport_invoices_taxes($trans_type, $trans_no)
{
    $sql = "SELECT ttd.id,
                    ttd.trans_no,
                    ttd.amount, 
                    tt.sales_gl_code,               
                    tt.purchasing_gl_code,
                    ttd.suspended         
                    
            FROM ".TB_PREF."trans_tax_details ttd 
                JOIN ".TB_PREF."tax_types tt ON 
                    ttd.tax_type_id = tt.id 
                    
            WHERE ttd.trans_type = ".db_escape($trans_type)." 
                AND ttd.trans_no = ".db_escape($trans_no);
                    

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



?>