def delete_transaction():
    try:
        transaction_number = view.get_input("transaction number")
        if transaction_index_valid(transaction_number):
            sales.remove_transaction(transaction_number)
    except IndexError:
        view.print_error_message("Index not found")
def add_transaction():
    try:
        entry = view.get_inputs(["product", "price", "date"])
        if date_correct_input(entry[2]):
            sales.add_transaction(entry)
    except ValueError:
        view.print_error_message("Date in invalid format")
def get_biggest_revenue_product():
    biggest_revenue_product = sales.get_biggest_revenue_product()
    if not biggest_revenue_product == False:
        view.print_table(biggest_revenue_product)
    else:
        view.print_error_message(
            'Error while getting transactions number between dates')
Esempio n. 4
0
def add_employee():
    try:
        entry = get_input_from_user("add")
        if inputted_date_in_right_format(entry[1]):
            hr.append_nested_list_and_write_content(entry)
    except ValueError:
        view.print_error_message("Date in invalid format")
Esempio n. 5
0
def delete_customer():
    number = input("Please input number of customer: ")
    try:
        is_customer_index_valid(number)
        crm.delete_nested_list_and_write_content(number)
    except IndexError:
        view.print_error_message('There is no position with this number!')
Esempio n. 6
0
def delete_employee():
    try:
        number = view.get_input("number of employee")
        if check_employee_index_valid(number):
            hr.delete_nested_list_and_write_content(number)
    except IndexError:
        view.print_error_message("Index not found")
Esempio n. 7
0
def get_subscribed_emails():
    subscribed_emails_list = crm.get_emails_of_subscribent()

    if len(subscribed_emails_list) > 0:
        view.print_general_results(subscribed_emails_list,
                                   "Subscribed Emails:")
    else:
        view.print_error_message("There are no subscribed emails!")
Esempio n. 8
0
def update_customer():
    number = input("Please input number of customer: ")
    try:
        is_customer_index_valid(number)
        entry = view.get_inputs(
            ['name', 'email', 'if subscribed(Yes-1, No-0)'])
        crm.update_nested_list_and_write_content(number, entry)
    except IndexError:
        view.print_error_message('There is no position with this number!')
def update_customer():

    search_id = view.get_input('Id')
    if crm.if_customer_exists(search_id):
        print("Give the new data.")
        new_data = view.get_inputs(['Name', 'Email', 'Subscribed'])
        crm.update_customer(new_data)
    else:
        view.print_error_message("Id does not exist. \n")
Esempio n. 10
0
def menu():
    operation = None
    while operation != '0':
        display_menu()
        try:
            operation = view.get_input("Select an operation")
            run_operation(int(operation))
        except KeyError as err:
            view.print_error_message(err)
Esempio n. 11
0
def update_employee():

    employee_id = view.get_input("Please input user ID")
    table = ["","Please provide name","Please provide date of birth like YYYY-MM-DD","Please input your department","Please input Clearance status"]

    if hr.is_id_in_base(employee_id):
        [table[NAME_INDEX], table[DATE_OF_BIRTH], table[DEPARTMENT], table[CLEARANCE_LEVEL]] = view.get_inputs( [table[NAME_INDEX], table[DATE_OF_BIRTH], table[DEPARTMENT], table[CLEARANCE_LEVEL]])
        hr.update_employee(employee_id, table)
    else:
        view.print_error_message("There is no such id in the base.")
Esempio n. 12
0
def update_transaction():
    try:
        transaction_number = view.get_input("transaction number")
        if transaction_index_valid(transaction_number):
            entry = view.get_inputs(["product", "price", "date"])
            if date_correct_input(entry[2]):
                sales.update_transaction(transaction_number, entry)
    except IndexError:
        view.print_error_message("Index not found")
    except ValueError:
        view.print_error_message("Date in invalid format")
Esempio n. 13
0
def update_employee():
    try:
        number = view.get_input("number of employee")
        if check_employee_index_valid(number):
            entry = get_input_from_user("update")
            if inputted_date_in_right_format(entry[1]):
                hr.update_nested_list_and_write_content(number, entry)
    except IndexError:
        view.print_error_message("Index not found")
    except ValueError:
        view.print_error_message("Date in invalid format")
Esempio n. 14
0
def menu():
    operation = None
    while operation != 0:
        display_menu()
        try:
            operation = int(view.get_input("Select an operation"))
            util.clear_screen()
            run_operation(operation)
            util.wait() if operation != 0 else None
        except KeyError as err:
            view.print_error_message(err)
            util.wait()
