def return_item_type(inventory, history, choice):
    while True:
        return_type = input(
            '\n1) Return Item\n2) Replace Item\n3) Exit\nPlease choose whether you would like to return or replace the {}: '
            .format(inventory[choice]['name']))
        if return_type == '1':
            price = return_days(inventory, choice)
            inventory = core.return_item(inventory, choice)
            print(
                '\nYou\'ve returned 1 {}. Here is your deposit of ${} and your total is ${}'
                .format(
                    inventory[choice]['name'],
                    core.replacement_tax(
                        inventory[choice]['replacement price']), price))
            return write_in_return(inventory, choice, price)
        elif return_type == '2':
            inventory = core.return_item(inventory, choice)
            print('\nYou\'ve replaced 1 {}. The total price while be ${}.'.
                  format(inventory[choice]['name'],
                         (inventory[choice]['replacement price'] -
                          core.replacement_tax(
                              inventory[choice]['replacement price']))))
            return write_in_return(inventory, choice,
                                   inventory[choice]['replacement price'])
        elif return_type == '3':
            print('\nGoodbye')
            exit()
        else:
            print('\nPlease enter a correct response.')
Esempio n. 2
0
def test_return_item_half_stocked():
    item = {
        'item_name': 'car',
        'base_rental_price': 2,
        'replacement_cost': 3,
        'in_stock': 3,
        'initial_stock': 6
    }
    core.return_item(item)
    assert item['in_stock'] == 4
def main():
    rent_info = disk.open_file('inventory.txt')
    rent_dictionary = core.create_rent_dictionary(rent_info)
    print('Welcome to the Rental store!')
    name = input('What\'s your name?: ')
    print(f'Hello {name.upper()}')
    choice = define_customer_or_employee()
    if choice == 'employee':
        employee_options(rent_dictionary)
    elif choice == 'customer':
        while True:
            user_response = input('Would you like to rent anything? ')
            # this is a yes or no question
            if user_response == 'yes':
                print('These is what we have in stock')
                selection = choices(rent_dictionary)
                if rent_dictionary[selection]['stock'] == 0:
                    print('It\'s already rented')
                    continue
                else:
                    core.reduce_stock(rent_dictionary, selection)
                    total = core.rental_rates(rent_dictionary, selection)
                    days = input('How many days do you want to rent this?: ')
                    if days.isdigit():
                        total = total * int(days)
                        print('----------------')
                        print('Here\'s your receipt')
                        print('----------------')
                        print(f'total: {total:.2f}')
                        print('Thank for your service')
                        print('----------------')

                        disk.write_the_history(
                            core.create_history_string(name, 'check out',
                                                       selection, total))
                        file_string = core.create_file_string(rent_dictionary)
                        disk.write_file(file_string, 'inventory.txt')
                        break

            elif user_response == 'no':
                selection = print_dictionary(rent_dictionary)
                returning = input('What are you returning?: ')
                if returning in rent_dictionary:
                    print(
                        f'Thank you for returning {returning} and have a great day'
                    )
                    deposit = core.give_deposit(rent_dictionary, returning)
                    print(f'Here\'s your deposit:{deposit}')
                core.return_item(rent_dictionary, returning)
                disk.write_the_history(
                    core.create_history_string(name, 'check in', returning))

                file_string = core.create_file_string(rent_dictionary)
                disk.write_file(file_string, 'inventory.txt')
                exit()
