AX Consulting

Just another site

Creating and posting Ledger Journal via code

static void InsertLedgerJournal(Args _args)
    LedgerJournalName           ledgerJournalName;
    LedgerJournalTable          ledgerJournalTable;
    LedgerJournalTrans          ledgerJournalTrans;
    LedgerJournalCheckPost      ledgerJournalCheckPost;
    NumberSeq                   numberSeq;


    // Find LedgerJournalname Record
    select firstonly   ledgerJournalName where ledgerJournalname.JournalType == LedgerJournalType::Daily;

    //Create Ledger Journal Table
    ledgerJournalTable.JournalName      = ledgerJournalName.JournalName ;
    ledgerJournalTable.Name             = “Daily Trans”;
    numberSeq                           = NumberSeq::newGetVoucherFromCode(ledgerJournalTable.VoucherSeries);
    ledgerJournalTrans.Voucher          = numberSeq.voucher();

    //Create Transaction Line
    ledgerJournalTrans.JournalNum       = ledgerjournalName.JournalName;
    ledgerJournalTrans.CurrencyCode     = ‘EUR’;
    ledgerJournalTrans.ExchRate         = Currency::exchRate(ledgerJournalTrans.CurrencyCode);
    ledgerJournalTrans.AccountNum       = ‘140567’;
    ledgerJournalTrans.AccountType      = ledgerJournalACType::Ledger;
    ledgerJournalTrans.AmountCurDebit   = 102.00;
    ledgerJournalTrans.TransDate        = today();
    ledgerJournalTrans.Txt              = ‘good Product’;
    ledgerJournalTrans.OffsetAccount    = ‘140567’;

    info(strfmt(‘Journal Id: %1’,ledgerJournalTable.JournalNum));

    // Post Journal
    ledgerJournalCheckPost              = ledgerJournalCheckPost::newLedgerJournalTable(ledgerJournaltable,Noyes::Yes);;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: