This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
Dynamics AX 2012
|
|
|
|
|
|
|
This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The following job shows how to create and post a free text invoice by code.
static void createAndPostFreeTextInvoice(Args _args) { CustInvoiceTable custInvoiceTable; CustInvoiceLine custInvoiceLine; DimensionDefault dimensionDefault; LedgerDimensionAccount ledgerDimensionAccount; CustPostInvoice custPostInvoice; try { ttsBegin; // Create header custInvoiceTable.clear(); custInvoiceTable.initValue(); custInvoiceTable.OrderAccount = "US-004"; custInvoiceTable.modifiedField( fieldNum(CustInvoiceTable, OrderAccount)); custInvoiceTable.insert(); // Create line custInvoiceLine.clear(); custInvoiceLine.initValue(); custInvoiceLine.ParentRecId = custInvoiceTable.RecId; custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable); custInvoiceLine.Description = "Test"; custInvoiceLine.Quantity = 10; custInvoiceLine.modifiedField( fieldNum(CustInvoiceLine, Quantity)); custInvoiceLine.UnitPrice = 200; custInvoiceLine.modifiedField( fieldNum(CustInvoiceLine, UnitPrice)); ledgerDimensionAccount = DimensionDefaultingService::serviceCreateLedgerDimension( DimensionStorage::getDefaultAccountForMainAccountNum( "110110"), dimensionDefault); custInvoiceLine.LedgerDimension = ledgerDimensionAccount; custInvoiceLine.modifiedField( fieldNum(CustInvoiceLine, LedgerDimension)); custInvoiceLine.insert(); // Post custPostInvoice = new CustPostInvoice(custInvoiceTable); custPostInvoice.run(); ttsCommit; } catch { throw error(error::wrongUseOfFunction(funcName())); } }This is what a free text invoice looks like: