Auto calculating price of product depending on input raw materials

I am currently using the manufacturing vertical of erpnext. Now, when my stock valuation is considered, the selling price of the finished product is considered as the price of material. What I would like to do is auto calculate the price of finished good on the totals of the raw materials used divided by the price of finished goods manufactured. This will help me calculate the price of manufacturing for every batch. Please advise how can I implement this?




Maybe review the custom script examples - to find and leverage existing code, to learn from the work of others, always makes sense to formulate working code.