Esempio n. 1
0
def load(change, status_file):
    logging.debug("start 'load' operation")

    while os.path.isfile(status_file) == False:
        status_file = input("File not found! Write again >: ")

        if status_file == '':
            status_file = None
            break

    if status_file != None:
        if change == True:
            print(
                "Status of warehouse in this session was changed and you not saved this!"
            )

        if func.confirm_choice() == True:
            print("Loading...", end=' ')
            items_list = func.load_file(status_file)
            change = False
            print("complete", ' ')

        return change, items_list

    else:
        logging.debug("procedure is abort")
        print("Procedure is abort")
        return None, None
Esempio n. 2
0
def update_item(items_list):
    logging.debug("start updating procedure")
    change = False
    position, dictionary_list = get_pos_and_dict(items_list)

    if position == False:
        logging.debug("item is not found in warehouse\n")
        print(f"'{dictionary_list[0]}' is not found in warehouse!")

    else:
        if None not in dictionary_list:
            dictionary = {
                'name': dictionary_list[0],
                'quantity': dictionary_list[1],
                'unit': dictionary_list[2],
                'unit_price': float(dictionary_list[3])
            }

            if func.confirm_choice() == True:
                logging.debug("accepting of updating")
                print("Start updating...", end=' ')
                items_list[position] = dictionary
                change = True
                print('complete', ' ')

        else:
            logging.debug("procedure is abort")
            print("Procedure is abort")

    return change, items_list
Esempio n. 3
0
def add_item(items_list):
    logging.debug("start adding procedure")
    change = False
    position, dictionary_list = get_pos_and_dict(items_list)

    if position != False:
        dictionary_list[1] = int(items_list[position]['quantity']) + int(
            dictionary_list[1])

    else:
        if None not in dictionary_list:
            dictionary = {
                'name': dictionary_list[0],
                'quantity': dictionary_list[1],
                'unit': dictionary_list[2],
                'unit_price': float(dictionary_list[3])
            }

            if func.confirm_choice() == True:
                logging.debug("accepting of adding")
                print("Start adding...", end=' ')
                items_list.append(dictionary)
                change = True
                print('complete', ' ')

        else:
            logging.debug("procedure is abort")
            print("Procedure is abort")

    return change, items_list
Esempio n. 4
0
def save(status_file, items_list):
    logging.debug("start 'save' operation")

    if func.confirm_choice() == True:
        print("Saving...", end=' ')
        func.save_file(status_file, items_list)
        change = False
        print("complete", ' ')

    return change
Esempio n. 5
0
def remove(status_file):
    logging.debug("start 'remove' operation")

    while os.path.isfile(status_file) == False:
        status_file = input("File not found! Write again >: ")

        if status_file == '':
            status_file = None
            break

    if status_file != None and status_file != "status file.CSV":

        if func.confirm_choice() == True:
            print("Removing...", end=' ')
            os.remove(status_file)
            print("complete", ' ')

    elif status_file != "status file.CSV":
        logging.debug("procedure is abort")
        print("You can't remove default file")

    else:
        logging.debug("procedure is abort")
        print("Procedure is abort")
Esempio n. 6
0
def sell_item(revenue_list, items_list, today_date, path):
    logging.debug("start selling procedure")
    change = False
    date = today_date.strftime('%d-%b-%Y')
    position, dictionary_list = get_pos_and_dict(items_list, 'sell_item')

    if position == False:
        logging.debug("item is not found in warehouse\n")
        print(f"'{dictionary_list[0]}' is not found in warehouse!")

    else:
        if None not in dictionary_list:
            dictionary = {
                'date': today_date.strftime("%x"),
                'time': today_date.strftime("%X"),
                'name': dictionary_list[0],
                'quantity': dictionary_list[1],
                'unit': dictionary_list[2],
                'unit_price': float(dictionary_list[3])
            }

            if func.confirm_choice() == True:
                logging.debug("accepting of selling")
                print("Start selling...", end=' ')
                revenue_list.append(dictionary)
                func.save_revenue(date, dictionary, path)
                items_list[position]['quantity'] = int(
                    items_list[position]['quantity']) - int(dictionary_list[1])
                change = True
                print('complete', ' ')

        else:
            logging.debug("procedure is abort")
            print("Procedure is abort")

    return change, revenue_list, items_list
Esempio n. 7
0
    command = input(string_input)
    command = command.lower()
    command = command.strip()

    string_input = "What will we do? >: "
    logging.debug(f"user wrote: '{command}'")

    #--------------------------------
    if command == 'exit':
        if change == True:
            print(
                "Status of warehouse in this session was changed and you not saved this!"
            )

        if func.confirm_choice() == True:
            logging.debug("program will be ended")
            print('Goodbye')
            break

    #--------------------------------
    elif command == 'clear':
        logging.debug("clear console\n")
        os.system('cls')
        print('=' * 64 + f"\n{title}\n" + '=' * 64)

    #--------------------------------
    elif command == 'help':
        logging.debug("print help list\n")
        print(help_list)