Move to FastAPI with accounts, SQLite books, export and tax returns
Storage and export - Keep books and transactions in SQLite (data/cashbook.db) instead of .ods files; existing .ods books are migrated once at startup - Export a book as the cashbook spreadsheet (.xlsx/.ods, built from the template via LibreOffice) or as CSV - GST rounded per transaction to match the spreadsheet Tax - GST return page with IRD GST101A boxes 5-15 per six-monthly, two-monthly or monthly period, due dates, and a Zero-rated GST type - Income tax page with IR10 (financial statements summary) and IR4 (company return) boxes, from the cashbook plus year-end amounts typed in and saved per book FastAPI and accounts (following led-editor) - Replace the stdlib server with a FastAPI app (src/cashbook_app) run by uvicorn; dependencies in Pipfile - Cookie sessions with bcrypt passwords, first-run admin setup or BOOTSTRAP_ADMIN_*, invites (link or email), sign-in throttling, password change that signs out other sessions - Users page for administrators: rename, reset password, promote or demote, delete, list and revoke invites; last admin is protected - Replaces the shared CASHBOOK_PASSWORD basic auth; AUTH_* settings in .env (see .env.example) - Docker image uses a venv with system site packages for python3-uno - pytest suite for auth, user management, imports, GST and tax figures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17b48f25e8
commit
4b3e5f0932
47 files changed
+4189
-862
No files matched your search
+22
-8
@@ -1,16 +1,30 @@
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
# LibreOffice (headless Calc) + its Python bridge, and pdftotext for PDF statements
|
||||
# LibreOffice (headless Calc) + its Python bridge for spreadsheet export,
|
||||
# pdftotext for PDF statements
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
python3 python3-uno libreoffice-calc-nogui poppler-utils fonts-dejavu-core \
|
||||
python3 python3-venv python3-uno libreoffice-calc-nogui poppler-utils fonts-dejavu-core \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# a venv that can still see the system python3-uno
|
||||
COPY Pipfile Pipfile.lock ./
|
||||
RUN python3 -m venv --system-site-packages /opt/venv \
|
||||
&& /opt/venv/bin/pip install --no-cache-dir pipenv \
|
||||
&& /opt/venv/bin/pipenv requirements > /tmp/requirements.txt \
|
||||
&& /opt/venv/bin/pip install --no-cache-dir -r /tmp/requirements.txt \
|
||||
&& /opt/venv/bin/pip uninstall -y pipenv \
|
||||
&& rm /tmp/requirements.txt
|
||||
|
||||
COPY src ./src
|
||||
|
||||
# LibreOffice needs a writable home; /tmp is the only writable place besides /data
|
||||
ENV HOME=/tmp \
|
||||
ENV PATH=/opt/venv/bin:$PATH \
|
||||
HOME=/tmp \
|
||||
CASHBOOK_DATA=/data \
|
||||
CASHBOOK_STATEMENTS=/statements \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
@@ -18,9 +32,9 @@ ENV HOME=/tmp \
|
||||
USER 1000:1000
|
||||
EXPOSE 8765
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD ["python3", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8765/healthz', timeout=3)"]
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||
CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8765/healthz', timeout=3)"]
|
||||
|
||||
# /data holds the cashbooks and statements/;
|
||||
# /statements can hold a read-only folder of ANZ exports
|
||||
CMD ["python3", "src/webapp.py", "--host", "0.0.0.0", "--data", "/data", "--statements", "/statements"]
|
||||
# --proxy-headers: trust X-Forwarded-Proto from the hosts in FORWARDED_ALLOW_IPS
|
||||
# (so cookies are marked Secure behind an HTTPS proxy)
|
||||
CMD ["uvicorn", "app:app", "--app-dir", "src", "--host", "0.0.0.0", "--port", "8765", "--proxy-headers"]
|
||||
Reference in new issue
Block a user