Richard,
Here is a fix for the error you are receiving. PLEASE BACKUP BEFORE YOU RUN THIS. It is vey hard to test since generating this error is difficult.
Place the code snippet below replacing lines 319-321 in file /modules/gen_ledger/classes/gen_ledger.php
was:
Code:
if ($debit_total <> $credit_total) { // Trouble in paradise, need fraction cents adjustment function
return $this->fail_message(GL_ERROR_OUT_OF_BALANCE_A . $result->fields['debit'] . GL_ERROR_OUT_OF_BALANCE_B . $result->fields['credit'] . GL_ERROR_OUT_OF_BALANCE_C . $period);
}
To:
Code:
if ($debit_total <> $credit_total) { // Trouble in paradise, fraction of cents adjustment next
$tolerance = 2 * (1 / pow(10, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'])); // i.e. 2 cents in USD
$adjustment = $result->fields['credit'] - $result->fields['debit'];
if (abs($adjustment) > $tolerance) {
return $this->fail_message(GL_ERROR_OUT_OF_BALANCE_A . $result->fields['debit'] . GL_ERROR_OUT_OF_BALANCE_B . $result->fields['credit'] . GL_ERROR_OUT_OF_BALANCE_C . $period);
}
// find the adjustment account
if (!defined('ROUNDING_GL_ACCOUNT') || ROUNDING_GL_ACCOUNT == '') {
$result = $db->Execute("select id from " . TABLE_CHART_OF_ACCOUNTS . " where account_type = 44 limit 1");
if ($result->RecordCount() == 0) {
return $this->fail_message('Failed trying to locate retained earnings account to make rounding adjustment. There must be one and only one Retained Earnings account in the chart of accounts!');
}
$adj_gl_account = $result->fields['id'];
} else {
$adj_gl_account = ROUNDING_GL_ACCOUNT;
}
if (DEBUG) $messageStack->debug("\n Adjusting balance, adjustment = " . $adjustment . " and gl account = " . $adj_gl_account);
$sql = "update " . TABLE_CHART_OF_ACCOUNTS_HISTORY . "
set debit_amount = debit_amount + " . $adjustment . "
where period = " . $period . " and account_id = '" . $adj_gl_account . "'";
$result = $db->Execute($sql);
}
Dave