Stock diffusion theory: a dynamic model for inventory control