I want to Edit some calculations in the sales invoice Page 43 ( in the actions Ribbon )  I want to edit the calculations of (Post & New.....) & ( (Preview Posting) actions.

I tried to trace the code to understand how it work but I got lost in too many ways. 

Is there is a documentation for this code that explains the algorithm behind it ?