Fetch Customer Total unpaid amount from previous invoices

How can I fetch total unpaid amount by a customer from all previous invoices and place it into the new sales invoice receipt?

Is there a fieldname for total unpaid, similar to doc.total_advance… In other words, i want to show the amount due not the one paid in advance.

thank you