Update for a data problem with the IsCredit field in the GeneralJournalAccountEntry table
The GeneralJournalAccountEntry table contains the detailed General Ledger entries. The IsCredit field is the correct and easy way to determine if the entry is a debit (false) or a credit (true).
From Dynamics AX 2012 RTM until a hot fix that was released on November 6, 2012, there was a problem where the IsCredit field was not set correctly if the entry had an AccountingCurrencyAmount of zero. One way this problem will manifest itself is in the inability for processes such as settlement and revaluation to find the ledger dimension of an existing transaction. The result of not finding the original transaction is that the ledger dimension is empty and that results in a posting error similar to the following.
Account number for transaction type %1 does not exist.
%1 is the posting type, such as "Exchange rate loss" or "Exchange rate gain"
This problem is specific to Dynamics AX 2012 and was fixed starting in KB 2758624 and CU4.
Since there is no official way to deliver a data update, the job below will update the IsCredit field for this problem and can be run repeatedly as needed until the update is applied to your system.
static void GJAE_IsCreditFix(Args _args)
{
GeneralJournalAccountEntry a;
boolean doSave;
// TODO: change this to true to commit the changes
doSave = false;
ttsBegin;
update_recordSet a
setting IsCredit =
(a.TransactionCurrencyAmount < 0 && !a.IsCorrection) ||
(a.TransactionCurrencyAmount > 0 && a.IsCorrection)
where a.AccountingCurrencyAmount == 0
&& a.TransactionCurrencyAmount != 0;
info(strFmt('Transaction: %1', a.RowCount()));
update_recordSet a
setting IsCredit =
(a.ReportingCurrencyAmount < 0 && !a.IsCorrection) ||
(a.ReportingCurrencyAmount > 0 && a.IsCorrection)
where a.AccountingCurrencyAmount == 0
&& a.TransactionCurrencyAmount == 0
&& a.ReportingCurrencyAmount != 0;
info(strFmt('Reporting: %1', a.RowCount()));
if (doSave)
{
ttsCommit;
info('committed');
}
else
{
ttsAbort;
info('aborted');
}
}