Saturday, March 16, 2019

How to fetch HSNCode in Ax2012 Indian GST Microsoft Hotfix:

In order to get the value of HSN code in Ax2012, we should know where exactly the HSN code is attached?
1. Normally, HSN code is attached to each item on the Item master under Foreign tab.
2. At the sales or purchase order line under Tax information-GST Tab, the HSN code can be manually selected by user.

The list of tables which has reference to other tables below:

TaxDocument has a reference to SalesTable.
TaxDocumentExtension_IN has a reference to TaxDocument.
TaxDocumentRow has  reference to SalesLine.
TaxDocumentRowTransaction has a reference to CustInvoiceTrans, CustInvoiceJour.
SalesLine_IN has a reference to SalesLine.

TaxDocumentRowTransaction_IN has the HSN code, which will have reference to TaxDocumentExtension_IN and TaxDocumentRowTransaction.

The below code is used to fetch the HSN Code:
//Normally, HSNCode if fetched from the InventTable but otherwise, it will also be fetched from salesline level.:

TaxDocumentRowTransaction       taxDocumentRowTransaction;
TaxDocumentRowTransaction_IN    taxDocumentRowTransaction_IN;
SalesTable                  salesTable;
SalesLine_IN                salesLine_IN;

salesLine_IN    = custInvoiceTrans.salesLine().salesLine_IN();
//TmpSalesPurchRegister is my buffer table.

//TmpSalesPurchRegister.Intracode     = HSNCodeTable_IN::find(InventTable::find(TmpSalesPurchRegister.ItemId).HSNCodeTable_IN).Code;
            Select RecId, TransactionJourLineRecId from taxDocumentRowTransaction
                where taxDocumentRowTransaction.TransactionJourLineRecId == custInvoiceTrans.RecId
            join HSNCode, TaxDocumentRowTransactionRecId from taxDocumentRowTransaction_IN
                where taxDocumentRowTransaction_IN.TaxDocumentRowTransactionRecId == taxDocumentRowTransaction.RecId;
            if(taxDocumentRowTransaction_IN)

            /*select * from taxTrans where taxTrans.SourceRecId == custInvoiceTrans.RecId
            join taxTrans_IN where taxTrans_IN.RefRecId == taxTrans.RecId;
            if(taxTrans_IN)*/
            {

                TmpSalesPurchRegister.Intracode = taxDocumentRowTransaction_IN.HSNCode;
                //TmpSalesPurchRegister.Intracode = HSNCodeTable_IN::find(taxTrans_IN.HSNCodeTable).Code;
            }
            else
            {
                TmpSalesPurchRegister.Intracode = HSNCodeTable_IN::find(salesLine_IN.HSNCodeTable).Code;
            }

No comments: