This Python script helps manage stock inventory for a woodworking company. It supports adding, removing, displaying and saving a report on stocks available in a warehouse. The user has the possibility to request the state of the whole inventory or a stock in particular.
This app is developed with using Python with an “Object Oriented Programming” focus. It is split between three scripts described more in depth below. In short, all the constraints and information storing is in the Stock.py script, and all the display and app components are in Warehouse.py.
This script stores a class called “Generic Stock”, which defines a generic stock type and methods to add and remove stock. All stock have the “quantity” attribute, which is used as the memory endpoint to store the inventory every time an operation is done, to avoid using a .csv file.
We use class inheritance to define three types of stock: Redwood, Maple and Oak. The super function allows to keep the methods of the Generic Stock function.
Each inherited class has a particular attribute that is unique to each type of stock: Redwood has density, Maple has humidity, and Oak has varnish.
We use a separate script for stock to keep all the definitions of functions and attribute in a tidy space without all the visual components of the app.
The Warehouse script contains the MainWarehouse class which includes all the functionalities of the app and its visual aspects.
It has:
Note: to avoid unwanted app termination, all the input checks are made using try/except or if statement. Assert statements can be found in the test script (see below.)
Imports the elements of the MainWarehouse class from the Warehouse script. Triggers the display_menu() function as an entry point to access the app.
A test.py script is provided in the GitHub files. It features an edited version of the app to test its functionalities. All the user inputs are replaced by hard-coded answers to run through all the code. The test_warehouse() function runs through all functions separately and prints a success statement if all assets are checked.