Skip to main content

Code to get opening balance for Ledger Main account in Ax 2012

If you want to check opening balance for particular main account then you can check below code to get the same.

This is sample Code to get opening balance for Ledger Main account in Ax 2012.

  LedgerBalanceMainAccountAmounts ledgerBalance;  
   AmountMst  opSum;  
   ;  
   ledgerBalance = LedgerBalanceMainAccountAmounts::construct();  
   ledgerBalance.parmIncludeRegularPeriod(true);  
   ledgerBalance.parmIncludeOpeningPeriod(true);  
   ledgerBalance.parmIncludeClosingPeriod(false);  
   ledgerBalance.parmAccountingDateRange(mkDate(01,01,2000), mkDate(31,12,2017));  
   ledgerBalance.calculateBalance(MainAccount::findByMainAccountId('1123333'));  
   opSum = ledgerBalance.getAccountingCurrencyBalance();  
   info(num2str(opSum,10,2,1,1));  

Popular posts from this blog

X++ Code to run SSRS Report with parameter in D365 F&O (Example Sales Invoice )

Below is sample X++ Code to run SSRS Report with parameter in D365 F&O (Example Sales Invoice )      Args                       args = new Args();     CustInvoiceJour            custInvoiceJour;     SalesInvoiceJournalPrint   salesInvoiceJournalPrint;       select firstonly custInvoiceJour where custInvoiceJour.SalesId != '';       // Add record to be printed.     // In order to have the context table we need to set args.record().     args.record(custInvoiceJour);       salesInvoiceController = new SalesInvoiceController();     salesInvoiceController.parmReportName(         PrintMgmtDocType::construct(PrintMgmtDocumentType::SalesOrderInvoice).getDefaultReportFormat());       salesInvoiceContract = salesInvoiceController.parmReportContrac...