From 46e8c095cfc8fa2143bc5820512584dda387563f Mon Sep 17 00:00:00 2001 From: dvorak Date: Mon, 22 Jan 2024 14:18:58 +0800 Subject: [PATCH] format --- README.md | 2 ++ monthly_expenses/__init__.py | 12 +++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0ce3203..2642c54 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # fava-monthly-expenses +## Screenshot +![screenshot](./showcase.webm) ## Get Started add this line to your main beancount file: diff --git a/monthly_expenses/__init__.py b/monthly_expenses/__init__.py index 4569290..10fec54 100644 --- a/monthly_expenses/__init__.py +++ b/monthly_expenses/__init__.py @@ -20,10 +20,6 @@ class MonthlyExpenses(FavaExtensionBase): # pragma: no cover report_title = "Monthly Expenses" - def valid(self): - return "ok" if "account_used_to_get_valid_month" in self.config else "missing account_used_to_get_valid_month" - - def get_all_report(self): return [self.build_report_for_account(account) for account in self.config['accounts']] @@ -54,7 +50,7 @@ def build_report_for_account(self, account): entries = self.ledger.all_entries opts = self.ledger.options if "operating_currency" not in opts or len(opts["operating_currency"]) == 0: - return "","","",account,"missing operating_currency" + return "", "", "" ,account, "missing operating_currency" currency = opts["operating_currency"][0] cols, rows = run_query(entries, opts, f"SELECT account, YEAR(date) AS year, convert(sum(position),'{currency}') AS amount\ @@ -70,7 +66,7 @@ def build_report_for_account(self, account): df = df.replace({'month_count': month_count}) print(df) if df.empty: - return "","","",account,"no transaction under this account" + return "" ,"" ,"" ,account , "no transaction under this account" df[f'amount ({currency})'] = df[f'amount ({currency})'] / df['month_count'] df = df.drop(columns=['month_count']) df.rename(columns={"account": "Account", "year": "Year", f"amount ({currency})": f"Amount ({currency})"}, inplace=True) @@ -82,9 +78,7 @@ def build_report_for_account(self, account): n_levels = df["Account"].str.count(":").max() + 1 if n_levels == account.count(":") + 1: - print("account is at the lowest level") - return "","","",account,"no finer level under this account" - + return "", "", "", account, "no finer level under this account" cols = ["Account_L{}".format(k) for k in range(n_levels)] df[cols] = df["Account"].str.split(':', n=n_levels - 1, expand=True)