Вы находитесь на странице: 1из 27

1.

INTRODUCTION

The main objective of the python project on stock management system is to manage the
details of the customer, inventory, supplier, sales, and payment. It manages all the
information about the customer, purchasing, payment. The project is totally built on
administrative end and access is only guaranteed to the administrator. The purpose of this
project is to build a hassle free application program to reduce manual work. It tracks all the
details about the amount available in stock and payment on producing the bill.

For optimal sales and inventory management processes, you need robust functionality for
managing your logistics facilities. Support for inventory management helps you record and
track materials on the basis of both quantity and value. Warehouse inventory management
functions cover internal warehouse movements and storage. Using this software we can
reduce costs for warehousing, transportation, order fulfillment, and material handling – while
improving customer service. You can significantly improve inventory turns, optimize the
flow of goods, and shorten routes within your warehouse or distribution center. Additional
benefits of inventory management include improved cash flow, visibility, and decision
making. This software is user friendly and hence easy to use. Employees can plan, enter, and
document warehouse and internal stock movements by managing goods receipts, goods
issues, storage, picking and packing, physical stock transfers, and transfer postings. In
existing system there are numerous problems of manual stock management system
As we know manual system are quite tedious, time consuming and less efficient and accurate
in comparison to the computerized system.

So following are some disadvantages of the old system:

1. Time consuming

2. Less accurate

3. Less efficient

4. Lot of paper work

5. Slow data processing

6. Not user friendly environment

7. Difficult to keep old records

1|Page
2. LIBRARIES USED

i. mysql.connector: It enables python programs to access MySQL databases. MySQL


provides standards-based drivers for JDBC, ODBC, and .Net enabling developers to
build database applications in their language of choice. In addition, a native C library
allows developers to embed MySQL directly into their applications.

ii. tabulate: It enables readable representation of mixed textual and numeric data using
tables. The main function of this library is printing small tables without hassle: just one
function call, formatting is guided by the data itself, authoring tabular data for
lightweight plain-text markup: multiple output formats suitable for further editing or
transformation, readable presentation of mixed textual and numeric data: smart column
alignment, configurable number formatting, alignment by a decimal point

iii. webbrowser: It enables python programs to access websites. The webbrowser library


provides a high-level interface to allow displaying Web-based documents to users.
Under most circumstances, simply calling the open() function from this module will do
the right thing. Being able to easily launch a browser can be a useful operation in many
scripts. For example, maybe a script performs some kind of deployment to a server and
one would like to have it quickly launch a browser so one can verify that it’s working.
Or maybe a program writes data out in the form of HTML pages and just like to fire up
a browser to see the result. Either way, the webbrowser module is a simple solution.

iv. getpass: It prompts the user for a password without echoing. The getpass
module provides a secure way to handle the password prompts where programs
interact with the users via the terminal. The getpass library is used to prompt to users
using the string prompt and reads the input from the user as Password

2|Page
3. FUNCTIONS USED

Inbuilt Functions:

i. input():This function is used to tell the program to stop and wait for the user to key in
the data to interact with the python program.

ii. print(): This function is used to print the specified information or message on the
screen.

iii. cursor(): This function is used to facilitate the row by row processing of records in
the result set.

iv. execute(): This function is used in python to use the various commands available in
python.

v. fetchall(): This function is used to return all the records retrieved as per query in a
tuple form.

vi. connect(): This function is used to create a connection to the database having four
arguments namely Server Name, Database Username, Password And Database Name.

vii. exit(): This function is used to terminate a program abruptly in python.

User Defined Functions:

i. feed(): This function is used to take the feedback from the customer.

ii. dat(): This function is used to create a table in mysql for storing product details.

iii. shop(): This function is used by the shopkeeper to manage the stock and product
details.

iv. customer(): This function is used to execute the buying procedure of the products.

v. dele(): This function is used to delete the database.

vi. main(): This function is used to select the features of the main menu.

3|Page
4. DATABASE DESCRIPTION

A database is a data structure that stores organized information. Most databases contain
multiple tables, which may each include several different fields. For example, a company
database may include tables for products, employees, and financial records. Each of these
tables would have different fields that are relevant to the information stored in the table.

Nearly all e-commerce sites use databases to store product inventory and customer


information. These sites use a database management system (or DBMS), such as Microsoft
Access, FileMaker Pro, or MySQL as the "back end" to the website. By storing website data
in a database, the data can be easily searched, sorted, and updated. This flexibility is
important for e-commerce sites and other types of dynamic websites.

Table 1: Product details

Column Name Datatype Description


Product_ID char(100) Id of the product
Product_Name char(100) Name of the product
Brand_Name char(100) Brand of the product
Qty int(11) Quantity of the product
cost_price int(11) Cost price of the product
selling_price Int(11) Selling price of the product

Table 2: Billing details

Column Name Datatype Description


Product_ID char(100) Id of the product
Product_Name char(100) Name of the product
Brand_Name char(100) Brand of the product
Price int(11) Price of the product bought

Table 3: Feedback details

Column Name Datatype Description


Name char(50) Name of the customer
Experience char(30) Overall experience of
customer
Satisfied char(10) Customer satisfaction
Rating int(11) Rating of the product
Service char(10) Customer service
Feedback char(100) Feedback and suggestion

4|Page
5. SOURCE CODE

stock.py
import getpass
import webbrowser
import mysql.connector as ms
from tabulate import tabulate
print("\t\t===========WELCOME TO STOCK
MANAGEMENT=============\n\t\t\t")
def feed1():
x=ms.connect(host="localhost",user="root",passwd="123",databas
e='stock')
if x.is_connected():
cur=x.cursor()
cur.execute("create table Feedback(Name
char(50),Experience char(30),Satisfied char(10),Rating
int,Service char(10),Feedback char(100))")
feed2()
def feed2():
x=ms.connect(host="localhost",user="root",passwd="123",databas
e='stock')
if x.is_connected():
cur=x.cursor()
Name=input("Enter your name: ")
Experience=input("How was your overall experience?
")
Satisfied=input("Are you satisfied with the product?
")
Rating=int(input("How would you like to rate our
product on the scale of 1-10? "))
Service=input("Was the service good? ")
Feedback=input("Please suggest us how to improve to
live up to your expectations: ")

5|Page
cur.execute("Insert into Feedback
values('{}','{}','{}',
{},'{}','{}')".format(Name,Experience,Satisfied,Rating,Service
,Feedback))
x.commit()
x.close()
def feed():
while True:
print("1. Online Feedback")
print("2. Offline Feedback")
print("3. Back to main menu")
g1=int (input("\t\t Enter Your Choice: "))
if g1==1:
webbrowser.open_new_tab('https://forms.gle/x
LS6BteXzKdFh6gw8')
elif g1==2:
print("1. Feedback Form")
print("2. Feedback Result [Does not open
without entering feedback form]")
s1=int (input("\t\t Enter Your Choice: "))
if s1==1:
feed1()
elif s1==2:
result()
else:
print("ERROR")
elif g1==3:
main()
else:
print("ERROR")
def dat():
x=ms.connect(host="localhost",user="root",passwd="123")
if x.is_connected():

6|Page
cur=x.cursor()
cur.execute("create database stock")
cur.execute("use stock")
cur.execute("create table products ( Product_ID
char(100),Product_Name char(100),Brand_Name char(100),Qty
int,cost_Price int,selling_price int)")
x.commit()
x.close()
print("database is successfully created\n*** Please Note
that once Database is created it need not be created
again***")
main()
def shop():
x=ms.connect(host="localhost",user="root",passwd="123",databas
e='stock')
if x.is_connected():
cur=x.cursor()
a="y"
while a=="y" or a=="Y":
chooser=int(input("Enter the choice to be
selected \n 1. Insert Products details \n 2. Read Product
details \n 3. Update Product details \n 4. Delete Product
details \n 5. View Record \n 6.Main menu\n"))
if chooser==1:
a="y"
while a=="y" or a=="Y":
Product_id=input("Enter Product Id: ")
Product_name=input("Enter Product Name:
")
Brand_name=input("Enter Brand Name: ")
Qty=int(input("Enter Quantity of the
product: "))
cost_price=int(input("Enter cost Price
of the products: "))

7|Page
selling_price=int(input("Enter selling
Price of the products: "))

cur.execute("Insert into products


values(‘{}’,’{}’,’{}’{},{},{})”.format (Product_Id,
Product_name,Brand_name,Qty,cost_price,selling_price)
x.commit()
print ("Data inserted
successfully \n Viewing the result...")
cur.execute("select * from products")
head=['Product id','Product name','Brand
name','Qty','cost price','selling price']
data=cur.fetchall()
print(tabulate(data,headers=head,tablefm
t='psql'))

a=input("Do you want to enter more


products?(y/n)")
if chooser==2:
cur.execute("select * from products")
head=['Product id','Product name','Brand
name','Qty','cost price','selling price']
data=cur.fetchall()
print(tabulate(data,headers=head,tablefmt='p
sql'))
if chooser==3:
a="Y"
while a=="y" or a=="Y":
update_chooser=int(input("Enter choice
to be updated \n 1. Update Product id \n 2. Update Product
name \n 3. Update Brand name \n 4. Update Quantity \n 5.
Update cost price \n 6.Update selling price"))
if update_chooser==1:
existing_id=input("Enter
existing Product Id: ")
cur.execute("select
exists(select * from products where
Product_Id='{}')".format(existing_id))

8|Page
data=cur.fetchone()

if data[0]==1:
new_id=input("Enter new
Product Id: ")
cur.execute("update
products set Product_id='{}' where
Product_id='{}'".format(new_id,existing_id))
print ("Data updated
successfully")
x.commit()
cur.execute("select *
from products")
head=['Product
id','Product name','Brand name','Qty','cost price','selling
price']
data=cur.fetchall()
print(tabulate(data,head
ers=head,tablefmt='psql'))
a=input("Do you want to
update more data? (y/n)")
else:
print("Invalid Product
Id")
if update_chooser==2:
existing_id=input("Enter
existing Product Id: ")
cur.execute("select
exists(select * from products where
Product_Id='{}')".format(existing_id))
data=cur.fetchone()
if data[0]==1:
new_name=input("Enter
new Product Name: ")
cur.execute("update
products set Product_name='{}' where
Product_Id='{}'".format(new_name,existing_id))

9|Page
print ("Data updated
successfully")

x.commit()
cur.execute("select *
from products")
head=['Product
id','Product name','Brand name','Qty','cost price','selling
price']
data=cur.fetchall()
print(tabulate(data,head
ers=head,tablefmt='psql'))

a=input("Do you want to


update more data? (y/n)")
else:
print("Invalid Product
Id")
if update_chooser==3:
existing_id=input("Enter
existing Product Id: ")
cur.execute("select
exists(select * from products where
Product_Id='{}')".format(existing_id))
data=cur.fetchone()
if data[0]==1:
new_brandname=input("Ent
er new Brand Name: ")
cur.execute("update
products set Brand_name='{}' where
Product_Id='{}'".format(new_brandname,existing_id))
print ("Data updated
successfully")
x.commit()
cur.execute("select *
from products")

10 | P a g e
head=['Product
id','Product name','Brand name','Qty','cost price','selling
price']

data=cur.fetchall()
print(tabulate(data,headers=head,tablefmt='psql'))
a=input("Do you want to
update more data? (y/n)")
else:
print("Invalid Product
Id")
if update_chooser==4:
existing_id=input("Enter
existing Product Id: ")
cur.execute("select
exists(select * from products where
Product_id='{}')".format(existing_id))
data=cur.fetchone()
if data[0]==1:
new_qty=input("Enter new
Qty of the Product: ")
cur.execute("update
products set Qty={} where
Product_id={}".format(new_qty,existing_id))

print ("Data updated


successfully")
x.commit()
cur.execute("select *
from products")
head=['Product
id','Product name','Brand name','Qty','cost price','selling
price']
data=cur.fetchall()
print(tabulate(data,head
ers=head,tablefmt='psql'))

11 | P a g e
a=input("Do you want to
update more data? (y/n)")
else:

print("Invalid Product
Id")
if update_chooser==5:
existing_id=input("Enter
existing Product Id: ")
cur.execute("select
exists(select * from products where
Product_id='{}')".format(existing_id))
data=cur.fetchone()
if data[0]==1:
new_price=input("Enter
new cost Price: ")
cur.execute("update
products set cost_price={} where
Product_id='{}'".format(new_price,existing_id))
print ("Data updated
successfully")
x.commit()
cur.execute("select *
from products")
head=['Product
id','Product name','Brand name','Qty','cost price','selling
price']
data=cur.fetchall()
print(tabulate(data,head
ers=head,tablefmt='psql'))
a=input("Do you want to
update more data? (y/n)")
else:
print("Invalid Product
Id")
if update_chooser==6:

12 | P a g e
existing_id=input("Enter
existing Product Id: ")
cur.execute("select
exists(select * from products where
Product_id='{}')".format(existing_id))

data=cur.fetchone()
if data[0]==1:
new_price=input("Enter
new selling Price: ")
cur.execute("update
products set selling_price={} where
Product_id='{}'".format(new_price,existing_id))
print ("Data updated
successfully")
x.commit()
cur.execute("select *
from products")
head=['Product
id','Product name','Brand name','Quantity','cost
price','selling price']
data=cur.fetchall()
print(tabulate(data,head
ers=head,tablefmt='psql'))
a=input("Do you want to
update more data? (y/n)")
else:
print("Invalid Product
Id")

if chooser==4:
a='y'
while a=='y' or a=='Y':
Product_id=input("Choose Product
id to delete: ")
cur.execute("select
exists(select * from products where
Product_id='{}')".format(Product_id))
13 | P a g e
data=cur.fetchone()

if data[0]==1:

cur.execute("delete from
products where Product_id='{}'".format(Product_id))
x.commit()
print("Data of Product_id:
'{}' deleted successfully".format(Product_id))
a=input("Delete more data ?
(y/n)")
else:
print("Invalid Product_id")
a=input("Do you want to try
again ?(y/n)")
if chooser==5:
a='y'
while a=='y' or a=='Y':
head=['Product id','Product
name','Brand name','Quantity','cost price','selling price']
Product_id=input("Enter Your
Product id: ")
cur.execute("select
exists(select * from products where
Product_id='{}')".format(Product_id))
data=cur.fetchone()
if data[0]==1:
cur.execute("select * from
products where Product_id='{}'".format(Product_id))
data=cur.fetchall()
print(tabulate(data,headers=
head,tablefmt='psql'))
a=input("View another
result? (y/n)")
else:
print("Invalid Product_id")
14 | P a g e
a=input("Do you want to try
again ?(y/n)")
a=input("Do you want to continue(y/n)?")

if chooser==6:
main()
x.close()
def customer():
x=ms.connect(host="localhost",user="root",passwd="123",databas
e='stock')
if x.is_connected():
cur=x.cursor()
cur.execute("create table bill (Product_id
char(100),Product_name char(100),Brand_name char(100),Price
int)")
x.commit()
m="y"
while m=="Y" or m=="y":
chooser1=int(input("Enter the choice
to be selected \n 1. Show the menu \n 2. Add into cart \n 3.
Remove from cart \n 4. View Bill \n 5. Main Menu\n"))
if chooser1==1:
cur.execute("Select
Product_ID,Product_Name,Brand_Name,Selling_price from
products")
head=['Product Id','Product
name','Brand name','price']
data=cur.fetchall()
print(tabulate(data,headers=head
,tablefmt='psql'))
if chooser1==2:
m="y"
while m=="y" or m=="Y":
i=input("enter the ID of the
product to add into the cart:")

15 | P a g e
cur.execute("insert into
bill (Product_Id,Product_name,Brand_name,Price) select
Product_Id,Product_Name,Brand_Name,selling_Price from products
where Product_Id='{}'".format(i))

cur.execute("update products
set Qty=Qty-1 where Product_Id='{}'".format(i))
x.commit()
print("item has been
successfully added to cart.\n")

m=input("do you want to add


more(y/n)?")
if chooser1==3:
m="y"
while m=="y" or m=="Y":
i=input("enter the ID of the
product to remove from the cart:")
cur.execute("delete from
bill where Product_Id='{}'".format(i))
cur.execute("update products
set Qty=Qty+1 where Product_Id='{}'".format(i))
x.commit()
print("item has been
successfully removed from cart.")
m=input("Do you want to
remove more(y/n)?")
if chooser1==4:
cur.execute("Select
Product_Id,Product_Name,Price from bill")
head=['Product Id','Product
name','Price']
data=cur.fetchall()
print(tabulate(data,headers=head
,tablefmt='psql'))
print("\n")

16 | P a g e
cur.execute("select SUM(price)
as totalsum from bill")
result=cur.fetchall()
for i in result:

print("
total=Rs",i[0])
cur.execute("drop table bill")
x.commit()
x.close()
print("\n")
if chooser1==5:
main()
m=input("Do you want to
continue(y/n)?")
def dele():
x=ms.connect(host="localhost",user="root",passwd="123")
if x.is_connected():
cur=x.cursor()
cur.execute("drop database Stock")
x.commit()
x.close()
main()

def main():

while True :
print("\t\t\t 1. Create Database (Only
when used first time)")

print("\t\t\t 2. For Shopkeeper")


print("\t\t\t 3. For customer")
17 | P a g e
print("\t\t\t 4. Delete database")
print("\t\t\t 5. Feedback")
print("\t\t\t 6. Exit ")

p=int (input("\t\tEnter Your Choice: "))


if p==1:
dat()
elif p==2:
shop()
elif p==3:
customer()
elif p==4:
dele()
elif p==5:
feed()
elif p==6:
exit()
else:
print ("ERROR")
p = getpass.getpass(prompt='Password')
if p == 'a':
main()
else:
print('The Password entered by you is incorrect..!!!')

18 | P a g e
6. OUTPUT SCREENSHOTS

Fig 1-Main Menu

Fig 2-Creating database before first use

19 | P a g e
Fig 3-Menu for Shopkeeper

Fig 4- Item added in the stock (i)

Fig 4- Item added in the stock (ii)

20 | P a g e
Fig 5- Items present in Stock

Fig 6-Update the details of the Item

21 | P a g e
Fig 7- Customer Menu

Fig 8-Add to Cart

Fig 9- Remove from cart

Fig 10- Billing

22 | P a g e
Fig. 11 Offline Feedback Form

Fig. 12 Offline Feedback Result

23 | P a g e
24 | P a g e
Fig. 13 Online Feedback Result (i)

Fig. 14 Online Feedback Result (ii)

Fig. 15 Online Feedback Result (iii)

25 | P a g e
7. CONCLUSION

To conclude, stock management is a simple computing device base application basically


suitable for Small Corporation. It has all primary items that are used for the small
organization. In any commercial enterprise, make it large or small; we should remember the
fact that taking suitable care of our inventory could be very essential. One of the reasons for
the failure of a business is its stock control. There are numerous methods to combat failure,
and we can begin from here. There are new generation which could assist us maintain and
supervise our stock. The scope of this system is to provide user efficient working
environment and more output can be generated through this. This system provides user
friendly interface resulting in knowing each and every usability features of the system. This
system helps in tracking records so that past records can be verified through them and one
can make decisions based on the past records. This system completes the work in a very less
time resulting in less time consumption and high level of efficiency. This system is developed
in such a way that even a naïve user can also operate the system easily. The calculations are
made very quickly and the records are directly saved into databases and the databases can be
maintained for a longer period of time. Each record can be retrieved and can be verified for
the future transactions. Also this system provides high level of security for data leaking as
only admin people can access the database no changes can be made in it until it verifies the
password. We also have operator login through which operator can take orders but can’t
make changes in the database. This system thus can be really useful for the present as well as
the future generations to combat with stock management problems.

26 | P a g e
8. Bibliography

1. www.wikipedia.com (Visited on October 19,2019)


2. www.answersite.com (Visited on September 25,2019)
3. www.stackoverflow.com (Visited on October 20,2019)
4. www.codespeedy.com (Visited on October 6,2019)
5. www.sevenforums.com (Visited on September 18,2019)
6. www.github.com (Visited on October 23,2019)
7. www.geeksforgeeks.com (Visited on September 22,2019)
8. Computer Science with Python by Sumita Arora

27 | P a g e

Вам также может понравиться