def main():
    inventory = disk.read_file('inventory.txt')
    inventory = core.make_inv(inventory)
    name = get_name()
    print_inventory(inventory)
    decision = sign_in()

    # decision 1 == employee
    while True:
        if decision == '1':
            decision = rent_or_return(name)
            if decision == 'rent':
                rental_shell(inventory, name)
        # decision 2 == customer
        if decision == '2':
            decision = rent_or_return(name)
            if decision == 'rent':
                rental_shell(inventory, name)
            elif decision == 'return':
                core.return_item(inventory, user_choice)

            # elif rent_or_return() == 'return':
            #     return_choice()
            #     core.add_to_stock(inventory, return_choice)
            #     print(inventory[return_choice])

            # elif rent_or_return() == 'done':
            #     break
            # elif user_days() == '':
            #     break
            # else:
            #     print('Not in stock')
            # print(inventory.keys())
            # user_choice()
            #                      '?').strip().lower()
            # if core.in_stock(inventory, user_choice):
            #     user_days()
            #     inventory[user_choice]['stock'] -= 1
            #     print(inventory[user_choice])
            #     taxed = core.price_with_tax(inventory, user_choice)
            #     cost_indays = int(inventory[user_choice]['price'] * user_days)
            #     print('taxed:', core.price_with_tax(inventory, user_choice))
            #     print('cost with days rented:', cost_indays)
            #     taxed = core.price_with_tax(inventory, user_choice)
            #     cost_indays = inventory[user_choice]['price'] * int(user_days)
            #     replacement = core.find_replacement(inventory, user_choice)
            #     total = round(taxed + cost_indays + replacement, 2)
            #     print('total:', total)
            #     disk.write_file(inventory, user_choice, user_days)
            elif decision == 'done':
                break
Esempio n. 5
0
def test_return_item_replaced():
    """
    Tests passing in an item that is in the transaction history as rented,
    but was later replaced.
    """
    assert core.return_item(
        "air3", False) == "\nI can't seem to find that item in the transaction history. Sorry!"
Esempio n. 6
0
def customer_path(identity, inventory, cart):
    ''' (str, list of dict, list of lists [dict, str]) -> NoneType

    Options for the customer when they run the application 
    '''
    username = user_login()
    while True:
        if username == 'back':
            _ = clear_screen()
            break
        choice = rent_or_return()
        customer_manifesto = disk.process_user_items(
            disk.read_manifesto('customer_manifesto.txt'))
        if choice == 'leave':
            _ = clear_screen()
            break
        if choice == 'rent':
            item_choice = which_item(inventory, 'rent', username,
                                     customer_manifesto)
            if item_choice == 'back':
                _ = clear_screen()
                continue
            core.rent_item(item_choice)
            print(
                f'1 {item_choice["item_name"]} has been added to your cart.\n\n'
            )
            core.add_item_to_cart(cart, item_choice, choice)
        if choice == 'return':
            item_choice = which_item(inventory, 'return', username,
                                     customer_manifesto)
            if item_choice == 'back':  # if the user wants to back out
                _ = clear_screen()
                continue
            elif item_choice:  # if the user can return something
                core.return_item(item_choice)
                print(
                    f'1 {item_choice["item_name"]} has been returned.  Please checkout to get your deposit back.\n\n'
                )
                core.add_item_to_cart(cart, item_choice, choice)
            else:  # if the user cannot return anything
                continue
        if choice == 'checkout':  #next on the agenda
            checkout_operations(inventory, cart, username, customer_manifesto)
Esempio n. 7
0
def test_return_item():
    assert core.return_item(
        {
            'bike': {
                'name': 'Bike',
                'rent price': 25,
                'replacement price': 150,
                'amount': 10
            },
            'skateboard': {
                'name': 'Skateboard',
                'rent price': 10,
                'replacement price': 80,
                'amount': 6
            },
            'scooter': {
                'name': 'Scooter',
                'rent price': 15,
                'replacement price': 65,
                'amount': 8
            }
        }, 'bike') == {
            'bike': {
                'name': 'Bike',
                'rent price': 25,
                'replacement price': 150,
                'amount': 11
            },
            'skateboard': {
                'name': 'Skateboard',
                'rent price': 10,
                'replacement price': 80,
                'amount': 6
            },
            'scooter': {
                'name': 'Scooter',
                'rent price': 15,
                'replacement price': 65,
                'amount': 8
            }
        }
Esempio n. 8
0
 def test_return_item():
     assert core.return_item(({
         'bikes': {
             'name': 'bike',
             'rent price': 25,
             'replacement price': 150,
             'amount': 10
         },
         'skateboards': {
             'name': 'skateboard',
             'rent price': 10,
             'replacement price': 80,
             'amount': 6
         },
         'scooters': {
             'name': 'scooter',
             'rent price': 15,
             'replacement price': 65,
             'amount': 8
         }
     }), 'bikes') == ({
         'bikes': {
             'name': 'bike',
             'rent price': 25,
             'replacement price': 150,
             'amount': 11
         },
         'skateboards': {
             'name': 'skateboard',
             'rent price': 10,
             'replacement price': 80,
             'amount': 6
         },
         'scooters': {
             'name': 'scooter',
             'rent price': 15,
             'replacement price': 65,
             'amount': 8
         }
     })
Esempio n. 9
0
def choose_trans() -> Any:
    """
    Handles transaction choice; returns result of one of several functions.
    """
    choice = input(
        "\nPlease enter the number according to the transaction.\n"
        "1 - Rental\n2 - Purchase\n3 - Return\n4 - Replace\n").strip().lower()
    if choice == '1':
        item_num = input(
            "\nEnter the corresponding number for your choice: \n"
            "1 - Auger\n2 - Nailgun\n3 - Generator\n4 - Pressure Washer\n"
            "5 - Air Compressor\n6 - Tilesaw\n").strip()
        time_choice = input(('\nEnter 1 to rent the item for 5 hours.\n'
                             'Enter 2 for one day.\nEnter 3 for one week.\n'
                             'Enter 4 for one month.\n')).strip()
        if is_valid_item(choice_num_to_item(item_num)):
            return rent(choice_num_to_item(item_num), time_choice)
    elif choice == '2':
        item_num = input(
            "\nEnter the corresponding number for your choice: \n"
            "1 - Auger\n2 - Nailgun\n3 - Generator\n4 - Pressure Washer\n"
            "5 - Air Compressor\n6 - Tilesaw\n").strip()
        if is_valid_item(choice_num_to_item(item_num)):
            return purchase(choice_num_to_item(item_num))
    elif choice == '3':
        item_id = input(
            "\nPlease input the ID of the returning item.\n").strip().lower()
        damaged = input(
            "\nPlease enter 1 if the item is damaged and 2 if not.\n").strip()
        damaged_dict = {'1': True, '2': False}
        return return_item(item_id, damaged_dict[damaged])
    elif choice == '4':
        item_id = input("\nPlease input the ID of the item being replaced.\n"
                        ).strip().lower()
        return replace_item(item_id)
    elif choice == '9':
        return '\nHave a nice day!'
    else:
        return "\nI'm sorry, I didn't quite catch that."
Esempio n. 10
0
def test_add_to_stock():
    inventory = {'hardwear': {'stock': 7}}

    result = core.return_item(inventory, 'hardwear')

    assert inventory['hardwear']['stock'] == 8
def test_return_item():
    result = core.return_item(fake_dict, '1')
    assert result == 10
Esempio n. 12
0
def test_return_item_damaged():
    """
    Tests returning a damaged item.
    """
    assert core.return_item('gen3', True) == "\nTotal: ${0:.2f}".format(0.00)
Esempio n. 13
0
def test_return_item_normal():
    """
    Tests normal functionality of return_item.
    """
    assert core.return_item('nai5', False) == "\nTotal: ${0:.2f}".format(-30.00)
Esempio n. 14
0
def test_return_item_invalid():
    """
    Tests passing an invalid ID into return_item.
    """
    assert core.return_item('potato', False) == "\nThat is an invalid ID. Please try again."
Esempio n. 15
0
def test_return_item_cancel():
    """
    Tests cancelling out of the program through the return_item function.
    """
    assert core.return_item('9', False) == '\nHave a nice day!'
Esempio n. 16
0
def test_return_item_not_rented():
    """
    Tests the return_item function on an item that wasn't rented (still in inventory).
    """
    assert core.return_item(
        'til1', False) == "\nI can't seem to find that item in the transaction history. Sorry!"