Get line wise GST (India) value in AX 2012 (x++)



Recently i came across a requirement which needs to print line wise GST Tax Amount in Purchase Order Confirmation Report After India GST Update.

Along with that i want to print Tax Amount based on the Tax Type like GST ,Custom Duty & Tax components like CGST, SGST ,IGST etc.

You may also find this tax amount value from TaxTrans table if Purchase order or sales order is processed as "Invoice" in our AX system.

Here i am sharing the code to get line wise GST Tax amount value. You may pass different line table's object instead of  PurchLine table like SalesLine,PurchRFQReplyLine.



PurchId                                 objPurchId;
real                                    _LineNum;
int64                                   _Recid;
ITaxDocumentComponentLineEnumerator     componentLineEnumerator;
ITaxDocumentComponentLine               componentLineObject;
PurchLine                               objPurchLine;
ITaxDocumentLine                        line;
ITaxDocumentLineEnumerator              lineEnumerator;
real                                    _CGST,_CRate,_SGST,_SRate,_IGST,_IRate;
TaxComponent_IN                         taxComponent;
;
objPurchId='AP-000004';
_LineNum=1.0;
_Recid=5637231586;
objPurchLine   = PurchLine::findRecId(_Recid);
line= TaxBusinessService::getTaxDocumentLineBySource(objPurchLine.TableId, objPurchLine.RecId);
if(line != null)
{
componentLineEnumerator = Line.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 line wise CGST amount, SGST amount and IGST amount.

Previous
Next Post »

3 comments

Write comments