This paper presents an optimal rate scheduling algorithm called Truncation for an energy-harvesting enabled wireless transmitter to transmit a set of dynamically arrived packets with minimum transmission energy. Distinct from existing works, we allow packets to have individual delay constraints, which is the most general model ever assumed but is very much desired to guarantee per-application quality-of-service (QoS). Moreover, we restrict the allowable rates to a set of discrete values, which is more practical and required in many real applications. As the first achievement, we obtain an optimal offline algorithm, which assumes the rate is continuously adjustable. Then, we propose a general framework that transforms any algorithm using the continuous-rate model into an algorithm using only discrete-rates, while preserving the optimality as long as the optimality holds for convex rate-power functions. It is possible that the harvested energy is insufficient to guarantee all packets to meet their deadlines. Should this occur, maximizing throughput with the limited available energy becomes the goal to achieve. Our Truncation algorithm is able to identify this case and produces a schedule that guarantees maximum throughput, if packets share a common deadline. Furthermore, based on the optimal offline algorithms, an efficient online algorithm is designed which has been shown by simulations to produce near optimal results.