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

Description :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 Purchase Order.

static void GSTTaxCalculation(Args _args)
{
    TmpTaxDocument tmpTax;
    PurchCalcTax PurchCalcTax;
    //SalesTotals salesTotals1;
    purchtotals purchtotals1;
    ITaxableDocument taxableDocument;
    ITaxDocumentComponentLineEnumerator lineEnumerator;
    ITaxDocument taxDocumentObject;
    real taxTotalGTE,taxtotal,SGST,CGST,IGST;
    ITaxDocumentMeasure taxMeasure;
    PurchTable  purchTable;
    ITaxDocumentMeasureEnumerator taxMeasureEnumerator;
    ITaxDocumentMeasureValue partyTaxMeasureValue;
    int i;

    purchTable = purchtable::find('YourPurchaseOrderId');
    purchtotals1 = PurchTotals::newPurchTable(purchTable);

    taxableDocument = TaxableDocumentObject::construct(purchtotals1.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();
                    info(strFmt("SGST = %1",partyTaxMeasureValue.amountTransactionCurrency()));
                    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();
                    info(strFmt("CGST = %1",partyTaxMeasureValue.amountTransactionCurrency()));
                    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();
                    info(strFmt("IGST = %1",partyTaxMeasureValue.amountTransactionCurrency()));
                    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));
    }
}

Related Posts

Previous
Next Post »

Thanks for comments.....