Exemplo n.º 1
0
def mainMenu(cursor, cnx):
    clear()
    flag = 1
    print("{:~^60}".format(""))
    print("{:^60}".format("Budget Bananza v1.0"))
    print("{:^60}".format("Author: Michael Rayson"))
    print("{:~^60}".format(""))
    input("{:^60}".format("\nPress enter to continue..."))

    while (flag == 1):
        #clear()
        print("Main Menu")
        print("{:~^43}".format(""))
        print("1) BudgetView Menu")
        print("2) Transaction Management Menu")
        print("{:~^43}".format(""))
        ans = input("\nPlease enter your choice: ")
        while (ans.isnumeric() == False or int(ans) < 1 or int(ans) > 2):
            ans = input("\nPlease enter your choice: ")
        if (int(ans) == 1):
            budgetMenu(cursor, cnx)
        elif (int(ans) == 2):
            transactionMenu(cursor, cnx)

        choice = input(
            "Enter 1 to return to the main menu, otherwise another number to quit: "
        )
        while (choice.isnumeric() == False):
            choice = input(
                "\nEnter 1 to return to the main menu, otherwise another number to quit: "
            )
        if (int(choice) == 1):
            flag = 1
        else:
            flag = 2
Exemplo n.º 2
0
def showBudget(cursor, date):
    '''Retrieves the budget for the given month. If none exists, creates one.'''
    exists = budgetExists(cursor, date)
    if (exists == False):
        createBlankBudget(cursor, date)
    budgetCategories = [
        "Monthly Expense: Rent", "Everyday Expense: Groceries",
        "Everyday Expense: Gas", "Everyday Expense: Eating Out",
        "Misc Expense: Clothes", "Misc Expense: Entertainment",
        "Misc Expense: Repair/Home"
    ]
    budgetedValues = readBudgetValues(cursor, budgetCategories, date)
    activity = []
    for i in budgetCategories:
        activity.append(getActivity(cursor, i, date))
    remaining = []
    for i in range(len(budgetCategories)):
        remaining.append(float(budgetedValues[i]) + float(activity[i]))

    totalBudgeted = 0.00
    for i in budgetedValues:
        totalBudgeted = totalBudgeted + float(i)
    totalActivity = 0.00
    for i in activity:
        totalActivity = totalActivity + float(i)
    totalRemaining = 0.00
    for i in remaining:
        totalRemaining = totalRemaining + i

    if (totalRemaining >= 0):
        needHome = getAccountBalance(cursor) - totalRemaining

    #Display the table
    clear()
    print("\n{:^83}".format("The " + date + " budget"))
    print("{:<16} {:>9.2f}".format("Account Balance:",
                                   getAccountBalance(cursor)))
    if (totalRemaining > 0):
        print("{:<16} {:>9.2f}".format("To Be Budgeted:", needHome))
    else:
        print("{:<16} {:>9.2f}".format("Missing Funds:", totalRemaining))
    print("{:-^83}".format(""))
    print("|{:^30}|{:^16}|{:^16}|{:^16}|".format("Category", "Budgeted ($)",
                                                 "Activity ($)",
                                                 "Remaining ($)"))
    print("{:-^83}".format(""))
    for i in range(len(budgetCategories)):
        print("|{:<30}|{:>16}|{:>16.2f}|{:>16.2f}|".format(
            budgetCategories[i], budgetedValues[i], activity[i],
            float(budgetedValues[i]) + float(activity[i])))
    print("{:-^83}".format(""))
    print("|{:<30}|{:>16.2f}|{:>16.2f}|{:>16.2f}|".format(
        "Totals", totalBudgeted, totalActivity, totalRemaining))
    print("{:-^83}".format(""))
    if (totalRemaining > 0):
        print("*{:<47}{:<6.2f}\n".format(
            "Recommended you put the following in savings next month, $",
            totalRemaining))
Exemplo n.º 3
0
def transactionMenu(cursor, cnx):
    clear()
    print("Transaction Menu")
    print("{:~^43}".format(""))
    print("1) Retrieve and Import Transactions from CSV files")
    print("2) List all transactions in the database")
    print("{:~^43}".format(""))
    ans = input("\nPlease enter your choice: ")
    while (ans.isnumeric() == False or int(ans) < 1 or int(ans) > 2):
        ans = input("\nPlease enter your choice: ")
    if (int(ans) == 1):
        password1 = getpass.getpass("Please enter scotiabank password: "******"Please enter pcfinancial password: "******"pcbanking.csv", cursor, cnx)
        getTransactions("report.csv", cursor, cnx)
    if (int(ans) == 2):
        listAllTrans(cursor)
Exemplo n.º 4
0
def main():
    '''Establishes a connection with the database and directs user to where they want to go'''
    try:
        clear()
        dbUser = input("Please enter your database username: "******"Password: "******"Error while connecting to the database", err)
    finally:
        if (cnx):
            cursor.close()
            cnx.close()
            print("Connection closed")
