Example Class for Reference : \Classes\TutorialLedgerVoucher\runSalesPost
Example: Using LedgerVoucher
The following job posts a petty cash disbursement for a payment for a stapler and
some stamps. The accounts and amounts are set in the variable declaration.
Usually these would be obtained from parameters, user input or a calculation.
static void ExampleLedgerVoucher(Args _args)
{
LedgerVoucher ledgerVoucher;
LedgerVoucherTransObject ledgerVoucherTransObject;
Dimension dimension;
NumberSeq numSeq;
NumberSequenceCode NumberSequenceCode =
'Acco_18';
ledgerAccount accountNumPetty = '110180';
// Petty cash
ledgerAccount accountNumOffsetOffice =
'606300'; // Office Supplies
ledgerAccount accountNumOffsetPostage =
'606500'; // Postage
amountMST amountPetty = 55;
amountMST amountOffice = 50;
amountMST amountPostage = 5;
;
numSeq =
NumberSeq::newGetNumFromCode(NumberSequenceCode);
ttsbegin;
//First Step - Create Voucher
ledgerVoucher =
ledgerVoucher::newLedgerPost(DetailSummary::Summary,
SysModule::Ledger,
LedgerParameters::numRefLedgerExchAdjVoucher().NumberSequen
ce) ;
//Second Step - Create Voucher Number
ledgerVoucher.AddVoucher(LedgerVoucherObject::newVoucher(nu
mseq.num(),
today(),
Sysmodule::Ledger,
LedgerTransType::None));
//Create the first Transaction - this is the credit
side of the transaction (-55)
//The other two DR transactions should total to the CR
otherwise it won't post.
ledgerVoucherTransObject =
LedgerVoucherTransObject::newCreateTrans(
ledgerVoucher.findLedgerVoucherObject(),
LedgerPostingType::LedgerJournal,
accountNumPetty, // Ledger Account
dimension,
CompanyInfo::standardCurrency(),
-
amountPetty, // Amount
0, //
TableId
0); //
ReciID
ledgerVoucherTransObject.parmTransTxt("Petty cash
disbursement");
ledgerVoucher.addTrans(ledgerVoucherTransObject);
//Create the second Transaction
ledgerVoucherTransObject =
LedgerVoucherTransObject::newCreateTrans(
ledgerVoucher.findLedgerVoucherObject(),
LedgerPostingType::LedgerJournal,
accountNumOffsetOffice,
dimension,
CompanyInfo::standardCurrency(),
amountOffice, // Amount
0,
// TableId
0);
// ReciID
ledgerVoucherTransObject.parmTransTxt("Red stapler");
ledgerVoucher.addTrans(ledgerVoucherTransObject);
//Create third Transaction
ledgerVoucherTransObject =
LedgerVoucherTransObject::newCreateTrans(
ledgerVoucher.findLedgerVoucherObject(),
LedgerPostingType::LedgerJournal,
accountNumOffsetPostage,
dimension,
CompanyInfo::standardCurrency(),
amountPostage,
0,
// TableId
0);
// ReciID
ledgerVoucherTransObject.parmTransTxt("Stamps");
ledgerVoucher.addTrans(ledgerVoucherTransObject);
//Last Step - To Balance Voucher and Close
ledgerVoucher.end();
numseq.used();
ttsCommit;
}
This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
Subscribe to:
Post Comments (Atom)
Ledger Voucher creation Framework and x++ code to create ledger voucher
Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...
-
{ "Message" : "Please verify that the user is valid and set up correctly." } Sol: System Administration > Se...
-
Please click here to access Custom Workflow step by step process:
-
FormRun formRun = sender.formRun(); Object inventTrans_ds = formRun.dataSource(formDataSourceStr(InventMarking,InventTransO...
coding curriculum I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.
ReplyDelete