Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Get GST values for Proforma project invoice proposal

(0) ShareShare
ReportReport
Posted on by 323

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
    PriyaDutta 323 on at
    RE: Get GST values for Proforma project invoice proposal

    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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans