How to get salesline taxes in ax 2012

Description : If we customize Sales Invoice and Free Tax Invoice report for AX2012, we may need to get sales tax information. But how to get it. They are quite several ways to get it, and it depends only type of document you print also.

If you need go to until every line level, you can use.

static void CalcTaxForSalesLine(Args _args)
{
    TaxOnItem       TaxOnItem;
    TaxGroupData    TaxGroupData;
    real            TaxAmount;
    TaxValue        TaxValue;
    SalesLine       SalesLine
    ;
    
    select firstOnly salesLine where salesLine.SalesId == 'YourSalesOrderId';
    if(salesLine.TaxItemGroup && salesLine.TaxGroup && salesLine.LineAmount != 0)
    {
        while select TaxOnItem
            where TaxOnItem.TaxItemGroup == salesline.TaxItemGroup
        {
            if(TaxOnItem)
            {
                while select TaxGroupData
                    where TaxGroupData.TaxGroup == Salesline.TaxGroup
                        && TaxGroupData.TaxCode  == TaxOnItem.TaxCode
                {
                    if(TaxGroupData)
                    {
                        TaxValue  =  TaxData::find(TaxOnItem.TaxCode, Systemdateget(), 0).TaxValue;
                        TaxAmount = (Salesline.LineAmount * TaxValue) / 100;
                        info(strFmt("Rate = %1, Tax Amount = %2",TaxValue,TaxAmount));
                        
                    }
                }
            }
        }
    }
}

Related Posts

Previous
Next Post »

Thanks for comments.....