<?php


function cs_get_supplier_invoices_with_no_tax_group(){
    $sql = "SELECT * FROM  ".TB_PREF."supp_trans 
            WHERE type IN(20, 21) AND tax_group_id = 0 LIMIT 1";
    return db_query($sql,"Could not cs_get_supplier_invoices_with_no_tax_group");
}

function  cs_update_supp_invoice_tax_group($type, $trans_no, $tax_included, $tax_group_id)
{
    $sql = "UPDATE ".TB_PREF."supp_trans   
            SET tax_included =".db_escape($tax_included). ",
                tax_group_id =".db_escape($tax_group_id). " 
            WHERE type = ".db_escape($type)."  AND trans_no =".db_escape($trans_no).
                " AND tax_group_id = 0";
    
    db_query($sql,"Could not cs_update_po_tax_group");
}


function cs_update_loan_repayment_loan_id()
{
    $invs = cs_loan_repayments();
    while ($row = db_fetch($invs)) {
        $supplier = get_supplier($row['supplier_id']);             
        cs_update_supp_invoice_tax_group($row['type'], $row['trans_no'], $supplier['tax_included'], $supplier['tax_group_id']);   
    }
}

?>