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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to alter the discount amount while calculating the total in a sales order?

(0) ShareShare
ReportReport
Posted on by 2,894

Hi, I need to make some adjustments in the calculation of the totals in a sales order, I've been debugging and noticing that the container displayFields contains all the values that I need to change (amount, discount, percent, etc) this in the method:

Classes\TradeTotals\displayFields

For example, I am able to recalculate the discount, but no matter what I do, in that method, at this point:

case  TradeTotals::posEndDisc() : displayFields = conpoke(displayFields, TradeTotals::posEndDisc() , this.totalEndDisc()); 

I always get the old discount. Where do I have to set my new discount in order to see it properly in the sales order summary?

Thanks!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rachit Profile Picture
    4,015 User Group Leader on at

    Hi,

    You have done good analysis, but you will have to dive a little more deeper at more granular level.

    Try to debug the class TradeTotals\calc() method, under this method discounts are calculated and applied to the total amount. This figure is returned from linediscAmount() method. You have to also check the classes which inherit tradeTotals class because the lineDiscAmount() is calculated in the child class which gets initialized depending on the order. Further when you will debug you will notice the actual calculation happens in Maps\SalesPurchLine\calcLineDiscExclTax() method.

    It is really important to understand how all these classes, tables, maps are knitted together nicely. The more you debug, the more you are able to connect the dots.

    Hope this helps.

    Thanks,

    Rachit Garg

  • Suggested answer
    Community Member Profile Picture
    on at

    you need consider classes related to sales order total for your purpose of customization

    TradeTotals class is parent class for both Sales order and purchase order

    try exploring and debugging

    following classes like

    SalesTotals

    SalesTotals_Sales

    SalesTotals_Trans

    Please verify and update us with your findings

  • saman0suke Profile Picture
    2,894 on at

    I kept doing some debugging and ended up modifying the calc() method in the TradeTotals class, it did the job, thanks for the tips!

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans