Beispiel #1
0
 def choose_product(self, page):
     products_paginate = product_manager.get_product_list(page)
     products = products_paginate['products']
     last_page = products_paginate['last_page']
     index = PrintLists.print_products_paginate(products, page, last_page)
     if len(products) == 0:
         return False
     if (page - 1) >= 1:
         if index == 8:
             if not self.choose_product(page - 1):
                 return False
     if index == 9:
         return False
     if not page == last_page:
         if index == 10:
             if not self.choose_product(page + 1):
                 return False
     if len(products) < index:
         PrinterStatemants().print_not_found(index, 'product')
         return self.choose_product(page)
     quantity = PrintInputs.ask_quantity()
     product_price = product_manager.get_product_list(page)['products'][
         index - 1].price
     if PrintInputs().is_want_to_buy(quantity, product_price) == 'yes':
         if self.buy_product(index, page, quantity):
             PrinterStatemants().print_thanks_purchase()
     self.choose_product(page)
 def add_product(self):
     product = PrintInputs.enter_product()
     product_add = ProductManager().add_product(product)
     if product_add:
         PrinterStatemants.print_product_added()
         return True
     else:
         return False
Beispiel #3
0
 def register():
     admin = PrintInputs.print_admin_register()
     register = AdminManager().register(admin)
     if register:
         PrinterStatemants.print_register_success()
         return True
     else:
         PrinterStatemants.print_register_error()
         return False
Beispiel #4
0
 def lay_off_worker(self):
     if not PrintLists().print_workers(WorkerManager().get_worker_list()):
         return False
     id = PrintInputs.enter_worker_id(
         WorkerManager().get_worker_list()[-1].id)
     worker_remove = WorkerManager().remove_worker(id)
     if worker_remove:
         PrinterStatemants.print_worker_fired()
         return True
     else:
         PrinterStatemants.print_not_found(id, 'worker')
         return False
Beispiel #5
0
 def login(self):
     if self.admin:
         return True
     admin = PrintInputs.print_admin_login()
     login = AdminManager().login(admin)
     if login:
         self.admin = login
         PrinterStatemants.print_greet_admin(self.admin.login)
         return True
     else:
         PrinterStatemants.print_wrong_login()
         return False
Beispiel #6
0
 def edit_worker_salary(self):
     if not PrintLists().print_workers(WorkerManager().get_worker_list()):
         return False
     id = PrintInputs.enter_worker_id(
         WorkerManager().get_worker_list()[-1].id)
     salary = PrintInputs.enter_worker_new_salary()
     worker_edit = WorkerManager().edit_worker_salary(id, salary)
     if worker_edit:
         PrinterStatemants.print_worker_salary_updated()
         return True
     else:
         PrinterStatemants.print_not_found(id, 'worker')
         return False
 def remove_product(self):
     if not PrintLists().print_products(
             ProductManager().get_product_list()):
         return False
     id = PrintInputs.enter_product_id(
         ProductManager().get_product_list()[-1].id)
     product_remove = ProductManager().remove_product(id)
     if product_remove:
         PrinterStatemants.print_product_removed()
         return True
     else:
         PrinterStatemants.print_not_found(id, 'product')
         return False
Beispiel #8
0
 def add_worker(self):
     worker = PrintInputs.enter_worker()
     if worker['age'] <= 18:
         print("We can't take him, he is too young")
         return False
     if worker['age'] >= 65:
         print("We can't take a pensioner")
         return False
     worker_add = WorkerManager().add_worker(worker)
     if worker_add:
         PrinterStatemants.print_worker_added()
         return True
     else:
         return False
Beispiel #9
0
def show_accountancy():
    sel = PrintMenu().print_accountancy_menu()
    if int(sel) == 1:
        product_list = Accountancy().get_sold_products()
        PrintLists().print_products(product_list)
        show_accountancy()
    if int(sel) == 2:
        profit = Accountancy().get_profit()
        PrinterStatemants().print_profit(profit)
        show_accountancy()
    if int(sel) == 3:
        profit = Accountancy().get_total_salary()
        PrinterStatemants().print_total_salary(profit)
        show_accountancy()
    if int(sel) == 4:
        choose_admin_action()
    if int(sel) == 5:
        start_shop()
Beispiel #10
0
 def buy_product(self, index, page, quantity):
     current_product = product_manager.get_product_list(page)['products'][
         index - 1]
     current_id = current_product.id
     if not product_manager.get_product(current_id):
         PrinterStatemants().print_not_found(current_id, 'product')
         return False
     if current_product.quantity < quantity:
         PrinterStatemants().print_no_so_much()
         return False
     current_quantity = current_product.quantity - quantity
     current_product.quantity = current_quantity
     sold_product = product_manager.get_product(current_id)
     sold_product.quantity = quantity
     Accountancy().add_sold_product(sold_product)
     current_product = current_product.__dict__
     if product_manager.edit_product(current_product):
         return True
 def edit_product(self):
     if not PrintLists().print_products(
             ProductManager().get_product_list()):
         return False
     id = PrintInputs.enter_product_id(
         ProductManager().get_product_list()[-1].id)
     product = PrintInputs.enter_product()
     product = {
         'id': id,
         'name': product['name'],
         'price': product['price'],
         'quantity': product['quantity']
     }
     product_edit = ProductManager().edit_product(product)
     if product_edit:
         PrinterStatemants.print_product_updated()
         return True
     else:
         PrinterStatemants.print_not_found(id, 'product')
         return False