def total_payments(self):
payments = PaymentBase.objects.filter(invoice=self)<EOL>total_paid = payments.aggregate(Sum("<STR_LIT>"))["<STR_LIT>"] or <NUM_LIT:0><EOL>return total_paid<EOL>
Returns the total amount paid towards this invoice.