How Net rate and Net total amount is calculating for line wise items in delivery note version 12 distributor module

Hi,

When I’m processing a delivery note if I’m applying an additional discount on the net total net rate is calculating perfectly like [ON Net Total = Price * qty - additional Discount + taxes ] but when I applying on Grand total I’m unable to understand how it is calculating but at the end grand total is calculated as [on Grand Total = Price*qty + taxes - additional discount]. anyone can suggest how the net total amount is calculated for line-wise items in the delivery note.