web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Access tax trans fields

(1) ShareShare
ReportReport
Posted on by 434
Hi,

If you go to "custInvoiceJour" form, then click on "posted sales tax". There is a tab called "Amount" and inside it there is a field on the form called "Origin"
This is a display method on the form data sources methods.


Now I have another class, where I have access to the invoiceId, but i would like to get this value from taxTrans
I can see the relation between custInvoiceJour and taxTrans



but as you can see, that there is logic in the display method that could show the sign as positive or negative, and i can't call this method in my class because it's private and it's on form datasource.
is the only thing i can do is to repeat the logic inside the display method again in my class? or what should i do?
I have the same question (0)
  • Suggested answer
    Jonas "Jones" Melgaard Profile Picture
    4,894 Super User 2025 Season 2 on at
    Access tax trans fields
    Hi DELDYN,  
    My advice is to avoid replicating the logic of the display method and use Tax.getOriginForSourceLine instead.  

    It’s always better to try to find a clean interface and use that if possible. This way, you can be sure that any changes in logic that Microsoft might introduce will also work in your method.
     
    The logic in the form is fairly simple though, if you need to use it; it’s "just" some logic to handle specific country/region scenarios in CZ.
     
     
  • DELDYN Profile Picture
    434 on at
    Access tax trans fields
    Hi Jonas,

    Maybe the first line in the display method is related to CZ

    But the 2nd line is not
    this.taxChangeDisplaySign(_taxTrans.TaxDirection, _taxTrans.ReverseCharge_W, Tax::changeSignForReverseCharge(_taxTrans));

    if now you want me to replace the whole logic in the display method with the code below, the change display sign variable should be true right?
            CustInvoiceJour custInvoiceJour;
            select custInvoiceJour where custInvoiceJour.InvoiceId == 'xxxx';
            TaxBase taxBase = tax.getOriginForSourceLine(custInvoiceJour.TableId, custInvoiceJour.RecId, true);

     currently taxBase is 0 even though it should be 1000, why?
    and custInvoiceJour is returning data -- so i have no issue here

    shall i pass other values?
  • Jonas "Jones" Melgaard Profile Picture
    4,894 Super User 2025 Season 2 on at
    Access tax trans fields

    I haven't tested the tax method out (need to fix my development environment, so going off memory), but I don't think it works against the journal header (or journals at all, only order lines and free text lines) judging by how it's used in the standard application.

    Sleeping on it, the best bet might be to just replicate the display method, since it's fairly simple if we disregard any country/region functionality. It might not be needed in your case.

    If we examine the form display method, it contains the following code (as of 10.0.40). I have blacked out any country/region functionality we don't care about:

    display TaxBase displayTaxBaseAmount(TaxTrans _taxTrans)
    {
        //<GEECZ>
        changeDisplaySign = this.doChangeDisplaySign(_taxTrans);
        //</GEECZ>
        return _taxTrans.TaxBaseAmount * this.taxChangeDisplaySign(_taxTrans.TaxDirection, _taxTrans.ReverseCharge_W, Tax::changeSignForReverseCharge(_taxTrans));
    }
    

    The method taxChangeDisplaySign contains the following code:

    private int taxChangeDisplaySign(TaxDirection _taxDirection, TaxReverseCharge _taxReverseCharge = NoYes::No, boolean _changeSignForReverseCharge = true)
    {
        if (changeDisplaySign && (_taxReverseCharge == NoYes::No || _changeSignForReverseCharge))
        {
            return Tax::changeDisplaySign(_taxDirection);
        }
        else
        {
            return 1;
        }
    }
    

    So, looking at the code, we can see that:

    • It's taking _taxTrans.TaxBaseAmount.
    • Based on the value of _taxTrans.TaxDirection, and a call to Tax::changeSignForReverseCharge(_taxTrans), it will flip the sign.

    I think this logic should be easy to implement. Let me know if you need an example or if I should test the Tax method.

     
     
  • DELDYN Profile Picture
    434 on at
    Access tax trans fields
    Hi Jonas,

    So do you mean this method can't be used?

    this is what i did at first just like you mentioned, but i wanted a standard method in case in the future this will change

    but in this case I had to do two selects to the database based on my logic (as i need to sum tax base amount based on tax value
  • Jonas "Jones" Melgaard Profile Picture
    4,894 Super User 2025 Season 2 on at
    Access tax trans fields
    I meant that it's worth looking for standard methods in the tax engine and, if one is available, use that. In your specific example, none might be available, as you are trying to get the base from the posted journal (Customer invoices, based on the "CustInvoiceJour" form you mention).
     
    Looking at the attached code, your logic appears to be flawed and will most likely not work.
    You summarize "TaxBaseAmount," grouped by the amount field "TaxValue." That select statement cannot return a RecId value for later use. Grouping on TaxValue makes little use in this context.
     
    I suggest testing your logic first, making a "While Select" on TaxTrans for all fields, performing the sign manipulation, and then appending that value to a variable outside your loop. After you have made that work, then you can look at summarizing and grouping to improve performance.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 734 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 636

#3
Martin Dráb Profile Picture

Martin Dráb 553 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans