We model a practical problem in stochastic inventory systems which has not been investigated yet. We prove the essential properties of an optimal solution. Presenting an algorithm based on the optimal properties which is able to find the optimal solution of the problem. We examine our algorithm efficiency via generating and solving some numerical examples.