You are on page 1of 8

import os,getpass

print
"<=================================================================================
==============>"
print "|\t\t\t\tWelcome to the Online Expense manager program.\t\t\t|"
print
"<=================================================================================
==============>"
log = open('login.txt', 'a+')
choice1 = raw_input("Do you wish to create a new account (Y/N) : ")
if choice1.upper() == 'Y':
uniq = False
while uniq != True:
accname = raw_input("Enter the Username : ")
pas = getpass.getpass("Enter the Password : ")
for m in log:
m= m.rstrip('\n').split(':')
if accname== m[0]:
print "Username already exists! Enter another username."
break
else:
uniq = True
log.writelines(accname + ':' + pas + '\n')
_dir = os.path.join("Expense Management system/", accname) # creating
directories form variables..
os.makedirs(_dir)
login = True
log.close()
else:
tries = 1 # User allowed a maximum of 3 tries before the program gets Aborted.
For security reasons.
while tries <= 3:
accname = raw_input("Enter the Username : ")
pas = getpass.getpass("Enter the Password : ")
for i in log:
i = i.rstrip("\n").split(':')
if accname == i[0] and pas == i[1]:
login = True
print "Password Verification Success! Accessing the Files........"
_dir = os.path.join("Expense Management system/", accname) #
creating directories form variables..
tries = 4
break
else:
print "Verification falied! You have %d chances remaining!" %(4 -
tries)
login = False
tries += 1
log.seek(0)
while login == True:
print "Welcome"
username=accname+'.txt'
username1=accname+'schedule'+'.txt'
file1=open(username,'a+')
file1.close()
while True:
print"1.Add an expense"
print"2.Track expense"
print"3.Modify the entries or add a entry to a already present date"
print"4.Delete entries"
print"5.Schedule payments"
print"6.Overall report"
print"7.Exit"

choice=int(raw_input("Please enter your choice(1-6):"))


if choice==1:
date=raw_input("Enter the date (dd/mm/yyyy):")
file1.write('Date:'+'\n'+date+'\n')
while True:
print"Which category?"
print"1.Automobile(Fuel,Maintenance)"
print"2.Entertainment(Movies,Party,Concert,Sports)"
print"3.Family(Childcare,Toys,Others)"
print"4.Food(Breakfast,Lunch,Dinner,Snacks,Groceries)"
print"5.Insurance(Auto,Health,Life)"
print"6.Tax(Property,Vehicle,Others)"
print"7.Travel(Airplane,Bus,Train,Food,Hotel,Taxi,Misc,Others)"
print"8.Utilities(Water,Cable
tv,Electrical,Gas,Internet,Telephone)"
print"9.Completed entering"
ch1=int(input("Enter your choice(1-9):"))
if ch1==1:
fuel=float(input("Fuel cost:"))
maintenance=float(input("Maintenance cost:"))
automobile=['Fuel:'+str(fuel),'Maintenance:'+str(maintenance)]
file1.write(str(automobile)+'\n')
elif ch1==2:
movies=float(input("Movies cost:"))
party=float(input("Party cost:"))
concert=float(input("Concert cost:"))
sports=float(input("Sports cost:"))

entertainment=['Movies:'+str(movies),'Party:'+str(party),'Concert:'+str(concert),'S
ports:'+str(sports)]
file1.write(str(entertainment)+'\n')
elif ch1==3:
childcare=float(input("Child care cost:"))
toys=float(input("Toys cost:"))
others=float(input("Other cost:"))

family=['Childcare:'+str(childcare),'Toys:'+str(toys),'Others:'+str(others)]
file1.write(str(family)+'\n')
elif ch1==4:
self.breakfast=float(input("breakfast:"))
lunch=float(input("Lunch:"))
dinner=float(input("Dinner:"))
snacks=float(input("Snacks:"))
groceries=float(input("Groceries:"))

food=['Breakfast:'+str(breakfast),'Lunch:'+str(lunch),'Dinner:'+str(dinner),'Snacks
:'+str(snacks),'Groceries'+str(groceries)]
file1.write(str(food)+'\n')
elif ch1==5:
auto=float(input("auto:"))
health=float(input("health:"))
life=float(input("life:"))

insurance=['Auto:'+str(auto),'Health:'+str(health),'Life:'+str(life)]
file1.write(str(insurance)+'\n')
elif ch1==6:
propertytax=float(input("property:"))
vehicletax=float(input("vehicle:"))
other1=float(input("others:"))

tax=['Property:'+str(propertytax),'Vehicle:'+str(vehicletax),'Others:'+str(other1)]
file1.write(str(tax)+'\n')
elif ch1==7:
airplane=float(input("airplane:"))
bus=float(input("bus:"))
train=float(input("train:"))
food=float(input("food:"))
hotel=float(input("hotel:"))
taxi=float(input("taxi:"))
othertrans=float(input("Other transportation related costs:"))
misc=float(input("misc"))

travel=['Airplane:'+str(airplane),'Bus:'+str(bus),'Train:'+str(train),'Food:'+str(f
ood),'Hotel:'+str(hotel),'Taxi:'+str(taxi),'Misc:'+str(misc),'Others:'+str(othertra
ns)]
file1.write(str(travel)+'\n')
elif ch1==8:
water=float(input("water:"))
cabletv=float(input("cabletv:"))
electrical=float(input("electrical:"))
gas=float(input("gas:"))
internet=float(input("internet:"))
telephone=float(input("telephone:"))
utilities=['Water:'+str(water),'Cable
tv:'+str(cabletv),'Electrical:'+str(electrical),'Gas:'+str(gas),'Internet:'+str(int
ernet),'Telephone:'+str(telephone)]
file1.write(str(utilities)+'\n')
elif ch1==9:
break
else:
print"Wrong choice... Retry"
file1.close()
elif choice==2:
file2=open(username,'r')
date1=raw_input('Enter date(dd/mm/yyyy):')
x=file2.readline()
while True:
if x.rstrip('\n')==date1:
while True:
print x
x=file2.readline()
if x=='\n'+'Date'+'\n' or x=='':
break
elif x=='':
print" Date not found.."
break
else:
x=file2.readline()
file2.close()
elif choice==3:
date2=raw_input('Enter date under which the entry that requires to be
modified is present(dd/mm/yyyy):')
file3=open(username,'r')
file4=open('samp.txt','w')
x1=file3.readline()
while True:
if x1.rstrip('\n')==date2:
file4.write(x1)
while True:
print"Which category?"
print"1.Automobile(Fuel,Maintenance)"
print"2.Entertainment(Movies,Party,Concert,Sports)"
print"3.Family(Childcare,Toys,Others)"
print"4.Food(Breakfast,Lunch,Dinner,Snacks,Groceries)"
print"5.Insurance(Auto,Health,Life)"
print"6.Tax(Property,Vehicle,Others)"

print"7.Travel(Airplane,Bus,Train,Food,Hotel,Taxi,Misc,Others)"
print"8.Utilities(Water,Cable
tv,Electrical,Gas,Internet,Telephone)"
print"9.Completed entering"
ch2=int(raw_input("Enter your choice(1-9):"))
if ch2==1:
fuel=float(input("Fuel cost:"))
maintenance=float(input("Maintenance cost:"))

automobile=['Fuel:'+str(fuel),'Maintenance:'+str(maintenance)]
file4.write(str(automobile)+'\n')
elif ch2==2:
movies=float(input("Movies cost:"))
party=float(input("Party cost:"))
concert=float(input("Concert cost:"))
sports=float(input("Sports cost:"))

entertainment=['Movies:'+str(movies),'Party:'+str(party),'Concert:'+str(concert),'S
ports:'+str(sports)]
file4.write(str(entertainment)+'\n')
elif ch2==3:
childcare=float(input("Child care cost:"))
toys=float(input("Toys cost:"))
others=float(input("Other cost:"))

family=['Childcare:'+str(childcare),'Toys:'+str(toys),'Others:'+str(others)]
file4.write(str(family)+'\n')
elif ch2==4:
self.breakfast=float(input("breakfast:"))
lunch=float(input("Lunch:"))
dinner=float(input("Dinner:"))
snacks=float(input("Snacks:"))
groceries=float(input("Groceries:"))

food=['Breakfast:'+str(breakfast),'Lunch:'+str(lunch),'Dinner:'+str(dinner),'Snacks
:'+str(snacks),'Groceries'+str(groceries)]
file4.write(str(food)+'\n')
elif ch2==5:
auto=float(input("auto:"))
health=float(input("health:"))
life=float(input("life:"))

insurance=['Auto:'+str(auto),'Health:'+str(health),'Life:'+str(life)]
file4.write(str(insurance)+'\n')
elif ch2==6:
propertytax=float(input("property:"))
vehicletax=float(input("vehicle:"))
other1=float(input("others:"))

tax=['Property:'+str(propertytax),'Vehicle:'+str(vehicletax),'Others:'+str(other1)]
file4.write(str(tax)+'\n')
elif ch2==7:
airplane=float(input("airplane:"))
bus=float(input("bus:"))
train=float(input("train:"))
food=float(input("food:"))
hotel=float(input("hotel:"))
taxi=float(input("taxi:"))
othertrans=float(input("Other transportation related
costs:"))
misc=float(input("misc"))

travel=['Airplane:'+str(airplane),'Bus:'+str(bus),'Train:'+str(train),'Food:'+str(f
ood),'Hotel:'+str(hotel),'Taxi:'+str(taxi),'Misc:'+str(misc),'Others:'+str(othertra
ns)]
file4.write(str(travel)+'\n')
elif ch2==8:
water=float(input("water:"))
cabletv=float(input("cabletv:"))
electrical=float(input("electrical:"))
gas=float(input("gas:"))
internet=float(input("internet:"))
telephone=float(input("telephone:"))
utilities=['Water:'+str(water),'Cable
tv:'+str(cabletv),'Electrical:'+str(electrical),'Gas:'+str(gas),'Internet:'+str(int
ernet),'Telephone:'+str(telephone)]
file4.write(str(utilities)+'\n')
elif ch2==9:
break
else:
print " Wrong choice....Retry!!"
x1=file3.readline()
while True:
if x1=='\n'+'Date'+'\n'or x1=='':
break
else:
x1=file3.readline()
elif x1=='':
break
else:
file4.write(x1)
x1=file3.readline()
file3.close()
file4.close()
os.remove(username)
os.rename('samp.txt',username)
elif choice==4:
date3=raw_input('Enter date under which the entry that requires to be
modified is present(dd/mm/yyyy):')
file5=open(username,'r')
file6=open('samp1.txt','w')
x2=file5.readline()
while True:
if x2.rstrip('\n')==date3:
while True:
if x2=='\n'+'Date'+'\n'or x2=='':
break
else:
x2=file5.readline()

continue
elif x2=='':
break
else:
file6.write(x2)
x2=file5.readline()
file5.close()
file6.close()
os.remove(username)
os.rename('samp1.txt',username)
elif choice==5:
print
"<=================================================================================
====================================>"
print " \t Welcome to the Scheduler of EMS. You can schedule payments
to be made in futute and track them wih ease."
print
"<=================================================================================
====================================>"
while True:
print'1.Add entry'
print'2.View entries'
print'3.Modify entries'
print'4.Delete entries'
print'5.Done entering'
ch3=int(raw_input("Enter your choice(1-5)"))
if ch3==1:
file7=open(username1,'a')
s_no = int(raw_input("Enter the S.no : "))
details = raw_input("Enter the Details for the payment : ")
payment = int(raw_input("Enter the payment amount : "))
deadline=raw_input('Enter deadline date(dd/mm/yyyy):')
lst=[details,payment,deadline]
file7.write(str(s_no)+'.'+str(lst)+'\n')
file7.close()
elif ch3==2:
file8=open(username1,'r')
no=raw_input('Enter serial no.:')
x4=file8.readline()
while True:
if x4.strip('\n')[0]==no:
print x4
break
else:
x4=file8.readline()
file8.close()
elif ch3==3:
no1=raw_input('Enter serial no.:')
file9=open(username1,'r')
file10=open('samp2.txt','w')
x5=file9.readline()
while True:
if x5.strip('/n')[0]==no1:
details = raw_input("Enter the Details for the
payment : ")
payment = int(raw_input("Enter the payment amount : "))
deadline=raw_input('Enter deadline date(dd/mm/yyyy):')
lst1=[details,payment,deadline]
file10.write(str(no1)+'.'+str(lst1)+'\n')
x5=file9.readline()
elif x5=='':
break
else:
file10.write(x5)
x5=file9.readline()
file9.close()
file10.close()
os.remove(username1)
os.rename('samp2',username1)
elif ch3==4:
no2=raw_input('Enter serial no.:')
file11=open(username1,'r')
file12=open('samp3.txt','w')
x6=file11.readline()
while True:
if x6.strip('\n')[0]==no2:
x6=file11.readline()
continue
elif x6=='':
break
else:
file12.write(x6)
x6=file11.readline()
file11.close()
file12.close()
os.remove(username1)
os.rename('samp3.txt',username1)
elif ch3==5:
break
elif choice==6:
file13=open(username,'r')
file14=open(username1,'r')
x7=file13.readline()
while True:
print x7
if x7=='':
break
else:
x7=file13.readline()
x8=file14.readline()
while True:
print x8
if x8=='':
break
else:
x8=file14.readline()
file13.close()
file14.close()
elif choice==7:
break
else:
print'Wrong choice.. Retry!!'

You might also like