Code to Create On Account Transaction for Project in Ax 2012

Path for On Account Transaction for Project is as below.

Project management and accounting/Common/Projects/All projects/  On Account Transactions

This is Code sample to Create On Account Transaction for Project in Ax 2012. You need to declare required variables.

         _ProjTable =ProjTable::find(_projId);  
         projOnAccTrans.clear();  
         projOnAccTrans.ProjID       = _projId;  
         projOnAccTrans.TransDate     = _str2Date("3/11/2015",123);  
         projOnAccTrans.editTransactionOrigin(true,ProjOriginOnAcc::Milestone);  
         projOnAccTrans.Description    = _Description;  
         projOnAccTrans.CurrencyId     = _Currency;  
         projOnAccTrans.TotalSalesAmountCur = _SalesPrice;  
         projOnAccTrans.TransId       = ProjParameters::newTransId();  
         projOnAccTrans.Qty=_Quantity;  
         projOnAccTrans.DefaultDimension=_ProjTable.DefaultDimension;  
         projOnAccTrans.projInvoiceStatus();  
         projOnAccTrans.insert()