Yesterday I faced a situation that does not seems to be handled by ERPNext.
Customer overpays a Sales Invoice by mistake. Payment is processed with a Payment Entry and the full amount is entered, leaving an unallocated amount on the customer account. No other invoice is planned for this customer, so he ask for a reimbursement (keeping the money as a credit that can be eventually be used on a Sales Invoice in not an option).
Reimbursement is not possible with a Payment Entry, because there is no negative outstanding invoice:
Because a Journal Entry cannot be linked to a Payment Entry, this is also not an option, since the Journal Entry would not clear the unallocated amount.
The only solution I found is to enter only the amount of the Sales Invoice when making the Payment Entry. Create a Journal Entry to put the unallocated amount on the customer account, then do another Journal Entry linked to the first one to emit a payment to the customer.
I think that the unallocated amount should be allowed in Payment Entry, like they can be fetched as an Advance on a Sales Invoice.
Is there a better way to handle this?