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

Shop 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)
78 views

Shop 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

Shop Management system

The Shop Management System provides a comprehensive


approach to handling essential aspects of shop operations,
including inventory, supplier relations, and sales tracking. Users
can easily add new products, update existing product details,
and keep track of stock levels through the low-stock check
feature. The system records each sale transaction, capturing
details like product ID, customer ID, quantity sold, and total
price, which allows it to compile an accurate sales history over
time.
Additionally, the system can generate a detailed sales report
that shows revenue by product, giving the user valuable insights
into best-selling items and overall shop profitability. Supplier
management functionality lets users add and retrieve supplier
information, ensuring that restocking and supplier
communications are streamlined. All interactions are guided
through a user-friendly menu, and every operation is backed up
to the relevant CSV files, allowing for reliable data storage and
easy retrieval. This setup is ideal for small shops needing a
simple, accessible tool for day-to-day management and efficient
data tracking.
Function List
1. add_new_product(products, new_product): Adds a new product record to the
products list and updates the "Products.csv" file with the new data.
2. update_product_stock(products, product_id, quantity): Updates the stock of a
specific product by its product_id and saves the updated product list to
"Products.csv".
3. record_sale(sales, new_sale): Adds a new sale record to the sales list and
updates the "Sales.csv" file with this new sale.
4. generate_sales_report(sales): Generates a report that shows the total sales
revenue per product based on the sales list.
5. add_new_supplier(suppliers, new_supplier): Adds a new supplier record to
the suppliers list and saves it to "Suppliers.csv".
6. find_supplier(suppliers, supplier_id): Searches for a supplier by supplier_id
and returns their details if found.
7. check_low_stock(products, threshold): Checks for products with stock levels
below the specified threshold and returns a list of low-stock items.
8. calculate_total_revenue(sales): Calculates and returns the total revenue from
all recorded sales in the sales list.
9. list_all_products(products): Lists all products in the products list by printing
each product's details.
10. delete_product(products, product_id): Deletes a product from the products
list by its product_id and updates the "Products.csv" file.
Codes
import csv

import os

# Base file path

BASE_PATH = "D:\\"

# Function to load data from CSV files

def load_data(file_name):

data = []

try:

with open(os.path.join(BASE_PATH, file_name), mode='r', newline='', encoding='utf-8') as file:

reader = csv.DictReader(file)

for row in reader:

data.append(row)

except FileNotFoundError:

print(f"{file_name} not found.")

return data

# Function to save data to CSV files

def save_data(file_name, data):

with open(os.path.join(BASE_PATH, file_name), mode='w', newline='', encoding='utf-8') as file:

writer = csv.DictWriter(file, fieldnames=data[0].keys())


writer.writeheader()

writer.writerows(data)

# Function to add a new product

def add_new_product(products, new_product):

products.append(new_product)

save_data("Products.csv", products)

# Function to update product stock

def update_product_stock(products, product_id, quantity):

for product in products:

if product['Product_ID'] == product_id:

product['Stock_Quantity'] = str(int(product['Stock_Quantity']) + quantity)

break

save_data("Products.csv", products)

# Function to record a sale

def record_sale(sales, new_sale):

sales.append(new_sale)

save_data("Sales.csv", sales)

# Function to generate sales report

def generate_sales_report(sales):

report = {}

for sale in sales:

product_id = sale['Product_ID']

total_price = float(sale['Total_Price'])

if product_id in report:

report[product_id] += total_price
else:

report[product_id] = total_price

return report

# Function to add a new supplier

def add_new_supplier(suppliers, new_supplier):

suppliers.append(new_supplier)

save_data("Suppliers.csv", suppliers)

# Function to find a supplier

def find_supplier(suppliers, supplier_id):

for supplier in suppliers:

if supplier['Supplier_ID'] == supplier_id:

return supplier

return None

# Function to check low stock products

def check_low_stock(products, threshold):

low_stock_products = []

for product in products:

if int(product['Stock_Quantity']) < threshold:

low_stock_products.append(product)

