GST Tax Calculation for all formats (SO,PO Confirmation & Invoice) for AX2012,AX2009

Recently many (IND Localization) requirement which needs to print Total Tax Amount in Sales order, Purchase Order Confirmation Report After India GST Update.

Along with that we need to print Tax Amount based on Tax Type (GST ,Custom Duty) & Tax components (i.e CGST, SGST ,IGST etc).

Below is the Job to get Tax amount details based on Tax Type & Tax component for a given Sales Order.

static void GSTTaxCalculation(Args _args)
{
    TmpTaxDocument                      tmpTax;
    PurchCalcTax                        PurchCalcTax;
    SalesTotals                         salesTotals;

    ITaxableDocument                    taxableDocument;
    ITaxDocumentComponentLineEnumerator lineEnumerator;
    ITaxDocument                        taxDocumentObject;
    real                                taxTotalGTE,taxtotal,SGST,CGST,IGST;
    ITaxDocumentMeasure                 taxMeasure;
    ITaxDocumentMeasureEnumerator       taxMeasureEnumerator;
    ITaxDocumentMeasureValue            partyTaxMeasureValue;
    int                                 i;

    salesTotals = SalesTotals::construct(SalesTable::find("SO-XXXXXX"));
    taxableDocument = TaxableDocumentObject::construct(salesTotals.parmTaxableDocumentDescriptor());
    taxDocumentObject = TaxBusinessService::calculateTax(taxableDocument);

    if (taxDocumentObject)
    {
        taxTotalGTE = taxDocumentObject.getTotalTax().amountTransactionCurrency();

        // Calculation of Tax amount for Tax type GST and Tax component SGST
        lineEnumerator = taxDocumentObject.componentLines("GST","SGST");
        while (lineEnumerator.moveNext())
        {
            taxMeasureEnumerator = lineEnumerator.current().measures();
            while (taxMeasureEnumerator.moveNext())
            {
                i++;
                if (i == 3)
                {
                    partyTaxMeasureValue = taxMeasureEnumerator.current().value();
                    SGST += partyTaxMeasureValue.amountTransactionCurrency();
                    i=0;
                    break;
                }
            }
        }

        // Calculation of Tax amount for Tax type GST and Tax component CGST
        lineEnumerator = taxDocumentObject.componentLines("GST","CGST");
        while (lineEnumerator.moveNext())
        {
            taxMeasureEnumerator = lineEnumerator.current().measures();
            while (taxMeasureEnumerator.moveNext())
            {
                i++;
                if (i == 3)
                {
                    partyTaxMeasureValue = taxMeasureEnumerator.current().value();
                    CGST += partyTaxMeasureValue.amountTransactionCurrency();
                    i=0;
                    break;
                }
            }
        }
        
        // Calculation of Tax amount for Tax type GST and Tax component IGST
        lineEnumerator = taxDocumentObject.componentLines("GST","IGST");
        while (lineEnumerator.moveNext())
        {
            taxMeasureEnumerator = lineEnumerator.current().measures();
            while (taxMeasureEnumerator.moveNext())
            {
                i++;
                if (i == 3)
                {
                    partyTaxMeasureValue = taxMeasureEnumerator.current().value();
                    IGST += partyTaxMeasureValue.amountTransactionCurrency();
                    i=0;
                    break;
                }
            }
        }   
    }

    info( strFmt("Total GST value of sales order : %1 " , taxTotalGTE));
    if(IGST)
    {
        info( strFmt("Line IGST value of sales order : %1 " , IGST));
    }
    else
    {
        info( strFmt("Line SGST value of sales order : %1 " , SGST));
        info( strFmt("Line CGST value of sales order : %1 " , CGST));
    }
}

I have done modifications and posted here in this group.

Source Code Courtesy:

https://siddarthax.wordpress.com/2017/06/27/tax-amount-based-on-tax-component-for-a-sales-order-in-ax-2012-r3-after-india-gst-update/

 

Regards,

Arunachalam MR

MS Dynamics AX Developer.

Parents Reply Children
Related
Recommended