LedgerJournalEngine* classes are mostly used by the forms to do work and execute code before/after events and datasource actions.
It may make more sense to just complete all of the LedgerJournalTrans fields, but using the engine can't really hurt and might be more helpful in some cases.
static void Job81(Args _args) { LedgerJournalEngine_CustPayment ledgerJournalEngine; LedgerJournalTable ledgerJournalTable; LedgerJournalTrans ledgerJournalTrans; NumberSeq numberSeq; Voucher voucher; ; // This just selects the header you are inserting into select firstonly ledgerJournalTable where ledgerJournalTable.JournalNum == 'GB 0056226'; if (!ledgerJournalTable) throw error ("Unable to find journal table record"); ledgerJournalTrans.initValue(); numberSeq = NumberSeq::newGetNumFromCode(ledgerJournalTable.VoucherSeries); if (numberSeq) { ledgerJournalTrans.Voucher = numberSeq.num(); voucher = ledgerJournalTrans.Voucher; } ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum; ledgerJournalTrans.TransDate = SystemDateGet(); ledgerJournalTrans.AccountType = LedgerjournalACType::Cust; ledgerJournalTrans.AccountNum = '100003'; ledgerJournalEngine = LedgerJournalEngine::construct(LedgerJournalType::CustPayment); ledgerJournalEngine.newJournalActive(ledgerJournalTable); ledgerJournalEngine.accountModified(ledgerJournalTrans); ledgerJournalTrans.AmountCurCredit = 10; ledgerJournalTrans.OffsetAccountType = ledgerJournalTable.OffsetAccountType; ledgerJournalTrans.OffsetAccount = ledgerJournalTable.OffsetAccount; ledgerJournalTrans.CurrencyCode = CompanyInfo::standardCurrency(); ledgerJournalEngine.currencyModified(ledgerJournalTrans); ledgerJournalTrans.insert(); if (numberSeq && ledgerJournalTrans.Voucher == voucher) { numberSeq.used(); } else { if (numberSeq) numberSeq.abort(); } info("Done"); }
I have a ledger question and I was asking if you can help
ReplyDelete