def SearchByAmount(LstToSearch): fltAmount = float(input("Enter the amount you are seeking: ")) LstResult = [] Successful = False for trans in LstToSearch: if fltAmount == trans[6]: LstResult.append(trans) Successful = True if Successful == True: Presentation.PrintRegister(LstResult) else: print("No transactions match your search") return
def DesignateClearedTxs(TxLst): for trans in TxLst: if trans[7] == False: Presentation.PrintRegister([ trans ]) #must put trans in list for this function to work properly Decision = input( "To mark transaction as cleared, hit 'c'; otherwise hit <enter>; hit 'q' to" "return to main menu: ") if Decision.lower() == "c": trans[7] = True elif Decision.lower() == "q": print("Cleared balance review ended") return else: pass print("Cleared balance review complete")
def SearchByText(LstToSearch): strText = input("Enter the text you are seeking: ") strExact = input("For exact match, type 'e'; otherwise hit any key: ") LstResult = [] Successful = False if strExact.lower() == "e": for trans in LstToSearch: if strText in trans: Successful = True LstResult.append(trans) else: for trans in LstToSearch: if strText.lower() in trans[2].lower() or strText.lower() in trans[3].lower()\ or strText.lower() in trans[4].lower() or strText.lower() in trans[5].lower(): Successful = True LstResult.append(trans) if Successful == True: Presentation.PrintRegister(LstResult) else: print("No transactions match your search.") return
def ReviseTx(TxLst): IdExists = False DidChangeAmt = False DidChangeClearedStatus = False IdNum = int(input("Enter the unique ID of the transaction: ")) #Find the transaction by its unique ID number for i in range(len(TxLst)): if TxLst[i][0] == IdNum: IdExists = True Location = i print("Transaction to revise: ") #, TxLst[Location]) #Need to create a list within a list for the Presentation.PrintRegister function to work DLst = [TxLst[Location]] #Display the transaction to revise: Presentation.PrintRegister(DLst) break if IdExists == False: print("No such unique ID exists.") return print(""" 1 = Change date 2 = Change type 3 = Change description/payee 4 = Change category 5 = Change memo 6 = change amount 7 = change cleared status """) while True: changeItem = input( "Enter the number of the item to revise. Hit 'q' when finished: ") if changeItem == "1": Date = EnterTxs.CustomDate() TxLst[Location][1] = Date elif changeItem == "2": newType = input("Enter the type: ") TxLst[Location][2] = newType elif changeItem == "3": newDescrip = input("Enter the description: ") TxLst[Location][3] = newDescrip elif changeItem == "4": newCat = input("Enter the category: ") TxLst[Location][4] = newCat elif changeItem == "5": newMemo = input("Enter the memo: ") TxLst[Location][5] = newMemo elif changeItem == "6": newAmt = float(input("Enter the new amount: ")) TxLst[Location][6] = newAmt DidChangeAmt = True elif changeItem == "7": TxLst[Location][7] = not TxLst[Location][7] DidChangeClearedStatus = True elif changeItem.lower() == "q": print("Revisions completed.") if DidChangeAmt == True: EnterTxs.CalculateBalance(TxLst) print("Revised balance = ", TxLst[-1][-1]) if DidChangeClearedStatus == True: return True return False else: print("Invalid entry.")
LstTrans = StoreData.RetrieveTransLst() #Each separate transaction is a list. Balance is the last item in the list. # The last item of the last transaction in LstTrans is the final balance. Balance = LstTrans[-1][-1] print("Welcome to the checking account register\n") print("Ending balance:", Balance) print("Today's balance:", Searches.GetTodaysBalance(LstTrans)) print("Cleared balance:", ClearedBal) print("Last unique ID:", intUniqueId) #Print the last 10 transactions on opening the script: print( "\nLast 10 transactions--------------------------------------------------") LstRecentTrans = LstTrans[-10:] Presentation.PrintRegister(LstRecentTrans) #----------------I/O------------------------------------------------------- while True: print(""" MENU of options: Enter a debit......................w Enter a deposit....................d Print register for a date range....p Print complete register............c Search for text....................s Search for an amount...............a Check off cleared entries..........b Display cleared balance history....h Revise a transaction...............r