It is typically very difficult in QuickBase to do calculations where one record affects the calculation on the next sequential record. However if the nature of your payment calculations are such that they can all be on one record than any calculation as possible.

If that is the case, then each of your payment records will be a separate field and the formula can refer to the value in other fields on that same record.