+ . "IF(trans.type IN(".implode(',', array(ST_CUSTCREDIT,ST_CUSTPAYMENT,ST_BANKDEPOSIT))."), -1, 1)
+ *(IF(prep_amount, prep_amount, trans.ov_amount + trans.ov_gst + trans.ov_freight
+ + trans.ov_freight_tax + trans.ov_discount)-trans.alloc) Balance,
+ debtor.debtor_no,";
+