db_query($sql, "Could not delete debtor trans");
}
}
- $sql = "DELETE FROM ".TB_PREF."cust_allocations WHERE trans_no_from = {$row['trans_no']} AND type_no_from = {$row['type']}";
+ $sql = "DELETE FROM ".TB_PREF."cust_allocations WHERE trans_no_from = {$row['trans_no']} AND trans_type_from = {$row['type']}";
db_query($sql, "Could not delete cust allocations");
$sql = "DELETE FROM ".TB_PREF."debtor_trans_details WHERE debtor_trans_no = {$row['trans_no']} AND debtor_trans_type = {$row['type']}";
db_query($sql, "Could not delete debtor trans details");
$result = db_query($sql, "Could not retrieve supp trans");
while ($row = db_fetch($result))
{
- $sql = "DELETE FROM ".TB_PREF."supp_allocations WHERE trans_no_from = {$row['trans_no']} AND type_no_from = {$row['type']}";
+ $sql = "DELETE FROM ".TB_PREF."supp_allocations WHERE trans_no_from = {$row['trans_no']} AND trans_type_from = {$row['type']}";
db_query($sql, "Could not delete supp allocations");
$sql = "DELETE FROM ".TB_PREF."supp_invoice_items WHERE supp_trans_no = {$row['trans_no']} AND supp_trans_type = {$row['type']}";
db_query($sql, "Could not delete supp invoice items");
db_query($sql, "Could not delete exchange rates");
$sql = "DELETE FROM ".TB_PREF."budget_trans WHERE tran_date <= '$to'";
db_query($sql, "Could not delete exchange rates");
+
$sql = "SELECT account, SUM(amount) AS amount FROM ".TB_PREF."gl_trans WHERE tran_date <= '$to' GROUP by account";
$result = db_query($sql, "Could not retrieve gl trans");
while ($row = db_fetch($result))
db_query($sql, "Could not delete gl trans");
if (is_account_balancesheet($row['account']))
{
- $trans_no = get_next_trans_no(0);
- if (is_bank_account($row['account']))
- {
- $sql = "SELECT SUM(amount) FROM ".TB_PREF."bank_trans WHERE trans_date <= '$to' AND bank_act = '{$row['account']}'";
- $res = db_query($sql, "Could not retrieve bank trans");
- $row2 = db_fetch_row($res);
- $sql = "DELETE FROM ".TB_PREF."bank_trans WHERE trans_date <= '$to' AND bank_act = '{$row['account']}'";
- 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, $trans_no, '$to', '{$row['account']}', '$ref', {$row2[0]})";
- db_query($sql, "Could not insert bank trans");
- }
+ $trans_no = get_next_trans_no(ST_JOURNAL);
$sql = "INSERT INTO ".TB_PREF."gl_trans (type, type_no, tran_date, account, memo_, amount) VALUES
- (0, $trans_no, '$to', '{$row['account']}', '$ref', {$row['amount']})";
+ (ST_JOURNAL, $trans_no, '$to', '{$row['account']}', '$ref', {$row['amount']})";
db_query($sql, "Could not insert gl trans");
}
}
+
+ $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");
delete_fiscalyear($selected_id);
commit_transaction();
}
$result = get_all_fiscalyears();
start_form();
- display_note(_("Warning: During fiscal year removal all transactions
+ display_note(_("Warning: Deleting a fiscal year all transactions
are removed and converted into relevant balances. This process is irreversible!"),
0, 0, "class='currentfg'");
start_table($table_style);
if ($myrow["id"] != $company_year) {
delete_button_cell("Delete".$myrow['id'], _("Delete"));
submit_js_confirm("Delete".$myrow['id'],
- sprintf(_("Are you sure you want to remove fiscal year %s - %s? All transactions are removed and converted into relevant balances. Do you want to continue ?"), $from, $to));
+ sprintf(_("Are you sure you want to delete fiscal year %s - %s? All transactions are deleted and converted into relevant balances. Do you want to continue ?"), $from, $to));
} else
label_cell('');
end_row();