+
+ $sql = "SELECT bank_act, SUM(amount) AS amount FROM ".TB_PREF."bank_trans WHERE trans_date <= '$to' GROUP BY bank_act";
+ $result = db_query($sql, "Could not retrieve bank trans");
+ while ($row = db_fetch($result))
+ {
+ $sql = "DELETE FROM ".TB_PREF."bank_trans WHERE trans_date <= '$to' AND bank_act = '{$row['bank_act']}'";
+ db_query($sql, "Could not delete bank trans");
+ $sql = "INSERT INTO ".TB_PREF."bank_trans (type, trans_no, trans_date, bank_act, ref, amount) VALUES
+ (0, 0, '$to', '{$row['bank_act']}', '$ref', {$row['amount']})";
+ db_query($sql, "Could not insert bank trans");
+ }
+
+ $sql = "DELETE FROM ".TB_PREF."audit_trail WHERE gl_date <= '$to'";
+ db_query($sql, "Could not delete audit trail");