def edit_goal(ats: Account) -> None: """Mutates the goal of the selected Account and timeframe. Provides user interface for mutating this information """ print("\nEditing Goal\n" + ("="*40)) while True: a = bc.select_account(ats) if a == bc.breakout_account: break while True: print() y = bc.trans_timeframe(a.get_budgets()) print() m = bc.months_to_int[bc.trans_timeframe([bc.months(i) for i in a.get_budgets(y)] + [-1])[:3]] while True: print("\nInput New Goal\n" + ("="*40)) try: choice_str = input("Enter new goal (Current goal: {:.2f}): ".format(a.get_goal(y,m)/100)) choice = int(choice_str) * 100 valid.amount(choice) if bc.binary_question("Confirm new goal is {:.2f}".format(choice/100) + " ([y]es [n]o): ", "y", "n"): a.set_goal(y, m, choice) break except Exception as e: print(" An error has occurred: " + str(e)) if not bc.binary_question("Enter goals for other months ([y]es or [n]o): ", "y", "n"): break if not bc.binary_question("Edit a goal for another Account ([y]es or [n]o): ", "y", "n"): break
def _cts(ats: [Account]) -> None: """Executes choice to view transactions of an Account over a custom time period """ def _cond(t): return y0 <= t.get_year() <= y1 and \ bc.months_to_int[m0] <= t.get_month() <= bc.months_to_int[m1] a = bc.select_account(ats) print("\nSelect Start Timeframe\n"+("="*40)) # Timeframe selection y0 = bc.trans_timeframe(_uy(ats)) if y0 == -1: return print() m0 = bc.trans_timeframe(_um(a, y0)) if m0 == -1: return print("\nSelect End Timeframe\n"+("="*40)) y1 = bc.trans_timeframe(_uy(ats)) if y1 == -1: return print() m1 = bc.trans_timeframe(_um(a, y1)) if m1 == -1: return print( "\nDisplaying Transactions for {} from {} {} to {} {}\n".format( a.get_name(), m0, y0, m1, y1)) print(_display_all_trans(a, _cond))
def edit_kind(ats: Account) -> None: """Prompts user for a new value for Account name """ print("\nEditing Kind\n" + ("=" * 40)) while True: a = bc.select_account(ats) if a == bc.breakout_account: break while True: print("\nInput New Kind\n" + ("=" * 40)) try: for k, v in bc.kind_to_str.items(): print("{:>3}.".format(k + 1), v) choice_str = input( "Select new name by number (Current kind: " + bc.kind_to_str[a.get_kind()] + "): ") choice = int(choice_str) - 1 valid.kind(choice) if bc.binary_question( "Confirm new kind is " + bc.kind_to_str[choice] + " ([y]es [n]o): ", "y", "n"): a.set_kind(choice) if not bc.binary_question("Enter a new kind ([y]es or [n]o): ", "y", "n"): break except Exception as e: print(" An error has occurred: " + str(e)) if not bc.binary_question( "Edit another Account's kind ([y]es or [n]o): ", "y", "n"): break
def _ocst(ats: [Account]) -> None: """Executes choice to view one account over a custom period """ def _cond(y,m): return (y0,bc.months_to_int[m0]) <= (y,m) <= (y1,bc.months_to_int[m1]) a = bc.select_account(ats) print("\nSelect Start Timeframe\n"+("="*40)) # Timeframe selection - copy in account analysis module y0 = bc.trans_timeframe(_uy(ats)) if y0 == -1: return print() m0 = bc.trans_timeframe(_um(a, y0)) if m0 == -1: return print("\nSelect End Timeframe\n"+("="*40)) y1 = bc.trans_timeframe(_uy(ats)) if y1 == -1: return print() m1 = bc.trans_timeframe(_um(a, y1)) if m1 == -1: return it = [(y,m) for y in a.get_budgets() \ for m in a.get_budgets()[y] if _cond(y,m)] print( "\nDisplaying {} with Budgets from {} {} to {} {}".format( a.get_name(), m0, y0+1, m1, y1+1)) print(_view_range_budget( a, sorted(it, key=lambda x: (x[0], x[1]), reverse=True), max_char))
def _omy(ats: [Account]) -> None: """Executes choice to view one account for one year and one month """ a = bc.select_account(ats) print() y0 = bc.trans_timeframe(_uy(ats)) if y0 == -1: return print() m0 = bc.trans_timeframe(_um(a, y0)) if m0 == -1: return print(_view_tf_budget(a, (y0, bc.months_to_int[m0] )))
def edit_name(ats: Account) -> None: """Prompts user for a new value for Account name """ print("\nEditing Name\n" + ("="*40)) while True: a = bc.select_account(ats) if a == bc.breakout_account: break while True: print("\nInput New Name\n" + ("="*40)) choice = input("New name (Current name: " + a.get_name() + "): ") if bc.binary_question("Confirm new name is " + choice + " ([y]es [n]o): ", "y", "n"): a.set_name(choice) if not bc.binary_question("Enter a new name ([y]es or [n]o): ", "y", "n"): break if not bc.binary_question("Edit another Account's name ([y]es or [n]o): ", "y", "n"): break
def _compare_cash_flows(ats: [Account]) -> None: """Executes choice to view the cash flows of an Account """ a = bc.select_account(ats) if a == bc.breakout_account: return it = bc.timeframe_from_account(a) if it == [(-1,-1)]: return try: print("Displaying graph of cash flows") AccountGraphCashFlow(a, it).view() except Exception as e: print(" An error has occurred: {}".format(e)) else: print("Graph closed")
def _compare_cash_flows(ats: [Account]) -> None: """Executes choice to view the cash flows of an Account """ a = bc.select_account(ats) if a == bc.breakout_account: return it = bc.timeframe_from_account(a) if it == [(-1, -1)]: return try: print("Displaying graph of cash flows") AccountGraphCashFlow(a, it).view() except Exception as e: print(" An error has occurred: {}".format(e)) else: print("Graph closed")
def _rate_of_reach(ats: [Account]) -> None: """Executes choice to view rate of spending or saving, depending on the type of the Account """ a = bc.select_account(ats) if a == bc.breakout_account: return it = bc.timeframe_from_account(a) if it == [(-1, -1)]: return try: print("Displaying graph of rate of spending") AccountGraphRate(a, it).view() except Exception as e: print(" An error has occurred: {}".format(e)) else: print("Graph closed")
def _compare_goal_to_reach(ats: [Account]) -> None: """Executes choice to view the goals of an Account against its reached attributes """ a = bc.select_account(ats) if a == bc.breakout_account: return it = bc.timeframe_from_account(a) if it == [(-1, -1)]: return try: print("Displaying graph comparing spending to goals") AccountGraphCompare(a, it).view() except Exception as e: print(" An error has occurred: {}".format(e)) else: print("Graph closed")
def _compare_goal_to_reach(ats: [Account]) -> None: """Executes choice to view the goals of an Account against its reached attributes """ a = bc.select_account(ats) if a == bc.breakout_account: return it = bc.timeframe_from_account(a) if it == [(-1,-1)]: return try: print("Displaying graph comparing spending to goals") AccountGraphCompare(a, it).view() except Exception as e: print(" An error has occurred: {}".format(e)) else: print("Graph closed")
def _rate_of_reach(ats: [Account]) -> None: """Executes choice to view rate of spending or saving, depending on the type of the Account """ a = bc.select_account(ats) if a == bc.breakout_account: return it = bc.timeframe_from_account(a) if it == [(-1,-1)]: return try: print("Displaying graph of rate of spending") AccountGraphRate(a, it).view() except Exception as e: print(" An error has occurred: {}".format(e)) else: print("Graph closed")
def edit_name(ats: Account) -> None: """Prompts user for a new value for Account name """ print("\nEditing Name\n" + ("=" * 40)) while True: a = bc.select_account(ats) if a == bc.breakout_account: break while True: print("\nInput New Name\n" + ("=" * 40)) choice = input("New name (Current name: " + a.get_name() + "): ") if bc.binary_question( "Confirm new name is " + choice + " ([y]es [n]o): ", "y", "n"): a.set_name(choice) if not bc.binary_question("Enter a new name ([y]es or [n]o): ", "y", "n"): break if not bc.binary_question( "Edit another Account's name ([y]es or [n]o): ", "y", "n"): break
def edit_goal(ats: Account) -> None: """Mutates the goal of the selected Account and timeframe. Provides user interface for mutating this information """ print("\nEditing Goal\n" + ("=" * 40)) while True: a = bc.select_account(ats) if a == bc.breakout_account: break while True: print() y = bc.trans_timeframe(a.get_budgets()) print() m = bc.months_to_int[bc.trans_timeframe( [bc.months(i) for i in a.get_budgets(y)] + [-1])[:3]] while True: print("\nInput New Goal\n" + ("=" * 40)) try: choice_str = input( "Enter new goal (Current goal: {:.2f}): ".format( a.get_goal(y, m) / 100)) choice = int(choice_str) * 100 valid.amount(choice) if bc.binary_question( "Confirm new goal is {:.2f}".format(choice / 100) + " ([y]es [n]o): ", "y", "n"): a.set_goal(y, m, choice) break except Exception as e: print(" An error has occurred: " + str(e)) if not bc.binary_question( "Enter goals for other months ([y]es or [n]o): ", "y", "n"): break if not bc.binary_question( "Edit a goal for another Account ([y]es or [n]o): ", "y", "n"): break
def edit_kind(ats: Account) -> None: """Prompts user for a new value for Account name """ print("\nEditing Kind\n" + ("="*40)) while True: a = bc.select_account(ats) if a == bc.breakout_account: break while True: print("\nInput New Kind\n" + ("="*40)) try : for k,v in bc.kind_to_str.items(): print("{:>3}.".format(k + 1), v) choice_str = input("Select new name by number (Current kind: " + bc.kind_to_str[a.get_kind()] + "): ") choice = int(choice_str) - 1 valid.kind(choice) if bc.binary_question("Confirm new kind is " + bc.kind_to_str[choice] + " ([y]es [n]o): ", "y", "n"): a.set_kind(choice) if not bc.binary_question("Enter a new kind ([y]es or [n]o): ", "y", "n"): break except Exception as e: print(" An error has occurred: " + str(e)) if not bc.binary_question("Edit another Account's kind ([y]es or [n]o): ", "y", "n"): break
def _ats(ats: [Account]) -> None: """Executes choice to view all Transactions of an Account """ a = bc.select_account(ats) print("\nDisplaying Transactions for {}\n".format( a.get_name())+_display_all_trans(a, bool))
def _oaa(ats: [Account]) -> None: """Executes choice to view one account for all years and months """ a = bc.select_account(ats) print(_view_all_budgets(a, max_char))