import string
import random


def generate_random_ticket_number(prefix=''):
    """
    The following function generates a ticket number in one of two ways:
    Legacy (prefix not specified): 13 random digits
    Prefix != None: Ticket Number with the prefix (Airline code) and random digits making up the balance to 13 char
    """
    if prefix == '':
        size = 13
    else:
        size = 13 - len(prefix)

    chars = string.digits
    return str.upper(prefix) + (''.join(random.choice(chars) for _ in range(size)))