patched calculation of discount and realTotal