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.
So, you want CustInvoiceTrans hold the balance that the customer had at the time of invoice generation, right? But why do you want it on invoice lines - isn't it the same for all lines of an invoice, because the invoice is always for a single customer?
Regarding maintaining the balance, it's not just about invoices, but also about receiving payments. Note that I don't understand the sentence "For this I should create a credit not or reverse general journal to maintain correct customer balance amount" - please try to rephrase it.
By the way, I'm not very familiar with balance calculation, but isn't it also influenced by the current exchange rate (in case of invoices in foreign currencies)?