2016-11-09 63 views
1

我们必须为报告“LedgerAccountStatementPerCurrency”(AX 2012)开发一些功能。AX Report Mainaccount期初余额数据集

其中一个特点是,为报表中的每个主要账户显示期初余额(交易币种)。

很久以前,我在SQL Server上写了一个存储过程,这个存储过程给了我这个返回值。主要参数,datefrom和dateto。

我的问题是如果有可能使用此存储过程? 报告依赖于类“LedgerAccountStatementPerCurrencyDP”,我可以执行,系统给报告的每个mainaccount,我打电话给我的存储过程和给另一个领域的余额回来?

这种情况是怎么回事?

回答

1

对于此报告,您有此信息。检查LedgerAccountStatementPerCurrencyDPprocessReport方法。在while (queryRun.next())之后您可以看到这个标准代码来计算期初余额

在接下来的代码中找到这个标签//Here OpeningBalance

下面的代码

... 
... 
... 
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; 
    } 
... 
... 
... 
+0

确定,我怎么可以添加是考虑到报告如“OpeningBalanceTransaction”一个新的领域?在这段代码中,我有我需要的所有东西来存储过程(dateFrom,dateTo,mainaccountID),所以我可以在这里调用它并填充新添加的字段“OpeningBalanceTransaction”或? – JamesnxD

+0

是的,当然可以。要执行该操作,您必须在“LedgerAccountStatementPerCurrencyTmp”表中创建一个新字段。在'ProcessReport'方法中为这个新字段添加代码。然后在** Visual Studio **中刷新数据源'LedgerAccountStatementPerCurrencyDS'以显示您的新字段,然后在布局中添加您的新字段。 –

+1

好吧,我会尝试一下,发布我的结果并将您的答案标记为最佳;) – JamesnxD