예제 #1
0
def add_order():
    insert_dict = {}
    for column in oc.get_columns():
        if column != "_id" and column != "id":
            if column == "customer_info":
                value = {}
                value["first_name"] = input('first_name : ')
                value["last_name"] = input('last_name: ')
                value["address"] = input('address: ')
                value["phone"] = input('phone: ')
            elif column == "products":
                running = True
                value = []
                while running:
                    dict_values = {
                        "product_name": input('product_name: '),
                        "retail_price": int(input('retail_price: ')),
                    }
                    value.append(dict_values)
                    print('Do you want to add more products?\n'
                          '1: Yes\n'
                          '2: No')
                    if int(f_input()) == 1:
                        continue
                    else:
                        running = False
            else:
                value = input(f'{column}: ')

            insert_dict[column] = value
    divider()

    order = oc.add_order(insert_dict)
    if order is not None:
        print_tablerow(order)
예제 #2
0
def delete_product_by_id():
    print("Enter a product id to delete product")
    p_id = f_input()
    deleted = pc.delete_product(p_id)
    if deleted:
        print(f'Product {p_id} was successfully deleted')
    divider()
예제 #3
0
def add_product():
    insert_dict = {}
    for column in pc.get_columns():
        if column != "_id" and column != "id":
            # hook up associates
            # hook up storage info
            # empty orders []
            if column == 'associate':
                value = choose_associate()
            elif column == 'storage_info':
                value = {}
                value["shop_id"] = choose_shop()
                value["product_amount"] = input('product amount: ')
                value["min_amount"] = input('minimum amount: ')
                value["reorder_amount"] = input('re-order amount: ')
                value["internal_order"] = []
            elif column == 'orders':
                value = []
            else:
                value = input(f'{column}: ')

            insert_dict[column] = value
    divider()

    product = pc.add_product(insert_dict)
    if product is not None:
        print_tablerow(product)
예제 #4
0
def add_car():
    insert_dict = {}
    for column in cc.get_columns():
        if column != "_id":
            insert_dict[column] = input(f'{column}: ')

    car = cc.add_car(insert_dict)
    if car:
        print_tablerow(car)
        divider()
        return car
예제 #5
0
def add_shop():
    insert_dict = {}
    for column in sc.get_columns():
        if column != '_id' and column != 'id':
            if column == 'employees':
                value = []
            else:
                value = input(f'{column}: ')
            insert_dict[column] = value
    divider()
    sc.add_shop(insert_dict)
예제 #6
0
def add_employee():
    get_all_shops()
    print('============================================')
    print('Enter a shop id to add employee to that shop')
    s_id = f_input()
    insert_dict = {}
    for column in ec.get_columns():
        if column == 'shop_id':
            insert_dict['shop_id'] = s_id
        elif column != '_id':
            insert_dict[column] = input(f'{column}: ')
    divider()

    employee = ec.add_employee(insert_dict)
    value = employee._id
    if employee is not None:
        shop = sc.get_shop_by_id(s_id)
        sc.update_shop_column(shop, 'employees', value)
예제 #7
0
def add_customer():
    insert_dict = {}
    for column in cc.get_columns():
        if column != "_id" and column != "id":
            if column == "cars":
                value = choose_cars()
            elif column == "address_info":
                value = {}
                value["address_line_one"] = input('address_line_one: ')
                value["address_line_two"] = input('address_line_two: ')
                value["zip_code"] = input('zip_code: ')
                value["country"] = input('country: ')
            elif column == "orders":
                value = []
            else:
                value = input(f'{column}: ')

            insert_dict[column] = value
    divider()

    customer = cc.add_customer(insert_dict)
    if customer is not None:
        print_tablerow(customer)
예제 #8
0
def get_product_by_id():
    print("Enter a Product Id")
    p_id = f_input()
    product = pc.get_product_by_id(p_id)
    print_tablerow(product)
    divider()