In this paper, we study a dynamic inventory optimal control problem in a finite planning horizon with the consideration of debt financing and tax, which are two important factors that influence inventory decisions. The retailer, who raises funds from the financial market at the beginning of the planning horizon and pays off the debt at the end of the horizon, replenishes its stock under the constraint of its cash flow over each period of the planning horizon. The retailer faces random demand and the unmet demand in each period is lost. We assume tax losses are not allowed for tax carrybacks or carry-forwards. We determine the optimal ordering policy at the retailer to maximize the expected terminal wealth at the end of the planning horizon. Finally, we will find out the optimal inventory policy and the optimal debt financing decision with the capital constraint and the effect of tax.