AX Consulting

Just another WordPress.com site

Creating and posting Ledger Journal via code

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

    ttsbegin;

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

    //Create Ledger Journal Table
    ledgerJournalTable.JournalName      = ledgerJournalName.JournalName ;
    ledgerJournalTable.initFromLedgerJournalName();
    ledgerJournalTable.Name             = “Daily Trans”;
    ledgerJournalTable.insert();
    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’;
    ledgerJournalTrans.insert();

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

    // Post Journal
    ledgerJournalCheckPost              = ledgerJournalCheckPost::newLedgerJournalTable(ledgerJournaltable,Noyes::Yes);
    LedgerJournalCheckPost.run();
}

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: