def update_transaction(): try: transaction_number = view.get_input("transaction number") if transaction_index_valid(transaction_number): entry = view.get_inputs(["product", "price", "date"]) if date_correct_input(entry[2]): sales.update_transaction(transaction_number, entry) except IndexError: view.print_error_message("Index not found") except ValueError: view.print_error_message("Date in invalid format")
def update_transaction(): user_input = view.get_input("Transaction ID / or 'quit'") user_wants_to_quit = False while not __is_transaction_to_update_valid( user_input) and not user_wants_to_quit: view.print_error_message( "Error: Invalid input for Transaction to update") user_input = view.get_input("Transaction ID / or 'quit'") if user_input == 'quit': user_wants_to_quit = True transaction_id_to_update = user_input new_transaction = [] new_transaction.append(transaction_id_to_update) new_transaction.append(view.get_input("Customer")) new_transaction.append(view.get_input("Product")) user_input = view.get_input("Price") while not __is_transaction_price_valid(user_input): view.print_error_message("Error: Invalid input for Price") user_input = view.get_input("Price") new_transaction.append(user_input) user_input = view.get_input("Date i.e. 1989-03-21") while not __is_transaction_date_format_valid(user_input): view.print_error_message("Error: Invalid input for Date") user_input = view.get_input("Date i.e. 1989-03-21") new_transaction.append(user_input) if sales.update_transaction(new_transaction): view.print_message("Transaction updated") else: view.print_error_message("Error while updating transaction!")
def update_transaction(): transaction_id = view.get_input( "Please choose a transaction ID you want to update") try: index, product_list = sales.look_for_product_list(transaction_id) print(*product_list) change_info = view.get_input( "Please choose what you want to change in the information").lower( ) if change_info in UPDATE_OPTIONS: new_info = view.get_input("Enter new information") sales.update_transaction(index, UPDATE_OPTIONS[change_info], new_info) except: view.print_error_message("Invalid ID") update_transaction()
def update_transaction(): view.print_message("Update transaction.") transaction_id = view.get_input("Provide transaction ID") sale = sales.find_by_id(transaction_id) if sale: view.print_message( f"Transaction found. Updating:\n{sales.HEADERS[id_index]}: {sale[id_index]}" ) updated_sale = [] for header_index in range(1, len(sales.HEADERS)): new_option = view.get_input( f"Current value of {sales.HEADERS[header_index]}: {sale[header_index]}\n" f"New value (ENTER to keep current value)") updated_sale.append( new_option if len(new_option) > 0 else sale[header_index]) sales.update_transaction(transaction_id, updated_sale) else: view.print_error_message( f"Transaction of ID {transaction_id} does not exist.")
def update_transaction(): # view.print_error_message("Not implemented yet.") transaction_id = view.get_input(f"Specify the transaction {sales.HEADERS[sales.ID_TRANSACTION_INDEX]}") # view.print_message("Specify what do you want to change.") headers_menu = sales.HEADERS.copy()[sales.ID_CUSTOMER_INDEX:] insert_exit_option(headers_menu) view.print_menu("Possible positions to update", headers_menu) index = view.get_input("Specify which position would you like to update") index_in_headers_menu = int(index) if index_in_headers_menu == 0: return new_value = view.get_input("Enter new value") updated_transaction = sales.update_transaction(transaction_id,index_in_headers_menu,new_value) view.print_message("The updated transaction: ") view.print_table(updated_transaction,sales.HEADERS)