return low_stock_products

# Function to calculate total revenue

def calculate_total_revenue(sales):

total_revenue = sum(float(sale['Total_Price']) for sale in sales)

return total_revenue
# Function to list all products

def list_all_products(products):

for product in products:

print(product)

# Function to delete a product

def delete_product(products, product_id):

products[:] = [product for product in products if product['Product_ID'] != product_id]

save_data("Products.csv", products)

# Load data from CSV files

products = load_data("Products.csv")

sales = load_data("Sales.csv")

suppliers = load_data("Suppliers.csv")

while True:

print("\nWelcome to the Shop Management System")

print("1. Add New Product")

print("2. Update Product Stock")

print("3. Record Sale")

print("4. Generate Sales Report")

print("5. Add New Supplier")

print("6. Find Supplier")

print("7. Check Low Stock")

print("8. Calculate Total Revenue")

print("9. List All Products")

print("10. Delete a Product")

print("11. Exit")
choice = input("Please choose an option (1-11): ")

if choice == '1':

product_id = input("Enter Product ID: ")

product_name = input("Enter Product Name: ")

category = input("Enter Product Category: ")

price = input("Enter Product Price: ")

stock_quantity = input("Enter Product Stock Quantity: ")

supplier_id = input("Enter Supplier ID: ")

new_product = {

'Product_ID': product_id,

'Product_Name': product_name,

'Category': category,

'Price': price,

'Stock_Quantity': stock_quantity,

'Supplier_ID': supplier_id

add_new_product(products, new_product)

print("Product added successfully!")

elif choice == '2':

product_id = input("Enter Product ID to update stock: ")

quantity = int(input("Enter quantity to add: "))

update_product_stock(products, product_id, quantity)

print("Product stock updated successfully!")

elif choice == '3':

sale_id = input("Enter Sale ID: ")


product_id = input("Enter Product ID: ")

customer_id = input("Enter Customer ID: ")

quantity_sold = int(input("Enter Quantity Sold: "))

sale_date = input("Enter Sale Date (YYYY-MM-DD): ")

total_price = input("Enter Total Price: ")

new_sale = {

'Sale_ID': sale_id,

'Product_ID': product_id,

'Customer_ID': customer_id,

'Quantity_Sold': str(quantity_sold),

'Sale_Date': sale_date,

'Total_Price': total_price

record_sale(sales, new_sale)

print("Sale recorded successfully!")

elif choice == '4':

sales_report = generate_sales_report(sales)

print("Sales Report:", sales_report)

elif choice == '5':

supplier_id = input("Enter Supplier ID: ")

supplier_name = input("Enter Supplier Name: ")

contact_info = input("Enter Contact Info: ")

address = input("Enter Address: ")

new_supplier = {

'Supplier_ID': supplier_id,
'Supplier_Name': supplier_name,

'Contact_Info': contact_info,

'Address': address

add_new_supplier(suppliers, new_supplier)

print("Supplier added successfully!")

elif choice == '6':

supplier_id = input("Enter Supplier ID to find: ")

supplier = find_supplier(suppliers, supplier_id)

if supplier:

print("Supplier found:", supplier)

else:

print("Supplier not found.")

elif choice == '7':

threshold = int(input("Enter low stock threshold: "))

low_stock = check_low_stock(products, threshold)

print("Low Stock Products:", low_stock)

elif choice == '8':

total_revenue = calculate_total_revenue(sales)

print("Total Revenue:", total_revenue)

elif choice == '9':

print("All Products:")

list_all_products(products)

elif choice == '10':


product_id = input("Enter Product ID to delete: ")

delete_product(products, product_id)

print("Product deleted successfully!")

elif choice == '11':

print("Exiting the program. Goodbye!")

break

else:

print("Invalid choice. Please try again.")


Outputs
1. Add a new product

2.Update product stock

3.Record sales
4.Generate sales report
5.Add new Supplier

6.Find supplier
7.Check Low Stock
8.Calculate total revenue
9.List all products
10.delete a products

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