Debit Note / Credit Note Enhancements

As a refresher, I found another situation where Credit/Debit Notes do not apply directly to invoices and where Payments/Receipts should directly reference Credit/Debit Notes.

The situation is refund of a cash transaction or previously settled invoice from locked periods:
https://forum.manager.io/t/receipt-refund-payment-refund/27311/4