If you need to deduct an unpaid advance payment from a final invoice, you must enable this in Company Settings - Modules tab - Sales - Invoice and check the Allow deduction of unpaid issued advance payment checkbox.
The same applies to received invoices - Company Settings -> Modules -> Purchasing -> Allow deduction of unpaid received advance payment.
