def test_which_year_max(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = accounting.which_year_max(table)
     self.assertEqual(result, 2015)
def get_the_sum_of_prices(item_ids):
    datas = data_manager.get_table_from_file("sales/sales.csv")
    return get_the_sum_of_prices_from_table(datas, item_ids)
def get_num_of_sales_per_customer_ids():
    datas = data_manager.get_table_from_file("sales/sales.csv")
    return get_num_of_sales_per_customer_ids_from_table(datas)
def start_module():
    """
    Starts this module and displays its menu.
    User can access default special features from here.
    User can go back to main menu from here.

    Returns:
        None
    """
    table = data_manager.get_table_from_file('sales/sales.csv')

    is_not_main_menu = True
    while is_not_main_menu:
        data_manager.write_table_to_file('sales/sales.csv', table)

        sales_manager_menu = [
            "(1) Show table", "(2) Add", "(3) Remove", "(4) Update",
            "(5) Get lowest price item id", "(6) Get items sold between"
        ]

        ui.print_menu("Sales manager menu: ", sales_manager_menu,
                      "(0) Back to main menu")

        inputs = ui.get_inputs(['Choose option from menu ', 9], '')
        chose_menu_number = inputs[0]

        is_menu_sales = True
        while is_menu_sales:

            if chose_menu_number == "1":
                show_table(table)
                is_menu_sales = False

            elif chose_menu_number == "2":
                add(table)
                is_menu_sales = False

            elif chose_menu_number == "3":
                remove(table, ui.get_inputs(['Enter id: ', 6],
                                            'Remove record'))
                is_menu_sales = False

            elif chose_menu_number == "4":
                update(table, ui.get_inputs(['Enter id: ', 6],
                                            'Update record'))
                is_menu_sales = False

            elif chose_menu_number == "5":
                result = get_lowest_price_item_id(table)

                ui.print_result(result, 'The id of lowest price: \n')
                is_menu_sales = False

            elif chose_menu_number == "6":
                questions_list = [
                    'Enter initial month ', 4, 'Enter initial day ', 5,
                    'Enter initial year ', 3, 'Enter final month ', 4,
                    'Enter final day ', 5, 'Enter final year ', 3
                ]

                inputs_list = ui.get_inputs(questions_list, 'Enter a time')
                result = get_items_sold_between(table, inputs_list[0],
                                                inputs_list[1], inputs_list[2],
                                                inputs_list[3], inputs_list[4],
                                                inputs_list[5])
                ui.print_result(result, 'Items in part of time: \n')
                is_menu_sales = False

            elif chose_menu_number == "0":
                is_menu_sales = False
                is_not_main_menu = False
def get_title_by_id(id):

    datas = data_manager.get_table_from_file("sales/sales.csv")
    return get_title_by_id_from_table(datas, id)
 def test_get_lowest_price_item_id(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = selling.get_lowest_price_item_id(table)
     self.assertEqual(result, "kH35Ju#&")
 def test_get_available_tools(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = [["kH34Ju#&", "PlayStation 4", "Sony", 2013, 4], ["jH34Ju#&", "Xbox One", "Microsoft", 2013, 4]]
     result = selling.get_available_tools(table)
     compare_lists(self, expected, result)
Exemple #8
0
 def test_get_items_sold_between(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = get_item_sold_between_dates()
     result = sales.get_items_sold_between(table, 2, 12, 2016, 7, 6, 2016)
     compare_lists(self, expected, result)
Exemple #9
0
 def test_get_counts_by_manufacturers(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = get_count_by_manufacturer_list()
     result = store.get_counts_by_manufacturers(table)
     self.assertEqual(result, expected)
Exemple #10
0
 def test_get_persons_closest_to_average(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = ["Jimmy Hendrix"]
     result = hr.get_persons_closest_to_average(table)
     compare_lists(self, expected, result)
Exemple #11
0
 def test_get_lowest_price_item_id(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = sales.get_lowest_price_item_id(table)
     self.assertEqual(result, "kH35Ju#&")
Exemple #12
0
 def test_get_oldest_person(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = ["Barbara Streisand", "Joey Tribbiani", "Evelin Smile"]
     result = hr.get_oldest_person(table)
     compare_lists(self, expected, result)
Exemple #13
0
 def test_get_subscribed_emails(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = get_subscribed_list()
     result = crm.get_subscribed_emails(table)
     compare_lists(self, expected, result)
Exemple #14
0
 def test_get_longest_name_id(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = crm.get_longest_name_id(table)
     self.assertEqual(result, "kH14Ju#&")
 def test_get_longest_name_id(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = crm.get_longest_name_id(table)
     self.assertEqual(result, "kH14Ju#&")
Exemple #16
0
 def test_get_average_by_manufacturer(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = store.get_average_by_manufacturer(table, "Ensemble Studios")
     self.assertEqual(result, 12.25)
 def test_get_oldest_person(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = ["Barbara Streisand", "Joey Tribbiani", "Evelin Smile"]
     result = hr.get_oldest_person(table)
     compare_lists(self, expected, result)
Exemple #18
0
 def test_get_available_items(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = [["kH34Ju#&", "PlayStation 4", "Sony", 2013, 4],
                 ["jH34Ju#&", "Xbox One", "Microsoft", 2013, 4]]
     result = inventory.get_available_items(table)
     compare_lists(self, expected, result)
 def test_get_counts_by_manufacturers(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = get_count_by_manufacturer_list()
     result = selling.get_counts_by_manufacturers(table)
     self.assertEqual(result, expected)
Exemple #20
0
 def test_get_average_durability_by_manufacturers(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = {"Sony": 3.5, "Microsoft": 4, "Nintendo": 3.25}
     result = inventory.get_average_durability_by_manufacturers(table)
     self.assertEqual(result, expected)
Exemple #21
0
 def test_avg_amount(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = accounting.avg_amount(table, 2016)
     self.assertEqual(result, 48.125)
def show_table_wrapper():
    table = data_manager.get_table_from_file('crm/customers.csv')
    show_table(table)
import ui  # User interface module
""" Accounting module

Data table structure:
    * id (string): Unique and random generated identifier
        at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters)
    * month (number): Month of the transaction
    * day (number): Day of the transaction
    * year (number): Year of the transaction
    * type (string): in = income, out = outflow
    * amount (int): amount of transaction in USD
"""
# everything you'll need is imported:

file_name = "/home/stefan/Codecool/Python/5th_TW_week/lightweight-erp-python-phoenix/accounting/items.csv"
table = data_manager.get_table_from_file(file_name)
title = "Please enter the product data"
list_labels = ["id", "month", "day", "year", "type", "ammount"]
year_months_day = {
    "01": 31,
    "02": 29,
    "03": 31,
    "04": 30,
    "05": 31,
    "06": 30,
    "07": 31,
    "08": 31,
    "09": 30,
    "10": 31,
    "11": 30,
    "12": 31
def add_wrapper():
    table = data_manager.get_table_from_file('crm/customers.csv')
    add(table)
def get_item_id_sold_last():
    datas = data_manager.get_table_from_file("sales/sales.csv")
    return get_item_id_sold_last_from_table(datas)
def update_wrapper():
    table = data_manager.get_table_from_file('crm/customers.csv')
    update(table, ui.get_inputs(['ID :'], 'Enter ID: '))
def get_customer_id_by_sale_id(sale_id):
    datas = data_manager.get_table_from_file("sales/sales.csv")
    return get_customer_id_by_sale_id_from_table(datas, sale_id)
def get_longest_name_id_wrapper():
    table = data_manager.get_table_from_file('crm/customers.csv')
    get_longest_name_id(table)
def start_module():
    while True:
        datas = data_manager.get_table_from_file("sales/sales.csv")
        options = [
            "Display table",
            "Add",
            "Remove",
            "Update",
            "The ID of the item sold for the lowest price",
            "Items that are sold between two given dates",
            "Get the title of the item by ID",
            "Get the title of the item by ID from table",
            "Get the ID of the item sold last",
            "Get the ID of the item sold last from table",
            "Get the title of the item sold last from table",
            "Get the sum of prices of the given item IDs",
            "Get the sum of prices of the given item IDs from table",
            "Get the customer ID by the given sale ID",
            "Get the customer ID by the given sale ID from table",
            "Get all customer IDs",
            "Get all customer IDs from table",
            "Get all sales IDs for the customer IDs",
            "Get all sales IDs for the customer IDs from table",
            "Get the number of sales per customer IDs",
            "Get the number of sales per customer IDs from table"]
        ui.print_menu("\nSales menu", options, "Main menu")
        inputs = ui.get_inputs(["Please, choose an option: "], "")
        option = inputs[0]
        if option == "1":
            os.system("clear")
            show_table(datas)
        elif option == "2":
            os.system("clear")
            add(datas)
            write_to_file(datas)
        elif option == "3":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter an ID to remove the line: "], "")
            remove(datas, given_id)
            write_to_file(datas)
        elif option == "4":
            os.system("clear")
            update_id = ui.get_inputs(["Please, enter an ID to update the line: "], "")
            update(datas, update_id)
            write_to_file(datas)
        elif option == "5":
            os.system("clear")
            ui.print_result(get_lowest_price_item_id(datas), "The ID of the item sold for the lowest price:")
        elif option == "6":
            os.system("clear")
            date_list = ui.get_inputs(["Month from: ", "Day from: ", "Year from: ",
                                       "Month to: ", "Day to: ", "Year to: "], "Please, add the dates!")
            ui.print_result(
                get_items_sold_between(
                    datas, int(
                        date_list[0]), int(
                        date_list[1]), int(
                        date_list[2]), int(
                        date_list[3]), int(
                            date_list[4]), int(
                                date_list[5])), "Items that are sold between two given dates:\n")
        elif option == "7":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter an ID to get the title: "], "")
            ui.print_result(get_title_by_id(given_id[0]), "The title of the item by ID:")
        elif option == "8":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter an ID to get the title: "], "")
            ui.print_result(get_title_by_id_from_table(datas, given_id[0]), "The title of the item by ID:")
        elif option == "9":
            os.system("clear")
            ui.print_result(get_item_id_sold_last(), "The ID of the item sold last:")
        elif option == "10":
            os.system("clear")
            ui.print_result(get_item_id_sold_last_from_table(datas), "The ID of the item sold last:")
        elif option == "11":
            os.system("clear")
            ui.print_result(get_item_title_sold_last_from_table(datas), "The title of the item sold last:")
        elif option == "12":
            os.system("clear")
            given_ids = ui.get_inputs(
                ["Please, enter the IDs (seperated by comma) to get the sum of the prices of the items: "], "")
            splitted_given_ids = given_ids[0].split(",")
            ui.print_result(get_the_sum_of_prices(splitted_given_ids), "The sum of prices of the given item IDs:")
        elif option == "13":
            os.system("clear")
            given_ids = ui.get_inputs(
                ["Please, enter the IDs (seperated by comma) to get the sum of the prices of the items: "], "")
            splitted_given_ids = given_ids[0].split(",")
            ui.print_result(
                get_the_sum_of_prices_from_table(
                    datas,
                    splitted_given_ids),
                "The sum of prices of the given item IDs:")
        elif option == "14":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter the sale ID to get the customer ID: "], "")
            ui.print_result(get_customer_id_by_sale_id(given_id[0]), "The customer ID by the given sale ID:")
        elif option == "15":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter the sale ID to get the customer ID: "], "")
            ui.print_result(
                get_customer_id_by_sale_id_from_table(
                    datas,
                    given_id[0]),
                "The customer ID by the given sale ID:")
        elif option == "16":
            os.system("clear")
            ui.print_result(get_all_customer_ids(), "All customer IDs:")
        elif option == "17":
            os.system("clear")
            ui.print_result(get_all_customer_ids_from_table(datas), "All customer IDs:")
        elif option == "18":
            os.system("clear")
            ui.print_result(get_all_sales_ids_for_customer_ids(), "All sale IDs for the customer IDs:")
        elif option == "19":
            os.system("clear")
            ui.print_result(get_all_sales_ids_for_customer_ids_from_table(datas), "All sale IDs for the customer IDs:")
        elif option == "20":
            os.system("clear")
            ui.print_result(get_num_of_sales_per_customer_ids(), "The number of sales per customer IDs:")
        elif option == "21":
            os.system("clear")
            ui.print_result(
                get_num_of_sales_per_customer_ids_from_table(datas),
                "The number of sales per customer IDs:")
        elif option == "0":
            os.system("clear")
            break
        else:
            ui.print_error_message("There is no such option.")
def get_subscribed_emails_wrapper():
    table = data_manager.get_table_from_file('crm/customers.csv')
    get_subscribed_emails(table)
 def test_avg_amount(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = accounting.avg_amount(table, 2015)
     self.assertEqual(result, 48.125)
Exemple #32
0
Data table structure:
    * id (string): Unique and random generated identifier
        at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters)
    * name (string): Name of item
    * manufacturer (string)
    * purchase_year (number): Year of purchase
    * durability (number): Years it can be used
"""
import ui
import data_manager
import common

list_labels = ["id", "name", "year"]
read_file = common.path() + "hr/persons.csv"
table = data_manager.get_table_from_file(read_file)
back_to_main_menu = True


def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    global back_to_main_menu
    back_to_main_menu = True
    while back_to_main_menu == True:
 def test_get_subscribed_emails(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = get_subscribed_list()
     result = crm.get_subscribed_emails(table)
     compare_lists(self, expected, result)
Exemple #34
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    table = data_manager.get_table_from_file("sales/sales.csv")
    list_options = ["Show table", "Add new record", "Remove record",
                    "Update record", "Lowest price item", "Items sold in given time", "Get title by ID",
                    "Get item ID sold last", "Get item title sold last", "Get the sum of prices", "Get customer ID by sale ID",
                    "Get all customers ID", "get all sale ID", "Get number of sales per customer"]
    while True:
        ui.print_menu("Sales manager", list_options, "Back to main menu")
        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        if option == "1":
            show_table(table)
        elif option == "2":
            add(table)
        elif option == "3":
            id_ = ui.get_inputs(["ID: "], "Please type ID to remove")
            table = remove(table, id_)
        elif option == "4":
            id_ = ui.get_inputs(["ID: "], "Please type ID to update")
            table = update(table, id_)
        elif option == "5":
            ui.print_result(get_lowest_price_item_id(table),
                            "The id of the item sold for the lowest price is")
        elif option == "6":
            month_from = ui.get_inputs(["Month from: "], "")
            day_from = ui.get_inputs(["Day from: "], "")
            year_from = ui.get_inputs(["Year from: "], "")
            month_to = ui.get_inputs(["Month to: "], "")
            day_to = ui.get_inputs(["Day to: "], "")
            year_to = ui.get_inputs(["Year to: "], "")
            ui.print_result(get_items_sold_between(table, month_from, day_from, year_from, month_to,
                                                   day_to, year_to), "The list with the items sold in the chosen amount of time is")
        elif option == "7":
            id_ = ui.get_inputs(["ID: "], "Please type ID:")
            ui.print_result(get_title_by_id_from_table(
                table, id_), "The title is:")
        elif option == "8":
            ui.print_result(get_item_id_sold_last_from_table(
                table), "The last id item sold is:")

        elif option == "9":
            ui.print_result(get_item_title_sold_last_from_table(
                table), "The last id item sold is:")

        elif option == "10":
            item_idss = [1, 1]
            item_ids = []
            while item_idss[1] == True:
                item_idss = ui.get_inputs(
                    ["ID:", "add another one?:"], "introduce ID")
                item_ids.append(item_idss[0])
            ui.print_result(get_the_sum_of_prices_from_table(
                table, item_ids), "The sum of items is:")
        elif option == "11":
            sale_id = ui.get_inputs(["ID:"], "introduce ID")
            ui.ptint_result(
                get_customer_id_by_sale_id_from_table(table, sale_id), "ID sale is:")
        elif option == "12":
            ui.print_result(get_all_customer_ids_from_table(
                table), "All customer ids is:")
        elif option == "13":
            ui.print_result(
                get_all_sales_ids_for_customer_ids_from_table(table), "All sales IDs is:")
        elif option == "14":
            ui.print_result(
                get_num_of_sales_per_customer_ids_from_table(table), "All sales per customer are:")
        elif option == "0":
            break
        else:
            ui.print_error_message("Choose something else!")
 def test_get_persons_closest_to_average(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = ["Jimmy Hendrix"]
     result = hr.get_persons_closest_to_average(table)
     compare_lists(self, expected, result)
def list_questions():
    file_name = current_file_path + "/data/question.csv"
    question_list = data_manager.get_table_from_file(file_name, (4, 5, 6))
    question_list = data_manager.table_sort(question_list, 1, True)
    return render_template('list_questions.html', question_list=question_list)
 def test_get_items_sold_between(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = get_item_sold_between_dates()
     result = selling.get_items_sold_between(table, 2, 12, 2016, 7, 6, 2016)
     compare_lists(self, expected, result)
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    table = data_manager.get_table_from_file("store/games.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "Games per manufacturer",
        "Average stock by manufacturer"]

    while True:
        ui.print_menu("- Store manager -", options, "Back to Main menu")
        option = ui.get_inputs(["Please enter a number: "], "")

        try:
            if option == "1":
                show_table(table) 
                common.go_back_in_menu()

            elif option == "2":
                table = add(table) 
                data_manager.write_table_to_file("store/games.csv", table)

            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the title you wish to remove: "], ""
                )
                if common.check_id_in_table(table, id_to_remove):
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("store/games.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the ID of the title you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update): 
                    update(table, id_to_update)
                    data_manager.write_table_to_file("store/games.csv", table)

            elif option == "5":
                count_by_manufacturer = get_counts_by_manufacturers(table)
                ui.print_result(count_by_manufacturer, ["MANUFACTURER", "GAMES"])
                common.go_back_in_menu()
                
            elif option == "6":
                which_manuf = ui.get_inputs(
                    ["Please enter which manufacturer: "],
                    ""
                )
                try:
                    average_stock_by_manufacturer = get_average_by_manufacturer(table, which_manuf)
                except ZeroDivisionError:
                    continue

                ui.print_result(average_stock_by_manufacturer,"The avarege stock by the manufacturer is ")
                common.go_back_in_menu()

            elif option == "0":
                break

            else:
                raise KeyError("There is no such option")

        except KeyError as err:
            ui.print_error_message(str(err))
 def test_get_average_by_manufacturer(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = selling.get_average_by_manufacturer(table, "Ensemble Studios")
     self.assertEqual(result, 12.25)
Exemple #40
0
def show_table(table):
    table_headers=['id','title','price','month','day','year']  
    table= data_manager.get_table_from_file(sales.csv) 
    ui.print_table(table,table_headers)
 def test_get_average_durability_by_manufacturers(self):
     table = data_manager.get_table_from_file(self.data_file)
     expected = {"Sony": 3.5, "Microsoft": 4, "Nintendo": 3.25}
     result = selling.get_average_durability_by_manufacturers(table)
     self.assertEqual(result, expected)
Exemple #42
0
 def test_which_year_max(self):
     table = data_manager.get_table_from_file(self.data_file)
     result = accounting.which_year_max(table)
     self.assertEqual(result, 2015)