def load_totals_data(self, initial_balances, expenditures_by_type, current_balances): if expenditures_by_type is not None and expenditures_by_type != []: total_spending = 0 for row in expenditures_by_type: total_spending += row[1] spending_text = TableWidget.format_as_currency(total_spending) self.totals_table.set_value(spending_text, 0, 1) else: self.totals_table.set_value("-", 0, 1) if initial_balances is not None and initial_balances != []: total_initial_balance = 0 for balance in initial_balances: total_initial_balance += balance[2] initial_text = TableWidget.format_as_currency( total_initial_balance) self.totals_table.set_value(initial_text, 0, 0) else: self.totals_table.set_value("-", 0, 0) if current_balances is not None and current_balances != []: total_current_balance = 0 for balance in current_balances: total_current_balance += balance[2] current_text = TableWidget.format_as_currency( total_current_balance) self.totals_table.set_value(current_text, 0, 2) else: self.totals_table.set_value("-", 0, 2)
def set_balances(self, balance_matrix: [[]]): # sets the values in the balances table given the balance matrix table = [] for row_index in range(len(balance_matrix)): values = [balance_matrix[row_index][1], TableWidget.format_as_currency(balance_matrix[row_index][2])] table.append(values) self.balance_table.load_table_data(table) self.expenditures_set = True
def set_expenditures(self, expenditure_matrix: [[]]): # passes the label values to the table to be inserted into the labels self.expenditures_set = True table = [] for row_index in range(len(expenditure_matrix)): values = [ TableWidget.format_as_currency( expenditure_matrix[row_index][1]), expenditure_matrix[row_index][2], expenditure_matrix[row_index][3] ] table.append(values) self.expenditure_table.load_table_data(table)
def load_expenditure_data(self, expenditures_by_type: [[]]): if expenditures_by_type is not None and expenditures_by_type != []: labels = [] values = [] table = [] for row_index in range(len(expenditures_by_type)): labels.append(expenditures_by_type[row_index][0]) values.append(expenditures_by_type[row_index][1]) table.append([ expenditures_by_type[row_index][0], TableWidget.format_as_currency( expenditures_by_type[row_index][1]) ]) self.category_table.load_table_data(table) self.pie_chart.construct_pie_chart( labels, values, text_col=self.pie_chart.label_text_col) else: self.category_table.clear_labels() self.pie_chart.construct_empty_chart()