Add check for record['discount'] = None

@mdietrichc2c with your correction, if discount_amount is not in record dict, discount_value variable will not be assigned