Apply loan to unpaid invoice

At my organization, we allow customers to convert unpaid invoices to loans, under certain circumstances. I am trying to figure out how to do this in ERPNext.

I am able to use the correct creditor account for the Loan Disbersement, but what I haven’t been able to figure out is how to reconcile the disbursement against the invoice. The payment reconciliation tool doesn’t recognize the loan as a payment, and there’s no way that I can identify to disburse the loan to the invoice directly.

Does anyone have any ideas about how this might be done? I’m on v14 and still trying to wrap my head around the new Payment Ledger a bit.

Any thoughts on best practices here?

Any suggestions here? I’m eager to rebook these invoices as loans, but I can’t figure out a coherent way to do it.

For anyone trying to do this in the future, I ended up doing the following:

I added three fields to the Loan Disbursement doctype: Against Voucher Type (Link to DocType), Against Voucher Name (Dynamic Link), and Voucher Reconciliation (Link to Journal Entry).

I disbursed the loans to a temporary account, then automatically generated a Journal Entry doc allocating the disbursed money against the voucher named in the Against Voucher Name field.

It’s an extra step and an extra transaction in the ledger, but it works with relatively little hackiness.