Complicated discounts--need help with calculation logic