@transaction.atomic<EOL><INDENT>def refund(self):<DEDENT>
if self.invoice.is_void:<EOL><INDENT>raise ValidationError("<STR_LIT>")<EOL><DEDENT>amount = self.invoice.total_payments()<EOL>if amount == <NUM_LIT:0>:<EOL><INDENT>self.void()<EOL>return<EOL><DEDENT>CreditNoteController.generate_from_invoice(self.invoice, amount)<EOL>self.update_status()<EOL>
Refunds the invoice by generating a CreditNote for the value of
        all of the payments against the cart.

        The invoice is marked as refunded, and the underlying cart is marked
        as released.