Error in grand total when apply discount and margin


In purchase order, when I apply discount of Rs. 2500 on grand total, it gives the wrong total amount.
Attaching scrrenshot before and after of discount apply.

Any applied shipping cost?

I think looks like the same issue.

Not applying any shipping cost.
Only discount is applied.