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

Pay. Roll

The document contains code for a payroll management system with the following functions: 1. A main menu with options to add, view, modify, and delete employee and payment details and generate pay slips. 2. Functions to add, view, modify and delete employee records stored in a .dat file using pickle module. 3. Functions to add, view and delete payment parameters by entering employee code and calculating salary components. 4. A pays() function with options to add, view and search pay slip details.

Uploaded by

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

Pay. Roll

The document contains code for a payroll management system with the following functions: 1. A main menu with options to add, view, modify, and delete employee and payment details and generate pay slips. 2. Functions to add, view, modify and delete employee records stored in a .dat file using pickle module. 3. Functions to add, view and delete payment parameters by entering employee code and calculating salary components. 4. A pays() function with options to add, view and search pay slip details.

Uploaded by

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

NAME --

ADITIYA,PRASHANT,SHORYA,
SOURABH
acknowledgement

I would like to express my special thanks


of gratitude to my COMPUTER SCIENCE
TEACHER “MR. AMIT SHARMA SIR” for
his able guidance and support in
completing our project.

I would also like to extend my gratitude


to principal
Ma’am “MRS. J.RAO” and vice principle
ma’am “MRS. G. LAMBA” for providing
me with all facility that was required.
At last I would like to thank my parents
and friends for helping me in completion
of the project.
payrollll(1)
###importing modules###
import pickle
import csv

### Defining main menu ###

def menu():
print("MAIN MENU".center(70),"\n")
print("***********WELCOME TO PAYROLL MANAGEMENT SYSTEM*******\n")
print("Choose options to perform:")
print("1.HOME")
print("2.EMPLOYEE")
print("3.PAYMENT PARAMETERS")
print("4.PAY SLIP")
print("5.SET SALARY")
print("6.QUIT")
choice=int(input("\nENTER YOUR CHOICE(1/2/3/4/5/6/7):"))
if choice==1:
print("\n****WELCOME TO THE HOME PAGE OF PAYROLL MANAGEMENT SYSTEM****")
a=input("ENTER YOUR USERNAME :")
b=input("ENTER THE PASSWORD :")
print("\n ENTER YOUR DETAILS : ")
print(a)
print(b)
elif choice==2:
print("\n****EMPLOYEE DATA****")
print("ENTER THE EMPLOYEE DETAILS")
employee()
elif choice==3:
print("\n****PAYMENT PARAMETERS****")
pay()
elif choice==4:
print("\n****PAY SLIP DETAILS****")
pays()
elif choice==5:
print("\n*****SET SALARY*****")
setsal()
elif choice==6:
print("MENU 6".center(70),"\n")
print("\n**** QUIT****")
print("THANK YOU!!!!".center(70),"\n")

else:
print("INVALID CHOICE")

### EMPLOYEE DETAILS FUNCTION ###

Page 1
payrollll(1)
def employee():
print("\n*****EMPLOYEE DETAILS******")
print("CHOOSE THE OPERATION TO PERFORM:")
print("1. ADD EMPLOYEE DETAILS")
print("2. VIEW EMPLOYEE DETAILS")
print("3. MODIFY EMPLOYEE DETAILS")
print("4. DELETE EMPLOYEE DETAILS")
choice2=int(input("\n ENTER YOUR CHOICE"))
if choice2==1:
writingE()
elif choice2==2:
readingE()
elif choice2==3:
modifyingE()
elif choice2==4:
deletingE()
else:
print("SORRY THE OPTION DOES NOT EXIST")

### ADD EMPLOYEE DETAILS ####

def writingE():
f=open("emp.dat","wb")
rec1=[]
while True:
e_code=int(input("ENTER EMPLOYEE CODE : "))
dep=(input("ENTER DEPARTMENT NAME :"))
desg=(input("ENTER DESIGNATION :"))
nm=(input("ENTER EMPLOYEE NAME :"))
ag=int(input("ENTER EMPLOYEE AGE :"))
db=int(input("ENTER EMPLOYEE'S DOB(DD/MM/YYYY) :"))
gen=(input("ENTER EMPLOYEE GENDER :"))
do=(input("ENTER DATE OF JOINING(DD/MM/YYYY"))
ph=int(input("ENTER PHONE NUMBER OF EMPLOYEE :"))
ad=(input("ENTER EMPLOYEE'S ADDRESS :"))
em=(input("ENTER EMPLOYEE'S EMAIL ADDRESS :"))
d1=[e_code,dep,desg,nm,ag,db,gen,do,ph,ad,em]
rec1.append(d1)
choice3=input("WANT TO ADD MORE EMPLOYEE'S DETAILS?(Y/N)")
if choice3=="N":
break
pickle.dump(rec1,f)
f.close()
choice4=input("WANT TO VIEW THE EMPLOYEES'S DETAILS?(Y/N)")
if choice4=="Y":
readingE()

Page 2
payrollll(1)
### VIEWING EMPLOYEE DETAILS ###

