Column Q on each row can use this formula to show zero if no balance paid or to show the balance paid once the column P cell (date balance received) has been completed:
To total column O (balance amount) for all rows use this:
(adjust row numbers as appropriate)
This only sums positive amounts.
To find total of outstanding balances use this:
This only sums negative amounts
(I am assuming that the amount in column O changes from negative to positive when column P is completed).