def ui_menu(): cmd = ui_read_command() cmd = validate_cmd(cmd) if (cmd[0] == "add"): ui_add(storage, cmd) ui_menu() if (cmd[0] == "insert"): ui_insert(storage, cmd) ui_menu() if (cmd[0] == "remove"): if (len(cmd) == 4): remove_to(storage, int(cmd[1]), int(cmd[3])) elif (cmd[1] == "in" or cmd[1] == "out"): remove_type(storage, cmd[1]) else: remove(storage, int(cmd[1])) ui_menu() if (cmd[0] == "replace"): replace(storage, cmd) ui_menu() if (cmd[0] == "default"): create_df_storage(storage) ui_menu() if (cmd[0] == "list"): if (len(cmd) == 1): ui_list(storage) elif (len(cmd) == 2): ui_list_type(storage, cmd[1]) elif (cmd[1] == "balance"): ui_list_balance(storage, int(cmd[2])) else: ui_list_value(storage, cmd[1], int(cmd[2])) ui_menu() if (cmd[0] == "exit"): exit()
def ui_menu(): cmd = ui_read_command() cmd = validate_cmd(cmd) if(cmd[0] == "add"): ui_add(storage, cmd) add_stack(stack, storage) ui_menu() if(cmd[0] == "insert"): ui_insert(storage, cmd) add_stack(stack, storage) ui_menu() if(cmd[0] == "remove"): if(len(cmd) == 4): remove_to(storage, int(cmd[1]), int(cmd[3])) elif(cmd[1] == "in" or cmd[1] == "out"): remove_type(storage, cmd[1]) else: remove(storage, int(cmd[1])) add_stack(stack, storage) ui_menu() if(cmd[0] == "replace"): replace(storage, cmd) add_stack(stack, storage) ui_menu() if(cmd[0] == "default"): create_df_storage(storage) add_stack(stack, storage) ui_menu() if(cmd[0] == "list"): if(len(cmd)==1): ui_list(storage) elif(len(cmd) == 2): ui_list_type(storage, cmd[1]) elif(cmd[1] == "balance"): ui_list_balance(storage, int(cmd[2])) else: ui_list_value(storage, cmd[1], int(cmd[2])) ui_menu() if(cmd[0] == "exit"): exit() if(cmd[0] == "sum"): sum_type(storage, cmd[1]) ui_menu() if(cmd[0] == "max"): max_tr(storage, cmd[1], int(cmd[2])) ui_menu() if(cmd[0] == "filter"): l = len(cmd) if(l == 2): filter_type(storage, cmd[1]) ui_list(storage) if(l == 3): filter(storage, cmd[1], int(cmd[2])) ui_list(storage) add_stack(stack, storage) ui_menu() if(cmd[0] == "undo"): storage.clear() storage.update(undo(stack,storage)) ui_menu()
def ui_menu1(): print("\nTo exit the application input 9\n" "To add a new transaction in the current day input 0\n" "To insert a new transaction in a certain day input 1\n" "To remove transactions input 2\n" "To replace a transaction input 3\n" "To list the transactions input 4\n" "To sum the transaction considering their type input 5\n" "To get the maximum value of a transaction considering its type input 6\n" "To undo an operation input 7\n" "To get a default account input 8\n") menu = int(input()) cmd = ui_read_comm(menu) cmd = validate_cmd(cmd) if(cmd[0] == "add"): ui_add(storage, cmd) add_stack(stack, storage) ui_menu1() if(cmd[0] == "insert"): ui_insert(storage, cmd) add_stack(stack, storage) ui_menu1() if(cmd[0] == "remove"): if(len(cmd) == 4): remove_to(storage, int(cmd[1]), int(cmd[3])) elif(cmd[1] == "in" or cmd[1] == "out"): remove_type(storage, cmd[1]) else: remove(storage, int(cmd[1])) add_stack(stack, storage) ui_menu1() if(cmd[0] == "replace"): replace(storage, cmd) add_stack(stack, storage) ui_menu() if(cmd[0] == "default"): create_df_storage(storage) add_stack(stack, storage) ui_menu1() if(cmd[0] == "list"): if(len(cmd)==1): ui_list(storage) elif(len(cmd) == 2): ui_list_type(storage, cmd[1]) elif(cmd[1] == "balance"): ui_list_balance(storage, int(cmd[2])) else: ui_list_value(storage, cmd[1], int(cmd[2])) ui_menu1() if(cmd[0] == "exit"): exit() if(cmd[0] == "sum"): sum_type(storage, cmd[1]) ui_menu1() if(cmd[0] == "max"): max_tr(storage, cmd[1], int(cmd[2])) ui_menu() if(cmd[0] == "filter"): l = len(cmd) if(l == 2): filter_type(storage, cmd[1]) ui_list(storage) if(l == 3): filter(storage, cmd[1], int(cmd[2])) ui_list(storage) add_stack(stack, storage) ui_menu1() if(cmd[0] == "undo"): storage.clear() storage.update(undo(stack,storage)) ui_menu1()