def calculate_penalty(row):
    """
    Calculate penalty as `(current_amount_due + total_paid) - fine_level1_amount`
    """

    # If current amount due is negative or ticket was dismissed,
    # penalty is null
    if float(row[14]) < 0 or row[16] == 'Dismissed':
        penalty = None
    else:
        penalty = (float(row[14]) + float(row[15])) - float(row[12])

    return penalty