Running balance against specific customer and oversold stock

Hi, I am a newbie to ERPnext. I am currently playing around different functionalities of this software in order to elaborate a report for the management to decide whether ERPnext fits most of the business logic in our company. Our business is majorly wholesale of various products.

After a couple of days’ trial, I have two major questions here and hope someone can help me to understand.
1st, what is most clear and efficient way to handle running balance against specific customer regarding the payment? In our business, our customers do not pay us per invoice but instead they refill their balances periodically. Lets say, one customer start with putting $1000 in our bank account, and we credit $1000 on his account balance. If he made 3 orders which respectively amount to $300, $800 and $200. His balance will be $-300. Then he may again refill his balance with $2000 then his balance will be $1700. In the current setup at our company, we mark each invoice automatically being paid by customer account balance, and we maintain a balance sheet of his account. So is there anything similar or even beter in ERPnext to handle this logic?

2nd, how to handle oversold stock? It is very common that for some specific products we do not have enough stock in hand to deliver but we still take the order and issue the invoice. Lets say a customer order 1000 units of item A. We have only 50 units in stock, and we have ordered this product from our supplier and this product will be delivered to us partially each week, say, 300 units each week. But we would like to ship out this product to our customer instead of waiting for all of them into our stock and ship out once for all. So this will result multiple deliveries of single order - 50 -300 -300 -300- 50. How do should we handle this scenario in ERPnext?
Another problem occurred with oversold stock is that if there is purchase price difference between the old stock and new stock, lets say the old 50 units in our hand were purchased at $10 per unit and the newly ordered item costs $11 per unit, how ERPnext does calculation of cost of goods at the time when we issue the invoice? The problem here is that we take the order and issue the invoice to our customer before we order the item from our supplier, so at that moment we do not have full information of the cost of the item being sold.

I hope that you understand my questions and thanks for your time :slight_smile: