The code is about displaying membership information of all clients from a database. This is for homework and I'm just curious if more can be done to improve this. Feel free to alter it, but please include some reasons for your alterations.
import sys
import re
def menu():
print("---------------Tracking Jobs and Revenue---------------")
print(" Option A: Search for an estimate ")
print(" Option B: Display outstanding payments ")
print(" Option C: Display total revenue ")
print(" ")
print(" Enter Q to quit ")
print("-------------------------------------------------------\n")
def choiceOptions():
global DoAnother
DoAnother = True
while DoAnother == True:
print("")
choice = input("Please enter an option of your choice(A/B/C/Q):\n")
if choice == "A":
optionA()
DoAnother = False
elif choice == "B":
optionB()
DoAnother = False
elif choice == "C":
optionC()
DoAnother = False
elif selection == "Q":
endprog()
DoAnother = False
else:
print("")
print("Please enter a valid letter from the list shown")
return choiceOptions()
def optionA():
global DoAnother
while DoAnother == True:
print("")
estimate = input("Please enter the estimate number:")
if len(member) !=5:
print("That isn't a valid estimate number. Please try again")
DoAnother = True
else:
global estimatefile
estimatefile = open("clientRecords","r+")
searchEst = True
for line in estimatefile.readlines():
listed = line.split(",")
if member in lister:
print("")
print("Estimate Number: {0}".format(listed[0]))
print("CustomerID: {0}".format(listed[1]))
print("Final Total: {0}".format(listed[2]))
print("Amount Paid: {0}".format(listed[3]))
print("Amount Outstanding: {0}".format(listed[4]))
print("Status: {0}".format(listed[5]))
searchEst = False
nextchoice()
if searchEst == True:
optionA()
def optionB():
print("")
print("--------------------------------------------------------------")
print("Estimate Number|CustomerID|Etimate Amount|Estimate Date|Status")
global estimatefile
estimatefile = open("clientRecords","r+")
amountOut = 0
for line in estimatefile.readlines():
listed = line.split(",")
if listed[5] == "A" and listed[3].strip('\n')<listed[2]:
difference = (int(listed[5]-int(listed[2]))
amountOut = (amountOut + difference)
print("{0} {1} £{2} £{3} £{4} {5}".format(listed[0], listed[1], listed[2], listed[3], listed[4], listed[5].strip('\n'), difference))
print("")
print(" Total Outstanding: £{0}".format(amountOutstanding))
nextchoice()
def optionC():
global estimatefile
estimatefile = open("clientRecords","r+")
global amountOwed
amountOwed = 0
for line in estimatefile.readlines():
listed = line.split(",")
if listed[5] == "A" and listed[3].strip('\n') == listed[5]:
amountOwed = amountOwed + int(listed[3])
print("")
print("Total Revenue")
print("")
print("The company's total revenue so far is £{0}".format{amountOwed))
nextchoice()
def nextchoice():
global DoAnother
while DoAnother == True:
print("")
option = input("Would you like to choose another option(Y/N)?")
if option == "Y":
print("")
DoAnother = False
main()
elif option == "N":
print("")
DoAnother = False
endprog()
break
else:
print("")
print("Please enter a valid letter")
DoAnother = True
def endprog():
print("\n------------------------")
print(" Thank you
print("------------------------")
def main():
menu()
selectOption()
main()