Need help with Customer Invoice Items

I have successfully created the fields in Sales Invoice Items as shown in the 1st picture below according to my needs.
What I don’t know, is how and what can I do to make the calculations as shown here:


Currently, ERPNext shows the items table in the invoice like this:

I would really appreciate any help on this. I’ve been trying to figure this out for 5 hours. No luck yet.