Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Tax amount calculation for Sales order

Posted on by 1,737

I am Customize the sales Invoice Report Morphx Report In ax 2012, 

I am Writing the code to get the total tax amount and Individual Tax amount for Particular Sales order

Below code  and call in the fetch method.

public real TaxAmountLoc3(SalesLine saleLine)
{
TmpTaxWorkTrans tmpTax;
SalesTotals salesTotals;
CustInvoiceJour _CustInvoiceJourLoc;
TaxData taxData;

;
_CustInvoiceJourLoc = element.args().record();
salesTotals = salesTotals::construct(salesTable);

// Calculate Tax
salesTotals.calc();

// Load tmpTaxWorkTrans
tmpTax.setTmpData(salesTotals.tax().tmpTaxWorkTrans());

// Showing taxes with tax value
while
select tmpTax
{
select taxTable
where taxTable.TaxCode == tmpTax.TaxCode
join taxData
where taxData.TaxCode == TaxTable.TaxCode;
if(taxTable.TaxType_IN == TaxType_IN::None)
{
None += tmpTax.TaxAmount;
}
if(taxTable.TaxType_IN == TaxType_IN::Excise)
{
Excise += tmpTax.TaxAmount;
ExciseValue += taxData.TaxValue;
}
if(taxTable.TaxType_IN == TaxType_IN::VAT)
{
Vat += tmpTax.TaxAmount;
VatValue += taxData.TaxValue;
}
if(taxTable.TaxType_IN == TaxType_IN::SalesTax)
{
CST += tmpTax.TaxAmount;
CSTValue += taxData.TaxValue;
}
/*if(taxTable.TaxType_IN == TaxType_IN::ServiceTax)
{
ServiceTax += tmpTax.TaxAmount;
}*/
}
return None+Excise+Vat+CST;

}

But the Problem is If Tax amount is setup for the Particular Sales order it is running and tax amount is calculated.

Suppose  "tax is not setup" in the Sales order it is Throwing the below Error.

"A currency to convert from is required to retrieve exchange rate information."

How to solve this Please Help me.

  • Suggested answer
    Bashir Ahmad Profile Picture
    Bashir Ahmad 5,248 on at
    RE: Tax amount calculation for Sales order

    in class salesTotals there is no calc() method.

    is some custom method written in this class if so please share the method detail code inside method body by pressing F12 on the method calc()  the method body will be shown.

  • srinivas pamidi Profile Picture
    srinivas pamidi 1,737 on at
    RE: Tax amount calculation for Sales order

    Hi Bashir,

    Thank you for your reply, i am getting this error on

    this line in the above code

    salesTotals.calc();

    if i commented this line error comes in the next line.

    what i do now Please help me.

  • Suggested answer
    Bashir Ahmad Profile Picture
    Bashir Ahmad 5,248 on at
    RE: Tax amount calculation for Sales order

    have you tried to debug the code? and identified exactly on which line you are getting this message. if not place break point and debug the code after that hopefully you will understand exactly on which statement you are getting error. seems like on tax field empty string is being passed to some method

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans