27.07.2007, 17:30 | #1 |
Участник
|
Arijit Basu: Post Ledger Transactions via X++
Источник: http://daxguy.blogspot.com/2007/07/p...ons-via-x.html
============== For beginner AX developers, I’m listing some codes which will help someone to post ledger transactions via X++ codes. This may be helpful to new Developers. [Level 200] There are two ways to be considered when posting transactions: 1. Use the LedgerVoucher class and sub-classes API. 2. Use a journal Classes. 1. Use the LedgerVoucher class and sub-classes API. The Classes are: • LedgerVoucher - Posting {LedgerVoucher harnesses the posting of multiple vouchers at a time. } • LedgerVoucherObject - Voucher {The LedgerVoucher class holds all the vouchers in temporary storage.} • LedgerVoucherTransObject – Transactions {Holds transactions in each Voucher} Instantiation of LedgerVoucher LedgerVoucher::newLedgerPost(_detailSummary, _sysModule, _voucherSeriesCode, [_transactionLogType, _transactionLogText, _approveJournal, _posting]); Instantiation of LedgerVoucherObject LedgerVoucherObject::newVoucher(_voucher, [_transDate, _sysModule, _ledgerTransType, _correction, _operationsTax, _documentNum, _documentDate]); Instantiation of LedgerVoucherTransObject LedgerVoucherTransObject newCreateTrans(_ledgerVoucherObject, _ledgerPostingType, _ledgerAccount, _dimension, _currencyCode, _amountCur, _sourceTableId, _sourceRecId, [_qty, _exchRate , _exchRateSecond, _exchRatesTriangulation, _markBridging , ProjLedger, AmountMST ]) Sample Code static void LedgerVoucherAPISample(Args _args) { LedgerVoucher _LedgerVoucher; LedgerVoucherObject _LedgerVoucherObject; LedgerVoucherTransObject _LedgerVoucherTransObject; NumberSeq _NumberSeq; Dimension _Dimension; NumberSequenceCode _VoucherCode = 'Ledger_3'; LedgerAccount _Account = '110180'; LedgerAccount _OffsetAccount = '140270'; AmountCur _AmountCur = 12345.67; ttsbegin; _NumberSeq = NumberSeq::newGetVoucherFromCode(_VoucherCode); _LedgerVoucher = LedgerVoucher::newLedgerPost(DetailSummary::Detail, SysModule::Ledger, _VoucherCode); _LedgerVoucherObject = LedgerVoucherObject::newVoucher(_NumberSeq.voucher()); _LedgerVoucher.addVoucher(_LedgerVoucherObject); _LedgerVoucherTransObject = LedgerVoucherTransObject::newCreateTrans(_LedgerVoucherObject, LedgerPostingType::LedgerJournal, _Account, _Dimension, CompanyInfo::standardCurrency(), _AmountCur, 0, 0); _LedgerVoucherTransObject.parmTransTxt("Arijit Basu"); _LedgerVoucher.addTrans(_LedgerVoucherTransObject); _LedgerVoucherTransObject = LedgerVoucherTransObject::newCreateTrans(_LedgerVoucherObject, LedgerPostingType::LedgerJournal, _OffsetAccount, _Dimension, CompanyInfo::standardCurrency(), _AmountCur*-1, 0, 0); _LedgerVoucherTransObject.parmTransTxt("Arijit Basu"); _LedgerVoucher.addTrans(_LedgerVoucherTransObject); _LedgerVoucher.end(); ttscommit; } 2. Use a journal Classes. The tables used are LedgerJournalName, LedgerJournalTable, and LedgerJournalTrans. The steps are: • Create a journal table record {Table\LedgerJournalTable} • Create lines for each transaction to be posted {Table\LedgerJournalTrans}. • Post the journal. {Classes\LedgerJournalCheckPost} Sample Code static void LedgerJournalCheckPostDemo(Args _args) { LedgerJournalTable _LedgerJournalTable; LedgerJournalTrans _LedgerJournalTrans; LedgerJournalCheckPost _LedgerJournalCheckPost; NumberSeq _NumberSeq; ttsbegin; //----Journal Header _LedgerJournalTable.JournalName = 'Day1'; _LedgerJournalTable.initFromLedgerJournalName(); _LedgerJournalTable.Name = 'Daily Journal'; _LedgerJournalTable.insert(); //----Journal Line _NumberSeq =NumberSeq::newGetVoucherFromCode(LedgerJournalName::find(_LedgerJournalTable.JournalName).VoucherSeries); _LedgerJournalTrans.Voucher =_NumberSeq.voucher(); _LedgerJournalTrans.JournalNum =_LedgerJournalTable.JournalNum; _LedgerJournalTrans.CurrencyCode =CompanyInfo::standardCurrency(); _LedgerJournalTrans.ExchRate =Currency::exchRate(_LedgerJournalTrans.CurrencyCode); _LedgerJournalTrans.AccountNum ='110180'; _LedgerJournalTrans.AmountCurDebit =1000; _LedgerJournalTrans.TransDate =Today(); _LedgerJournalTrans.OffsetAccount ='140270'; _LedgerJournalTrans.Txt ='Arijit Basu :)'; _LedgerJournalTrans.insert(); //----Journal Posting _LedgerJournalCheckPost =LedgerJournalCheckPost::newLedgerJournalTable(_LedgerJournalTable,NoYes::Yes); _LedgerJournalCheckPost.run(); ttscommit; Info(StrFmt("Journal %1 is posted",_LedgerJournalTable.JournalNum)); } Happy DAXing :) Источник: http://daxguy.blogspot.com/2007/07/p...ons-via-x.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|