Beispiel #1
0
def input_range_option():
    print("Chose how would you like to specify range:")
    print("1) last month")
    print("2) last x months")
    print("3) x month")
    print("4) from x month to y month")
    print("5) from x month to y month in year z")
    print("6) last x days")

    from_date = datetime.now()
    to_date = datetime.now()
    option = safe_input("Choose option: ")

    if option == 1:
        from_date, to_date = core.last_months(1)
    elif option == 2:
        last_months = safe_input("Start from months ago: ")
        from_date, to_date = core.last_months(last_months)
    elif option == 3:
        month = safe_input("Month: ")
        from_date, to_date = core.from_to(month, month)
    elif option == 4:
        month_from = safe_input("From month: ")
        month_to = safe_input("To month: ")
        from_date, to_date = core.from_to(month_from, month_to)
    elif option == 5:
        month_from = safe_input("From month: ")
        month_to = safe_input("To month: ")
        year = safe_input("Year: ")
        from_date, to_date = core.from_to(month_from, month_to, year)
    elif option == 6:
        last_days = safe_input("Last days: ")
        from_date, to_date = core.last_days(last_days)

    return from_date, to_date
def main():
    print("SALES AND INVENTORY SYSTEM")
    print("""
Select an action

1. Register sale
2. Register product arrival
3. Query inventory data
4. Employees with most sales
""")

    while True:

        action = safe_input('int_positive', 'Action: ')

        if action > 0 and action < 9:
            break

        print("Oops! Try again with an action from 1 to 8")

    if action == 1:
        register_sale()
    elif action == 2:
        register_product_arrival()
    elif action == 3:
        query_inventory_data()
    elif action == 4:
        employees_with_most_sales()

    print("Thanks for using the system. Have a great day\n")
def register_product_arrival():
    """
    Register when a product has arrived. 
    This will update products.csv
    """

    print("--- Register product arrival ---\n")
    print("Which product is it?\n")

    menu = get_products()

    # display products to the user
    for thing in menu:
        print("- %s (%s)" % (thing['name'], thing['id']))
    print()

    chooosen_product = select_by_id_or_name(menu, 'product')

    print("Selected: %s (%s)\n" %
          (chooosen_product['name'], chooosen_product['id']))

    arrival_quantity = safe_input('int_positive', 'Recent arrival quantity:')
    print()

    chooosen_product['quantity'] += arrival_quantity

    # show feedback to the users
    print('OKAY. You\'ve registered %s items of %s' %
          (arrival_quantity, chooosen_product['name']))
    print('Now there are %s in stock' % chooosen_product['quantity'])

    update_products(menu)
Beispiel #4
0
 def get_opt(self):
     print("1) Doblar apuesta")
     print("2) Pedir otra carta")
     print("3) Plantarse")
     return safe_input(lambda x: x >= 1 and x <= 3,
                       "Ingrese el número de la opción",
                       f"{Fore.RED}Error: Ingrese una opción válida",
                       type_=int)
Beispiel #5
0
 def bet(self):
     print(f"Tienes {self.player.money} dinero")
     bet_value = safe_input(lambda x: x > 0 and x <= self.player.money,
                            "Ingrese la cantidad a apostar: ",
                            f"{Fore.RED}Error: Ingrese una cantidad válida",
                            type_=int)
     self.player.hands.append(Hand([], bet_value))
     self.player.money -= bet_value
Beispiel #6
0
def register_sale():
    sale = {
        "date": today()
    }

    print("--- Satış kaydı ---\n")
    print("Urunu kim satıyor?")

    employees = get_employees()
    for e in employees:
        print("- %s (%s)" % (e['name'], e['id']))
    print()

    employee = select_by_id_or_name(employees, 'employee')
    sale['employee_id'] = employee['id']

    print("Selected: %s (%s)\n" % (employee['name'], employee['id']))
    print("Bu hangi ürün?")
    products = get_products()

    for p in products:
        print("- (%s) %s (%s adet satilabilir.)" %
              (p['id'], p['name'], p['quantity']))
    print()

    product = select_by_id_or_name(products, 'product')

    sale['product_id'] = product['id']

    print("Secilen: %s (%s) (%s stokta var)\n" %
          (product['name'], product['id'], (product['quantity'])))

    quantity = 0
    while True:
        quantity = safe_input("int_positive", "Kaç urun var? ")
        if quantity > 0 and quantity <= product['quantity']:
            print("Emir geçerlidir. Toplam fiyat hesaplanıyor...")
            break
        else:
            print(
                "Sipariş geçersiz. Lütfen stoktaki miktardan büyük olmayan bir sayı seçin")

    # we are updating the reference, so this dictionary is also modified
    # on the products list
    product['quantity'] -= quantity
    sale['num_products'] = quantity
    sale['total_price'] = quantity * product['price']

    print("\nToplam fiyat: %sTL (+ %sTL vergi)" %
          (sale['total_price'], sale['total_price'] * 0.18))

    sale['id'] = len(get_sales())

    print("\nBu siparişin numarasi", sale['id'])

    update_products(products)
    add_sale(sale)
Beispiel #7
0
def register_sale():
    sale = {"date": today()}

    print("--- Register sale ---\n")
    print("Who is selling the product?")

    employees = get_employees()
    for e in employees:
        print("- %s (%s)" % (e['name'], e['id']))
    print()

    employee = select_by_id_or_name(employees, 'employee')
    sale['employee_id'] = employee['id']

    print("Selected: %s (%s)\n" % (employee['name'], employee['id']))
    print("Which product is it?")
    products = get_products()

    for p in products:
        print("- %s (%s) (%s in stock)" % (p['name'], p['id'], p['quantity']))
    print()

    product = select_by_id_or_name(products, 'product')

    sale['product_id'] = product['id']

    print("Selected: %s (%s) (%s in stock)\n" %
          (product['name'], product['id'], (product['quantity'])))

    quantity = 0
    while True:
        quantity = safe_input("int_positive", "How many items? ")
        if quantity > 0 and quantity <= product['quantity']:
            print("The order is valid. Calculating total price...")
            break
        else:
            print(
                "The order is invalid. Please choose a number that is not greater than the quantity in stock"
            )

    # we are updating the reference, so this dictionary is also modified
    # on the products list
    product['quantity'] -= quantity
    sale['num_products'] = quantity
    sale['total_price'] = quantity * product['price']

    print("\nTotal price: $%s (+ $%s tax)" %
          (sale['total_price'], sale['total_price'] * 0.16))

    sale['id'] = len(get_sales())

    print("\nThis order's id is", sale['id'])

    update_products(products)
    add_sale(sale)
Beispiel #8
0
def customer_satisfaction_form():
    """
    Ask a customer for their rating. 
    Writes a review to feedback.csv
    """

    feedback = {"date": today()}
    print("--- Customer satisfaction form ---\n")
    print('Which is your sale id (it is found on your receipt)?')

    total_sales = len(get_sales())

    sale_id = 0

    while True:
        sale_id = safe_input('int_positive', 'Sale id: ')
        # check if id exists
        if sale_id > -1 and sale_id < total_sales:
            break
        else:
            print('That sale id is invalid')

    print('\nHow was our service? (1, 2, 3, 4, 5)')
    rating = 0
    while True:
        rating = safe_input('int_positive', 'Rating: ')
        if rating > 0 and rating < 6:
            break
        else:
            print('Please select a number from 1 to 5')

    feedback['sale_id'] = sale_id
    feedback['rating'] = rating
    # last available id
    feedback['id'] = len(get_feedbacks())

    add_feedback(feedback)

    print('\nCool. Thanks for giving us your feedback.')
    print('We hope to see you again')
Beispiel #9
0
def input_format():
    print("Chose how would you like to print results:")
    print("1) human readable (%H h %m min)")
    print("2) processing friendly (%m)")

    output_format = safe_input("Choose option: ")

    if output_format == 1:
        pass
    elif output_format == 2:
        pass
    else:
        print("Illegal option")
        exit(0)

    return output_format
Beispiel #10
0
def main():
    print("\n\n[LOGO]\n\n")
    print("MKC' ye Hoşgeldiniz.")
    print("""
Menü seçim :

1. Satış kaydı
2. Ürün gelişini kaydedin
3. Envanter verilerini sorgulama
4. En çok satılan ürünler
5. En çok satış yapan çalışanlar
6. Satış raporu oluşturun
7. Yalnızca sezonluk ürünleri göster
8. Müşteri memnuniyeti formu
""")

    while True:

        action = safe_input('int_positive', 'Seçiminiz: ')

        if action > 0 and action < 9:
            break

        print("Seçiminizi 1-8 arası giriniz...")

    if action == 1:
        register_sale()
    elif action == 2:
        register_product_arrival()
    elif action == 3:
        query_inventory_data()
    elif action == 4:
        print(4)
        print("--- Most sold items ---")
    elif action == 5:
        employees_with_most_sales()
    elif action == 6:
        print(6)
        print("--- Çalışanın satış raporunu oluşturun ---")
    elif action == 7:
        print(7)
        print("--- Yalnızca sezonluk ürünleri göster ---")
    else:
        print(8)
        print("--- Müşteri memnuniyeti formu ---")

    print("Mkc_depo'yu kullandığınız için teşekkürler. İyi günler \ n")
def register_product_arrival():
    print("--- Register product arrival ---\n")
    print("Which product is it?")

    menu = get_products()

    for thing in menu:
        print(thing['name'], thing['id'])

    chooosen_product = select_by_id_or_name(menu, 'product')

    arrival_quantity = safe_input('int_positive', 'Recent arrival quantity:')

    chooosen_product['quantity'] += arrival_quantity

    print('OKAY. You\'ve registered %s items of %s product' %
          (arrival_quantity, chooosen_product['name']))
    print('Now there are %s in stock' % chooosen_product['quantity'])
    update_products(menu)
Beispiel #12
0
def main():
    print("""
Select an action

1. Register sale
2. Register product arrival
3. Query inventory data
4. Most sold items
5. Employees with most sales
6. Generate sales report
7. Show only seasonal products
8. Customer satisfaction form
""")

    while True:
        action = safe_input('int_positive', 'Action: ')

        if action > 0 and action < 9:
            break

        print("Oops! Try again with an action from 1 to 8")

    # action can only be from 1 to 8
    if action == 1:
        register_sale()
    elif action == 2:
        register_product_arrival()
    elif action == 3:
        query_inventory_data()
    elif action == 4:
        most_sold_items()
    elif action == 5:
        employees_with_most_sales()
    elif action == 6:
        generate_report()
    elif action == 7:
        show_only_seasonal_products()
    else:
        customer_satisfaction_form()

    print("\nThanks for using python_inventory. Have a great day\n")