Agriculture Stock Updates

I have been evaluating the agriculture module but i can’t figure out how stock is being updated from input distribution to farm and the produce output from a farm.

Please any lead on this will be highly appreciated