How to refund a customer after generating a credit memo

We have our use case where we receive advances via payment entry and sometime have to return the advances partially.

We pass a journal entry and then do reconciliation of payment entry against the journal entry.