Exemplo n.º 1
0
def fetch_vendor_payment_info(vendor_id):
    home_page_info = {}
    records = conn.execute(vsq.vendor_query_1.format(vendor_id))
    vendor_info = helpers.generate_json_results(records)[0]
    vendor_name = vendor_info[constants.VENDOR_NAME]
    home_page_info['vendor_name'] = str(vendor_name)
    records = conn.execute(vsq.vendor_query_3.format(vendor_id))
    payment_info = helpers.generate_json_results(records)[0]
    type = payment_info['type']
    home_page_info['type'] = str(type)
    account_name = payment_info['account_name']
    if account_name == "":
        account_name = "NA"
    home_page_info['account_name'] = str(account_name)
    account_number = payment_info['account_number']
    if account_number == "":
        account_number = "NA"
    home_page_info['account_number'] = str(account_number)
    routing_number = payment_info['routing_number']
    if routing_number == "":
        routing_number = "NA"
    home_page_info['routing_number'] = str(routing_number)
    paypal_id = payment_info['paypal_id']
    if paypal_id == "":
        paypal_id = "NA"
    home_page_info['paypal_id'] = str(paypal_id)
    venmo_id = payment_info['venmo_id']
    if venmo_id == "":
        venmo_id = "NA"
    home_page_info['venmo_id'] = str(venmo_id)
    return home_page_info
Exemplo n.º 2
0
def fetch_admin_home_info(admin_id):
    records = conn.execute(sq.admin_query_1.format(admin_id))
    home_page_info = {}
    products = helpers.generate_json_results(records)
    home_page_info['products'] = products

    records = conn.execute(sq.admin_query_19.format(admin_id))
    ordered_products = helpers.generate_json_results(records)
    home_page_info['ordered_products'] = ordered_products

    records = conn.execute(sq.admin_query_2.format(admin_id))
    admin_info = helpers.generate_json_results(records)[0]
    admin_name = admin_info[constants.ADMIN_NAME]

    records = conn.execute(sq.admin_query_3.format(id=admin_id))
    budget_info = helpers.generate_json_results(records)[0]

    home_page_info['total_budget'] = float(budget_info[constants.BUDGET])
    if budget_info['remaining_balance']:
        home_page_info['remaining_budget'] = float(
            budget_info['remaining_balance'])
    else:
        home_page_info['remaining_budget'] = float(
            budget_info[constants.BUDGET])
    home_page_info['admin_name'] = str(admin_name)

    return home_page_info
Exemplo n.º 3
0
def fetch_vendor_home_info(vendor_id):
    home_page_info = {}
    records = conn.execute(vsq.vendor_query_2.format(vendor_id))
    products = helpers.generate_json_results(records)
    home_page_info['products'] = products
    records = conn.execute(vsq.vendor_query_1.format(vendor_id))
    vendor_info = helpers.generate_json_results(records)[0]
    vendor_name = vendor_info[constants.VENDOR_NAME]
    home_page_info['vendor_name'] = str(vendor_name)
    return home_page_info
Exemplo n.º 4
0
def fetch_vendor_invoice_info(vendor_id, invoice_id):
    records = conn.execute(vsq.vendor_query_8.format(vendor_id, invoice_id))
    invoice = helpers.generate_json_results(records)[0]

    invoice['date_placed'] = invoice['date_placed'].strftime("%m/%d/%Y  %H:%M:%S")
    records = conn.execute(vsq.vendor_query_9.format(invoice['admin_id']))
    warehouse_info = helpers.generate_json_results(records)[0]

    records = conn.execute(vsq.vendor_query_10.format(vendor_id))
    vendor_info = helpers.generate_json_results(records)[0]
    return {'order_info': invoice, 'warehouse_info': warehouse_info, 'vendor_info': vendor_info}
Exemplo n.º 5
0
def fetch_admin_budget_info(admin_id):
    info = {}
    records = conn.execute(sq.admin_query_2.format(admin_id))
    admin_info = helpers.generate_json_results(records)[0]
    admin_name = admin_info[constants.ADMIN_NAME]

    records = conn.execute(sq.admin_query_3.format(id=admin_id))
    budget_info = helpers.generate_json_results(records)[0]

    info['total_budget'] = float(budget_info[constants.BUDGET])
    if budget_info['remaining_balance']:
        info['remaining_budget'] = float(budget_info['remaining_balance'])
        info['admin_name'] = str(admin_name)
    else:
        info['remaining_budget'] = float(budget_info[constants.BUDGET])
        info['admin_name'] = str(admin_name)
    return info
Exemplo n.º 6
0
def fetch_brand_info(category):
    records = conn.execute(sq.admin_query_11.format(category))
    brands = helpers.generate_json_results(records)
    brand_info = []
    for brand in brands:
        info = {"id": brand['brand'], "name": brand['brand']}
        brand_info.append(info)
    return brand_info
