business logic

Job ID: 30642369

Budget: $10 – $30 USD

I need a query/logic for the software I am planning to make.

The business is a stockist where I buy commodities during its season and sell during off-season.
My intake price for commodities will be different for each day but end of the month I will get an avg. price for x quantity of commodity in stock.

Also, I have daily expenses, but I can take the total for a month.

The question is ... how I can proportionally distribute my expense to different commodities according to their value in the stock?