fixed bugs related to calculating total discounts