diff --git a/monthly_expenses/__init__.py b/monthly_expenses/__init__.py index 4e16945..f94056a 100644 --- a/monthly_expenses/__init__.py +++ b/monthly_expenses/__init__.py @@ -116,6 +116,7 @@ def build_report(self): # Converting Result Rows to a Pandas Dataframe df = pd.DataFrame(rows, columns=[k[0] for k in cols]) df['month_count'] = df['year'] + month_count_html = df['year'] df = df.replace({'month_count': month_count}) df['amount (CNY)'] = df['amount (CNY)'] / df['month_count'] df = df.drop(columns=['month_count']) @@ -130,5 +131,5 @@ def build_report(self): cols = ["Account_L{}".format(k) for k in range(n_levels)] df[cols] = df["Account"].str.split(':', n_levels - 1, expand=True) df = df.fillna('').drop(columns="Account", level=0).set_index(cols) - return (df.groupby(["Account_L0", "Account_L1"]).sum().round(decimals=2)).to_html(),df.groupby(["Account_L0", "Account_L1"]).sum().sum().to_frame().to_html() + return (df.groupby(["Account_L0", "Account_L1"]).sum().round(decimals=2)).to_html(),df.groupby(["Account_L0", "Account_L1"]).sum().sum().to_frame().to_html(),pd.DataFrame(month_count.items(), columns=['Year', 'count']).to_html() diff --git a/monthly_expenses/templates/MonthlyExpenses.html b/monthly_expenses/templates/MonthlyExpenses.html index 9473a5b..eca29d2 100644 --- a/monthly_expenses/templates/MonthlyExpenses.html +++ b/monthly_expenses/templates/MonthlyExpenses.html @@ -6,13 +6,15 @@

Monthly Expenses

{% set report1 = extension.build_report() %} {% set report2 = extension.build_report_life() %} - {% set a = extension.get_valid_month_number() %}
{{report1[0] |safe}}
{{report1[1] |safe}}
+
+ {{report1[2] |safe}} +