web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Get GST values for Proforma project invoice proposal

(0) ShareShare
ReportReport
Posted on by 351

Hi,

I am trying to fetch GST values(tax code, tax component, tax component rate ,etc) as below for project invoice proposal.

I am able to fetch for posted project invoice through below code.

 while select taxtrans where taxtrans.Voucher == projInvoiceJour.LedgerVoucher && taxtrans.TransDate == projInvoiceJour.InvoiceDate
                {
                    navTaxComponent = taxtrans.TaxCode;
                    navTaxComponentRate = taxtrans.TaxValue/100;
                    navTaxComponentAmountPost =  navTaxComponentAmountPost   abs(taxtrans.TaxAmountCur);
                }

For proforma case I am not getting any value.

Report:PSAManageInvoice

Please find below my code:

public void navinitLineTaxAmount(Common _cursor)
    {
        //next initLineTaxAmount( _cursor);

        if(tmpPSAManageInvoice.taxcomponent=="")
        {
            TaxTrans taxtrans;
            TaxComponent_IN navTaxComponent;
            TaxValue        navTaxComponentRate;
            TaxAmount          navTaxComponentAmount,navTaxComponentAmountPost;
            [navTaxComponent, navTaxComponentRate, navTaxComponentAmount] = this.NAVGetGSTTaxComponent(_cursor);

            

            if(!navTaxComponentAmount)
            {
                while select taxtrans where taxtrans.Voucher == projInvoiceJour.LedgerVoucher && taxtrans.TransDate == projInvoiceJour.InvoiceDate
                {
                    navTaxComponent = taxtrans.TaxCode;
                    navTaxComponentRate = taxtrans.TaxValue/100;
                    navTaxComponentAmountPost =  navTaxComponentAmountPost   abs(taxtrans.TaxAmountCur);
                }
                                
            }

            if(navTaxComponent == 'CGST')
            {
                tmpPSAManageInvoice.NAVHSNGSTComponent = strFmt('CGST & SGST - %1 %', navTaxComponentRate*100);
                tmpPSAManageInvoice.CGSTAmount = navTaxComponentAmount;
                tmpPSAManageInvoice.CGSTAmountPost = navTaxComponentAmountPost;
            }

            if(navTaxComponent == 'SGST')
            {
                tmpPSAManageInvoice.NAVHSNGSTComponent = strFmt('CGST & SGST - %1 %', navTaxComponentRate*100);
                tmpPSAManageInvoice.SGSTAmount = navTaxComponentAmount;
                tmpPSAManageInvoice.SGSTAmountPost = navTaxComponentAmountPost;
            }

            else
            {
                tmpPSAManageInvoice.NAVHSNGSTComponent = strFmt('IGST - %1 %', navTaxComponentRate*100);
                tmpPSAManageInvoice.IGSTAmount = navTaxComponentAmount;
                tmpPSAManageInvoice.IGSTAmountPost = navTaxComponentAmountPost;
            }

           tmpPSAManageInvoice.NAVHSNGSTComponent = strFmt('%1 \n %2', tmpPSAManageInvoice.HSNOrSACCode, tmpPSAManageInvoice.NAVHSNGSTComponent);
        }
    }

    public void insertTmpPSAManageInvoice(Common _cursor, char _lineSign )
    {
        ProjProposalJour projProposalJour = ProjProposalJour::find(projInvoiceJour.ProposalId);

       
        this.navinitLineTaxAmount(_cursor);

        next insertTmpPSAManageInvoice( _cursor,  _lineSign);
    }
    
     public container NAVGetGSTTaxComponent(Common invoicejournal)
    {
        TaxDocumentComponentTransaction taxDocumentComponentTransaction;
        TaxDocumentRowTransaction taxDocumentRowTransaction;
        TaxComponent_IN taxComponent;
        TaxValue taxComponentRate;
        TaxAmount taxComponentAmount;
        //int tabledid = _tableID;
        //Common invoicejournal;



        while select taxDocumentRowTransaction
            where taxDocumentRowTransaction.TransactionJourHeaderTableId == invoicejournal.tableid
            && taxDocumentRowTransaction.TransactionJourHeaderRecId == invoiceJournal.RecId
            join taxDocumentComponentTransaction
            where taxDocumentComponentTransaction.TaxDocumentRowTransactionRecId == taxDocumentRowTransaction.RecId
        {
            if (taxDocumentComponentTransaction.RecId)
            {
                TaxDocumentComponentTransaction_IN taxDocumentComponentTransactionn_IN;
                TaxComponentTable_IN taxComponentTable;

                select firstonly Component from taxComponentTable
                    join RecId from taxDocumentComponentTransactionn_IN
                        where taxDocumentComponentTransactionn_IN.TaxComponent == taxComponentTable.RecId
                            && taxDocumentComponentTransactionn_IN.TaxDocumentComponnetTransactionRecId == taxDocumentComponentTransaction.RecId;

                taxComponent = taxComponentTable.Component;
                taxComponentRate = taxDocumentComponentTransaction.TaxRate;
                taxComponentAmount = taxDocumentComponentTransaction.TaxAmountCur;
            }
        }

        if(taxComponent == '')
        {
            ITaxDocumentLineEnumerator          taxDocumentLineEnumerator;
            ITaxDocumentComponentLineEnumerator componentLines;
            RefRecId sourceRecId;
            RefTableId sourceTableId;
            const str GST = 'GST';
            RefRecId LocalLineRecId;
            RefTableId LocalTableId;
            ProjProposalOnAcc projProposalOnAcc;
            ProjProposalRevenue projProposalRevenue;
            ProjProposalCost    projProposalCost;
            ProjProposalItem    projProposalItem;
            ProjProposalEmpl    projProposalEmpl;
            RefRecId proposalLineRecId;
            ITaxDocumentLine taxDocumentLine;
            ITaxDocumentComponentLine       taxDocumentComponentLine;
            PSAProjInvoiceContract contract = this.parmDataContract() as PSAProjInvoiceContract;
           // invoiceJournal= ProjInvoiceJour::findRecId(contract.parmProjInvoiceJourRecId());;
            //select invoiceJournal where invoiceJournal.tableid == tabledid;
            TableId tableId = invoiceJournal.TableId;
            RecId recid = invoiceJournal.recid;



            if (invoicejournal)
            {
                ITaxDocument taxDocumentObject = TaxBusinessService::getTaxDocumentBySource(TableId, RecId);

                if (taxDocumentObject)
                {
                    if (taxDocumentObject.getGUID())
                    {
                        taxDocumentExtension_in taxDocumentExtension = taxDocumentExtension_in::findByTaxDocument(taxDocumentObject.getGUID());
                    }
                    taxDocumentLineEnumerator = taxDocumentObject.lines();
                    while (taxDocumentLineEnumerator.moveNext())
                    {
                        taxDocumentLine = taxDocumentLineEnumerator.current();
                        componentLines = taxDocumentLine.componentLines(GST);
                        sourceRecId = taxDocumentLine.originSourceRecId();
                        sourceTableId = taxDocumentLine.originSourceTableId();
                       // LocalLineRecId = lineRecId;
                        //LocalTableId = lineTableId;

                        
                       str  hSNOrSACCode = taxDocumentLine.getFieldValue(TaxEngineModelFieldsConstants::HSNCode) ? taxDocumentLine.getFieldValue(TaxEngineModelFieldsConstants::HSNCode) : taxDocumentLine.getFieldValue(TaxEngineModelFieldsConstants::SAC);


                        //if (sourceRecId == LocalLineRecId || sourceRecId == proposalLineRecId )
                        //{
                            taxComponentAmount = 0;

                            while (componentLines.moveNext())
                            {
                                taxDocumentComponentLine = componentLines.current();

                                taxComponent = taxDocumentComponentLine.metaData().taxComponent();

                                ITaxDocumentMeasure taxRateMeasure = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxRate);
                                if (taxRateMeasure)
                                {
                                    taxComponentRate = taxRateMeasure.value().value();
                                }

                                ITaxDocumentMeasure taxAmountMeasure = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxAmount);
                                if (taxAmountMeasure)
                                {
                                    taxComponentAmount = taxAmountMeasure.value().value();
                                }
                            }
                       // }

                    }
                }
            }
        }
        return [taxComponent, taxComponentRate, taxComponentAmount];
    }

Please help. Code is quite complex and it was written by someone else .Is there a simpler way to fetch the values then please suggest.

Thanks,

Priya

  • PriyaDutta Profile Picture
    351 on at

    Hi,

    Please help .

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 265 Super User 2026 Season 2

#2
Aayush Tiwari Profile Picture

Aayush Tiwari 215

#3
Subra Profile Picture

Subra 177 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans