Skip to main content

Notifications

Microsoft Dynamics AX forum
Unanswered

Opening Balance, Credit and Debit in Trial Balance using SQL

Posted on by 16
Hi,
I'm recreating the trial balance that appears in AX 2012 in sql server. Rigth now, I have the closing balance but I want to get the opening balance, debit and credit. Is there a way that I can get those values? This is the query I have:
 
SELECT m.[PARTITION], m.MAINACCOUNTID, SUM(a.ACCOUNTINGCURRENCYAMOUNT) AS ACCOUNTINGCURRENCYAMOUNT
  FROM GENERALJOURNALACCOUNTENTRY a
  JOIN GENERALJOURNALENTRY e  ON e.[PARTITION] = a.[PARTITION] AND e.RECID = a.GENERALJOURNALENTRY
  JOIN MAINACCOUNT m          ON m.[PARTITION] = a.[PARTITION] AND m.RECID = a.MAINACCOUNT
  JOIN FISCALCALENDARPERIOD p ON p.[PARTITION] = e.[PARTITION] AND p.RECID = e.FISCALCALENDARPERIOD
  JOIN FISCALCALENDARYEAR FCY ON FCY.RECID = p.FISCALCALENDARYEAR
  WHERE p.[TYPE] = 1  -- 0=Opening,1=Operating,2=Closing
   AND m.MAINACCOUNTID = '111406'
   AND FCY.NAME = '2024'
  GROUP BY m.[PARTITION], m.MAINACCOUNTID
  ORDER BY m.[PARTITION], m.MAINACCOUNTID
 
  • Suggested answer
    Raj Borad Profile Picture
    Raj Borad 385 on at
    Opening Balance, Credit and Debit in Trial Balance using SQL
    Hi,
    You can get the Debit and Credit with the use of IsCredit Field of GeneralJournalAccountEntry Table in your query.
     
    Thank you,
    Raj D Borad

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,480 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,388 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans