コード例 #1
0
def add_transaction():
    # view.print_error_message("Not implemented yet.")
    '''cześć potrzebna gdy już bedzie działał crm'''
    matching_customers_names_list = []
    while matching_customers_names_list == []:
        partial_customer_name = view.get_input("Enter name or part of customer's name")
        matching_customers_names_list = get_matching_names(partial_customer_name)
        if matching_customers_names_list == None:
            return
    
    insert_exit_option(matching_customers_names_list)
    view.print_menu("Matching customers names", matching_customers_names_list)
    customer_number = int(view.get_input("Choose the customer to add transaction on it"))
    if customer_number == 0:
        return
    customer_name = matching_customers_names_list[customer_number]
    # # funkcja która dostaje nazwę klienta i zwraca jego id
    customer_id = crm.find_customer_id(customer_name)

    new_transaction_data = view.get_inputs(sales.HEADERS[sales.PRODUCT_INDEX:]) 
    new_transaction_data.insert(0,customer_id)
    
        
    new_transaction = sales.create_new_transaction(new_transaction_data)
    # print(new_transaction)
    view.print_message("New transaction has been added")
    view.print_table([new_transaction],sales.HEADERS)
コード例 #2
0
ファイル: sales_controller.py プロジェクト: mimik91/CodeCool
def update_transaction():
    HEADERS = ["record_id", "Customer", "Product", "Price", "Date"]
    labels = view.get_inputs(HEADERS)
    table = sales.modify_item(labels[0], labels[1], labels[2], labels[3],
                              labels[4])
    table.insert(0, sales.HEADERS)
    view.print_table(table)
コード例 #3
0
def update_employee():
    list_employees()
    view.print_message("Update employee.")
    updated_employee_id = view.get_input("Provide employee ID: ")
    updated_employee_data = view.get_inputs([hr.HEADERS[hr.NAME_INDEX], hr.HEADERS[hr.DATE_OF_BIRTH_INDEX], hr.HEADERS[hr.DEPARTMENT_INDEX], hr.HEADERS[hr.CLEARANCE_INDEX]])
    hr.update_employee(updated_employee_id, updated_employee_data)
    view.print_message("Employee updated!")
コード例 #4
0
ファイル: hr_controller.py プロジェクト: mimik91/CodeCool
def update_employee():
    HEADERS = ["Id", "Name", "Date of birth", "Department", "Clearance"]
    labels = view.get_inputs(HEADERS)
    table = hr.update_data(labels[0], labels[1], labels[2], labels[3],
                           labels[4])
    table.insert(0, hr.HEADERS)
    view.print_table(table)
コード例 #5
0
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")
コード例 #6
0
ファイル: sales_controller.py プロジェクト: mimik91/CodeCool
def add_transaction():
    HEADERS = ["Customer", "Product", "Price", "Date"]
    id_number = util.generate_id()
    labels = view.get_inputs(HEADERS)
    table = sales.create_item(id_number, labels[0], labels[1], labels[2],
                              labels[3])
    table.insert(0, sales.HEADERS)
    view.print_table(table)
コード例 #7
0
ファイル: hr_controller.py プロジェクト: mimik91/CodeCool
def add_employee():
    HEADERS = ["Name", "Date of birth", "Department", "Clearance"]
    id_number = util.generate_id()
    labels = view.get_inputs(HEADERS)
    table = hr.create_data(id_number, labels[0], labels[1], labels[2],
                           labels[3])
    table.insert(0, hr.HEADERS)
    view.print_table(table)
コード例 #8
0
def add_customer():
    new_customer_input = view.get_inputs([
        "Please provide new user name: ",
        "Please provide new user e-mail address: ",
        "Please provide 1 if subscribed, 0 if not: "
    ])
    crm.adding_new_customer(new_customer_input)
    view.print_message("Successfully added customer!")
コード例 #9
0
def add_employee():
    new_employee = view.get_inputs([
        "Enter new employee's name",
        "Enter new employee's birth date",
        "Specify new employee's department",
        "Specify new employee's clearance level"
    ])
    hr.create_new_employee(new_employee)
コード例 #10
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!')
コード例 #11
0
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")
コード例 #12
0
ファイル: sales_controller.py プロジェクト: imarcins/ERP
def add_transaction():
    #print(write_table_to_file(sales.csv, table, separator=';'))

    customer_id, product_name, price = view.get_inputs(TRANSACTION_LABELS)
    try:
        price = float(price)
    except ValueError:
        print("You can only use numbers")
        add_transaction()
    sales.add_transaction(customer_id, product_name, price)
コード例 #13
0
def add_transaction():
    view.print_message("Enter a new transaction into the database\n ")
    questions = [
        "Please enter customer id: ", "Please enter product name: ",
        "Please enter price value: ",
        "Please enter date of transaction(YYYY-MM-DD): "
    ]
    new_transaction = view.get_inputs(questions)
    sales.insert_data(new_transaction)
    view.print_message("Successfully added transaction!")
コード例 #14
0
ファイル: hr_controller.py プロジェクト: imarcins/ERP
def add_employee():
    # u_id = "Please write an Id: "
    # generate_id = view.get_input(u_id)

    new_line = view.get_inputs([
        "Please write an ID: ", "Please write a name: ",
        "Please write date of birth: ", "Please write a department: ",
        "Please write a clarence: "
    ])
    hr.add_employee(new_line)
コード例 #15
0
def add_employee():
    view.print_message("Enter a new employee into the database\n")
    questions = [
        "Enter new employee's name: ",
        "Enter new employee's birth date(YYYY-MM-DD): ",
        "Specify new employee's department: ",
        "Specify new employee's clearance level: "
    ]
    new_employee = view.get_inputs(questions)
    hr.create_new_employee(new_employee)
    view.print_message("Successfully added employee!")
