Margin on documents.

Margin on documents.

Hi 
A basic feature on invoicing software is to be able to see the margin on each 
Document & Lines on document.

As buying costs of goods & services changes , we input prices on each line.
For this we created a personalized field called "Prix d'achat" (ie BUYING PRICE)



and we want to be able to gat a new field calculating AMOUNT - BUYING PRICE in order to get
margin line by line 
margin total.


I made it with zoho analytics

but that is not good because we need it in real time when we create the estimate and analytics is not in real time.

We saw that a lot of people asked about that in the community.
Is there any way to achieve it?

Thanks a lot.