import functools


def generate_report(user):
    """Generates required report for a given user

    Note:
        expenses < (leftover + savings) - You have a good handle of your budget
        expenses > (leftover + savings) - You need to cut back on your expenses
        expenses = (leftover + savings) - Your budget is very tight

    Args:
        user: dictionary containing user data

    Return:
        report: dictionary containing additional reported information

        report = {
            'firstName': 'Dominic',
            'lastName': 'Henry',
            ...
            totalExpenses: 50000
            totalSavings: 170000
            totalIncome: 300000
            leftover: 80000,
            statement: 'You have a good handle of your budget'
        }

    """
    def __(category):
        """Consolidates a given category"""
        return functools.reduce(lambda x, y: x + y, user[category].values())

    user['totalExpenses'] = __('expense')
    user['totalSavings'] = __('savings')
    user['totalIncome'] = __('income')
    user['leftover'] = user['totalIncome'] - (user['totalExpenses'] +
                                              user['totalSavings'])

    # Setting statements
    if user['leftover'] > 0:
        user['statement'] = 'You have a good handle of your budget'
    elif user['leftover'] < 0:
        user['statement'] = 'You need to cut back on your expenses'
    else:
        user['statement'] = 'Your budget is very tight'

    return user