def remaining(self):
        payments = [p.amount for p in self.order.payments.all()]
        if payments:
            amount = reduce(operator.add, payments)
        else:
            amount = Decimal('0.00')

        remaining = self.order.total - amount
        if remaining > self.amount:
            remaining = self.amount

        return trunc_decimal(remaining, 2)
dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/satchmo_store/shop/models.py/OrderAuthorization.remaining/original