Sale of Inventory

If I buy an inventory item that is packed at a particular price for my production, my average cost is automatically calculated when I run my production order using all my other inventory.

My question is, if at a later stage I am able to sell the empty box/containers in bulk for a reasonable price, how do I then allocate this funds received to the cost of my item under inventory of finished goods or to the item I purchased in the first place, technically I get a better price for the same item.

Is this possible?

Any income received would just get posted directly to an P&L Income account called Sundry Income.
You wouldn’t try and distribute it over the Inventory items