Esempio n. 1
0
def register_product(catalog):

    header('Product Registration')

    # title, category, stock, price
    try:

        title = input('Enter product name: ')
        category = input('Enter category: ')
        stock = int(input('Enter amount in stock: '))
        price = float(input('Enter price: $'))

        next_id = 1
        if len(catalog) > 0:
            # ID generation = next_id
            next_id = catalog[-1].id + 1

        new_product = Product(next_id, title, category, stock, price)

        catalog.append(new_product)

    except:
        print('\n****ERROR REGISTERING PRODUCT****\n')
        print('Please do not enter numbers for names, or words for numbers')
        choice = input('Press Enter to continue, or `x` to quit.....')
        if (choice != 'x'):
            register_product(catalog)
        else:
            return

    print('\nProduct: ' + new_product.title + ' registered')

    return catalog
Esempio n. 2
0
def display_out_of_stock():
    """ Display out of catalog """
    cls()
    header("Out of stock")
    for p in CATALOG:
        if p.Stock == 0:
            product_info(p)
    input("Press Enter to continue...")
Esempio n. 3
0
def display_catalog(wait=True):
    """ Display catalog in screen """
    cls()
    header("Cataglog")
    for p in CATALOG:
        product_info(p)

    if wait:
        input("Press Enter to continue...")
def display_not_stock():
    size = len(catalog)
    header("Out of Stock (" + str(size) + "items)")
    for item in catalog:
        if (item.stock == 0):
            print("|" + str(item.id).rjust(2) + " | " + item.title.ljust(20) +
                  "|" + item.category.ljust(15) + "|" +
                  str(item.price).rjust(10) + "|" + str(item.stock).rjust(5) +
                  "|")
Esempio n. 5
0
def total_stock_value():
    """ Calc the total stock value """

    header('Total Stock value')
    total = 0
    for prod in CATALOG:
        total += prod.Price * prod.Stock

    print('Total stock value: $', total)
    input("Press Enter to continue . . .")
Esempio n. 6
0
def find_unique_categories():

    header('Unique Product Categories')
    category_list = []

    for product in catalog:
        category_list.append(product.category)
        unique = set(category_list)

    print(unique)
Esempio n. 7
0
def display_out_of_stock(file_name):

    header('Products out of stock')

    out_of_stock_products = []

    print('Out of Stock: ')
    for product in catalog:
        if product.stock == 0:
            out_of_stock_products.append(product)
            print(f'{out_of_stock_products[0].title: ^10}')
Esempio n. 8
0
def total_stock_value(file_name):

    header('Total Stock Value')

    total_value = 0

    for product in catalog:
        if product.stock != 0:
            price_times_stock = product.price * product.stock
            total_value += price_times_stock

    print('Total stock value: ${}\n'.format(total_value))
Esempio n. 9
0
def show_catalog(catalog):
    header('REGISTERED PRODUCTS')
    for product in catalog:

        print(product.title + ':')
        print('    Id: ' + str(product.id))
        print('    Price: ' + str(product.price))
        print('    Quantity: ' + str(product.stock))
        print('    Category: ' + str(product.category))
        print('\n')
        '''print(f"Id: {product.id} | Title: {product.title} | Category: {product.category} | Stock: {product.stock} | Price: {product.price}") '''

    print('\n')
Esempio n. 10
0
def display_catalog():
    size = len(catalog)
    header("Current Catalog (" + str(size) + " items)")

    print("|" + 'ID'.rjust(3) + "|" + 'Title'.ljust(30) + "|" +
          'Category'.ljust(15) + "|" + 'Price'.rjust(10) + "|" +
          'Stock'.rjust(5) + "|")
    print("-" * 70)

    for item in catalog:
        print("|" + str(item.id).rjust(3) + "|" + item.title.ljust(30) + "|" +
              item.category.ljust(15) + "|" + str(item.price).rjust(10) + "|" +
              str(item.stock).rjust(5) + "|")
        print("-" * 70)
Esempio n. 11
0
def show_catalog(catalog):
    header('REGISTERED PRODUCTS')
    for product in catalog:
        
        '''print(product.title + ':')
        print('    Id: ' + str(product.id))
        print('    Price: ' + str(product.price))
        print('    Quantity: ' + str(product.stock))
        print('    Category: ' + str(product.category))
        print('\n')'''
        

        print(f"Id: {product.id: <10}  Title: {product.title: <15}  Category: {product.category: <20}  Stock: {product.stock: <15}  Price: {product.price}") 

    print('\n')
Esempio n. 12
0
def show_catalog(catalog, text_to_display='Current Catalog'):
    header(text_to_display)
    for product in catalog:
        '''print(product.title + ':')
        print('    Id: ' + str(product.id))
        print('    Price: ' + str(product.price))
        print('    Quantity: ' + str(product.stock))
        print('    Category: ' + str(product.category))
        print('\n')'''

        print(
            f"Id: {product.id: <10}  Title: {product.title: <15}  Category: {product.category: <20}  Stock: {product.stock: <15}  Price: ${product.price}"
        )

    print('\n')
