Overview:
You are tasked with developing a Python program to manage inventory for a small retail store. The system should be able to handle basic inventory operations such as adding products, updating product information, recording sales transactions, and generating inventory and sales reports.
Requirements:
Products Management:
The system should allow the store manager to add products to the inventory. Each product should have a unique product ID, a name, a quantity available, and a price.
The manager should be able to update the quantity and price of existing products in the inventory.
Sales Transactions:
The system should allow the store manager to record sales transactions. Each transaction should include the product ID, the quantity sold, and the total price of the transaction.
When recording a sale, the system should ensure that the quantity of the product being sold is available in the inventory. If not, it should display an error message.
Reports Generation:
The system should be able to generate two types of reports:
Inventory Report: This report should display the current inventory, including the product ID, name, quantity available, and price of each product.
Sales Report: This report should display the sales transactions recorded, including the transaction date, product ID, quantity sold, and total price of each transaction.
Class Design:
You are required to implement a single class called Inventory
to manage the inventory operations. This class should have the following methods:
add_product(product_id, name, quantity, price)
: Add a new product to the inventory with the given product ID, name, quantity available, and price.update_product(product_id, quantity=None, price=None)
: Update the quantity and/or price of an existing product in the inventory identified by its product ID.record_sale(product_id, quantity, total_price)
: Record a sales transaction for a product identified by its product ID, specifying the quantity sold and the total price of the transaction.generate_inventory_report()
: Generate and display an inventory report showing the current status of the inventory.generate_sales_report(transactions)
: Generate and display a sales report based on the provided list of sales transactions.
Example Usage:
# Create an instance of the Inventory class
inventory = Inventory()
# Add products to the inventory
inventory.add_product("001", "Laptop", 10, 1500.00)
inventory.add_product("002", "Mobile Phone", 20, 800.00)
# Update product information
inventory.update_product("001", quantity=8, price=1600.00)
# Record sales transactions
transaction1 = {"transaction_date": datetime.now(), "product_id": "001", "quantity": 2, "total_price": 3200.00}
transaction2 = {"transaction_date": datetime.now(), "product_id": "002", "quantity": 5, "total_price": 4000.00}
transactions = [transaction1, transaction2]
for transaction in transactions:
if not inventory.record_sale(transaction["product_id"], transaction["quantity"], transaction["total_price"]):
print(f"Not enough quantity available for product {transaction['product_id']}")
# Generate inventory report
inventory.generate_inventory_report()
# Generate sales report
inventory.generate_sales_report(transactions)
This detailed problem statement outlines the requirements, class design, and example usage for the simplified Inventory Management System. It provides a clear guide for implementation while ensuring it remains beginner-friendly.