The paper considers the optimal control of a single-item continuous-review inventory system with random demand and discount opportunities. Items can always be purchased with the regular order setup and variable costs. However, when a discount opportunity occurs, they can also be purchased with a different setup cost and a lower variable cost. Demands for individual items and discount opportunities occur according to independent Poisson processes. The paper proposes an algorithm to compute the parameters of the optimal replenishment policy, which has been shown to be an (r, R, d, D) policy where r < R, r < d, and d < D. Under an (r, R, d, D) policy, when the inventory position drops to the level r, an order is placed with the regular costs to increase the inventory position to R; and when a discount opportunity occurs at or below d, an order is placed with the discount costs to increase the inventory position to D. The algorithm is based on a bisection search procedure to minimize the long-run average cost and is finitely convergent.