Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 10657

Utility code for creating the Free text invoice (FTI) in AX 2012

$
0
0

Hi Guys,

This post targeting developers and help creating free text invoice from code in dynamics ax 2012

 static void SimpleFtiCreation(Args _args)  
 {  
   custInvoiceTable custInvoiceTable;  
   custInvoiceLine custInvoiceLine;  
   custTable custTable;  
   int lineNum;  
   try  
   {  
     /// <summary>  
     ///   The <c>CustInvoiceTable</c> logic is implemented to create single <c>Header</c>.  
     /// </summary>  
     ttsbegin;  
     custInvoiceTable.clear();  
     custTable = CustTable::find("Test");  
     custInvoiceTable.initFromCustTable(custTable);  
     custInvoiceTable.InvoiceDate = systemDateGet();  
     custInvoiceTable.insert();  
     custInvoiceLine.clear();  
     custInvoiceLine.initValue();  
     custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable);  
     custInvoiceLine.LedgerDimension = 89897878;  
     custInvoiceLine.DefaultDimension = 67676767;  
     custInvoiceLine.Quantity = 100;  
     custInvoiceLine.UnitPrice = 2.5;  
     custInvoiceLine.AmountCur = 250;  
     custInvoiceLine.Description = strFmt("Subscription %1", "Test") ;  
     custInvoiceLine.InvoiceTxt = strFmt("Subscription %1" , "Test") ;  
     custInvoiceLine.ParentRecId = custInvoiceTable.RecId;  
     custInvoiceLine.editReasonCode(true, 'Device Sub');  
     custInvoiceLine.editReasonComment(true, 'Device Subscription');  
     //LINE NUM LOGIC.  
     if(!lineNum)  
     {  
       lineNum = CustInvoiceLine::lastLineNum_W(custInvoiceLine.ParentRecId);  
     }  
     lineNum += 1;  
     custInvoiceLine.LineNum = lineNum;  
     custInvoiceLine.insert();  
     ttscommit;  
     //just to be sure for proper distributions  
     SourceDocumentProcessor::submitSourceDocumentLinesForHeader(custInvoiceTable.SourceDocumentHeader);  
   }  
   catch(exception::Error)  
   {  
   }  
 }  

Viewing all articles
Browse latest Browse all 10657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>