In this article we will see how we can create and post free text invoice using X++ code in Microsoft Dynamics Finance & Operations.
We will create a new class named as FreeTextInvoiceHelper and in this class we will add some methods and using those method we will create and post free text invoice.
Creation of Free Text Invoice header
Create a new method named as createCustInvoiceHeader in this class to create the CustInvoiceTable record.
public CustInvoiceTable createCustInvoiceHeader(TransDate _invoiceDate , DueDate _dueDate, CustAccount _custAccount = '', CustGroupId _custGroup = '') { CustInvoiceTable custInvoiceTable; CustTable custTable; custTable = CustTable::find(_custAccount); custInvoiceTable.initFromCustTable(custTable); custInvoiceTable.CustGroup = _custGroup; custInvoiceTable.OrderAccount = _custAccount; custInvoiceTable.InvoiceAccount = _custAccount; custInvoiceTable.modifiedField(fieldNum(CustInvoiceTable, OrderAccount)); custInvoiceTable.InvoiceDate = _invoiceDate; custInvoiceTable.DueDate = _dueDate; if(custInvoiceTable.validateWrite()) { custInvoiceTable.insert(); } return custInvoiceTable; }
Creation of Free Text Invoice line
Create a new method named as createCustInvoiceLine in this class to create the CustInvoiceLine record.
public void createCustInvoiceLine(CustInvoiceTable _custInvoiceTable, TransactionTextLarge _description = '', TaxItemGroup _taxItemGroup = '', TaxGroup _taxGroup = '', InvoiceQuantity _qty = 1, InvoiceUnitPrice _unitPrice = 1, LedgerDimensionValueSet _defaultDimension = 0, LedgerDimensionDefaultAccount _ledgerDimension = 0) { CustInvoiceLine custInvoiceLine; LineNum lineNum; custInvoiceLine.initValue(); custInvoiceLine.initFromCustInvoiceTable(_custInvoiceTable); custInvoiceLine.Description = _description; custInvoiceLine.TaxItemGroup = _taxItemGroup; custInvoiceLine.TaxGroup = _taxGroup; custInvoiceLine.ParentRecId = _custInvoiceTable.RecId; custInvoiceLine.Quantity = _qty; custInvoiceLine.modifiedField(fieldNum(CustInvoiceLine, Quantity)); custInvoiceLine.UnitPrice = _unitPrice; custInvoiceLine.modifiedField(fieldNum(CustInvoiceLine, UnitPrice)); custInvoiceLine.AmountCur = custInvoiceLine.Quantity * custInvoiceLine.UnitPrice; custInvoiceLine.DefaultDimension = _defaultDimension; custInvoiceLine.LedgerDimension = _ledgerDimension; if(!lineNum) { lineNum = CustInvoiceLine::lastLineNum_W(custInvoiceLine.ParentRecId); } lineNum += 1; custInvoiceLine.LineNum = lineNum; if(custInvoiceLine.validateWrite()) { custInvoiceLine.insert(); } }
Posting of Free Text Invoice
For posting a free text invoice we will create another method named as postCustInvoice, this takes CustInvoiceTable record as parameter.
public void postCustInvoice(CustInvoiceTable _custInvoiceTable) { CustPostInvoice custPostInvoice; custPostInvoice = new CustPostInvoice(_custInvoiceTable); ttsbegin; custPostInvoice.run(); ttscommit; }
Thank you for reading this article hope you find it useful.
Technical Consultant
References:
I really like your writing style..Its so easily understandable. You can visit my blog at https://similar.my.id and then maybe you can share your thought about mine.
Im thankful for the blog post.Thanks Again.
Wonderful goods from you, man. I have understand your stuff prior to and you’re simply too excellent. I really like what you have obtained here, really like what you are saying and the way in which by which you say it. You are making it entertaining and you still care for to keep it smart. I cant wait to learn much more from you. That is really a wonderful website.
Heya i am for the first time here. I found this board and I find It really useful & it helped me out a lot.I’m hoping to provide one thing again and help others suchas you aided me.
What’s up, its fastidious article regarding media print, we all be aware of media is a impressive source of information.
Hello, I check your blogs like every week. Your humoristic style is awesome, keep up the good work!
Some truly superb information, Gladiola I discovered this.
It’s an remarkable piece of writing in support of all the online people;they will get benefit from it I am sure.
wow, awesome blog post.Thanks Again. Much obliged.
Looking forward to reading more. Great blog article.Really looking forward to read more.