Ejemplo n.º 1
0
    def user_action(self):
        """
        Function executes main user flow.
        For Manager calls manager input flow.
        For Salesman performs creating a new sale record.
        """
        if self.position == "Manager":
            self.get_manager_option()
        elif self.position == "Salesman":
            if self.check_salesman():
                beverages = select_beverages()
                for beverage in beverages:
                    print("{} \n".format(beverage))
                selected_beverage = int(
                    custom_input("Please, choose beverage id: \n"))
                print(selected_beverage)
                ingredients = select_ingredient()
                for ingredient in ingredients:
                    print("{} \n".format(ingredient))
                selected_ingredient = int(
                    custom_input("Please, choose ingredient id: \n"))
                print(selected_ingredient)

                user, beverage, ingredient, price = self.process_sale(
                    beverages, selected_beverage, ingredients,
                    selected_ingredient)
                create_sale(user, beverage, ingredient, price)
                create_bill(user, beverage, ingredient, price)
                print_bill()
            else:
                print("Please, contact your manager to register you.")

        else:
            print("Please, specify role as Manager or Salesman")
Ejemplo n.º 2
0
def create_beverage():
    """
    Function takes input from user and executes INSERT statement to create new beverage
    """
    beverage = custom_input("Enter beverage: \n")
    price = custom_input("Enter price: \n")
    if float_validator(price):
        exec_insert_query(
            "INSERT OR IGNORE INTO beverage VALUES (NULL, '{}', '{}')".format(
                beverage, price))
Ejemplo n.º 3
0
 def create_user():
     """
     Function takes input from Manager and
     performs INSERT statement to crate new user.
     """
     username = custom_input("Enter user name: \n")
     position = custom_input("Enter user position (Manager/Salesman): \n")
     if position == "Salesman" or position == "Manager":
         exec_insert_query(
             "INSERT OR IGNORE INTO users VALUES (NULL,'{}','{}','{}','{}')"
             .format(username, position, 0, 0))
     else:
         print(
             "Incorrect position '{}'.\nYou should specify position 'Manager' or 'Salesman'"
             .format(position))
Ejemplo n.º 4
0
 def get_manager_option(self):
     """
     Function takes input from Manager to perform multiple actions.
     It allows to create new user, beverage or ingredient,
     or show statistics for a user.
     """
     option = custom_input("Enter 's' to show statistics\n"
                           "Enter 'u' to create new user\n"
                           "Enter 'b' to create new beverage\n"
                           "Enter 'i' to create new ingredient\n"
                           "Or q to exit:\n")
     if option == 's':
         user = self.get_manager_input()
         self.statistics(user)
         self.get_manager_option()
     elif option == 'u':
         self.create_user()
         self.get_manager_option()
     elif option == 'b':
         create_beverage()
         self.get_manager_option()
     elif option == 'i':
         create_ingredient()
         self.get_manager_option()
     elif option == 'q':
         return
     else:
         print("'{}' option is not supported.".format(option))
         self.get_manager_option()
     return option
Ejemplo n.º 5
0
 def __init__(self):
     """
     Function generates a user instance depending on user name and position.
     """
     self.username = custom_input("Enter username: \n")
     self.position = custom_input("Enter position (Manager/Salesman): \n")
Ejemplo n.º 6
0
 def get_manager_input():
     user = custom_input("Please, enter your salesman name: \n")
     return user