def readingE():
print("EMPLOYEE DETAILS ARE AS FOLLOWS :".center(70),"\n")
f=open("emp.dat","rb")
try:
k=pickle.load(f)
print("EMPLOYEE
CODE","DEPARTMENT","DESIGNATION","NAME","AGE","DOB","GENDER","DOJ","PHONE
NUMBER","ADDRESS","EMAIL ADDRESS")
for m in k:
a=m[0]
b=m[1]
c=m[2]
d=m[3]
e=m[4]
f=m[5]
g=m[6]
h=m[7]
j=m[8]
l=m[9]
s=m[10]
print(a,b,c,d,d,e,f,g,h,j,l,s)
f.close()
except:
print( )

### MODIFICATION OF EMPLOYEE DETAILS ###

def modifyingE():
f=open("emp.dat","rb+")
q=pickle.load(f)
r=int(input("ENTER EMPLOYEE'S CODE TO UPDATE : "))
flag=0
for n in q:
if n[0]==r:
n[3]==(input("ENTER NEW NAME : "))
flag=1
break
if flag==1:
f.seek(0)
pickle.dump(q,f)
else:
print("SORRY NO SUCH RECORD FOUND ")
f.close()

### DELETING EMPLOYEES'S DETAILS ###


Page 3
payrollll(1)

def deletingE():
f=open("emp.dat","rb")
z=pickle.load(f)
nme=(input("ENTER EMPLOYEE'S CODE TO DELETE THE RECORD : "))
f.close()
flag=0
f1=open("emp.dat","wb")
d=[]
for m in z:
if m[0]==nme:
flag=1
continue
d.append(m)
pickle.dump(d,f1)
if flag==0:
print(" SORRY RECORD DOES NOT EXIST ")
else:
print("RECORD DELETED!")
f1.close()

### PAYMENT PARAMETERS MENU ##

def pay():

print("********PAYMENT DETAIlS******".center(70),"n")
print("CHOOSE ONE OPTION : (1,2,3)")
print("1.ADD PAYMENT DETAILS ")
print("2.VIEW PAYMENT DETAILS ")
print("3.DELETE PAYMENT DETAILS ")
choice5=int(input("\n ENTER YOUR CHOICE : "))
if choice5==1:
writingP()
elif choice5==2:
readingP()
elif choice5==3:
deletingP()
else:
print("SORRY THE RECORDS DOES NOT EXIST!!!!")

# ADDING PAYMENT DETAILS #

def writingP():
f=open("emp.dat","wb")
rec2=[]
while True:
Page 4
payrollll(1)
print("***************PAYMENT PARAMETERS*********".center(70),"\n")
ename=(input("ENTER EMPLOYEE NAME :"))
ecode=int(input("ENTER EMPLOYEE CODE:"))
desig=(input("ENTER EMPLOYEE DESIGNATION"))
totaldays=int(input("ENTER THE TOTAL DAYS PRESENT :"))
compensation=int(input("ENTER THE COMPENSATION PER DAY :"))

basicsalary=totaldays*compensation
HRA=basicsalary*0.40
conveyance=basicsalary*0.01
specialallowances=basicsalary*0.001
medicalexpenses=basicsalary*0.045
PF=basicsalary*12;
professionaltax=basicsalary*0.05
grosssalary=basicsalary+HRA+conveyance+specialallowances+medicalexpenses
deductions=PF+professionaltax
netsalary=grosssalary-deductions
print("\n")
print(" PACIFIC SOFTWARE UNIT ")
print(" (A QUALITY SOFTWARE BUSINESS CONSULTANCY) ")
print("EMPLOYEE NAME :",ename, "EMPLOYEE CODE :",ecode)
print("DESIGNATION :",desig)
print("----------------------------------------------------------")
print(" SALARY FOR THE MONTH OF DEC 2020")
print("----------------------------------------------------------")
print("BASIC SALARY ",basicsalary,sep='')
print("CONVEYANCE ",conveyance,sep='')
print("SPECIAL ALLOWANCES ",specialallowances,sep='')
print("MEDICAL EXPENSES ",medicalexpenses,sep='')
print("PROVIDENT FUND (-)",PF,sep='')
print("PROFESSIONAL TAX (-) ",professionaltax,sep='')
print(" --------------------------")
print("TOTAL SALARY ",grosssalary,sep='')
print("TOTAL DEDUCTIONS ",deductions,sep='')
print(" ---------------------------")
print("NET SALARY ",netsalary,sep='')

d=[ename,ecode,totaldays,compensation,basicsalary,HRA,conveyance,specialallowances,m
edicalexpenses,PF,professionaltax,grosssalary,deductions,netsalary]
rec2.append(d)
choice6=(input("WANT TO ENTER MORE PAYMENT DETAILS?(Y/N)"))
if choice6=="N":
break
pickle.dump(rec2,f)
f.close()
choice7=(input("WANT TO VIEW THE PAYMENT DETAILS?(Y/N)"))
if choice7=="Y":
readingP()
Page 5
payrollll(1)

# VIEW THE PAYMENT DETAILS #

def readingP():
print("\n****** DISPLAYING PAYMENT DETAILS******".center(70))
f=open("emp.dat","rb")
try:
k=pickle.load(f)
print("EMPLOYEE NAME","EMPLOYEE CODE","EMPLOYEE DESIGNATION","TOTAL DAYS
PRESENT","COMPENSATION PR DAY")
for m in k:
a=m[0]
b=m[1]
c=m[2]
d=m[3]
e=m[4]
print(a,b,c,d,e)
f.close()
except:
print("PAYMENT DETAILS DOES NOT EXIST!!")

# DELETING PAYMENT DETAILS #

def deletingP():
f=open("emp.dat","rb")
y=pickle.load(f)
cd=int(input("ENTER THE EMPOYEE'S CODE TO DELETE THE PAYMENT DETAILS"))
f.close()
flag=0
f1=open("emp.dat","wb")
d=[]
for m in y:
if m[0]==cd:
flag=1
continue
d.append
pickle.dump(d,f1)
if flag==0:
print("PAYMENT DETAILS DOES NOT EXIST")
else:
print("PAYMENT DETAILS DELETED SUCCESSFULLY")
f1.close()

### PAYSLIP DETAILS ###

def pays():
Page 6
payrollll(1)

print("********PAYSLIP DETAILS*****".center(70),"\n")
print("CHOOSE ONE OPTION : (1,2,3)")
print("1.ADDING PAYSLIP DETAILS ")
print("2.VIEWING PAYSLIP DETAILS ")
print("3.SEARCHING PAYSLIP DETAILS ")
choice8=int(input("ENTER THE CHOICE :"))
if choice8==1:
writingPS()
elif choice8==2:
readingPS()
elif choice8==3:
searchingPS()
else:
print("SORRY THE MENU DOES NOT EXIST !!!")

# ADD PAYSLIP DETAILS #

def writingPS():
f=open("emp.dat","wb")
rec=[]
while True:
pm=input("ENTER THE PAYMENT NUMBER ")
emi=int(input("ENTER THE EMPLOYEE ID : "))
nmi=input("ENTER THE EMPLOYEE NAME : ")
bn=int(input("ENTER THE ACCOUNT NUMBER :"))
ttl=int(input("ENTER THE TOTAL SALARY :"))
d=[pm,emi,nmi,bn,ttl]
rec.append(d)
choice9=input("WANT TO ADD MORE DETAILS(Y/N) ")
if choice9=="N":
break
pickle.dump(rec,f)
f.close()
choice10=input("WANT TO VIEW THE DETAILS ?(Y/N)")
if choice10=="Y":
readingPS()

# VIEW THE PAYSLIP DETAILS #

def readingPS():
print()
print("******* DISPLAYING PAY SLIP*******")
print("PAYSLIP DETAILS ARE AS FOLLOWS :")
f=open("emp.dat","rb")
try:
j=pickle.load(f)
Page 7
payrollll(1)
print("PAYMENT NUMBER","EMPLOYEE ID","EMPLOYEE NAME","ACCOUNT NUMBER","TOTAL
SALARY")
for m in j:
jn=m[0]
kp=m[1]
sd=m[2]
dc=m[3]
eu=m[4]
print(jn,kp,sd,dc,eu)
print()
f.close()
except:
print("NO RECORDS FOUND")

# SEARCHING PAYSLIP DETAILS #

def searchingPS():
f=open("emp.dat","rb")
j=pickle.load(f)
ecode=int(input("ENTER THE EMPLOYEE'S CODE TO SEARCH THE RECORD :"))
found=0
for m in j:
if ecode==m[1]:
print("RECORD FOUND!")
else:
print("RECORD NOT FOUND!!!!")

#### SET SALARY DETAILS ####

def setsal():
print("******SET EMPLOYEE SALARY*****".center(70),'\n')
print("CHOOSE THE OPERATION :")
print("1.SET DETAILS")
print("2.VIEW DETAILS")
print("3.SEARCHING DETAILS")
choice12=int(input("ENTER THE CHOICE :"))
if choice12==1:
writingcsv()
elif choice12==2:
readingcsv()
elif choice12==3:
searchingcsv()
else:
print("SORRY THE MENU DOES NOT EXIST !!!!")

# SETTING SALARY DETAILS #


Page 8
payrollll(1)

def writingcsv():
f=open("emp2.csv","w")
cwrk=csv.writer(f)
cwrk.writerow(["EMPLOYEE NAME","DESIGNATION","SALARY"])
rec=[]
while True:
name=input("ENTER THE NAME OF EMPLOYEE :")
designa=input("ENTER THE DESIGNATION :")
sal=int(input("ENTER THE SALARY : "))
p=[name,designa,sal]
rec.append(p)
choice13=input("WANT TO SET MORE RECORDS?(Y/N)")
if choice13=="N":
break
cwrk.writerows(rec)
f.close()
choice14=input("WANT TO VIEW THE SET RECORDS ?(Y/N)")
if choice14=="Y":
readingcsv()

# VIEWING THE SET SALARY #

def readingcsv():
print()
print("SET SALARY HERE ")
f=open("emp2.csv","r")
cwrk=csv.reader(f)
for i in cwrk:
print(*i)
f.close()

# SEARCHING THE SET SALARY #

def searchingcsv():
f=open("emp2.csv","r")
nam=input("ENTER EMPLOYEE NAME :")
cwrk=csv.reader(f)
for row in cwrk:
for row in cwrk:
for field in row:
if field==nam:
print(row)
f.close()

#calling main function


menu()
Page 9

You might also like