How to calculate GST for Sales order Confirmation


Description: How to calculate the GST taxes on sales order confirmation. Here i am sharing some code to get Taxes details (IGST/CGST/SGST) in AX.

static void GSTForSOLineWise(Args _args)
{
    CustConfirmJour                     CustConfirmJour;
    PurchLineAllVersions                ObjPurchLineAllVersions;
    ITaxDocument                        taxDocument;
    ITaxDocumentComponentLineEnumerator componentLineEnumerator;
    ITaxDocumentComponentLine           componentLineObject;
    ITaxDocumentMeasureEnumerator       measureEnumerator;

    ITaxDocumentLine                    line;
    ITaxDocumentLineEnumerator          lineEnumerator;

    TaxAmount                           taxAmount,taxValue;
    TaxComponent_IN                     taxComponent;
    ;
    //Find RecId through table method-1
    CustConfirmJour =   CustConfirmJour::findRecId(CustConfirmJour::find("APPL-000534-1").RecId);
    //Find RecId through table method-2
    //CustConfirmJour =   CustConfirmJour::findRecId(CustConfirmJour::findFromCustConfirmTrans("APPL-000534","APPL-000450",29\07\2017).RecId);    
    taxDocument = TaxBusinessService::getTaxDocumentBySource(CustConfirmJour.TableId, CustConfirmJour.RecId);
    //Tax Document not null,GST Apply start
    if(taxDocument != null)
    {
        componentLineEnumerator = taxDocument.componentLines();
        lineEnumerator = taxDocument.lines();
        //Tax Document not null,GST Apply start-1
        if (taxDocument)
        {
            //lineEnumerator for Current line taxDocument start
            lineEnumerator = taxDocument.lines();
            while(lineEnumerator.moveNext())
            {
                //Getting Current line RecId for GST start
                line = lineEnumerator.current();
                line.setTaxDocument(taxDocument);
                if(line.originSourceRecId() != 0 && line.getInvoiceTax().value() != 0)
                {   
                    //componentLineEnumerator for Getting GST Rate,Amount start
                    while(componentLineEnumerator.moveNext())
                    {
                        componentLineObject = componentLineEnumerator.current();
                        taxComponent = componentLineObject.metaData().taxComponent();
                        
                        //GST Calculation start
                        if(taxComponent == "CGST")
                        {   
                            info(strFmt("%1",CustConfirmTrans::findRecId(line.sourceRecId()).LineNum));
                            
                            taxValue = componentLineObject.getMeasure("Rate").value().value() * 100;
                            taxAmount = componentLineObject.getMeasure("Tax Amount").value().value();

                            info(strFmt("Component %1 ,Rate %2, Amount%3, RecId %4, ItemId %5",taxComponent,taxValue,taxAmount,CustConfirmTrans::findRecId(line.sourceRecId()).RecId,CustConfirmTrans::findRecId(line.sourceRecId()).ItemId));
                        }
                        if(taxComponent == "SGST")
                        {
                            //info(strFmt("%1",CustConfirmTrans::findRecId(line.sourceRecId()).LineNum));
                            taxValue = componentLineObject.getMeasure("Rate").value().value() * 100;
                            taxAmount = componentLineObject.getMeasure("Tax Amount").value().value();

                            info(strFmt("Component %1 ,Rate %2, Amount%3, RecId %4, ItemId %5",taxComponent,taxValue,taxAmount,CustConfirmTrans::findRecId(line.sourceRecId()).RecId,CustConfirmTrans::findRecId(line.sourceRecId()).ItemId));
                            break;
                        }
                        if(taxComponent == "IGST")
                        {
                            info(strFmt("%1",CustConfirmTrans::findRecId(line.sourceRecId()).LineNum));
                            taxValue = componentLineObject.getMeasure("Rate").value().value() * 100;
                            taxAmount = componentLineObject.getMeasure("Tax Amount").value().value();

                            info(strFmt("Component %1 ,Rate %2, Amount%3, RecId %4, ItemId %5",taxComponent,taxValue,taxAmount,CustConfirmTrans::findRecId(line.sourceRecId()).RecId,CustConfirmTrans::findRecId(line.sourceRecId()).ItemId));
                            break;
                        }
                        //GST Calculation end
                    }
                    //componentLineEnumerator for Getting GST Rate,Amount end
                }
                //Getting Current line RecId for GST end
            }
            //lineEnumerator for Current line taxDocument end
        }
        //Tax Document not null,GST Apply end-1
    }
    //Tax Document not null,GST Apply end
}

Related Posts

Previous
Next Post »

1 comments:

comments
Anonymous
January 11, 2021 at 3:06:00 PM GMT+5:30 delete

Thanks for the insight. Reach Vakilsearch site to know about gst invoice format

Reply
avatar

Thanks for comments.....