def void(self):
        ''' Voids the invoice if it is valid to do so. '''
        if self.invoice.total_payments() > 0:
            raise ValidationError("Invoices with payments must be refunded.")
        elif self.invoice.is_refunded:
            raise ValidationError("Refunded invoices may not be voided.")
        if self.invoice.is_paid:
            self._release_cart()

        self._mark_void()
Voids the invoice if it is valid to do so.