Home > X++ stuffs > Posting Issue in FreeText Invoice with same Item sales tax group on AX2009.

Posting Issue in FreeText Invoice with same Item sales tax group on AX2009.

 

When free text invoice is created via AIF with the same “Item sales tax group” and later try to post the free text invoice the following error message is encountered….

 

Sample xML:

                        

                        <? xml version="1.0" encoding="utf-8"?>

                        <CustInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/CustInvoice"&gt;

                                 <CustInvoiceTable class="entity">

                                           <CurrencyCode>USD</CurrencyCode>

                                           <InvoiceAccount>4000</InvoiceAccount>

                                           <InvoiceDate>2009-02-16</InvoiceDate>

                                           <OrderAccount>4000</OrderAccount>

                                               <CustInvoiceLine class="entity">

                                                         <AmountCur>100</AmountCur>

                                                         <Description>Line 1</Description>

                                                         <LedgerAccount>11005</LedgerAccount>

                                                         <TaxItemGroup>full</TaxItemGroup>

                                               </CustInvoiceLine>

                                               <CustInvoiceLine class="entity">

                                                         <AmountCur>200</AmountCur>

                                                         <Description>Line 2</Description>

                                                         <LedgerAccount>11010</LedgerAccount>

                                                          <TaxItemGroup>full</TaxItemGroup>

                                               </CustInvoiceLine>

                                 </CustInvoiceTable>

                        </CustInvoice>

 

 

These error is observed because the Line num is never incremented and is always zero for all invoice lines.

 

Screenshot showing the LineNum à 0

 

The solution provided  to fix the issue  is similar  to the  logic implemented in AxSalesLine class , SalesLine table.

 

Changes which needs to be incorporated are….

 

\Data Dictionary\Tables\CustInvoiceLine:

Create new method:

static LineNum lastLineNum (CustInvoiceTableRefRecId custInvoiceTableRefRecId)

{

    return (select maxof (LineNum) from CustInvoiceLine

                index hint ParentRecIdIdx

                where CustInvoiceLine.ParentRecId == custInvoiceTableRefRecId).LineNum;

}

 

Classes\ AxCustInvoiceLine

ClassDeclaration: Initialize the EDT LineNum

 

SetlineNum:  Add the following logic

                this.setParentRecId ();

                if (this.isFieldSet(fieldnum(CustInvoiceLine, ParentRecId)))

                {

                                if(!lineNum)

                {

                                lineNum = CustInvoiceLine::lastLineNum (this.parmParentRecId());

                }

                lineNum += 1;

                this.parmLineNum (lineNum);

   

Over-ride the end method () in the AxCustInvoiceLine. After super () call initialize the lineNum = 0. Now try posting the free text invoice which was created via AIF. With the follwing code the LineNum is incremented as a result the free text invoice is posted  successfully.

 

Hope this article is useful Smile

 

Advertisements
Categories: X++ stuffs
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: