Exemple #1
0
def add_record(category, data_):
    YEAR_INDEX = 0
    MONTH_INDEX = 1
    DAY_INDEX = 2
    record = [c.generate_id(data_)]

    amount = float(input('Enter the amount [0.0]: '))
    amount = format(amount, '.2f')
    record.append(str(amount))

    display.print_menu(category)
    selected_category = int(input('Chose category number: '))
    record.append(category[selected_category - 1])

    operation_details = input('Enter the operation details: ')
    record.append(operation_details)

    expanse_date = date.today()
    expanse_date = expanse_date.timetuple()
    record.append(str(expanse_date[YEAR_INDEX]))
    record.append(str(expanse_date[MONTH_INDEX]))
    record.append(str(expanse_date[DAY_INDEX]))

    data_.append(record)
    print('Record added correctly. \n')
    return data_
Exemple #2
0
def main():
    expenses = data_manager.data_import('expenses.txt')
    incomes = data_manager.data_import('earnings.txt')
    income_categories = income_expenses.get_category('income_categories.txt')
    expense_categories = income_expenses.get_category('categories.txt')

    os.system('clear')
    decision = 0


    while decision != 5:
        os.system('clear')
        display.print_message(intro.intro)
        display.print_message(intro.intro2)
        display.print_message("Main menu")
        menu = ['Expenses', 'Incomes', 'Raports', 'Categories configuration', 'Exit']  # main menu
        display.print_menu(menu)
        decision = common.get_decision_input(decision)
        os.system('clear')
        if decision == 1:
            income_expenses.expenses(expenses, expense_categories)
        elif decision == 2:
            income_expenses.incomes(incomes, income_categories)
        elif decision == 3:
            raport(incomes, expenses)
        elif decision == 4:
            config(income_categories, expense_categories)

    income_categories = common.prepare_list_to_save(income_categories)
    expense_categories = common.prepare_list_to_save(expense_categories)

    data_manager.data_export(expenses, 'expenses.txt')
    data_manager.data_export(incomes, 'earnings.txt')
    data_manager.data_export(income_categories, 'income_categories.txt')
    data_manager.data_export(expense_categories, 'categories.txt')
Exemple #3
0
def edit_record(data, category):
    options = ['Amount', 'Categories', 'Details', 'Year', 'Month', 'Day']

    display.print_table(data)
    edited_record = input('Enter id of record, which do you want edit: ')
    for element in data[:]:
        if edited_record == element[c.ID_INDEX]:
            display.print_menu(options)
            selected_option = int(
                input('Enter number, which element do you want edit: '))

            if selected_option == 1:
                new_amount = format(float(input('Enter the amount [0.0]: ')),
                                    '.2f')
                element[selected_option] = str(new_amount)
            elif selected_option == 2:
                display.print_menu(category)
                selected_category = int(input('Chose category number: '))
                element[selected_option] = category[selected_category - 1]
            elif selected_option == 3:
                new_details = input('Enter new details: ')
                element[selected_option] = new_details
            elif selected_option in (4, 5, 6):
                new_date = int(input('Enter new date: '))
                element[selected_option] = new_details

    return data
Exemple #4
0
def choose_option():
    display.print_menu(dict_menu_options)
    user_choice = display.get_user_input("What'cha wanna do?: ")

    if user_choice in dict_menu_options.keys():
        dict_menu_options[user_choice]["func"]()
    else:
        display.print_error_message("Hold your horses! No such option.")
Exemple #5
0
def edit_category():
    decision = 0
    while decision != 3:
        display.print_message("Edit categories")
        menu = ['Add category', 'Delete category', 'Return ']
        display.print_menu(menu)
        decision = common.get_decision_input(decision)
        if decision == 1:
            add_category()
        elif decision == 2:
            remove_category()
Exemple #6
0
def config(cat_income, cat_expenses):
    decision = 0
    while decision != 3:
        display.print_message("Configuration menu")
        menu = ['Incomes', 'Expenses', 'Back to main menu']
        display.print_menu(menu)
        decision = common.get_decision_input(decision)
        if decision == 1:
            cat_income = what_to_do(cat_income)
        elif decision == 2:
            cat_expenses = what_to_do(cat_expenses)
    return cat_income, cat_expenses
Exemple #7
0
def gen_raport(income, expenses):
    decision = 0
    while decision != 3:
        display.print_message("Generating raport menu")
        menu = ['Incomes', 'Expenses', 'Back to raports menu']
        display.print_menu(menu)
        decision = common.get_decision_input(decision)

        if decision == 1:
            data = common.sort(income)
            display.print_table(data)
            save_raport(data)
        elif decision == 2:
            data = common.sort(expenses)
            display.print_table(data)
            save_raport(data)
Exemple #8
0
def what_to_do(category):
    decision = 0
    table = []
    while decision != 4:
        display.print_message("What you want to do?")
        menu = [
            'Show categories', 'Add category', 'Remove category',
            'Back to configuration menu'
        ]
        display.print_menu(menu)
        decision = common.get_decision_input(decision)
        if decision == 1:
            for element in category:
                print(element)
        elif decision == 2:
            category = add_category(category)
        elif decision == 3:
            category = remove_category(category)
    return category
Exemple #9
0
def incomes(incomes, income_categories):
    income_options = ['Add income', 'Remove income', 'Edit income', 'Display incomes in the current month',\
    'Back to main menu']
    selected_option = 0

    while selected_option != '5':
        try:
            display.print_menu(income_options)
            selected_option = input('Enter a number: ')

            if selected_option == '1':
                add_record(income_categories, incomes)
            elif selected_option == '2':
                remove_record(incomes)
            elif selected_option == '3':
                edit_record(incomes, income_categories)
            elif selected_option == '4':
                display_current_month(incomes)
        except ValueError:
            print('Wrong value. Please, try again.')
        except IndexError:
            print('Wrong number. Please, try again. ')
Exemple #10
0
def raport(income, expenses):
    decision = 0
    while decision != 5:
        display.print_message("Raports menu")
        menu = [
            'Generate raport', 'Show raports', 'Show specified raport',
            'Delete raports', 'Back to main menu'
        ]
        display.print_menu(menu)
        decision = common.get_decision_input(decision)
        if decision == 1:
            gen_raport(income, expenses)
        elif decision == 2:
            data = get_list_raport()
            display.print_list(data, 'Files: \n')
        elif decision == 3:
            data = get_list_raport()
            filename = validate_filename(data)
            show_raport(filename)
        elif decision == 4:
            data = get_list_raport()
            filename = validate_filename(data)
            delete_raport(filename)
Exemple #11
0
def total_album_price():
    total = 0
    for album in catalog:
        total += album.price
    print(f'total: {total}')


# instructions
deserialize_data()
input("press enter to continue...")

opc = ''
while (opc != 'q' and opc != 'x'):
    clear()
    print_menu()
    opc = input("Please select an option: ")
    if (opc == '1'):
        register_album()
        serialize_data()

    elif (opc == '2'):
        register_song()
        serialize_data()

    elif (opc == '3'):
        print_albums()

    elif (opc == '4'):
        print_album_songs()
Exemple #12
0
def main():
    basket = []
    while True:
        option = "0"
        if option == "0":
            stock = function.read_file("stock.csv")
            display.print_table(stock, "inventory")
            display.print_menu(list_options_for_main_menu)
            get_input = display.get_input(["Enter your option!"], "")
            option = get_input[0]

        if option.lower() == "a":
            while True:
                items_for_basket = display.get_single_input("Choose id: ")
                if function.check_id(items_for_basket, stock):
                    quantity_for_basket = display.get_single_input(
                        "Quantity: ")

                    if function.check_quantity(items_for_basket,
                                               quantity_for_basket, stock):

                        function.add_basket(items_for_basket,
                                            quantity_for_basket, basket, stock)
                    else:
                        print("Not enough quantity! ")
                else:
                    print("Not in stock!")
                second_choose = display.get_input(
                    ["Do you want to add something? "], "")
                if second_choose[0].lower() == "no":
                    os.system('clear')
                    break
            option = "0"
        if option.lower() == "x":
            os.system('clear')
            exit()
        while option.lower() == "p":
            os.system('clear')
            display.print_table(basket, "basket")
            display.print_menu(list_options_for_basket_menu)
            second_choose = display.get_single_input('Choose the option: ')
            if second_choose.lower() == "r":
                id_for_remove = display.get_single_input(
                    "Choose the item for complet remove! ")
                function.remove_from_bascket(id_for_remove, basket)
                os.system('clear')
                option = "p"
            if second_choose.lower() == 'c':
                id_for_cahnge_quantity = display.get_single_input(
                    "Choose the item to change the quantity! ")
                if function.check_id(id_for_cahnge_quantity, basket):
                    quantity_for_cahange = display.get_single_input(
                        "Choose quantity! ")
                    if function.check_quantity(id_for_cahnge_quantity,
                                               quantity_for_cahange, basket):
                        function.change_qunatity_from_bascket(
                            id_for_cahnge_quantity, quantity_for_cahange,
                            basket)
                        option = 'p'
                    else:
                        print('You do not have this quantity in the basket!')
                        option = "p"
                else:
                    print('You do not have this item in the basket!')
                    option = 'p'
            if second_choose.lower() == 'f':
                a = 0
                while a < 3:
                    to_valid = function.card_payment()
                    if function.validate_card_details(to_valid):
                        function.write(function.update_stock(basket))
                        print(
                            "Nu ai bani pe card sarakule!!!, Mars la munca baaa, lepra ce esti! Oricum nu stii sa citesti. "
                        )
                        exit()
                    else:
                        a += 1
            if second_choose.lower() == 'b':
                option = "0"
                break
            if second_choose.lower() == 'x':
                os.system('clear')
                exit()