docs: def settle_credit_note(credit_note: Invoice, debit_note: Invoice, cls, account: Account, **kwargs) -> list:
      """
      Settles credit note. Records settling account entries for both original invoice and the credit note
      (negative entries for the credit note).
      Default timestamp for account entries is 'created' time of the credit note, can be overriden by kwargs.
      :param credit_note: Credit note to settle
      :param debit_note: Invoice to settle
      :param cls: AccountEntry (derived) class to use for new entries
      :param account: Settlement account
      :param kwargs: Variable arguments to cls() instance creation
      :return: list of new payments
      """
      assert isinstance(credit_note, Invoice)
      assert credit_note.type == INVOICE_CREDIT_NOTE
      assert debit_note
      assert debit_note.type == INVOICE_DEFAULT
  
      credit = -credit_note.get_unpaid_amount()
      balance = debit_note.get_unpaid_amount()
  
      amt = min(balance, credit)
      amount = kwargs.pop('amount', None)
      if amount is not None:
          if amount > amt:
              raise ValidationError(_('Cannot settle credit note amount which is larger than remaining unpaid balance'))
          amt = amount
  
      entry_type = kwargs.pop('entry_type', None)
      if entry_type is None:
          if not hasattr(settings, 'E_CREDIT_NOTE_RECONCILIATION'):
              raise Exception('settle_credit_note() requires settings.E_CREDIT_NOTE_RECONCILIATION (account entry type code) or entry_type to be pass in kwargs')
          entry_type = EntryType.objects.get(code=settings.E_CREDIT_NOTE_RECONCILIATION)
      description = kwargs.pop('description', _('credit.note.reconciliation'))
  
      pmts = []
      if amt > Decimal(0):
          timestamp = kwargs.pop('timestamp', credit_note.created or now())
          # record entry to debit note settlement account
          pmt1 = cls.objects.create(account=account, amount=amt, type=entry_type, settled_invoice=debit_note, description=description + ' #{}'.format(credit_note.number), timestamp=timestamp, **kwargs)
          pmts.append(pmt1)
          # record entry to credit note settlement account
          pmt2 = cls.objects.create(account=account, parent=pmt1, amount=-amt, type=entry_type, settled_invoice=credit_note, description=description + ' #{}'.format(debit_note.number), timestamp=timestamp, **kwargs)
          pmts.append(pmt2)
  
      return pmts