Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Calculate TaxAmount based on TaxOnItem

(0) ShareShare
ReportReport
Posted on by 20

Hi,
Here is brief scenario. At PurchReqTable form, I need to show TaxAmount and the calculation is LineAmount * TaxItemGroup.
And my problem here is, when I return the value is 0 means wrong. I used display method here and here is my code.
I hope someone help me with this since I have stuck for a while.

select firstOnly taxOnItem
    where taxOnItem.taxitemgroup == purchReqLine.TaxItemGroup && taxOnItem.TaxCode == taxData.TaxCode;
    return taxdata.TaxValue * purchreqTable.TotalAmount();

  • edwin90 Profile Picture
    edwin90 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi Sergei,

    I need your help.

    How I can get Sum from One of my tax amount, while the Tax on Item have 2 Sales tax Code (A + B).

    I have Item sales tax group A + B.
    pastedimage1680578894189v1.png


    on the Line :

    1. Item A  : tax A + B
    2. Item B : tax A + B

    How I can get Sum of tax A & Sum of tax B ?

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi HelioBuenos,

    In case if you have a different tax set up for each line, your result will be incorrect if you will use tax combination only from one line and total sum amount to get the total tax amount.

  • HelioBuenos Profile Picture
    HelioBuenos 20 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi Sergei,

    I had sum lineAmount with the same purchreqid.

    I think I do not explain it clear enough.

  • Suggested answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi HelioBuenos,

    You can get taxValue with the next snippet from the code.

    TaxGroupData        taxGroupData;
    TaxOnItem           taxOnItem;
    ;
    select firstOnly taxGroupData
        where taxGroupData.TaxGroup == purchReqLine.TaxGroup
    join taxOnItem
        where taxOnItem.TaxItemGroup    == purchReqLine.TaxItemGroup
           && taxOnItem.TaxCode         == taxGroupData.TaxCode;
    
    if (taxOnItem.RecId != 0)
    {
        taxValue = taxOnItem.showTaxValue();
    }
    else
    {
        error("Tax combination was not found");
    }

    But it's still not clear how you will select a line if there are several lines in requisition?

  • HelioBuenos Profile Picture
    HelioBuenos 20 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi Sergei,

    I need to calculate TaxAmount only for one line in header level.

    I cant get the taxValue percentage.

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi HelioBuenos,

    Do you need to calculate total amount or tax amount? Do you need to calculate it for all lines on the header level or only for one line (which one in multiline requisitions)?

  • HelioBuenos Profile Picture
    HelioBuenos 20 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi all,

    I create this method on PurchReqTable table.

    The exact requirement is to show a total of line amount on header level.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,703 Super User 2024 Season 2 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi HelioBuenos,

    You are using data from both the PurchRecLine and PurchRecTable. Where did you create this method? Can you share the full method including parameter and variable declarations?

    What is the exact requirement? Showing a total on the header level or an amount per line?

  • Suggested answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Calculate TaxAmount based on TaxOnItem

    Hi HeliioBuenos,

    It's not clear where you created the display method, on the form, or on the table.

    I would recommend you to create a display method on PurchReqTable table and use PurchReqTotals class

    [SysClientCacheDataMethodAttribute(true)]
    //BP Deviation documented
    public server display TaxAmountCur totalTaxAmount()
    {
        PurchReqTotals totals = PurchReqTotals::construct(this);
        totals.calc();
        return totals.totalTaxAmount();
    }

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! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans