Friday, September 6, 2013

Bank Reconciliation Fix

Here's a quick job to 'unreconcile' a bank account statement in Dynamics AX 2009.

'Cleared' check boxes will remain checked for the statement, so you can easily re-reconcile.  Set the Bank Account id and the Bank Account Statement Date in the code to suite your situation.

//Use this job to un-reconcile a bank account statement.
static void UnRenconcileBankAccount(Args _args)
{
    bankAccountStatement    bankAccountStatement;
    BankAccountTrans        bankAccountTrans;
    int                     i;
    ;

    select firstonly forupdate bankAccountStatement
        where bankAccountStatement.AccountId == '1050'                          //set this
        && bankAccountStatement.AccountStatementDate == mkDate(31,7,2013);      //set this (D,M,Y)

    if (bankAccountStatement)
    {
        ttsbegin;

        bankAccountStatement.ReconcileDate = datenull();
        bankAccountStatement.update();

        while select forupdate bankAccountTrans
            where bankAccountTrans.AccountId == bankAccountStatement.AccountId
            && bankAccountTrans.AccountStatementDate == bankAccountStatement.AccountStatementDate
            && bankAccountTrans.Reconciled == NoYes::Yes
        {
            bankAccountTrans.Reconciled = NoYes::No;
            bankAccountTrans.doUpdate();
        }
        ttscommit;
    }
}

No comments:

Post a Comment