def menu():
    option = None
    while option != '0':
        display_menu()
        try:
            option = int(view.get_input("Select module"))
            load_module(int(option))
        except KeyError:
            view.print_error_message("There is no such option!")
        except ValueError:
            view.print_error_message("Please enter a number!")
    view.print_message("Good-bye!")
def get_matching_names(partial_customer_name):

    # funkcja która zwraca listę nazw klientów, w których pojawia się podana częściowa nazwa klienta (string),
    # jeśli nie ma, to zwraca error value
    matching_names = crm.find_customer_names(partial_customer_name)
    if matching_names == []:
        view.print_error_message("Any customer matches")
        operation = short_menu()
        if operation == 0:
            return None
    
    return matching_names
Esempio n. 17
0
def count_transactions_between():
    try:
        start_date, end_date = view.get_inputs(["start date", "end date"])
        if date_correct_input(start_date) or date_correct_input(end_date):
            transactions = sales.read_data_from_file()
            view.print_general_results(
                len(
                    transactions_between_dates(start_date, end_date,
                                               transactions)),
                f"Number of transactions between {start_date} and {end_date}")
    except ValueError:
        view.print_error_message("Date in invalid format")
Esempio n. 18
0
def count_employees_with_clearance():
    view.print_message("")
    counter = 0
    while counter < 1:
        user_input = view.get_input("Please enter the clearance value: ")
        if int(user_input) not in range(0,8):
            view.print_message("Invalid input")
        else:
            counter = counter + 1           
    if hr.count_employees_clearance1(user_input) == False:
        view.print_message(f"There are no employees with level {user_input} clearance.")
    else:
        view.print_message("")
        view.print_error_message(f"There are {hr.count_employees_clearance1(user_input)} employees with level {user_input} clearance.")    
Esempio n. 19
0
def delete_transaction():
    view.clear_console()
    transactions = sales.read()
    view.print_table(transactions, sales.HEADERS)
    index = view.get_input('Provide a valid transactions id to delete profile: ')
    choices = range(len(transactions))
    choices = map(lambda x: str(x + 1), choices)
    while index not in choices:
        view.print_error_message("Incorrect value. Try again!")
        index = view.get_input('Provide a valid transactions id to update profile: ')
    transactions.pop(int(index) - 1)
    sales.create(transactions)
    view.print_message(view.color_sentence(Fore.GREEN, "Transaction was deleted."))
    view.wait_for_reaction()
def update_transaction():
    user_input = view.get_input("Transaction ID / or 'quit'")
    user_wants_to_quit = False
    while not __is_transaction_to_update_valid(
            user_input) and not user_wants_to_quit:
        view.print_error_message(
            "Error: Invalid input for Transaction to update")
        user_input = view.get_input("Transaction ID / or 'quit'")
        if user_input == 'quit':
            user_wants_to_quit = True
    transaction_id_to_update = user_input

    new_transaction = []
    new_transaction.append(transaction_id_to_update)
    new_transaction.append(view.get_input("Customer"))
    new_transaction.append(view.get_input("Product"))

    user_input = view.get_input("Price")
    while not __is_transaction_price_valid(user_input):
        view.print_error_message("Error: Invalid input for Price")
        user_input = view.get_input("Price")
    new_transaction.append(user_input)

    user_input = view.get_input("Date i.e. 1989-03-21")
    while not __is_transaction_date_format_valid(user_input):
        view.print_error_message("Error: Invalid input for Date")
        user_input = view.get_input("Date i.e. 1989-03-21")
    new_transaction.append(user_input)

    if sales.update_transaction(new_transaction):
        view.print_message("Transaction updated")
    else:
        view.print_error_message("Error while updating transaction!")
Esempio n. 21
0
def count_transactions_between():
    print("YYYY-MM-DD")
    starting_date, ending_date = view.get_inputs(TRANSACTION_DATES)
    starting_split = starting_date.split("-")
    ending_split = ending_date.split("-")
    int_starting_split = list(map(int, starting_split))
    int_ending_split = list(map(int, ending_split))
    starting_date_time = datetime(*int_starting_split)
    ending_date_time = datetime(*int_ending_split)
    if starting_date_time > ending_date_time:
        view.print_error_message("Invalid dates")
        count_transactions_between()
    else:
        print(sales.count_transactions(starting_date_time, ending_date_time))
def menu():
    operation = None
    while operation != '0':
        display_menu()
        try:
            operation = view.get_input(
                view.color_sentence(Fore.GREEN, "\nSelect an operation: "))
            run_operation(int(operation))
            view.wait_for_reaction()
        except KeyError:
            view.print_error_message("There is no such option.")
            view.wait_for_reaction()
        except ValueError:
            view.print_error_message("Please enter a number!")
            view.wait_for_reaction()
