Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)
Answered

i need to fatch tax from taxtrans table

(0) ShareShare
ReportReport
Posted on by 516

Hi, i need to get tax from taxtrans table, but my report is fatching data from customized table common is invoiceid of salesid,

i wrote code

invoiceid = dataContract.parmInvoiceID();//having invoice id of sales invoice

while select mytable where mytable.invoiceid == invoiceid

{

mytmp.name = mytable .name;

mytmp.invoiceid = mytable .invoiceid

select mytable where mytable.invoiceid == custinvoicetrans.invoicetrans join taxtrans

where taxtrans.inventtransid == custinvoicetrans.inventtransid

mytmp.taxvalue = taxtrans.taxvalue

}

but problem is in this select i am getting only one record till it find invoice id in first loop( means same inventtransid)

Please advice me how i get next inventtransid everytime 

Thanks in advance

akshay

*This post is locked for comments

  • Verified answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: i need to fatch tax from taxtrans table in ax 2012

    Hi,

    You can check method displayTaxAmount of table CustInvoiceTrans to know how the tax is getting calculated (or) you can use below code/job.

    
    
    static void AXC_CustInvoiceJour(Args _args)
    {
        CustInvoiceTrans custInvoiceTrans;
        CustInvoiceJour  custInvoiceJour;
        TaxAmount       taxAmount = 0;
        TaxTrans        taxTrans;
        
        while select custInvoiceJour
            join custInvoiceTrans
            where custInvoiceTrans.SalesId == custInvoiceJour.SalesId
            && custInvoiceTrans.InvoiceId == custInvoiceJour.InvoiceId
            && custInvoiceTrans.InvoiceDate == custInvoiceJour.InvoiceDate
            && custInvoiceTrans.numberSequenceGroup == custInvoiceJour.numberSequenceGroup
            && custInvoiceTrans.InvoiceId != ""
        {
            select sum(SourceRegulateAmountCur) from taxTrans
                where taxTrans.SourceRecId == custInvoiceTrans.RecId
                    && taxTrans.TransDate == custInvoiceJour.InvoiceDate
                    && taxTrans.Voucher == custInvoiceJour.LedgerVoucher;
            
            taxAmount = -taxTrans.SourceRegulateAmountCur;
            
            info(strFmt("InvoiceId: %1, LotId: %2, Tax amount: %3", custInvoiceJour.InvoiceId, custInvoiceTrans.InventTransId, taxAmount));
        }
    }
  • Verified answer
    Rana Anees Profile Picture
    Rana Anees 1,811 on at
    RE: i need to fatch tax from taxtrans table in ax 2012

    This code is to show TaxCode and TaxAmount on SQ and SO invoice line level.

    SalesQuotationDP -> setSalesQuotationDetailsTmp

        TmpTaxWorkTrans             tmpTax;
        SalesQuotationTable         salesQuotationTable;
        SalesQuotationTotals_Sales  salesQuotationTotals;
    
    
            salesQuotationTable  = SalesQuotationTable::find(custQuotationTrans.origQuotationId);
            salesQuotationTotals = SalesQuotationTotals_Sales::construct(salesQuotationTable);
            // Calculate Tax
            salesQuotationTotals.calc();
            // Load tmpTaxWorkTrans
            tmpTax.setTmpData(salesQuotationTotals.tax().tmpTaxWorkTrans());
    
            while select tmpTax where tmpTax.InventTransId == custQuotationTrans.InventTransId && tmpTax.Company == custQuotationTrans.dataAreaId
            {
                //info( strFmt('%1 : %2' , tmpTax.TaxCode, -tmpTax.TaxAmount));
                salesQuotationTmp.TaxCode = tmpTax.TaxCode;
                salesQuotationTmp.TaxAmount = -tmpTax.TaxAmount;
            }
    
            if(salesQuotationTmp.TaxCode == '')
            {
                salesQuotationTmp.TaxCode = '0.00';
            }


    SlaesInvoiceDP -> insertIntoSalesInvoiceTmp

        SalesTable                  salesTable;
        SalesTotals                 salesTotals;
        TaxTrans taxTrans;
    
        select taxTrans where taxTrans.InventTransId == _custInvoiceTrans.InventTransId;
        //salesInvoiceTmp.TaxValue = taxTrans.TaxValue;
    
        salesInvoiceTmp.TaxAmount = -taxTrans.TaxAmount;
        if(taxTrans.TaxCode == '')
        {
            salesInvoiceTmp.TaxCode = '0.00';
        }
        else
        {
            salesInvoiceTmp.TaxCode = taxTrans.TaxCode;
        }


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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans