Delivery Note and Sales Invoice

Hello Team,
I have a doubt in the selling flow-
When we book a Delivery Note, the system records the entry as -

Cost of Goods Sold A/c. Dr.
To Stock-in-Hand A/c.

After passing the Delivery Note, when we pass the actual Sales Invoice, the System records the entry as-

Debtors A/c. Dr.
To Sales A/c.

After Sales Invoice, when we receive the payment from the Customer, the system records that entry as,

Cash/Bank A/c. Dr.
To Debtors A/c.

My doubt in the above sales flow is that why is the transaction getting routed through 4 different account?
Now as per the system, there are 4 accounts which though which transactions have got passed.
The debtors account is the only account which has got knocked off after we received the payment, but what about the remaining accounts and how will they get knocked off?

Sales process involves multiple accounts to accurately track inventory, costs, and revenue. When a Delivery Note is created, it updates the Cost of Goods Sold and reduces inventory. A Sales Invoice records the sale, increasing the revenue and showing what customers owe you. When payment is received, this clears the amount owed from the customer’s account. Other accounts like Stock-in-Hand accumulate to show inventory levels and expenses over time. The Debtors account specifically tracks the money customers owe, which gets balanced out when payment is received, while the other accounts continue to reflect ongoing accounts activities.

@NCP
Thank you so much for responding to my query, but I have a doubt.
How will the stock in hand, cogs and sales account not get closed?
At the year end will the balances in these accounts get transferred to the trading account ? And is this the reason why these accounts are not getting knocked off at the sales cycle?

Another doubt is that why is this same process not being followed in the purchase cycle? Why is this followed only for sales?

Thank you.