added logic for percent and absolute discounts