Get Total GST (India) value in AX 2012


Recently i came across a requirement, Which needs to print total GST Tax Amount value in Purchase Order Confirmation Report after Indian GST update.

With that, I want to print the total tax amount based on the tax type like GST and tax components like CGST, SGST ,IGST etc.

Here i am sharing the code to get total GST amount value. 

You may pass a different Header level table's objects instead of  PurchTable objects like SalesTable,CustConfirmJour,PurchReqTable,PurchRFQCaseTable.




    ITaxDocumentComponentLineEnumerator                     componentLineEnumerator;
    ITaxDocument                                                                         taxDocument;
    ITaxDocumentComponentLine                                            componentLineObject;
    PurchTable                                                                                objPurchTable;
    ITaxDocumentLineEnumerator                                           lineEnumerator;
    real                                                                 _CGST,_CRate,_SGST,_SRate,_IGST,_IRate;
    TaxComponent_IN                                                                 taxComponent;
   
    objPurchTable   = PurchTable::find('AP-000004');
    taxDocument= TaxBusinessService::getTaxDocumentBySource(objPurchTable.TableId, objPurchTable.RecId);
    if(taxDocument != null)
    {
         componentLineEnumerator = taxDocument.componentLines();
         while(componentLineEnumerator.moveNext())
        {
            componentLineObject = componentLineEnumerator.current();
            taxComponent = componentLineObject.metaData().taxComponent();
            if(taxComponent =="CGST")
            {
            _CGST += componentLineObject.getMeasure("Tax Amount").value().value();
            _CRate +=componentLineObject.getMeasure("Rate").value().value() * 100;
            }
            else if(taxComponent =="SGST")
            {
            _SGST += componentLineObject.getMeasure("Tax Amount").value().value();
            _SRate +=componentLineObject.getMeasure("Rate").value().value() * 100;
            }
            else if(taxComponent =="IGST")
            {
            _IGST += componentLineObject.getMeasure("Tax Amount").value().value();
            _IRate +=componentLineObject.getMeasure("Rate").value().value() * 100;
            }
        }
    }
    info(strFmt("%1 %2 %3",_CGST,_SGST,_IGST));


OutPut: The infolog shows the total CGST amount, SGST amount and IGST amount.

Previous
Next Post »

1 comments:

Write comments
Anonymous
AUTHOR
27 July 2018 at 03:44 delete

Nice article...

Reply
avatar