Custom Layout Designer

We are trying to use sales order to manage our laybys in store

Is there a way/formula we can use that will do the following : Subtotal - Balance = Total outstanding

So basically it would take the Sales Order total subtract the total receipt of the customer, and then display a balance due

If anyone could help with this please

Thank you