Exemplo n.º 7
0
def fetch_product_drop_down_info(category, brand):
    records = conn.execute(sq.admin_query_12.format(category, brand))
    products = helpers.generate_json_results(records)
    product_list = []
    for product in products:
        info = {"id": product['product_name'], "name": product['product_name']}
        product_list.append(info)
    return product_list
Exemplo n.º 8
0
def fetch_category_drop_down_info():
    records = conn.execute(sq.admin_query_17)
    categories = helpers.generate_json_results(records)
    category_list = []
    for category in categories:
        info = {"id": category['category'], "name": category['category']}
        category_list.append(info)
    return category_list
Exemplo n.º 9
0
def fetch_vendor_drop_down_info(category, brand, product_name):
    records = conn.execute(
        sq.admin_query_13.format(category, brand, product_name))
    vendors = helpers.generate_json_results(records)
    vendor_list = []
    for vendor in vendors:
        val = vendor['vendor_name'] + " | Qt:" + str(
            vendor['quantity']) + " | Price:" + str(vendor['price'])
        info = {
            "id":
            val + "|" + vendor['product_id'] + "|" +
            vendor['vendor_product_id'] + "|" + vendor['vendor_id'],
            "name":
            val
        }
        vendor_list.append(info)
    return vendor_list
Exemplo n.º 10
0
def fetch_vendor_info(vendor_id):
    home_page_info = {}
    records = conn.execute(vsq.vendor_query_1.format(vendor_id))
    vendor_info = helpers.generate_json_results(records)[0]
    vendor_name = vendor_info[constants.VENDOR_NAME]
    home_page_info['vendor_name'] = str(vendor_name)
    vendor_id = vendor_info[constants.VENDOR_ID]
    home_page_info['vendor_id'] = str(vendor_id)
    mobile = vendor_info[constants.MOBILE]
    home_page_info['mobile'] = str(mobile)
    email = vendor_info[constants.EMAIL]
    home_page_info['email'] = str(email)
    address_id = vendor_info[constants.ADDRESS_ID]
    home_page_info['address_id'] = str(address_id)
    street = vendor_info['vendor_street']
    home_page_info['street'] = str(street)
    city = vendor_info['vendor_city']
    home_page_info['city'] = str(city)
    state = vendor_info['vendor_state']
    home_page_info['state'] = str(state)
    zip = vendor_info['vendor_zipcode']
    home_page_info['zip'] = str(zip)
    return home_page_info
Exemplo n.º 11
0
def generate_order(admin_id, product_id, vendor_product_id, vendor_id,
                   quantity, total_amount):
    """ Update vendor product info(quantity) after order is placed.

    :return:
    """
    invoice_id = uuid.uuid4().hex
    records = conn.execute(sq.admin_query_14.format(admin_id))
    warehouse_id = helpers.generate_json_results(records)[0]['warehouse_id']
    payment_status = "in progress"
    current_time = datetime.datetime.now()
    date_placed = current_time.strftime("%Y-%m-%d %H:%M:%S")
    conn.execute(
        sq.admin_query_15.format(invoice_id=invoice_id,
                                 admin_id=admin_id,
                                 vendor_id=vendor_id,
                                 warehouse_id=warehouse_id,
                                 product_id=product_id,
                                 payment_status=payment_status,
                                 price=total_amount,
                                 quantity=quantity,
                                 date_placed=date_placed))
    conn.execute(sq.admin_query_16.format(quantity, vendor_product_id))
    return invoice_id
Exemplo n.º 12
0
def fetch_vendor_order_history(vendor_id):
    records = conn.execute(vsq.vendor_query_6.format(vendor_id))
    order_history = helpers.generate_json_results(records)
    return order_history
Exemplo n.º 13
0
def get_product_id(name, category, brand):
    records =conn.execute(vsq.vendor_query_11.format(category=category, product_name=name, brand=brand))
    product_info = helpers.generate_json_results(records)[0]
    product_id = product_info['product_id']
    return product_id
Exemplo n.º 14
0
def fetch_order_history(admin_id):
    records = conn.execute(sq.admin_query_6.format(admin_id))
    order_history = helpers.generate_json_results(records)
    return order_history
Exemplo n.º 15
0
def fetch_admin_info(admin_id):
    records = conn.execute(sq.admin_query_5.format(admin_id))
    admin_info = helpers.generate_json_results(records)[0]
    admin_info['dob'] = admin_info['dob'].strftime("%m/%d/%Y")
    return admin_info
Exemplo n.º 16
0
def fetch_product_info(product_id):
    records = conn.execute(sq.admin_query_7.format(product_id))
    product_info = helpers.generate_json_results(records)
    return product_info[0]
Exemplo n.º 17
0
def fetch_order_home_info():
    records = conn.execute(sq.admin_query_4)
    products = {'products': helpers.generate_json_results(records)}
    return products