Hi,
Please find the code below that provides the link between GeneralJournalAccountEntry and LedgerJournalTransAccrual. Its a job and written in Ax(need to be translated into SQL)
static void Link(Args _args)
{
GeneralJournalEntry generalJournalEntry;
GeneralJournalAccountEntry journalAccountEntry;
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans;
LedgerJournalTransAccrual ledgerJournalTransAccrual;
SubledgerVoucherGeneralJournalEntry subledgerVoucherGeneralJournalEntry;
DataAreaId company;
company = curext();
select journalAccountEntry // Can include postingtype to further filter the data
join generalJournalEntry
where ((generalJournalEntry.RecId == journalAccountEntry.GeneralJournalEntry)
&& (generalJournalEntry.SubledgerVoucherDataAreaId == company)) // current company
join Voucher, AccountingDate from subledgerVoucherGeneralJournalEntry
where (subledgerVoucherGeneralJournalEntry.GeneralJournalEntry == generalJournalEntry.RecId)
join ledgerJournalTrans
where ledgerJournalTrans.Voucher == subledgerVoucherGeneralJournalEntry.Voucher
join ledgerJournalTable
where ledgerJournalTable.JournalNum == ledgerJournalTrans.JournalNum
join ledgerJournalTransAccrual
where ledgerJournalTransAccrual.RefTableid == ledgerJournalTrans.TableId
&& ledgerJournalTransAccrual.RefRecid == ledgerJournalTrans.RecId;
}
If its finds helpful, please mark it verified such that it is helpful to others and if anything is wrong/missing let me know.
Thanks,
Chaitanya Golla