Pages

Tuesday, 9 September 2014

Create & Posting For Free Text Invoice Through X++ code in Ax Dynamics 2009

      A free text invoice is an invoice that is not attached to a sales order. A free text invoice contains a header and one or more lines for items or services that are not tracked in inventory. Use a free text invoice for sales that do not require a sales order, packing slip, and customer invoice. For example, you can use a free text invoice for a consulting fee or services fee, or for a miscellaneous fee for an event reimbursement. 

     In Short Sales Invoice is transaction where Inventory will come into picture.. and For Free text invoice there is no relation of inventory in its Transaction. 

     Here using Tables are CustInvoiceTable and CustInvoiceLine && Class name is CustPostInvoice.It will be used for posting the data to free text invoice Table..

Examples

Public Static FreeTextInvoice(Args args)
{
         CustInvoiceTable      custInvoiceTable;
         CustInvoiceLine        custInvoiceLine;
         CustPostInvoice        custPostInvoice; 
         CustTable                  custTable;
         LedgerTable              ledgerTable;
         LineNum                    lineNum;
         ;

         //Inserting the values to CustInvoiceTable
         ttsbegin;
         custTable = CustTable::find('CustAccountNumber');//Example accountNumber:1000,3003 like wise
         custInvoiceTable.initFormCustTable(custTable);
         custInvoiceTable.insert();  
         ttscommit;
         
         //Inserting the values to CustInvoiceTable  

         ledgerTable = LedgerTable::find('ledgerAccountNumber');
         custInvoiceLine.clear();
         custInvoiceLine.initValue(); 
         custInvoiceLine.LedgerAccount = ledgerTable.AccountNum;
         custInvoiceLine.initFormCustInvoiceTable(ledgerTable);
         custInvoiceLine.AmountCur = 1000;
         custInvoiceLine.Description = "GoodWill";
         custInvoiceLine.TaxItemGroup = 'Full';
         custInvoiceLine.ParentRecId    = custInvoiceTable.RecId; 
         if(!lineNum)
         {
                lineNum = CustInvoiceLine::lastLineNum(custInvoieLine.ParentRecId); 
         } 
         lineNum += 1;
         custInvoiceLine.LineNum = lineNum;
         custInvoiceLine.insert();
         ttscommit; 
         
         //Posting to FreeTextInvoice class is called for Posting
          
         custPostInvoice = new CustPostInvoice(custInvoiceTable);
         custPostInvoice.run();
          
}



 

1 comment:

  1. There is no "lastLineNum" method in custinvoiceline table..
    I think this is for ax 2012

    ReplyDelete