JamesnxD
JamesnxD

Reputation: 163

AX Report Mainaccount Opening Balance Dataset

We have to develop some features for the report "LedgerAccountStatementPerCurrency" (AX 2012).

One of the Features is, to show for each mainaccount in the report the opening balance (transaction Currency).

I wrote a Stored Procedure a long time ago on the SQL Server which gives me this as return value. The parameters are mainaccountid, datefrom and dateto.

My question is if it is possible to use this Stored Procedure? The Report depence on the class "LedgerAccountStatementPerCurrencyDP", can i implement, that for each mainaccount the system gives to the report, i call my Stored Procedure an give the balance in another field back?

What's the way in this situation?

Upvotes: 1

Views: 474

Answers (1)

Jonathan Bravetti
Jonathan Bravetti

Reputation: 2238

For this report you have this info. Check LedgerAccountStatementPerCurrencyDP class processReport method. Here after while (queryRun.next()) you can see this standard code to calculate opening balance.

In the next code find this label //Here OpeningBalance

Here the code

...
...
...
queryRun = new QueryRun(query);
while (queryRun.next())
{
    generalJournalAccountEntry = queryRun.get(tableNum(GeneralJournalAccountEntry)) as GeneralJournalAccountEntry;
    generalJournalEntry = queryRun.get(tableNum(GeneralJournalEntry)) as GeneralJournalEntry;
    fiscalCalendarPeriod = queryRun.get(tableNum(FiscalCalendarPeriod)) as FiscalCalendarPeriod;
    dimAttrValueCombo = queryRun.get(tableNum(DimensionAttributeValueCombination)) as DimensionAttributeValueCombination;

    if (dimAttrValueCombo.MainAccount != prevMainAccount)
    {
        mainAccount = MainAccount::find(dimAttrValueCombo.MainAccount);
        localizedName = mainAccount.localizedName();
    }

    ledgerAccountStatementPerCurrencyTmp.clear();
    ledgerAccountStatementPerCurrencyTmp.MainAccountId = mainAccount.MainAccountId;
    ledgerAccountStatementPerCurrencyTmp.AccountName = localizedName;

    if (dimAttrValueCombo.MainAccount != prevMainAccount)
    {
        if (mainAccount && ledgerBalanceOpening)
        {
        //Here OpeningBalance
            ledgerBalanceOpening.calculateBalance(mainAccount);
            openingBalance = ledgerBalanceOpening.getAccountingCurrencyBalance();
        //Here OpeningBalance END
        }
        else
        {
            openingBalance = 0;
        }

        ledgerAccountStatementPerCurrencyTmp.OpeningBalance = openingBalance;
        ledgerAccountStatementPerCurrencyTmp.insert();

        prevMainAccount = dimAttrValueCombo.MainAccount;
    }
...
...
...

Upvotes: 1

Related Questions