The outstanding balance that were subject to Low Balance are included in the new invoice as a balance brought forward in D365 F&O

I have a requirement where if customer balance is less than or equal to a threshold amount then customer will be set up with a flag Low Balance. Whenever a new invoice getting generate for the customer I have to include existing balance amount in the new invoice as a balance brought forward. I have to add this existing balance amount to the new invoice amount. I have tried creating a COC for the createJournalLines() method in SalesInvoiceJournalCreateBase class but it does not allow me fetch buffer for the custinvoicetrans table to the coc code. How can I achieve the same in D365 F&O.

Along with this I have to maintain customer balance with correct amount as after posting the invoice amount will automatically add up in the customer balance. Hence, it will add the balance amount which I want to add with customer invoice + Invoice amount + existing balance amount. For this I should create a credit not or reverse general journal to maintain correct customer balance amount.

Any suggestions would be greatly appreciated. Thanks in advance.