def delete_transaction():
    user_input = view.get_input("Transaction ID / or 'quit'")
    user_wants_to_quit = False
    while not __is_transaction_to_delete_valid(
            user_input) and not user_wants_to_quit:
        view.print_error_message(
            "Error: Invalid input for Transaction to update")
        user_input = view.get_input("Transaction ID / or 'quit'")
        if user_input == 'quit':
            user_wants_to_quit = True
    transaction_id_to_delete = user_input

    if sales.delete_transaction(transaction_id_to_delete):
        view.print_message("Transaction deleted")
    else:
        view.print_error_message("Error while deleting transaction!")
Esempio n. 24
0
def update_customer():

    customer_id = view.get_input("Please input user ID")
    table = [
        "", "Please provide name", "Please provide email",
        "Please provide subscription status"
    ]

    if crm.is_id_in_base(customer_id):
        [table[NAME_INDEX], table[EMAIL_INDEX],
         table[SUBSCRIPTION_INDEX]] = view.get_inputs([
             table[NAME_INDEX], table[EMAIL_INDEX], table[SUBSCRIPTION_INDEX]
         ])
        crm.update_customers(customer_id, table)
    else:
        view.print_error_message("There is no such id in the base.")
Esempio n. 25
0
def delete_transaction():
    delete_id = view.get_input(
        "Please choose a transaction ID you want to delete")

    try:
        index, product_list = sales.look_for_product_list(delete_id)
        print(*product_list)
        check_answer = view.get_input(
            "Are you sure you want delete this transaction?")
        if check_answer == "yes":
            sales.delete_transaction(index)
        else:
            delete_transaction()
    except:
        view.print_error_message("Invalid ID")
        delete_transaction()
Esempio n. 26
0
def add_customer():
    table = [
        "", "Please provide name", "Please provide email",
        "Please provide subscription status"
    ]

    [table[NAME_INDEX], table[EMAIL_INDEX],
     table[SUBSCRIPTION_INDEX]] = view.get_inputs(
         [table[NAME_INDEX], table[EMAIL_INDEX], table[SUBSCRIPTION_INDEX]])

    if len(table[NAME_INDEX]
           ) < 4 or "@" not in table[EMAIL_INDEX] or "." not in table[
               EMAIL_INDEX] or table[SUBSCRIPTION_INDEX] not in ["0", "1"]:
        view.print_error_message("The entered data was incorrect!")
    else:
        crm.create_customer(table)
Esempio n. 27
0
def update_transaction():
    view.print_error_message("Not implemented yet.")
    with open("/Documents/erp/model/sales.csv", "w") as fil:
        find_id = input("Enter the id")
        for line in fil:
            if find_id in line:
                headers_element = input("Enter a number from 1 to 4")
                update = input("Enter the changes")
                if headers_element == "1":
                    line[1] = headers_element
                elif headers_element == "2":
                    line[2] = headers_element
                elif headers_element == "3":
                    line[3] = headers_element
                elif headers_element == "4":
                    line[4] = headers_element
    return fil
Esempio n. 28
0
def delete_transaction():
    view.print_message("Delete transaction.")
    transaction_id = view.get_input("Provide transaction ID")
    if view.get_input("Type 'yes' to confirm deletion").lower() == 'yes':
        view.print_message(f"Transaction {transaction_id} succesfully deleted.") if sales.remove_transaction(transaction_id) \
            else view.print_error_message(f"Transaction of ID {transaction_id} does not exist.")
    else:
        view.print_message("Delete cancelled")
Esempio n. 29
0
def update_employee():
    transaction_id = view.get_input(
        "Please choose a employee ID you want to update")

    try:
        index, product_list = hr.show_employee(transaction_id)
        print(*product_list)
        change_info = view.get_input(
            "Please choose what you want to change in the information").lower(
            )
        if change_info in UPDATE_OPTIONS:
            new_info = view.get_input("Enter new information")
            hr.update_element(index, UPDATE_OPTIONS[change_info], new_info)

    except:

        view.print_error_message("Invalid ID")
        update_employee()
Esempio n. 30
0
def delete_employee():

    delete_id = view.get_input(
        "Please choose a transaction ID you want to delete")
    try:

        index, product_list = hr.show_employee(delete_id)
        print(*product_list)
        check_answer = view.get_input(
            "Are you sure you want delete this transaction?").lower()
        if check_answer == "yes":
            hr.delete_employee(index)
        else:
            view.print_menu()
    except:

        view.print_error_message("Invalid ID")
        view.print_menu()