This should give you what you are looking for. Assuming the Ledger Dimension Account and Offset Ledger Dimension Account is coming from a table,
this is the quite simple, with less code. Tested and working!
public int CreateJnlEntry(RevenuePostingTable _revenuePosting) { MCRLedgerJournal journalTable; LedgerJournalTable ledgerJournalTable; Counter recordsInserted; journalTable = new MCRLedgerJournal_Daily(LedgerJournalType::Daily,"GnrJrnl"); //Instatiate the General Journal Table ledgerJournalTable = journalTable.createLedgerJournalTable("GnrJrnl"); journalTable.parmLedgerJournalTable(ledgerJournalTable); journalTable.parmMCRCCGeneralLedgerId(); journalTable.parmLedgerAccountType(_revenuePosting.AccountType); journalTable.parmLedgerOffsetAccountType(_revenuePosting.OffsetAccountType); journalTable.parmExchRate(_revenuePosting.ExchRate); journalTable.parmCurrencyCode(_revenuePosting.CurrencyCode); journalTable.parmLineNum(); journalTable.parmLedgerAccount(_revenuePosting.LedgerDimension); journalTable.parmledgerOffsetAccount(_revenuePosting.OffsetLedgerDimension); journalTable.parmTransDate(_revenuePosting.TransDate); journalTable.parmTransTxt(_revenuePosting.Txt); journalTable.createLedgerJournalTrans(abs(_revenuePosting.AmountCurCredit),abs(_revenuePosting.AmountCurDebit),LedgerJournalACType::Ledger); recordsInserted++; return recordsInserted; }
For more: www.linkedin.com/.../simplest-way-create-general-journal-d365-using-code-udoye-samuel