How to prevent transaction reversal from posting to closed dimensions
Current behavior of Dynamics AX allows for transaction reversals to post without a warning or error message when the reversal will post to a dimension that is closed. If you wish to have a message appear to stop the reversal, this can be achieved by making the following modification. Please note that the reversal process will be blocked by this code if the posting will affect a closed dimension so you will need to create an entry manually through a journal to reverse the effects of the transaction originally intended to be reversed.
The change would be made to \Classes\LedgerVoucherTransObject\check.
From:
...
// Find the account and then call the instance based nethods to validate the account.
ledgerTable = LedgerTable::find(ledgerTrans.AccountNum);
ok = ledgerTable.checkPostingType(ledgerTrans.Posting,false) && ok;
ok = Dimensions::checkDimension(ledgerTrans.Dimension, true,
_ledgerVoucher.parmCheckBlockedDimensions()) && ok;
ok = LedgerTable::checkDimension(ledgerTrans.AccountNum, ledgerTrans.Dimension) && ok;
ok = appl.dimensionSetValidation(false, company).checkDimension(ledgerTrans,
fieldnum(LedgerTrans, Dimension),
false, false, true) && ok;
ok = ledgerTable.checkUserId(curuserid()) && ok;
ok = ledgerTable.checkAccountCurrency(ledgerTrans.CurrencyCode,
(ledgerTrans.Posting == LedgerPostingType::ExchRateGain ||
ledgerTrans.Posting == LedgerPostingType::ExchRateLoss)) && ok;
}
// Validating amount
...
To:
...
// Find the account and then call the instance based nethods to validate the account.
ledgerTable = LedgerTable::find(ledgerTrans.AccountNum);
ok = ledgerTable.checkPostingType(ledgerTrans.Posting,false) && ok;
ok = LedgerTable::checkDimension(ledgerTrans.AccountNum, ledgerTrans.Dimension) && ok;
ok = appl.dimensionSetValidation(false, company).checkDimension(ledgerTrans,
fieldnum(LedgerTrans, Dimension),
false, false, true) && ok;
ok = ledgerTable.checkUserId(curuserid()) && ok;
ok = ledgerTable.checkAccountCurrency(ledgerTrans.CurrencyCode,
(ledgerTrans.Posting == LedgerPostingType::ExchRateGain ||
ledgerTrans.Posting == LedgerPostingType::ExchRateLoss)) && ok;
}
//Validate dimension
ok = Dimensions::checkDimension(ledgerTrans.Dimension, true,
_ledgerVoucher.parmCheckBlockedDimensions()) && ok;
// Validating amount
...