Sunday, August 9, 2020

Insert GeneralJournal through X++ , D365 (Insert JV through Code)

 here is the code to insert GeneralJournal through code

Paramenter are

1) Journal Name (_journalName ) : the name of the journal you want to add with

2) Account (_debit ) : the account is the int64 field representing account base on the Account type which you can change in code.

3) OffsetAcount (_Credit) : the account is the int64 field representing account base on the Account type which you can change in code.

4) Description (_description ) : the description you want to add in journal

(Note: I added 100 in debit)

private void insertGeneralJournal(str _journalName , int64 _debit , int64 _credit , str _description = "")

    {

        MCRLedgerJournal        journalTable;

        LedgerJournalTable      ledgerJournalTable;

        journalTable = new MCRLedgerJournal_Daily(LedgerJournalType::Daily,_journalName);

        //Creates the journal header table

        ledgerJournalTable = journalTable.createLedgerJournalTable(_journalName);


        journalTable.parmLedgerJournalTable(ledgerJournalTable);

        journalTable.parmMCRCCGeneralLedgerId();

        journalTable.parmLedgerAccountType(LedgerJournalACType::Ledger);

        journalTable.parmLedgerOffsetAccountType(LedgerJournalACType::Ledger);

        //    journalTable.parmExchRate(_revenuePosting.ExchRate);

        //   journalTable.parmCurrencyCode(_revenuePosting.CurrencyCode);

        journalTable.parmLineNum();

        journalTable.parmLedgerAccount(_debit);

        journalTable.parmledgerOffsetAccount(_credit);

        journalTable.parmTransDate(today());

        journalTable.parmTransTxt(_description );

        //create the journal trans table

        journalTable.createLedgerJournalTrans(abs(100),0,LedgerJournalACType::Ledger);

       

        info(strFmt("journal number %1 has been generated as assessment fee for student %2" ,         ledgerJournalTable.JournalNum , prospectStudentAssessmentTable.prospectStudentId));

      //To Post generalJournal

        ledgerjournalcheckpost      post ;

        post =  LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,true,true);


        // post = new LedgerJournalcheckPost::newLedgerJournalTable(table,NoYes::Yes,NoYes::Yes);

        post.run();

    }

No comments:

Post a Comment

Change SSRS Report Design Based On Condition , D365 ,X++

 To change Sales Invoice control document's design based on condition use following code. Here I have created COC of salesInvoiceControl...