I tried the same thing and failed to find anything free. You can buy software for raw materials, that has an inventory page and an output page and then the third page is stock held. It is fantastic but costs money!
I did this myself in excel- I have a column for things you can number, eg buttons, zips and a column for fabric, where I enter the dimensions and it calculates area. Again not foolproof as there is waste and pattern orientation affects cutting.... A simple formula breaks down the price per metre into cost of quantity used.
If you log your incoming stock, you can use the same titles for the outgoing stock and thus use references in excel. It is all time consuming and tedious though. I have added more columns to mine for other costs (variable and fixed) and duty, postage...
If you are ok to spend money, there are software suppliers in etsy that specialize their packages to etsy shops
You can export all your sales as CSV from here and maybe build something in excel working backwards...