You have accepted to finance the invoice for 1000. Lets say you didn't disburse the money and want to create a credit note.
Open the invoice card and click administration → credit note.

You will be asked: Do you want to create new credit note for invoice? Click yes.
Fill Document No. and Amount to credit:

Under factoring entries you can see that original Payable and receivable amount's was reduced

What if you already paid the advance?
The procedure is the same. You go to the invoice → administration → credit note and enter credit amount.
What’s different this time is that the overpayment will be transferred to the vendor’s balance. An amount of 800 was paid in advance, and you created a credit note for 500. Since the advance payment covers 80%, the remaining 400 is transferred to the vendor’s balance. More detailed calculations are shown in the Payments Calculation section.

Fees are also adjusted. You can check the fees before entering credit amount:

And after entering credit amount:

The system calculated everything automatically.
Also, when you trying to credit the invoice, where advance is paid, you can get the error saying that remaining amount is not enough. Then you need to select auto-unapply the entries:

Then you have to post the credit note.
Now you can check factoring entries:

All unrealized payments can be applied with the upcoming factoring invoices or the fees.