def display_catalog():
    size = len(catalog)
    header("Current Catalog(" + str(size) + "items")

    print("|" + "ID".rjust(2) + " | " + "Title".ljust(20) + " | " +
          "Category".ljust(15) + " | " + "Price".rjust(10) + " | " +
          "inventory".rjust(5) + "|")
    print("-" * 70)

    for item in catalog:
        print("|" + str(item.id).rjust(2) + " | " + item.title.ljust(20) +
              " | " + item.category.ljust(15) + " | " +
              str(item.price).rjust(10) + " | " +
              str(item.inventory).rjust(5) + "|")
    print("-" * 70)
Esempio n. 14
0
def list_of_categories():
    size = len(catalog)
    header('Current Categories (' + str(size) + ' items)')

    print(
        '|' + ' Categories'.ljust(1) + '|')
    print('-'*70)

    cat_list = []

    for item in catalog:
        if item.category not in cat_list:
            cat_list.append(item.category)
            print(item.category.ljust(15))

    print('-' * 70)
Esempio n. 15
0
def display_no_stock():
    size = len(catalog)
    header("Out of Stock (" + str(size) + " items)")

    print("|" + 'ID'.rjust(3) + "|" + 'Title'.ljust(30) + "|" +
          'Category'.ljust(15) + "|" + 'Price'.rjust(10) + "|" +
          'Stock'.rjust(5) + "|")
    print("-" * 70)

    for item in catalog:
        if (item.stock == 0):
            print("|" + str(item.id).rjust(3) + "|" + item.title.ljust(30) +
                  "|" + item.category.ljust(15) + "|" +
                  str(item.price).rjust(11) + "|" + str(item.stock).rjust(8) +
                  "|")
            print("-" * 70)
Esempio n. 16
0
def load_data(file_name):

    header('Product Counter')

    try:
        reader = open(file_name, 'rb')
        temporary_list = pickle.load(reader)

        for product in temporary_list:
            catalog.append(product)

        reader.close()

        print('Loaded: {} products'.format(len(catalog)))

    except:
        print("Error: File not accessable")
Esempio n. 17
0
def display_catalog():
    """ clear()
    print("-" *30)
    print("Current Catalog")
    print("-" *30) """
    """print("there are: "+ str(size) + "items") """
    
    size= len(catalog)
    header("Current Catalog ("+ str(size) + "items)")

    #print("-" * 70)
     print("|" +'ID'.rjust(2)
        + "|" + 'Title'.ljust(20)
        + "|" + 'Category'.ljust(15)
        + "|" + 'Price'.rjust(10)
        + "|" + 'Stock'.rjust(5)+ "|")
        print("-" * 70)
Esempio n. 18
0
def out_ofstock():
    size = len(catalog)
    header("Out of Stock(" + str(size) + "  items) ")

    #print(" " * 60)
    print("|" + 'ID'.rjust(2) + "|" + 'Title'.ljust(24) + "|" +
          'Category'.ljust(15) + "|" + 'Price'.rjust(10) + "|" +
          'Stock'.rjust(5) + "|")
    print("-" * 70)

    for item in catalog:
        if (item.stock == 0):
            print("|" + str(item.id).rjust(2) + "|" + item.title.ljust(24) +
                  "|" + item.category.ljust(15) + "|" +
                  str(item.price).rjust(10) + "|" + str(item.stock).rjust(5) +
                  "|")

    print("-" * 70)
Esempio n. 19
0
def register_product():
    """ Register product """
    global NEXT_ID
    cls()
    header("Register")
    title = input("Provide the title: ")
    category = input("Provide the category: ")

    try:
        stock = int(input("Provide the stock: "))
        price = float(input("Provide the price: "))

        product = Product(NEXT_ID, title, category, stock, price)
        NEXT_ID += 1
        CATALOG.append(product)
    except Exception:
        print('*** Unexpected format :/\n')
        input('Press Enter to continue ...')
Esempio n. 20
0
def find_cheapest_product(file_name):

    header('Cheapest Product')

    cheapest_product = [catalog[0]]

    for product in catalog:
        if product.price < cheapest_product[0].price:
            cheapest_product.clear()
            cheapest_product.append(product)

        elif product.price == cheapest_product[
                0].price and product.title != cheapest_product[0].title:
            cheapest_product.append(product)

    print(
        f'Cheapest Item:\n\n  {cheapest_product[0].title: <5} | Price: {cheapest_product[0].price}\n\n'
    )
Esempio n. 21
0
def main():

    os.system("cls")

    header()
    user_prompt()

    choice = input(">>> ")
    if choice == "1":
        search_crypto()
    elif choice == "2":
        fiat_currency()
    elif choice  == "3":
        top_list()
    elif choice == "4":
        future_values()
    elif choice == "5":
        create_xlsx()
