Add the year report and CSV export handlers
This commit is contained in:
1 parent
c222c1bd02
commit
2eb385b97f
1 file changed
+18
@@ -699,6 +699,24 @@ class SkuldHandler(BaseHTTPRequestHandler):
|
|||||||
return database.all_settings()
|
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():
|
def main():
|
||||||
"""Serve until the process is stopped."""
|
"""Serve until the process is stopped."""
|
||||||
port = int(os.environ.get("PORT") or DEFAULT_PORT)
|
port = int(os.environ.get("PORT") or DEFAULT_PORT)
|
||||||
|
|||||||
Reference in new issue
Block a user