0% found this document useful (0 votes)
25 views

Inventory Management System

Uploaded by

Aditya Rawat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Inventory Management System

Uploaded by

Aditya Rawat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Inventory Management System

The Inventory Management System is a comprehensive Python application


designed to facilitate the efficient handling of inventory data using CSV files. It
offers functionalities to manage products, suppliers, and sales, allowing users to
perform various operations such as displaying existing records, adding new
entries, and updating quantities.
The system operates with three primary CSV files: Products.csv, Suppliers.csv, and
Sales.csv. Users can add new products and suppliers, record sales transactions,
and generate sales reports. One of the standout features is the ability to view
products below a specified quantity threshold, which aids in inventory control and
helps prevent stockouts.
Error handling is integrated throughout the application, ensuring robust
performance and a better user experience. For example, when checking products
below the threshold, the program gracefully handles invalid data types without
terminating the process, allowing for continuous operation.
Overall, this program is designed for small to medium-sized businesses that need
a simple yet effective tool to manage their inventory, ensuring that they can easily
track stock levels, supplier information, and sales activity while minimizing the risk
of errors and inefficiencies. Its reliance on CSV files makes it easy to integrate with
other systems or tools.
1. display_products()
2. display_suppliers()
3. display_sales()
4. add_product(product_id, name, quantity, price, category)
5. add_supplier(supplier_id, name, contact, products_supplied)
6. record_sale(sale_id, product_id, quantity_sold, sale_date,
customer_name)
7. update_product_quantity(product_id, new_quantity)
8. search_product(product_id)
9. products_below_threshold(threshold)
10. generate_sales_report()
import csv
from datetime import datetime

file_path = "D:\\garv\\"

# Function 1: Display Products


def display_products():
with open(file_path + 'Products.csv', 'r') as file:
reader = csv.reader(file)
print("ProductID, ProductName, Quantity, Price, Category")
for row in reader:
print(", ".join(row))

# Function 2: Display Suppliers


def display_suppliers():
with open(file_path + 'Suppliers.csv', 'r') as file:
reader = csv.reader(file)
print("SupplierID, SupplierName, Contact, ProductsSupplied")
for row in reader:
print(", ".join(row))

# Function 3: Display Sales


def display_sales():
with open(file_path + 'Sales.csv', 'r') as file:
reader = csv.reader(file)
print("SaleID, ProductID, QuantitySold, SaleDate, CustomerName")
for row in reader:
print(", ".join(row))

# Function 4: Add New Product


def add_product(product_id, name, quantity, price, category):
with open(file_path + 'Products.csv', 'a', newline='') as file:
writer = csv.writer(file)
writer.writerow([product_id, name, quantity, price, category])
print("Product added successfully!")

# Function 5: Add New Supplier


def add_supplier(supplier_id, name, contact, products_supplied):
with open(file_path + 'Suppliers.csv', 'a', newline='') as file:
writer = csv.writer(file)
writer.writerow([supplier_id, name, contact, products_supplied])
print("Supplier added successfully!")

# Function 6: Record Sale


def record_sale(sale_id, product_id, quantity_sold, sale_date, customer_name):
with open(file_path + 'Sales.csv', 'a', newline='') as file:
writer = csv.writer(file)
writer.writerow([sale_id, product_id, quantity_sold, sale_date,
customer_name])
print("Sale recorded successfully!")

# Function 7: Update Product Quantity


def update_product_quantity(product_id, new_quantity):
rows = []
with open(file_path + 'Products.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
if row[0] == product_id:
row[2] = new_quantity
rows.append(row)
with open(file_path + 'Products.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerows(rows)
print("Product quantity updated!")

# Function 8: Search Product by ID


def search_product(product_id):
with open(file_path + 'Products.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
if row[0] == product_id:
print("Product found:", ", ".join(row))
return
print("Product not found.")

# Function 9: View Products Below Threshold

def products_below_threshold(threshold):
print("Products below threshold quantity:")
with open(file_path + 'Products.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
try:
if int(row[2]) < threshold:
print(", ".join(row))
except ValueError:
# Skip this row if there's an issue converting the quantity to an integer
continue

# Function 10: Generate Sales Report


def generate_sales_report():
sales = {}
with open(file_path + 'Sales.csv', 'r') as file:
reader = csv.reader(file)
next(reader) # Skip header
for row in reader:
product_id = row[1]
quantity_sold = int(row[2])
if product_id in sales:
sales[product_id] += quantity_sold
else:
sales[product_id] = quantity_sold
print("Sales Report:")
for product_id, total_sold in sales.items():
print(f"Product ID: {product_id}, Total Sold: {total_sold}")

# Main Program
def main():
while True:
print("\nInventory Management System")
print("1. Display Products")
print("2. Display Suppliers")
print("3. Display Sales")
print("4. Add New Product")
print("5. Add New Supplier")
print("6. Record Sale")
print("7. Update Product Quantity")
print("8. Search Product by ID")
print("9. View Products Below Threshold")
print("10. Generate Sales Report")
print("0. Exit")
choice = input("Enter your choice: ")
if choice == '1':
display_products()
elif choice == '2':
display_suppliers()
elif choice == '3':
display_sales()
elif choice == '4':
product_id = input("Enter Product ID: ")
name = input("Enter Product Name: ")
quantity = input("Enter Quantity: ")
price = input("Enter Price: ")
category = input("Enter Category: ")
add_product(product_id, name, quantity, price, category)
elif choice == '5':
supplier_id = input("Enter Supplier ID: ")
name = input("Enter Supplier Name: ")
contact = input("Enter Contact: ")
products_supplied = input("Enter Products Supplied (semicolon-separated
IDs): ")
add_supplier(supplier_id, name, contact, products_supplied)
elif choice == '6':
sale_id = input("Enter Sale ID: ")
product_id = input("Enter Product ID: ")
quantity_sold = input("Enter Quantity Sold: ")
sale_date = datetime.today().strftime('%Y-%m-%d')
customer_name = input("Enter Customer Name: ")
record_sale(sale_id, product_id, quantity_sold, sale_date, customer_name)
elif choice == '7':
product_id = input("Enter Product ID to update: ")
new_quantity = input("Enter New Quantity: ")
update_product_quantity(product_id, new_quantity)
elif choice == '8':
product_id = input("Enter Product ID to search: ")
search_product(product_id)
elif choice == '9':
threshold = int(input("Enter threshold quantity: "))
products_below_threshold(threshold)
elif choice == '10':
generate_sales_report()
elif choice == '0':
print("Exiting...")
break
else:
print("Invalid choice. Please try again.")

# Run the main program


main()
display_products()

display_suppliers()
display_sales()
add_product(product_id, name, quantity, price, category)
add_supplier(supplier_id, name, contact, products_supplied)

record_sale(sale_id, product_id, quantity_sold, sale_date, customer_name)


update_product_quantity(product_id, new_quantity)

search_product(product_id)
products_below_threshold(threshold)

generate_sales_report()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy