A Python program that manages shoe inventory for warehouses in multiple countries.
This program is a Nike warehouse manager that allows the manager to capture, view, edit, search and report on shoe inventory. The program enables the manager to keep a record of the shoe inventory and provides statistics for presentation purposes.
At startup, the program retrieves data from an external text file to access the information needed to run the program and then presents the manager with the program menu.
The external text file contains the following on each line:
- Country that's holding the stock
- Product code
- Name of product
- Cost of product
- Quantity of stock
From the menu, the user is able to:
- Search for a stock item by product code
- View all stock items in the inventory list
- Capture a new stock item
- View the stock item with the lowest stock and update it
- View the stock item with the highest stock and discount it
- Calculate the value of each stock item
- Exit the program
This program employs the programming concepts of Python OOP including classes, methods and functions. Furthermore it employs fundamental programming techniques that include external databases, lists, comparison operators, conditional logic, loops, indexing and string handling.
from tabulate import tabulate
Used to create tables from shoe data.
Run the inventory.py file in any Python IDE. View the inventory.txt file in any text editing program.
Note: The inventory data is stored in the inventory.txt file. Do not edit this file manually as it will cause errors in the program.
def capture_shoes():
"""Prompts the user to enter the country of origin, shoe code, product name, unit cost, and quantity.
If an invalid cost or quantity is entered, the user is prompted to re-enter the input.
The function then creates a new shoe object using the input and appends it to shoes_list.
Returns:
Confirmation that new object is added to list + text file
"""
country = input("What country: ")
code = input("Enter the shoe code: ")
product = input("Enter the shoe product: ")
# loop makes sure that user input is a float, gives error on incorrect entry
while True:
try:
cost = float(input("Enter the shoe unit cost: "))
break
except ValueError:
print(f"{RED}Enter a valid price.{RESET}")
continue
# looper makes sure that input is an integer, gives error on incorrect entry
while True:
try:
quantity = int(input("Enter the shoe quantity: "))
break
except ValueError:
print(f"{RED}Enter a whole number.{RESET}")
continue
# pass through shoe object
new_shoe = Shoe(country, code, product, cost, quantity)
# append object to list
shoes_list.append(new_shoe)
# append to text file too
with open("inventory.txt", "a") as file:
file.write(f"\n{new_shoe.country},{new_shoe.code},{new_shoe.product},{new_shoe.cost},{new_shoe.quantity}")
print(f"{GREEN}Product added to inventory list.\n{RESET}")]
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[ Inventory Program ]⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Choose the menu option by typing the corresponding letter:
'S'earch - Search products by code.
'V'iew - View a list of the inventory.
'A'dd - Add a product to the inventory.
'L'owest - Determine the product with the lowest quantity and restock it.
'H'ighest - Determine the product with the highest quantity and discount it.
'T'otal - Calculate the total value of each stock item.
'E'xit - Exit program.
: a
What country: Brazil
Enter the shoe code: SKU29201
Enter the shoe product: Nike Jordan Air
Enter the shoe unit cost: 90
Enter the shoe quantity: 300
Product added to inventory list.
Manjeet Dhiman