Automatically Split Entries For Different Batch Items in Invoice

Suppose Item A’s Stock is 150 Nos. That is in 2 different batches (75 each). As per the current setup, when we create an invoice for 100 items, we need to split the item entries manually by pointing to different batches. Is it possible to use custom code to automatically split the entries after entering the first entry with the total quantity?

if the total quantity cannot be supplied from a batch, then it should automatically add another entry with the remaining quantity from another batch.

Have you found a solution for this?

Sorry, Not yet. I think need custom code.