X++ Code to fetch GST, SGST, IGST Sales amounts in D365FO -Indian GST calculation logic

 X++ Code :


Syntax : this.calcGST("GSTTYPE" , InvoiceId)

GST  Type : SGST,CSGT,IGST

Assigning logic : this.calcGST("SGST",_ewaybillsales.invoiceid);

Core Code Logic :

public container calcGST(str _Type ,Invoiceid _invoiceid)

        {

            TmpTaxDocument tmpTax;

            SalesCalcTax PurchCalcTax;

            SalesTotals salesTotals;

            ITaxableDocument taxableDocument;

            ITaxDocumentComponentLineEnumerator lineEnumerator;

            ITaxDocument taxDocumentObject;

            ITaxDocumentMeasure taxMeasure;

            ITaxDocumentMeasureEnumerator taxMeasureEnumerator;

            ITaxDocumentMeasureValue partyTaxMeasureValue;

            int i;

            CustInvoiceJour custInvoiceJour;

            CustInvoiceSalesLink        link;

            AmountCur taxTotalGTE,GSTamt;

            InvoiceId _invoiceId;

            container GSTamounts;

     select firstonly firstfast parmId from custInvoiceJour

            where custInvoiceJour.InvoiceId == _invoiceId;

    

        select link where link.invoiceId==_invoiceId;


            salesTotals = SalesTotals::construct(SalesTable::find(link.salesId),SalesUpdate::All,AccountOrder::None,custInvoiceJour.ParmId);

            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",_Type);


                while (lineEnumerator.moveNext())

                {

                    taxMeasureEnumerator = lineEnumerator.current().measures();

                    while (taxMeasureEnumerator.moveNext())

                    {

                        i++;

                        if (i == 3)

                        {

                            partyTaxMeasureValue = taxMeasureEnumerator.current().value();

                        GSTamt += partyTaxMeasureValue.amountTransactionCurrency();

                            i=0;

                            break;

                        }

                    }

                }


               

            }

        GSTamounts =[taxTotalGTE,GSTamt];

            return GSTamounts;

            }

Comments

Popular posts from this blog

Create a Tile in a D365FO Workspace with X++ - Microsoft Dynamics Finance and operations

Disable editing of specific financial dimensions on form -Microsoft Dynamics Finance and operations(D365FO)