コード例 #16
0
def sum_transactions_between():
    start_date, end_date = view.get_inputs(["start date", "end date"])
    transactions = sales.read_data_from_file()
    price_index = sales.HEADERS.index("Price")
    transactions_price = [
        float(element[price_index]) for element in transactions_between_dates(
            start_date, end_date, transactions)
    ]
    prices_sum = sum(transactions_price)
    view.print_general_results(
        prices_sum, f"Sum of transactions between {start_date} and {end_date}")
コード例 #17
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")
コード例 #18
0
def add_employee():
    hr_table = hr.data_manager.read_table_from_file(hr.DATAFILE)
    add_input_labels = hr.HEADERS
    view.print_table(hr_table)
    all_inputs = view.get_inputs(add_input_labels)
    for item in all_inputs:
        if item == "PLACEHOLDER":
            item = hr.util.generate_id()
            all_inputs[0] = hr.util.generate_id()
    hr_table.append(all_inputs)
    hr.data_manager.write_table_to_file(hr.DATAFILE, hr_table)
    return add_input_labels
コード例 #19
0
def add_customer():
    customer_table = crm.data_manager.read_table_from_file(crm.DATAFILE)
    add_input_labels =  crm.HEADERS
    view.print_table(customer_table)
    all_inputs = view.get_inputs(add_input_labels)
    for item in all_inputs:
        if item == "PLACEHOLDER":
            item = crm.util.generate_id()
            all_inputs[0] = crm.util.generate_id()
    customer_table.append(all_inputs)
    crm.data_manager.write_table_to_file(crm.DATAFILE,customer_table)
    return add_input_labels
コード例 #20
0
def sum_transactions_between():
    date_labels = [
        "Please enter date to sum transactions from (i.e. YYYY-MM-DD): ",
        "Please enter date to sum transactions to (i.e. YYYY-MM-DD): "
    ]
    time_frame = view.get_inputs(date_labels)
    date_from, date_to = time_frame[0], time_frame[1]
    summed_transactions = sales.find_sum_transactions_between(
        date_from, date_to)
    view.print_general_results(
        summed_transactions,
        f"Sum of transactions between {date_from} to {date_to} equals")
コード例 #21
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")
コード例 #22
0
def add_customer():
    '''Creates the new customer in the dataset.'''
    PREFIX = "New Customer"

    # prepares labels to ask User about the new customer data
    labels = (f"{PREFIX} {HEADERS[HEADER_NAME]}",
              f"{PREFIX} {HEADERS[HEADER_EMAIL]}",
              f"{PREFIX} {HEADERS[HEADER_SUBSCRIBE]}")

    customer_data = view.get_inputs(labels)
    crm.create_item(customer_data)

    view.print_general_results(customer_data, "New Customer added")
コード例 #23
0
ファイル: sales_controller.py プロジェクト: imarcins/ERP
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))
コード例 #24
0
def count_transactions_between():
    date_labels = [
        "Please enter date to count from (i.e. YYYY-MM-DD): ",
        "Please enter date to count to (i.e. YYYY-MM-DD): "
    ]
    time_frame = view.get_inputs(date_labels)
    date_from, date_to = time_frame[0], time_frame[1]
    transactions_between = sales.find_transactions_between(date_from, date_to)
    if len(transactions_between) > 1:
        view.print_message(f"\nTransactions between {date_from} to {date_to}")
        view.print_table(sales.HEADERS, transactions_between)
    else:
        view.print_general_results(
            transactions_between,
            f"Transaction between {date_from} to {date_to}")
コード例 #25
0
def update_customer():
    '''Updates informations of the customer in the dataset.'''
    PREFIX = "Update"
    SUFIX = "(empty -> no change)"

    # prepares labels to ask User about the new customer data
    labels = (f"Enter Customer {HEADERS[HEADER_ID]} to make changes",
              f"{PREFIX} {HEADERS[HEADER_NAME]} {SUFIX}",
              f"{PREFIX} {HEADERS[HEADER_EMAIL]}{SUFIX}",
              f"{PREFIX} {HEADERS[HEADER_SUBSCRIBE]}{SUFIX}")

    data_to_update = view.get_inputs(labels)
    crm.update_item(data_to_update)

    view.print_message(f"Customer '{data_to_update[HEADER_ID]}' updated")
コード例 #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)
コード例 #27
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.")
コード例 #28
0
def get_input_from_user(mode):
    text = {
        "add": [
            "name",
            "birth date",
            "department",
            "clearance"
            ],
        "update": [
            "new name",
            "new birth date",
            "new department",
            "new clearance"
            ]
    }
    return view.get_inputs(text[mode])
コード例 #29
0
def add_transaction():
    view.print_message("New transaction: ")
    customer_id = view.get_input(f"{sales.HEADERS[customer_index]}")
    if not any(customer_id in customers[id_index]
               for customers in crm.CUSTOMERS):
        answer = view.get_input(
            "Given customer does not exist. Type 'Y' to create").upper()
        if answer == "Y":
            view.print_message("Add customer")
            new_customer = crm_controller.add_customer()
            customer_id = new_customer[id_index]
            view.print_message(
                f"New customer generated with random id of {customer_id}")
    values = view.get_inputs(sales.HEADERS[product_index:])
    sales.add_transaction([customer_id, *values])
    view.print_message("Transaction added!")
コード例 #30
0
ファイル: crm_controller.py プロジェクト: imarcins/ERP
def update_customer():
    update_labels = ["customer index", "data index", "new info"]
    update_info = view.get_inputs(update_labels)
    crm.update_customer(update_info)