Exemplo n.º 5
0
def budgetMenu(cursor, cnx):
    clear()
    print("Budget Menu")
    print("{:~^43}".format(""))
    print("1) Check Month Progression")
    print("2) Set budget values")
    print("{:~^43}".format(""))
    ans = input("\nPlease enter your choice: ")
    while (ans.isnumeric() == False or int(ans) < 1 or int(ans) > 2):
        ans = input("\nPlease enter your choice: ")
    if (int(ans) == 1):
        clear()
        print("Budget Menu 1.1")
        print("{:~^43}".format(""))
        print("1) Current Month")
        print("2) Last Month")
        print("{:~^43}".format(""))
        ans = input("\nPlease enter your choice: ")
        while (ans.isnumeric() == False or int(ans) < 1 or int(ans) > 2):
            ans = input("\nPlease enter your choice: ")
        clear()
        if (int(ans) == 1):
            showBudget(cursor, getThisMonth())
        elif (int(ans) == 2):
            showBudget(cursor, getLastMonth())
    elif (int(ans) == 2):
        clear()
        print("Budget Menu 1.2")
        print("{:~^43}".format(""))
        print("1) Current Month")
        print("2) Last Month")
        print("{:~^43}".format(""))
        ans = input("\nPlease enter your choice: ")
        while (ans.isnumeric() == False or int(ans) < 1 or int(ans) > 2):
            ans = input("\nPlease enter your choice: ")
        if (int(ans) == 1):
            setMonthBudgetValues(cursor, getThisMonth())
        elif (int(ans) == 2):
            setMonthBudgetValues(cursor, getLastMonth())
    cnx.commit()
Exemplo n.º 6
0
def setMonthBudgetValues(cursor, date):
    exists = budgetExists(cursor, date)
    if (exists == False):
        createBlankBudget(cursor, date)
    isNull = isBudgetNull(cursor, date)
    if (isNull == True):
        vals = []
        print("\nPlease enter values for the months budget")
        vals.append(input("Monthly Expense: Rent -> "))
        vals.append(input("Monthly Expense: Hydro -> "))
        vals.append(input("Monthly Expense: Internet -> "))
        vals.append(input("Everyday Expense: Groceries -> "))
        vals.append(input("Everyday Expense: Gas -> "))
        vals.append(input("Everyday Expense: Eating Out -> "))
        vals.append(input("Misc Expense: Clothes -> "))
        vals.append(input("Misc Expense: Entertainment -> "))
        vals.append(input("Misc Expense: Repair/Home -> "))
        setMonthBudgetData(cursor, vals, date)
    elif (isNull == False):
        flag = True
        while (flag == True):
            clear()
            print("Categories available to be changed: ")
            print("\n0-Unsorted")
            print("1-Monthly Expense: Rent")
            print("2-Monthly Expense: Hydro")
            print("3-Monthly Expense: Internet")
            print("4-Everyday Expense: Groceries")
            print("5-Everyday Expense: Gas")
            print("6-Everyday Expense: Eating Out")
            print("7-Misc Expense: Clothes")
            print("8-Misc Expense: Entertainment")
            print("9-Misc Expense: Bills")
            print("10-Misc Expense: Repair/Home")
            print("11-Misc Expense: School")
            print("12-Transfer: Savings")
            print("13-Transfer: Misc")
            print("14-Income: Work")
            print("15-Income: Misc\n")
            ans = input("Please enter your choice: ")
            while (ans.isnumeric() == False or int(ans) < 0 or int(ans) > 15):
                ans = input("\nPlease enter your choice: ")
            catDict = {
                0: "Unsorted",
                1: "Monthly Expense: Rent",
                2: "Monthly Expense: Hydro",
                3: "Monthly Expense: Internet",
                4: "Everyday Expense: Groceries",
                5: "Everyday Expense: Gas",
                6: "Everyday Expense: Eating Out",
                7: "Misc Expense: Clothes",
                8: "Misc Expense: Entertainment",
                9: "Misc Expense: Bills",
                10: "Misc Expense: Repair/Home",
                11: "Misc Expense: School",
                12: "Transfer: Savings",
                13: "Transfer: Misc",
                14: "Income: Work",
                15: "Income: Misc"
            }
            cat = catDict[int(ans)]
            budg = input("Buget Value: ")
            while (budg.isnumeric() == False):
                ans = input("\nBudget Value: ")
            setSingleBudget(cursor, cat, budg, date)
            choice = input("\nEnter 1 to set more, else another number: ")
            while (choice.isnumeric() == False):
                choice = input("\nEnter 1 to set more, else another number: ")
            if (int(choice) == 1):
                flag = True
            else:
                flag = False