import enum
from collections import deque
from datetime import date, time, datetime
-
+from collections import OrderedDict
class BudgetGraphBaseError(Exception):
pass
new_err = BudgetGraphPayeesParseError(
self.bug.id, f"TOML parse error: {e}")
raise new_err.with_traceback(sys.exc_info()[2])
- retval = {}
+ retval = OrderedDict()
for key, value in parsed.items():
if not isinstance(key, str):
raise BudgetGraphPayeesParseError(
nodes: Dict[int, Node]
def __init__(self, bugs: Iterable[Bug], config: Config):
- self.nodes = {}
+ self.nodes = OrderedDict()
self.config = config
for bug in bugs:
self.nodes[bug.id] = Node(self, bug)
if node.parent is None:
continue
node.parent.immediate_children.add(node)
+ self.milestone_payments = OrderedDict()
# useful debug prints
#for bug in bugs:
# node = self.nodes[bug.id]
# childlist)
payees_total = Money(0)
- payee_payments = {}
+ payee_payments = OrderedDict()
for payment in node.payments.values():
if payment.amount < 0:
errors.append(BudgetGraphNegativePayeeMoney(
@cached_property
def payments(self) -> Dict[Person, Dict[Milestone, List[Payment]]]:
- retval = {}
+ retval = OrderedDict()
for person in self.config.people.values():
- milestone_payments = {}
+ milestone_payments = OrderedDict()
for milestone in self.config.milestones.values():
- milestone_payments[milestone] = []
+ milestone_payments[milestone] = [] # per-person payments
+ self.milestone_payments[milestone] = [] # global payments
retval[person] = milestone_payments
for node in self.nodes.values():
if node.milestone is not None:
for payment in node.payments.values():
retval[payment.payee][node.milestone].append(payment)
+ # add to global payments as well
+ self.milestone_payments[node.milestone].append(payment)
return retval
def __repr__(self):
if args.output_dir is not None:
write_budget_markdown(budget_graph, args.output_dir)
+ # quick hack to display total payment amounts per-milestone
+ for milestone, payments in budget_graph.milestone_payments.items():
+ print (milestone)
+ print ()
+ total = 0
+ for payment in payments:
+ print("\t", payment)
+ total += payment.amount
+ print ("\t", total)
if __name__ == "__main__":
main()