From 2eb385b97f52cd8944fbb3b2934b298ef144db3a Mon Sep 17 00:00:00 2001 From: ai-bot Date: Sat, 14 Nov 2026 12:22:31 +0000 Subject: [PATCH] Add the year report and CSV export handlers --- app.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app.py b/app.py index 0c8bb62..966168d 100644 --- a/app.py +++ b/app.py @@ -699,6 +699,24 @@ class SkuldHandler(BaseHTTPRequestHandler): return database.all_settings() + # -- the year report -------------------------------------------------- + + def report_get(self, params, query, body): + return tax.report(_parse_year(query.get("year", [""])[0])) + + def report_export(self, params, query, body): + year = _parse_year(query.get("year", [""])[0]) + data = (export.report_csv(year) + export.transactions_csv(year)).encode("utf-8") + return self._send_bytes( + data, + "text/csv; charset=utf-8", + headers={ + "Content-Disposition": + 'attachment; filename="skuld-%d.csv"' % year + }, + ) + + def main(): """Serve until the process is stopped.""" port = int(os.environ.get("PORT") or DEFAULT_PORT)