+function get_open_balance($supplier_id, $to)
+{
+ $to = date2sql($to);
+
+ $sql = "SELECT
+ SUM(IF(type IN(".ST_SUPPINVOICE.",".ST_BANKDEPOSIT."), (ov_amount + ov_gst + ov_discount), 0)) AS charges,
+ SUM(IF(type NOT IN(".ST_SUPPINVOICE.",".ST_BANKDEPOSIT."), (ov_amount + ov_gst + ov_discount), 0)) AS credits,
+ SUM(IF(type NOT IN(".ST_SUPPINVOICE.",".ST_BANKDEPOSIT."),alloc * -1, alloc)) AS Allocated,
+ SUM(IF(type IN(".ST_SUPPINVOICE.",".ST_BANKDEPOSIT."), (ov_amount + ov_gst + ov_discount - alloc),
+ (ov_amount + ov_gst + ov_discount + alloc))) AS OutStanding
+ FROM ".TB_PREF."supp_trans
+ WHERE tran_date < '$to'
+ AND supplier_id = '$supplier_id' GROUP BY supplier_id";
+
+ $result = db_query($sql,"No transactions were returned");
+ return db_fetch($result);
+}
+
+function getTransactions($supplier_id, $from, $to)