Esempio n. 22
0
def register_item():
    global last_id
    header("Register new Item:")

    title = input("New Item Title: ")
    category = input("New Item Category: ")
    price = float(input("New Item Price: "))
    stock = int(input("New Item Quantity:"))

    new_item = Item()  # <- create instances of a class (objects)
    last_id += 1  # No last_id++
    new_item.id = last_id
    new_item.title = title
    new_item.category = category
    new_item.price = price
    new_item.stock = stock

    catalog.append(new_item)
    print("Item created!")
def register_item():
    global last_id
    header("Register new item")

    title = input("New item name: ")
    category = input("Item's category: ")
    price = float(input("Price of item: "))
    inventory = int(input("Amount of items: "))

    new_item = Item()
    last_id += 1
    new_item.id = last_id
    new_item.title = title
    new_item.category = category
    new_item.price = price
    new_item.inventory = inventory

    catalog.append(new_item)
    add_log_event("New Item", "Added Item: ", +str(last_id))
    print("Item has been created...")
Esempio n. 24
0
def display_catalog():
    size = len(catalog)
    header('Current Catalog (' + str(size) + 'items)')

    print(
        '|' + 'ID'.rjust(2)
            + ' |' + ' Title'.ljust(27)
            + ' |' + ' Category'.ljust(15)
            + ' |' + ' Price'.ljust(10)
            + ' |' + ' Stock'.ljust(5) + '|')
    print('-'*70)

    for item in catalog:
        print(
            '|' + str(item.id).rjust(2)
            + ' |' + item.title.ljust(27)
            + ' |' + item.category.ljust(15)
            + ' |' + str(item.price).rjust(10)
            + ' |' + str(item.stock).rjust(5) + ' |')
    print('-' * 70)
Esempio n. 25
0
def register_item():
    global last_id
    header("Register new Item")

    title = input("New item title: ")
    cat = input("New item category: ")
    price = float(input("New item price: "))
    stock = int(input("New item stock: "))

    new_item = Item()  # <- create instances of a class (objects)
    last_id += 1
    new_item.id = last_id
    new_item.title = title
    new_item.category = cat
    new_item.price = price
    new_item.stock = stock

    catalog.append(new_item)
    add_log_event("NewItem", "Added item: " + str(last_id))
    print("Item created!")
Esempio n. 26
0
def register_item():
    global last_id
    header('Register new item')
    title = input('New item title: ')
    cat = input('New item category: ')
    price = float(input('New item price: '))
    stock = int(input('New item stock: '))

    new_item = Item()  # <- how you create instances of a class (objects)

    last_id += 1  # no last_id ++
    new_item.id = last_id
    new_item.title = title
    new_item.category = cat
    new_item.price = price
    new_item.stock = stock

    catalog.append(new_item)
    add_log_event('New Item', 'Added: ' + str(last_id))

    print("Item created!")
Esempio n. 27
0
def register_item():
    global last_id
    clear()
    header("Register an item")

    title = input("New item title: ")
    cat = input("New item category: ")
    price = float(input("New item price: "))
    stock = int(input("New item stock: "))        
            

    new_item = Item() # how to create new objects
    last_id += 1
    new_item.id = last_id
    new_item.title = title
    new_item.category = cat
    new_item.price = price
    new_item.stock = stock

    catalog.append(new_item)
    add_log_events("New Item", "Added item: " + str(last_id))
    print("Item created!")
Esempio n. 28
0
def register_item():
    """ clear()
    print("-" * 30)
    print(" Register New Item")
    print("-" * 30) """
    
    header(" Register new Item")

    title= input("New item title:    ")
    category = input ("New item category:   ")
    price= float(input ("New item price:   "))
    stock= int(input("New Item stock:    "))

    new_item = Item() #Create instances of a class (objects)
    new_item.id= 0
    new_item.title= title
    new_item.category= category
    new_item.price= price
    new_item.stock= stock

    catalog.append(new_item)
    print("Item created!")
Esempio n. 29
0
def display_oos():
    size = len(catalog)
    header('Out of stock items')

    print(
        '|' + 'ID'.rjust(2)
            + ' |' + ' Title'.ljust(27)
            + ' |' + ' Category'.ljust(15)
            + ' |' + ' Price'.ljust(10)
            + ' |' + ' Stock'.ljust(5) + '|')
    print('-'*70)

    for item in catalog:

        if (item.stock == 0):
            print(
                '|' + str(item.id).rjust(2)
                + ' |' + item.title.ljust(27)
                + ' |' + item.category.ljust(15)
                + ' |' + str(item.price).rjust(10)
                + ' |' + str(item.stock).rjust(5) + ' |')
        print('-' * 70)
def print_log():
    header("Logged Events")
    for entry in log:
        print(entry)