From 511feb8a2a95ade9e32522e1bbc3cce4b1321721 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 15 Nov 2026 10:16:56 +0100 Subject: [PATCH 1/7] feat(expenses): on a phone a new expense starts with the camera (#188) Tapping Uitgave on a phone opens the camera. The photo goes into the tray at once, then a page shows it above the amount, the supplier, the date and the category of one line. Uitgave opslaan makes the expense with the photo on it; Alleen de foto bewaren leaves it for Verwerken. Without a connection the photo stays to send again. Wide screens and no-JS keep the old form. Co-Authored-By: Claude Opus 5.5 --- huismus/core/static/core/app.js | 72 ++++++++ huismus/core/static/core/huismus.css | 10 ++ huismus/expenses/photo_views.py | 109 ++++++++++++ huismus/expenses/urls.py | 5 +- huismus/templates/base.html | 11 ++ huismus/templates/expenses/photo.html | 71 ++++++++ tests/e2e/test_every_page.py | 3 + tests/e2e/test_photo_first.py | 116 +++++++++++++ tests/expenses/test_photo.py | 241 ++++++++++++++++++++++++++ 9 files changed, 637 insertions(+), 1 deletion(-) create mode 100644 huismus/expenses/photo_views.py create mode 100644 huismus/templates/expenses/photo.html create mode 100644 tests/e2e/test_photo_first.py create mode 100644 tests/expenses/test_photo.py diff --git a/huismus/core/static/core/app.js b/huismus/core/static/core/app.js index 4e7c14c..888f793 100644 --- a/huismus/core/static/core/app.js +++ b/huismus/core/static/core/app.js @@ -674,3 +674,75 @@ function showReceiptPdfs(root) { wideScreen.addEventListener("change", () => showReceiptPdfs(document)); if (window.htmx) window.htmx.onLoad(showReceiptPdfs); else showReceiptPdfs(document); + +// The photo first (#188, expenses/photo_views.py): on a phone, a link to the +// new-expense form opens the camera instead. The photo is sent at once; +// Huismus puts it with the receipts and opens the page with the amount. +// Cancelling the camera opens the ordinary form, where a photo from the +// library, a PDF or no receipt at all is possible. On a wide screen, in the +// desktop app and without JS, the link is the ordinary form. +const phone = window.matchMedia("(max-width: 760px) and (pointer: coarse)"); + +// Capture, and no further: htmx's boost listens on the link itself. +document.addEventListener( + "click", + (event) => { + const camera = document.getElementById("camera"); + const link = event.target.closest?.("a[href]"); + if (!camera || !link || !phone.matches || event.defaultPrevented) return; + if (link.pathname !== camera.dataset.newExpense || link.search) return; + event.preventDefault(); + event.stopPropagation(); + link.closest("[popover]")?.hidePopover(); + const input = camera.querySelector("input[type=file]"); + input.value = ""; + // Browsers that don't say "cancel" leave the user where they tapped. + input.oncancel = () => window.location.assign(link.href); + input.click(); + }, + true, +); + +// A photo taken, from that hidden form or from "Opnieuw" on the photo page: +// sent with fetch, so a failed connection leaves the photo here to send +// again. A photo from the camera isn't always in the library too: a +// browser error page would lose it. +let unsent = null; + +function cameraToast(id) { + for (const toast of document.querySelectorAll("[data-camera-toast]")) toast.remove(); + const template = document.getElementById(id); + if (template) document.getElementById("toasts")?.append(template.content.cloneNode(true)); +} + +async function sendPhoto(form, file) { + unsent = { form, file }; + cameraToast("camera-busy"); + const data = new FormData(form); + data.set("file", file); + let response; + try { + response = await fetch(form.action, { method: "POST", body: data }); + } catch { + response = null; + } + if (!response?.ok) { + cameraToast("camera-offline"); + return; + } + unsent = null; + // Where Huismus sent it: the photo page, or the ordinary form with the + // reason it refused the file. + window.location.assign(response.url); +} + +document.addEventListener("change", (event) => { + const input = event.target; + if (!input.matches?.("input[type=file][data-camera]") || !input.files.length) return; + input.oncancel = null; + sendPhoto(input.form, input.files[0]); +}); + +document.addEventListener("click", (event) => { + if (event.target.closest?.("[data-camera-retry]") && unsent) sendPhoto(unsent.form, unsent.file); +}); diff --git a/huismus/core/static/core/huismus.css b/huismus/core/static/core/huismus.css index 5fb555e..64b3665 100644 --- a/huismus/core/static/core/huismus.css +++ b/huismus/core/static/core/huismus.css @@ -809,6 +809,16 @@ div.hint-banner:hover { border-color: var(--border); } .process-receipt { position: static; } .process-img { max-height: 50dvh; } } +/* A new expense on a phone, the photo first (#188, expenses/photo.html): + the photo with "Opnieuw" on it, then the amount, large. */ +.photo-shot { position: relative; padding: var(--s-3); } +.photo-shot .process-img { max-height: 40dvh; } +.photo-again { position: absolute; right: var(--s-5); bottom: var(--s-5); } +.amount-xl .input { height: 60px; font-size: var(--fs-2xl); font-weight: var(--fw-semibold); } +.amount-xl .money::before { font-size: var(--fs-lg); } +/* Its bar: "Uitgave opslaan" with "Alleen de foto bewaren" under it. */ +.actionbar.photo-actions { flex-direction: column; align-items: stretch; flex-wrap: nowrap; } +.actionbar.photo-actions .btn { flex: none; } .report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden; } .report + .report { margin-top: var(--s-3); } diff --git a/huismus/expenses/photo_views.py b/huismus/expenses/photo_views.py new file mode 100644 index 0000000..80e17f3 --- /dev/null +++ b/huismus/expenses/photo_views.py @@ -0,0 +1,109 @@ +# SPDX-FileCopyrightText: 2026 Huismus contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +"""A new expense on a phone, the photo first (#188; huismus-intern/besluiten.md, +2026-11-15, "Nieuwe huisstijl", and the plan of #188). + +On a phone app.js turns "Uitgave" into the camera. The photo is sent to +photo_upload(), which puts it in the tray at once, as a receipt from the +receipts folder would be: walking away never loses it. photo_expense() +then shows it above the few fields of one line, the amount first. "Uitgave +opslaan" makes the expense with the receipt on it, as Verwerken does; +"Alleen de foto bewaren" leaves it in the tray, where Verwerken has it. + +Without JS, or on a wide screen, "Uitgave" is the ordinary form +(views._expense_form); nothing here is needed for that. +""" + +from django.contrib import messages +from django.contrib.auth.decorators import login_required +from django.shortcuts import redirect, render +from django.urls import reverse +from django.utils import timezone +from django.utils.translation import gettext as _ + +from huismus.core.models import Attachment + +from . import batch, reading +from .adding import RECEIPT_GONE +from .forms import ExpenseForm, ExpenseLineFormSet, ReceiptUploadForm +from .models import Expense +from .receipts import sha256_of +from .views import TrayReceiptGone, all_valid, save_expense + +# Attachment.source of a photo taken here. +SOURCE = "telefoon" + + +@login_required +def photo_upload(request): + """The photo from the camera, into the tray. With `vervangt` + ("Opnieuw"), the photo it replaces goes, if it still waits.""" + if request.method != "POST": + return redirect("expenses:create") + form = ReceiptUploadForm(request.POST, request.FILES) + if not form.is_valid(): + # The form's own reason: "Dit bonnetje is groter dan 10 MB. …". The + # ordinary form can take a photo from the library or a PDF. + messages.error(request, form.errors["file"][0]) + return redirect("expenses:create") + uploaded = form.cleaned_data["file"] + replaced = Attachment.objects.in_tray().filter(pk=_int(request.POST.get("vervangt"))).first() + if replaced is not None: + replaced.file.delete(save=False) + replaced.delete() + receipt = Attachment.objects.create( + file=uploaded, kind="receipt", sha256=sha256_of(uploaded), source=SOURCE + ) + return redirect("expenses:photo", pk=receipt.pk) + + +@login_required +def photo_expense(request, pk): + """The photo above the amount, where, date and category of one line.""" + receipt = Attachment.objects.in_tray().filter(pk=pk).first() + if receipt is None: + # Made into an expense or removed meanwhile, in another tab. + messages.error(request, str(RECEIPT_GONE)) + return redirect("expenses:list") + if request.method == "POST" and "alleen_foto" in request.POST: + # It is in the tray already. Read now, if the AI service is on. + reading.read_in_background() + messages.success(request, _("Bonnetje bewaard. Je vindt het bij Verwerken.")) + return redirect("expenses:list") + + # A new expense's amount 0 lasts only until save_lines() sets it. + instance = Expense(amount_cents=0) + if request.method == "POST": + form = ExpenseForm(request.POST, instance=instance) + formset = ExpenseLineFormSet(request.POST, instance=instance, prefix="lines") + if all_valid(form, formset): + try: + save_expense(form, formset, tray_receipt=receipt) + except TrayReceiptGone: + messages.error(request, str(RECEIPT_GONE)) + return redirect("expenses:list") + messages.success(request, _("Uitgave opgeslagen.")) + return redirect("expenses:list") + else: + form = ExpenseForm(instance=instance, initial={"date": timezone.localdate()}) + formset = ExpenseLineFormSet(instance=instance, prefix="lines") + return render( + request, + "expenses/photo.html", + { + "receipt": receipt, + "form": form, + "formset": formset, + "line_form": formset.forms[0], + # More lines or a description: the whole form, in Verwerken. + "full_form_url": batch.Item(batch.RECEIPT, receipt.pk).url(), + "upload_url": reverse("expenses:photo_upload"), + }, + ) + + +def _int(value) -> int | None: + try: + return int(value) + except (TypeError, ValueError): + return None diff --git a/huismus/expenses/urls.py b/huismus/expenses/urls.py index 8184223..0d53f5b 100644 --- a/huismus/expenses/urls.py +++ b/huismus/expenses/urls.py @@ -3,13 +3,16 @@ from django.urls import path from django.views.generic import RedirectView -from . import inbox_views, process_views, views +from . import inbox_views, photo_views, process_views, views app_name = "expenses" urlpatterns = [ path("", views.expense_list, name="list"), path("nieuw/", views.expense_create, name="create"), + # On a phone, the photo first (#188). + path("nieuw/foto/", photo_views.photo_upload, name="photo_upload"), + path("nieuw/foto//", photo_views.photo_expense, name="photo"), path("verwerken/", process_views.process, name="process"), path( "verwerken///", diff --git a/huismus/templates/base.html b/huismus/templates/base.html index b9df5bd..28703d6 100644 --- a/huismus/templates/base.html +++ b/huismus/templates/base.html @@ -116,6 +116,17 @@
{% translate "Facturen en uitgaven voor zzp'ers, met of zonder KOR" %}{% translate "Sneltoetsen:" %} N {% translate "nieuw" %}{% block shortcut_search %}{% endblock %}
+{% if user.is_authenticated %} +{% comment %}On a phone every "Uitgave" opens the camera, and the photo goes +here (#188; app.js, "The photo first"; expenses/photo_views.py). Without JS +this stays hidden and unused: the link goes to the ordinary form.{% endcomment %} + + + +{% endif %} {% include "core/_toasts.html" %} {% endblock %} diff --git a/huismus/templates/expenses/photo.html b/huismus/templates/expenses/photo.html new file mode 100644 index 0000000..9eb1095 --- /dev/null +++ b/huismus/templates/expenses/photo.html @@ -0,0 +1,71 @@ +{% extends "base.html" %} +{% load i18n forms %} + +{% block title %}{% translate "Nieuwe uitgave" %} — Huismus{% endblock %} +{% block content_class %}content-narrow{% endblock %} + +{% block content %} +{% comment %}A new expense on a phone, the photo first (#188, +huismus/expenses/photo_views.py). The photo is in the tray already; the +fields are one line of the ordinary form, the amount first.{% endcomment %} +
+
+ {% translate "Uitgaven" %} +

{% translate "Nieuwe uitgave" %}

+
+
+ +{% form_errors form formset %} + +
+ {% blocktranslate with name=receipt.filename asvar receipt_label %}Bonnetje {{ name }}{% endblocktranslate %} + {% if receipt.is_pdf %} +
{{ receipt.filename }}
+ {% else %} + {{ receipt_label }} + {% endif %} + {% comment %}"Opnieuw": a new photo in place of this one (photo_upload, + vervangt). Its own form: forms can't nest. data-camera: app.js sends it + as soon as it is taken, and says so when Huismus can't be reached. The + old photo goes only once the new one is in.{% endcomment %} +
+ {% csrf_token %} + + + +
+
+ +
+ {% csrf_token %} + {% comment %}Enter saves: the first submit button of a form is the one + Enter clicks, and "Meer regels" comes before the bar.{% endcomment %} + + {{ formset.management_form }} + {{ line_form.id }} +
+ {% translate "Bedrag, zoals je het betaalde" as amount_label %} +
{% field line_form.amount_cents money=True label=amount_label %}
+ {% comment %}Without the KOR every line needs its VAT and its rate + (ExpenseLineForm), right under the amount.{% endcomment %} + {% if "vat_rate" in line_form.fields %} + {% field line_form.vat_info_cents span=3 money=True %} + {% field line_form.vat_rate span=3 %} + {% endif %} + {% field form.supplier %} + {% field form.date span=3 %} + {% field line_form.category span=3 %} +
+ {% comment %}Verwerken for this receipt, with what was typed and one + line more, saving nothing: its "Regel toevoegen" without JS + (process_views._one_more_line).{% endcomment %} +
+
+ + +
+
+{% endblock %} diff --git a/tests/e2e/test_every_page.py b/tests/e2e/test_every_page.py index ea1c066..6d9aad2 100644 --- a/tests/e2e/test_every_page.py +++ b/tests/e2e/test_every_page.py @@ -93,6 +93,9 @@ def _pages(): f"/uitgaven/verwerken/bonnetje/{receipt.pk}/" for receipt in Attachment.objects.in_tray() ), + # A new expense on a phone, the photo first (#188): any receipt in + # the tray can be that photo. + *(f"/uitgaven/nieuw/foto/{receipt.pk}/" for receipt in Attachment.objects.in_tray()[:1]), "/rapporten/jaaroverzicht/", # The VAT return (SPEC.md M21, part 4): a year of the history, with # imports and lines without a rate under "Niet meegeteld". diff --git a/tests/e2e/test_photo_first.py b/tests/e2e/test_photo_first.py new file mode 100644 index 0000000..8378998 --- /dev/null +++ b/tests/e2e/test_photo_first.py @@ -0,0 +1,116 @@ +# SPDX-FileCopyrightText: 2026 Huismus contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +"""A new expense on a phone, the photo first (#188; app.js, "The photo +first"; huismus/expenses/photo_views.py): "Uitgave" opens the camera, the +photo goes into the tray, then the amount. Without a connection the photo +stays to send again. On a wide screen "Uitgave" is the ordinary form.""" + +import pytest +from playwright.sync_api import expect + +from huismus.core.demo_receipts import _photo +from huismus.core.models import Attachment +from huismus.expenses.models import Expense + +pytestmark = pytest.mark.django_db(transaction=True) + +PHOTO = { + "name": "IMG_3001.jpg", + "mimeType": "image/jpeg", + "buffer": _photo(["KANTOORCENTRUM", "TOTAAL 48,95"], "JPEG"), +} + + +@pytest.fixture +def phone(app, browser, browser_name): + """The logged-in user on a phone 390 px wide with touch.""" + args = {"viewport": {"width": 390, "height": 844}, "has_touch": True, "locale": "nl-NL"} + # Firefox has no mobile mode in Playwright; touch it does have. + if browser_name != "firefox": + args["is_mobile"] = True + context = browser.new_context(**args) + context.add_cookies(app.context.cookies()) + page = context.new_page() + errors = [] + page.on("pageerror", lambda error: errors.append(str(error))) + page.base = app.base + yield page + context.close() + assert errors == [], f"JavaScript errors: {errors}" + + +def _camera(page, tap): + """Taps `tap`, which must open the camera, and takes PHOTO.""" + with page.expect_file_chooser() as chooser: + tap() + assert chooser.value.element.get_attribute("capture") == "environment" + chooser.value.set_files(PHOTO) + + +def test_on_a_phone_uitgave_opens_the_camera_then_the_amount(phone): + phone.goto(phone.base + "/uitgaven/") + phone.locator(".tabbar .fab").tap() + _camera(phone, lambda: phone.locator("#plus-menu a", has_text="Uitgave").tap()) + + expect(phone.locator("h1")).to_have_text("Nieuwe uitgave") + expect(phone.get_by_role("img", name="Bonnetje IMG_3001.jpg")).to_be_visible() + assert Attachment.objects.in_tray().count() == 1 + # The amount first, with the number keyboard. + amount = phone.get_by_label("Bedrag, zoals je het betaalde") + expect(amount).to_have_attribute("inputmode", "decimal") + amount.fill("48,95") + # Without the KOR (as here) the VAT and its rate too, right under it. + phone.get_by_label("Btw", exact=True).fill("8,50") + phone.get_by_label("Btw-tarief").select_option("21") + phone.get_by_label("Leverancier").fill("Kantoorcentrum Zuid") + phone.get_by_role("button", name="Uitgave opslaan").tap() + + expect(phone).to_have_url(phone.base + "/uitgaven/") + expect(phone.locator("#toasts")).to_contain_text("Uitgave opgeslagen.") + expense = Expense.objects.get() + assert expense.amount_cents == 4895 + assert expense.attachments.get().filename == "IMG_3001.jpg" + assert not Attachment.objects.in_tray().exists() + + +def test_opnieuw_and_only_the_photo(phone): + phone.goto(phone.base + "/uitgaven/") + _camera(phone, lambda: phone.get_by_role("link", name="Nieuwe uitgave").first.tap()) + expect(phone.locator("h1")).to_have_text("Nieuwe uitgave") + first = Attachment.objects.get().pk + + _camera(phone, lambda: phone.locator(".photo-again label").tap()) + expect(phone).not_to_have_url(phone.base + f"/uitgaven/nieuw/foto/{first}/") + assert Attachment.objects.in_tray().count() == 1 + assert Attachment.objects.get().pk != first + + phone.get_by_role("button", name="Alleen de foto bewaren").tap() + kept = "Bonnetje bewaard. Je vindt het bij Verwerken." + expect(phone.locator("#toasts")).to_contain_text(kept) + expect(phone.get_by_role("link", name="Verwerken (1)")).to_be_visible() + assert not Expense.objects.exists() + + +def test_without_a_connection_the_photo_stays_to_send_again(phone): + phone.goto(phone.base + "/uitgaven/") + phone.context.set_offline(True) + _camera(phone, lambda: phone.get_by_role("link", name="Nieuwe uitgave").first.tap()) + + expect(phone.locator("#toasts")).to_contain_text( + "Huismus is niet bereikbaar. Probeer het opnieuw als je verbinding hebt." + ) + expect(phone).to_have_url(phone.base + "/uitgaven/") + assert not Attachment.objects.exists() + + phone.context.set_offline(False) + phone.get_by_role("button", name="Opnieuw proberen").tap() + expect(phone.locator("h1")).to_have_text("Nieuwe uitgave") + assert Attachment.objects.in_tray().count() == 1 + + +def test_on_a_wide_screen_uitgave_is_the_ordinary_form(app): + app.set_viewport_size({"width": 1440, "height": 900}) + app.goto(app.base + "/uitgaven/") + app.get_by_role("link", name="Nieuwe uitgave").first.click() + expect(app).to_have_url(app.base + "/uitgaven/nieuw/") + expect(app.get_by_text("Sleep een bonnetje hierheen")).to_be_visible() diff --git a/tests/expenses/test_photo.py b/tests/expenses/test_photo.py new file mode 100644 index 0000000..19f5c35 --- /dev/null +++ b/tests/expenses/test_photo.py @@ -0,0 +1,241 @@ +# SPDX-FileCopyrightText: 2026 Huismus contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +"""A new expense on a phone, the photo first (#188, +huismus/expenses/photo_views.py): the photo goes into the tray at once, +then the amount, where, date and category of one line. The camera itself +(app.js) is tests/e2e/test_photo_first.py.""" + +import datetime +import io + +import pytest +from django.contrib.auth import get_user_model +from django.core.files.uploadedfile import SimpleUploadedFile +from django.urls import reverse +from django.utils import timezone +from PIL import Image + +from huismus.business.models import Settings +from huismus.core.models import Attachment +from huismus.expenses import photo_views, reading +from huismus.expenses.models import Expense, ExpenseCategory + +pytestmark = pytest.mark.django_db + + +def _kor(on): + business = Settings.load() + business.kor_enabled = on + business.save() + + +@pytest.fixture(autouse=True) +def kor_on(settings, tmp_path): + settings.DATA_DIR = tmp_path / "data" + settings.MEDIA_ROOT = settings.DATA_DIR + settings.DATA_DIR.mkdir() + _kor(True) + + +@pytest.fixture +def logged_in(client): + get_user_model().objects.create_user(username="freelancer", password="s3cret-pass") + client.login(username="freelancer", password="s3cret-pass") + return client + + +def _photo(name="IMG_0001.jpg", color="red"): + buffer = io.BytesIO() + Image.new("RGB", (8, 8), color=color).save(buffer, format="JPEG") + return SimpleUploadedFile(name, buffer.getvalue(), content_type="image/jpeg") + + +def _take(client, color="red", **extra): + """The photo from the camera, as app.js sends it.""" + return client.post(reverse("expenses:photo_upload"), {"file": _photo(color=color), **extra}) + + +def _form(**extra): + return { + "date": "2026-11-07", + "supplier": "Kantoorcentrum Zuid", + "description": "", + "lines-TOTAL_FORMS": "1", + "lines-INITIAL_FORMS": "0", + "lines-MIN_NUM_FORMS": "1", + "lines-MAX_NUM_FORMS": "1000", + "lines-0-description": "", + "lines-0-amount_cents": "48,95", + "lines-0-vat_info_cents": "", + "lines-0-category": "", + **extra, + } + + +# --- The photo ----------------------------------------------------------- + + +def test_the_photo_goes_into_the_tray_at_once(logged_in): + response = _take(logged_in) + receipt = Attachment.objects.in_tray().get() + assert receipt.source == photo_views.SOURCE and receipt.sha256 + assert response.url == reverse("expenses:photo", args=[receipt.pk]) + + +def test_a_receipt_that_is_too_big_goes_to_the_ordinary_form_with_the_reason( + logged_in, monkeypatch +): + monkeypatch.setattr("huismus.expenses.receipts.MAX_RECEIPT_BYTES", 10) + response = _take(logged_in) + assert response.url == reverse("expenses:create") + assert not Attachment.objects.exists() + page = logged_in.get(response.url).content.decode() + assert "groter dan" in page + + +def test_without_a_post_it_is_the_ordinary_form(logged_in): + assert logged_in.get(reverse("expenses:photo_upload")).url == reverse("expenses:create") + + +def test_opnieuw_replaces_the_photo(logged_in): + _take(logged_in) + first = Attachment.objects.get() + response = _take(logged_in, color="blue", vervangt=str(first.pk)) + second = Attachment.objects.get() + assert second.pk != first.pk + assert response.url == reverse("expenses:photo", args=[second.pk]) + assert not first.file.storage.exists(first.file.name) + + +def test_opnieuw_never_removes_a_receipt_that_is_on_an_expense(logged_in): + _take(logged_in) + receipt = Attachment.objects.get() + logged_in.post(reverse("expenses:photo", args=[receipt.pk]), _form()) + _take(logged_in, vervangt=str(receipt.pk)) + receipt.refresh_from_db() + assert receipt.expense is not None + assert Attachment.objects.count() == 2 + + +# --- The page ------------------------------------------------------------ + + +def test_the_page_shows_the_photo_the_amount_first_and_today(logged_in): + _take(logged_in) + receipt = Attachment.objects.get() + page = logged_in.get(reverse("expenses:photo", args=[receipt.pk])).content.decode() + assert f'src="{receipt.file.url}"' in page + assert "Opnieuw" in page + assert page.index('name="lines-0-amount_cents"') < page.index('name="supplier"') + assert page.index('name="supplier"') < page.index('name="date"') + assert f'value="{timezone.localdate().isoformat()}"' in page + assert "Bedrag, zoals je het betaalde" in page + # The app's own labels, not "Waar" and "Soort" of the design (PO, #188). + assert "Leverancier" in page and "Categorie" in page + assert "Uitgave opslaan" in page and "Alleen de foto bewaren" in page + assert page.index("Uitgave opslaan") < page.index("Alleen de foto bewaren") + + +def test_meer_regels_opens_verwerken_with_what_was_typed_and_saves_nothing(logged_in): + _take(logged_in) + receipt = Attachment.objects.get() + page = logged_in.get(reverse("expenses:photo", args=[receipt.pk])).content.decode() + process_url = reverse("expenses:process_item", args=["bonnetje", receipt.pk]) + assert f'formaction="{process_url}"' in page + + # The button posts the form there, as its "Regel toevoegen" without JS. + response = logged_in.post(process_url, _form(regel_toevoegen="1")) + + page = response.content.decode() + assert response.status_code == 200 + assert 'value="Kantoorcentrum Zuid"' in page and 'value="48,95"' in page + assert 'name="lines-1-amount_cents"' in page + assert not Expense.objects.exists() + assert Attachment.objects.in_tray().get() == receipt + + +def test_without_the_kor_it_asks_the_vat_and_the_rate(logged_in): + _kor(False) + _take(logged_in) + receipt = Attachment.objects.get() + page = logged_in.get(reverse("expenses:photo", args=[receipt.pk])).content.decode() + assert 'name="lines-0-vat_info_cents"' in page and 'name="lines-0-vat_rate"' in page + # Right under the amount. + assert page.index('name="lines-0-vat_rate"') < page.index('name="supplier"') + + response = logged_in.post(reverse("expenses:photo", args=[receipt.pk]), _form()) + assert response.status_code == 200 + assert "Vul het btw-bedrag in." in response.content.decode() + assert not Expense.objects.exists() + + +def test_a_receipt_gone_meanwhile_goes_to_uitgaven_with_the_reason(logged_in): + _take(logged_in) + receipt = Attachment.objects.get() + url = reverse("expenses:photo", args=[receipt.pk]) + receipt.delete() + response = logged_in.get(url) + assert response.url == reverse("expenses:list") + page = logged_in.get(response.url).content.decode() + assert "Dit bonnetje staat niet meer bij de bonnetjes zonder uitgave." in page + + +# --- Saving -------------------------------------------------------------- + + +def test_uitgave_opslaan_makes_the_expense_with_the_photo_on_it(logged_in): + office = ExpenseCategory.objects.create(name="Kantoor", sort_order=1) + _take(logged_in) + receipt = Attachment.objects.get() + + response = logged_in.post( + reverse("expenses:photo", args=[receipt.pk]), _form(**{"lines-0-category": office.pk}) + ) + + assert response.url == reverse("expenses:list") + expense = Expense.objects.get() + assert expense.amount_cents == 4895 + assert expense.supplier == "Kantoorcentrum Zuid" + assert expense.date == datetime.date(2026, 11, 7) + assert expense.lines.get().category == office + assert not expense.needs_review + receipt.refresh_from_db() + assert receipt.expense == expense + assert not Attachment.objects.in_tray().exists() + assert "Uitgave opgeslagen." in logged_in.get(response.url).content.decode() + + +def test_without_an_amount_nothing_is_saved_and_the_photo_stays(logged_in): + _take(logged_in) + receipt = Attachment.objects.get() + response = logged_in.post( + reverse("expenses:photo", args=[receipt.pk]), _form(**{"lines-0-amount_cents": ""}) + ) + assert response.status_code == 200 + assert not Expense.objects.exists() + assert Attachment.objects.in_tray().get() == receipt + + +def test_alleen_de_foto_bewaren_leaves_it_in_the_tray_and_reads_it(logged_in, monkeypatch): + started = [] + monkeypatch.setattr(reading, "read_in_background", lambda: started.append(True)) + _take(logged_in) + receipt = Attachment.objects.get() + + response = logged_in.post( + reverse("expenses:photo", args=[receipt.pk]), + _form(**{"lines-0-amount_cents": "", "alleen_foto": "1"}), + ) + + assert response.url == reverse("expenses:list") + assert Attachment.objects.in_tray().get() == receipt + assert not Expense.objects.exists() + assert started == [True] + page = logged_in.get(response.url).content.decode() + assert "Bonnetje bewaard. Je vindt het bij Verwerken." in page + assert "Verwerken (1)" in page + + +def test_both_need_a_login(client): + assert client.post(reverse("expenses:photo_upload")).status_code == 302 + assert "/login/" in client.get(reverse("expenses:photo", args=[1])).url From 0ba81572a4f9878bb48ae01d730eb24f30d9c135 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 15 Nov 2026 10:17:51 +0100 Subject: [PATCH 2/7] docs(hulp): an expense with the camera on your phone (#188) Co-Authored-By: Claude Opus 5.5 --- SPEC.md | 3 ++- docs/hulp/telefoon.en.md | 17 +++++++++++++++++ docs/hulp/telefoon.nl.md | 18 ++++++++++++++++++ docs/hulp/uitgaven.en.md | 3 +++ docs/hulp/uitgaven.nl.md | 3 +++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/SPEC.md b/SPEC.md index 61a32e6..555e41e 100644 --- a/SPEC.md +++ b/SPEC.md @@ -86,7 +86,7 @@ One table for quotes, invoices and credit notes. `document` FK, `paid_on`, `amount_cents`, `method`, `note`. Payment state (unpaid, partial, paid, credited) is derived, not stored: an invoice is settled by its payments plus the issued credit notes against it; "credited" when the credit notes alone cover the total. Outstanding = invoice total − issued credit notes − payments. ### Attachment -`document` or `expense` FK, `file`, `kind` (`original_pdf`, `receipt`, `other`), `sha256`, `source`. Never both. Neither only for a receipt waiting for an expense, fetched from the receipts folder (`source` `bonnetjesmap`, M20). +`document` or `expense` FK, `file`, `kind` (`original_pdf`, `receipt`, `other`), `sha256`, `source`. Never both. Neither only for a receipt waiting for an expense, fetched from the receipts folder (`source` `bonnetjesmap`, M20) or taken with a phone's camera (`source` `telefoon`, M20). ### Expense `date`, `supplier`, `description`, `amount_cents` (**gross amount paid**, always stored gross: invariant 7 of CLAUDE.md), `vat_info_cents` (under the KOR informational; with the KOR off the input VAT, decided by the owner 2026-11-06, not built yet: issue "Voorbelasting op uitgaven"), `source`, `external_id`. Has lines, as in Moneybird (decided 2026-11-02, `huismus-intern/besluiten.md`): `amount_cents` and `vat_info_cents` are the sums of its lines, stored by one function (`huismus/expenses/lines.py`). @@ -308,6 +308,7 @@ Decided by the owner on 2026-11-04 (`huismus-intern/backlog.md`); build choices - **Never paid twice:** a receipt counts as read once the service answered, whatever the answer, and after a timeout (3 minutes; the work may have been done). Errors where the service did no work (unreachable, key refused, unknown model, busy or out of credit, a server error) are red above the tray and on Bonnetjes lezen, not on the overview, and the receipts wait for the next look. - **What the user sees:** under each receipt in the tray "Huismus leest dit bonnetje…" while it waits for its turn, or "Niet gelezen: " when it stayed (a similar expense links to it); "Uitgave maken" stays. On the overview, below "n nieuwe bonnetjes" (which then counts only receipts that stay in the tray, or wait while the service fails), "n nieuwe uitgaven om na te kijken" with "Bekijken →" to Verwerken, counted from the last visit to Verwerken or the Nakijken list. While reading, nothing else changes on the overview. Code: `huismus/expenses/reading.py`, which `expenses.inbox` calls after each look. - **Verwerken** (`/uitgaven/verwerken/`, `huismus/expenses/process_views.py`; decided by the product-owner agent on 2026-11-06, `huismus-intern/besluiten.md`, "Verwerken: één stapel, het bonnetje groot naast de velden"). One stack of everything that waits, one at a time: first the expenses to check (the order of Nakijken, date newest first), then the receipts without an expense (the tray's order, newest first), whether Huismus left them with a reason, is still reading them, or no service is set up (`huismus/expenses/batch.py`). Reached by the button "Verwerken (n)" on Uitgaven (n the whole stack, gone at 0; "Bonnetjes (n)" stays), "Bekijken →" of "n nieuwe uitgaven om na te kijken" on the overview, "Uitgave maken" in the tray, and "Klopt"/"Overslaan" on an expense's own page. On a wide screen (the 980px breakpoint) the receipt is large on the left, half the width, staying in view while the fields scroll: a photo whole, a PDF in the browser's own viewer with every page (the file may be framed by Huismus's own pages only, `X-Frame-Options: SAMEORIGIN`; app.js sets the frame's address on a wide screen only). On a phone the receipt is above the fields, a photo at most half the screen high, a PDF as its name (an iPhone shows only the first page of a frame); everywhere "Bonnetje openen" opens the file in a new tab. No PDF rendering on the server. An expense without a receipt shows "Geen bonnetje bij deze uitgave." with the expense page's upload. On the right the expense page's fields and lines: an expense with its notice ("Huismus las dit bonnetje met …" or the assistant's) and **Klopt**; a receipt with empty fields, the tray's line ("Niet gelezen: …" or "Huismus leest dit bonnetje…") in that same notice (none without one) and **Opslaan**. Both save through the expense page's code, take the mark away and go on to the next one (the first after this one in the stack as it was, else the top one left); **Overslaan** goes there without saving. At the top "3 van 24": the ones done in this round plus where this one is in what is left, of the ones done plus what is left; the number done (`?klaar=`, a hidden field in the form) counts only Klopt and Opslaan and is never stored. An error stays on the same item with the same count; "Regel toevoegen" without JS shows the same item with one line more, saving nothing. After the last one, or with nothing to do, "Niets meer te verwerken." and "Naar Uitgaven". No "Verwijderen" here: in the tray or on the expense. With the KOR off, VAT per line stays required, via Klopt and via Opslaan. The new-expense form without a receipt is unchanged; `/uitgaven/nieuw/?bonnetje=` opens Verwerken at that receipt. +- **The photo first, on a phone** (#188; approved by the owner on 2026-11-15, build choices by the product-owner agent the same day, `huismus-intern/besluiten.md`). On a phone (JS: `(max-width: 760px) and (pointer: coarse)`) every link to the new-expense form opens the camera instead (`capture="environment"`); cancelling it opens the ordinary form, a browser that doesn't say "cancel" leaves the user where they tapped. The photo is sent at once with "Bonnetje uploaden…" (`/uitgaven/nieuw/foto/`, `huismus/expenses/photo_views.py`) and goes into the tray (`source` `telefoon`), so walking away never loses it; a refused file (too big, not a receipt) goes to the ordinary form with the upload's reason. Without a connection the page stays, with "Huismus is niet bereikbaar. Probeer het opnieuw als je verbinding hebt." and "Opnieuw proberen", which sends the same photo again. Then `/uitgaven/nieuw/foto//`, "Nieuwe uitgave": the photo with "Opnieuw" (a new photo; the old one goes only once the new one is in, and only while it waits in the tray), then one line: "Bedrag, zoals je het betaalde" (large), without the KOR "Btw" and "Btw-tarief" right under it, "Leverancier", "Datum" (today) and "Categorie". **Uitgave opslaan** saves through Verwerken's code, the receipt onto the expense, and goes to Uitgaven ("Uitgave opgeslagen."); **Alleen de foto bewaren** leaves it in the tray, starts Bonnetjes lezen if that is on, and goes to Uitgaven ("Bonnetje bewaard. Je vindt het bij Verwerken."). "Meer regels of een omschrijving" opens Verwerken at that receipt with what was typed and one line more, saving nothing. A wide screen, the desktop app and no JS keep the ordinary form. - Not in part 2: a scheduled task in the Claude app, a notice from macOS or Windows (`huismus-intern/backlog.md`). *Done when:* tests cover fetching (new, the same twice, a name taken in `Opgehaald`, files left with a reason, a file still syncing, a folder that's gone, saving or moving failing, the sample data), Dropbox and WebDAV against the fakes (the folder, unlinking, backups leaving it alone; on WebDAV also a name taken in `Opgehaald`, a file still being written, a refused password), the pages, making an expense from a receipt, looking sooner (a new file in a folder, the minute's wait, a skipped file once, a folder gone, the restore gate, Dropbox's wait against the fake with backoff and a forgotten cursor), the notice (new, seen, singular, off, sample data, only reading), and HEIC (a JPG with the original's name, upright and without metadata, at most 4032 px, the same JPG every time so it is fetched once and a failed move only moves next time, a damaged one or one of too many pixels left with a reason, the upload field); the pages are in `test_every_page.py`; a browser test sets up a folder, picks up now and makes an expense; strings exist in Dutch and English; `docs/hulp/bonnetjes.*.md` explains it. *Part 2:* tests cover the list, a photo (smaller, upright, PNG with transparency), a PDF with text, a scanned PDF, an unreadable PDF, an image of too many pixels, other attachments refused, and the receipt going onto the expense or nothing saved; `docs/hulp/bonnetjes.*.md` and `ai-assistenten.*.md` explain it. *Part 2b:* tests cover the mark from `add_expense`, the pill, the button and its count, the filter, "Klopt" (onward, the last one, an error keeps the mark), "Overslaan", the order, and saving; browser tests check three expenses with "Klopt" and "Overslaan", and three receipts made into expenses one after the other. *Verwerken:* tests cover the order of the stack, next after a save and round again, the count with `klaar`, Klopt, Opslaan with the receipt, Overslaan, an error, "Regel toevoegen" without JS, the KOR off, an expense without a receipt and its upload, items gone meanwhile, the empty stack, the PDF frame header, and English; browser tests process a photo, a PDF and a receipt at 1440 px (beside the fields, in view while scrolling, the PDF in a frame) and at 390 px (above the fields, no frame); the pages are in `test_every_page.py` with the demo receipts (`huismus/core/demo_receipts.py`). *Part 3:* tests against a fake service (never a real one) cover the page (a known service filled in, the address and key rules, saving tested first, the key never shown, kept when left empty, testing, turning off, left out of backups), and reading (an expense with the mark and the receipt, each reason to leave a receipt, VAT without the KOR, a duplicate, failures that retry and a timeout that doesn't, a receipt taken meanwhile, the sample data); browser tests choose a service and see a receipt become an expense; `docs/hulp/bonnetjes.*.md` and `ai-assistenten.*.md` explain it. diff --git a/docs/hulp/telefoon.en.md b/docs/hulp/telefoon.en.md index d10964d..b91bf61 100644 --- a/docs/hulp/telefoon.en.md +++ b/docs/hulp/telefoon.en.md @@ -29,6 +29,23 @@ home screen there's **Share**: use it to mail the PDF or save it to Files. In the browser there's **Download**, and **Share** too if the browser can share files. +## An expense with the camera + +Tap **+** and then **Expense**, or **New expense** under Expenses: the camera +opens. Take a photo of the receipt. Huismus keeps it at once. Then fill in the +amount, then the supplier, the date and the category, and tap **Save +expense**. + +No time? Tap **Just keep the photo**. The receipt then waits under +**Process** on the Expenses page, where you make it into an expense later. +Photo didn't work out? Tap **Retake**. + +Can't reach Huismus, for example in a shop without your VPN? The photo stays +on your screen. Tap **Try again** once you're connected. + +Rather use a photo from your library or a PDF? Close the camera: you get the +ordinary form. + ## What's on your phone Your records aren't on it. Everything stays on the server, and the app only diff --git a/docs/hulp/telefoon.nl.md b/docs/hulp/telefoon.nl.md index e47f4f2..dfbb672 100644 --- a/docs/hulp/telefoon.nl.md +++ b/docs/hulp/telefoon.nl.md @@ -29,6 +29,24 @@ beginscherm staat daar **Delen**: zo mail je de pdf of bewaar je hem in Bestanden. In de browser staat er **Downloaden**, en als de browser kan delen ook **Delen**. +## Een uitgave met de camera + +Tik op **+** en dan op **Uitgave**, of op **Nieuwe uitgave** bij Uitgaven: de +camera gaat open. Maak een foto van het bonnetje. Huismus bewaart hem meteen. +Daarna vul je het bedrag in, dan de leverancier, de datum en de categorie, en +tik je op **Uitgave opslaan**. + +Geen tijd? Tik op **Alleen de foto bewaren**. Het bonnetje staat dan bij +**Verwerken** op de pagina Uitgaven, en daar maak je er later een uitgave van. +Is de foto mislukt, tik dan op **Opnieuw**. + +Huismus is niet bereikbaar, bijvoorbeeld in de winkel zonder VPN? Dan blijft de +foto op je scherm staan. Tik op **Opnieuw proberen** als je weer verbinding +hebt. + +Wil je liever een foto uit je fotobibliotheek of een pdf? Sluit dan de camera: +je krijgt het gewone formulier. + ## Wat er op je telefoon staat Niets van je administratie. Alles blijft op de server, en de app laat alleen diff --git a/docs/hulp/uitgaven.en.md b/docs/hulp/uitgaven.en.md index b87c356..0ee2485 100644 --- a/docs/hulp/uitgaven.en.md +++ b/docs/hulp/uitgaven.en.md @@ -29,6 +29,9 @@ or a PDF. Huismus keeps a HEIC photo as a JPG. For a new expense you can do this **Save**. An expense can have more than one receipt: add the others after saving. +On your phone a new expense starts with the camera. See [On your +phone](telefoon.en.md). + Receipts from the road can also go in a folder that Huismus picks up itself. See [Receipts on the road](bonnetjes.en.md). diff --git a/docs/hulp/uitgaven.nl.md b/docs/hulp/uitgaven.nl.md index 2b7e211..09c9a75 100644 --- a/docs/hulp/uitgaven.nl.md +++ b/docs/hulp/uitgaven.nl.md @@ -30,6 +30,9 @@ HEIC) of een pdf. Een HEIC-foto bewaart Huismus als JPG. Bij een nieuwe uitgave **Opslaan** klikt. Een uitgave kan meer bonnetjes hebben: de rest voeg je toe na het opslaan. +Op je telefoon begint een nieuwe uitgave met de camera. Zie [Op je +telefoon](telefoon.nl.md). + Bonnetjes van onderweg kun je ook in een map zetten die Huismus zelf ophaalt. Zie [Bonnetjes onderweg](bonnetjes.nl.md). From ad95015b1cc3c42e7f2aa9453ae24551202a6661 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 15 Nov 2026 10:21:00 +0100 Subject: [PATCH 3/7] fix(expenses): Opnieuw only replaces a phone photo, never in the desktop app (#188) Review: the old photo goes only after the new one is in; an error from Huismus says so instead of claiming no connection; closing the camera has its browser test. Co-Authored-By: Claude Opus 5.5 --- SPEC.md | 2 +- huismus/core/static/core/app.js | 9 ++++++--- huismus/expenses/photo_views.py | 21 ++++++++++----------- huismus/templates/base.html | 6 ++++-- tests/e2e/test_photo_first.py | 18 +++++++++++++++++- tests/expenses/test_photo.py | 20 ++++++++++++++++++++ 6 files changed, 58 insertions(+), 18 deletions(-) diff --git a/SPEC.md b/SPEC.md index 555e41e..257738c 100644 --- a/SPEC.md +++ b/SPEC.md @@ -308,7 +308,7 @@ Decided by the owner on 2026-11-04 (`huismus-intern/backlog.md`); build choices - **Never paid twice:** a receipt counts as read once the service answered, whatever the answer, and after a timeout (3 minutes; the work may have been done). Errors where the service did no work (unreachable, key refused, unknown model, busy or out of credit, a server error) are red above the tray and on Bonnetjes lezen, not on the overview, and the receipts wait for the next look. - **What the user sees:** under each receipt in the tray "Huismus leest dit bonnetje…" while it waits for its turn, or "Niet gelezen: " when it stayed (a similar expense links to it); "Uitgave maken" stays. On the overview, below "n nieuwe bonnetjes" (which then counts only receipts that stay in the tray, or wait while the service fails), "n nieuwe uitgaven om na te kijken" with "Bekijken →" to Verwerken, counted from the last visit to Verwerken or the Nakijken list. While reading, nothing else changes on the overview. Code: `huismus/expenses/reading.py`, which `expenses.inbox` calls after each look. - **Verwerken** (`/uitgaven/verwerken/`, `huismus/expenses/process_views.py`; decided by the product-owner agent on 2026-11-06, `huismus-intern/besluiten.md`, "Verwerken: één stapel, het bonnetje groot naast de velden"). One stack of everything that waits, one at a time: first the expenses to check (the order of Nakijken, date newest first), then the receipts without an expense (the tray's order, newest first), whether Huismus left them with a reason, is still reading them, or no service is set up (`huismus/expenses/batch.py`). Reached by the button "Verwerken (n)" on Uitgaven (n the whole stack, gone at 0; "Bonnetjes (n)" stays), "Bekijken →" of "n nieuwe uitgaven om na te kijken" on the overview, "Uitgave maken" in the tray, and "Klopt"/"Overslaan" on an expense's own page. On a wide screen (the 980px breakpoint) the receipt is large on the left, half the width, staying in view while the fields scroll: a photo whole, a PDF in the browser's own viewer with every page (the file may be framed by Huismus's own pages only, `X-Frame-Options: SAMEORIGIN`; app.js sets the frame's address on a wide screen only). On a phone the receipt is above the fields, a photo at most half the screen high, a PDF as its name (an iPhone shows only the first page of a frame); everywhere "Bonnetje openen" opens the file in a new tab. No PDF rendering on the server. An expense without a receipt shows "Geen bonnetje bij deze uitgave." with the expense page's upload. On the right the expense page's fields and lines: an expense with its notice ("Huismus las dit bonnetje met …" or the assistant's) and **Klopt**; a receipt with empty fields, the tray's line ("Niet gelezen: …" or "Huismus leest dit bonnetje…") in that same notice (none without one) and **Opslaan**. Both save through the expense page's code, take the mark away and go on to the next one (the first after this one in the stack as it was, else the top one left); **Overslaan** goes there without saving. At the top "3 van 24": the ones done in this round plus where this one is in what is left, of the ones done plus what is left; the number done (`?klaar=`, a hidden field in the form) counts only Klopt and Opslaan and is never stored. An error stays on the same item with the same count; "Regel toevoegen" without JS shows the same item with one line more, saving nothing. After the last one, or with nothing to do, "Niets meer te verwerken." and "Naar Uitgaven". No "Verwijderen" here: in the tray or on the expense. With the KOR off, VAT per line stays required, via Klopt and via Opslaan. The new-expense form without a receipt is unchanged; `/uitgaven/nieuw/?bonnetje=` opens Verwerken at that receipt. -- **The photo first, on a phone** (#188; approved by the owner on 2026-11-15, build choices by the product-owner agent the same day, `huismus-intern/besluiten.md`). On a phone (JS: `(max-width: 760px) and (pointer: coarse)`) every link to the new-expense form opens the camera instead (`capture="environment"`); cancelling it opens the ordinary form, a browser that doesn't say "cancel" leaves the user where they tapped. The photo is sent at once with "Bonnetje uploaden…" (`/uitgaven/nieuw/foto/`, `huismus/expenses/photo_views.py`) and goes into the tray (`source` `telefoon`), so walking away never loses it; a refused file (too big, not a receipt) goes to the ordinary form with the upload's reason. Without a connection the page stays, with "Huismus is niet bereikbaar. Probeer het opnieuw als je verbinding hebt." and "Opnieuw proberen", which sends the same photo again. Then `/uitgaven/nieuw/foto//`, "Nieuwe uitgave": the photo with "Opnieuw" (a new photo; the old one goes only once the new one is in, and only while it waits in the tray), then one line: "Bedrag, zoals je het betaalde" (large), without the KOR "Btw" and "Btw-tarief" right under it, "Leverancier", "Datum" (today) and "Categorie". **Uitgave opslaan** saves through Verwerken's code, the receipt onto the expense, and goes to Uitgaven ("Uitgave opgeslagen."); **Alleen de foto bewaren** leaves it in the tray, starts Bonnetjes lezen if that is on, and goes to Uitgaven ("Bonnetje bewaard. Je vindt het bij Verwerken."). "Meer regels of een omschrijving" opens Verwerken at that receipt with what was typed and one line more, saving nothing. A wide screen, the desktop app and no JS keep the ordinary form. +- **The photo first, on a phone** (#188; the step chosen by the owner on 2026-11-15 with the new house style, build choices by the product-owner agent the same day, `huismus-intern/besluiten.md`). On a phone (JS: `(max-width: 760px) and (pointer: coarse)`) every link to the new-expense form opens the camera instead (`capture="environment"`); cancelling it opens the ordinary form, a browser that doesn't say "cancel" leaves the user where they tapped. The photo is sent at once with "Bonnetje uploaden…" (`/uitgaven/nieuw/foto/`, `huismus/expenses/photo_views.py`) and goes into the tray (`source` `telefoon`), so walking away never loses it; a refused file (too big, not a receipt) goes to the ordinary form with the upload's reason. Without a connection the page stays, with "Huismus is niet bereikbaar. Probeer het opnieuw als je verbinding hebt." and "Opnieuw proberen", which sends the same photo again. Then `/uitgaven/nieuw/foto//`, "Nieuwe uitgave": the photo with "Opnieuw" (a new photo; the old one goes only once the new one is in, and only a photo taken this way that still waits in the tray), then one line: "Bedrag, zoals je het betaalde" (large), without the KOR "Btw" and "Btw-tarief" right under it, "Leverancier", "Datum" (today) and "Categorie". **Uitgave opslaan** saves through Verwerken's code, the receipt onto the expense, and goes to Uitgaven ("Uitgave opgeslagen."); **Alleen de foto bewaren** leaves it in the tray, starts Bonnetjes lezen if that is on, and goes to Uitgaven ("Bonnetje bewaard. Je vindt het bij Verwerken."). "Meer regels of een omschrijving" opens Verwerken at that receipt with what was typed and one line more, saving nothing. A wide screen or a mouse, the desktop app (never, even in a narrow window on a touch screen) and no JS keep the ordinary form. - Not in part 2: a scheduled task in the Claude app, a notice from macOS or Windows (`huismus-intern/backlog.md`). *Done when:* tests cover fetching (new, the same twice, a name taken in `Opgehaald`, files left with a reason, a file still syncing, a folder that's gone, saving or moving failing, the sample data), Dropbox and WebDAV against the fakes (the folder, unlinking, backups leaving it alone; on WebDAV also a name taken in `Opgehaald`, a file still being written, a refused password), the pages, making an expense from a receipt, looking sooner (a new file in a folder, the minute's wait, a skipped file once, a folder gone, the restore gate, Dropbox's wait against the fake with backoff and a forgotten cursor), the notice (new, seen, singular, off, sample data, only reading), and HEIC (a JPG with the original's name, upright and without metadata, at most 4032 px, the same JPG every time so it is fetched once and a failed move only moves next time, a damaged one or one of too many pixels left with a reason, the upload field); the pages are in `test_every_page.py`; a browser test sets up a folder, picks up now and makes an expense; strings exist in Dutch and English; `docs/hulp/bonnetjes.*.md` explains it. *Part 2:* tests cover the list, a photo (smaller, upright, PNG with transparency), a PDF with text, a scanned PDF, an unreadable PDF, an image of too many pixels, other attachments refused, and the receipt going onto the expense or nothing saved; `docs/hulp/bonnetjes.*.md` and `ai-assistenten.*.md` explain it. *Part 2b:* tests cover the mark from `add_expense`, the pill, the button and its count, the filter, "Klopt" (onward, the last one, an error keeps the mark), "Overslaan", the order, and saving; browser tests check three expenses with "Klopt" and "Overslaan", and three receipts made into expenses one after the other. *Verwerken:* tests cover the order of the stack, next after a save and round again, the count with `klaar`, Klopt, Opslaan with the receipt, Overslaan, an error, "Regel toevoegen" without JS, the KOR off, an expense without a receipt and its upload, items gone meanwhile, the empty stack, the PDF frame header, and English; browser tests process a photo, a PDF and a receipt at 1440 px (beside the fields, in view while scrolling, the PDF in a frame) and at 390 px (above the fields, no frame); the pages are in `test_every_page.py` with the demo receipts (`huismus/core/demo_receipts.py`). *Part 3:* tests against a fake service (never a real one) cover the page (a known service filled in, the address and key rules, saving tested first, the key never shown, kept when left empty, testing, turning off, left out of backups), and reading (an expense with the mark and the receipt, each reason to leave a receipt, VAT without the KOR, a duplicate, failures that retry and a timeout that doesn't, a receipt taken meanwhile, the sample data); browser tests choose a service and see a receipt become an expense; `docs/hulp/bonnetjes.*.md` and `ai-assistenten.*.md` explain it. diff --git a/huismus/core/static/core/app.js b/huismus/core/static/core/app.js index 888f793..0198cec 100644 --- a/huismus/core/static/core/app.js +++ b/huismus/core/static/core/app.js @@ -724,12 +724,15 @@ async function sendPhoto(form, file) { try { response = await fetch(form.action, { method: "POST", body: data }); } catch { - response = null; - } - if (!response?.ok) { + // No answer at all: no connection with Huismus. cameraToast("camera-offline"); return; } + if (!response.ok) { + // Huismus answered, with an error. + cameraToast("camera-failed"); + return; + } unsent = null; // Where Huismus sent it: the photo page, or the ordinary form with the // reason it refused the file. diff --git a/huismus/expenses/photo_views.py b/huismus/expenses/photo_views.py index 80e17f3..d8d5e7f 100644 --- a/huismus/expenses/photo_views.py +++ b/huismus/expenses/photo_views.py @@ -47,13 +47,19 @@ def photo_upload(request): messages.error(request, form.errors["file"][0]) return redirect("expenses:create") uploaded = form.cleaned_data["file"] - replaced = Attachment.objects.in_tray().filter(pk=_int(request.POST.get("vervangt"))).first() - if replaced is not None: - replaced.file.delete(save=False) - replaced.delete() receipt = Attachment.objects.create( file=uploaded, kind="receipt", sha256=sha256_of(uploaded), source=SOURCE ) + # The old one goes only now the new one is in. Only a photo taken here + # that still waits in the tray: one on an expense meanwhile (another + # tab) or one from the receipts folder stays. Anything else than a + # number replaces nothing. + replaces = request.POST.get("vervangt", "") + if replaces.isdigit(): + replaced = Attachment.objects.in_tray().filter(source=SOURCE, pk=int(replaces)) + for old in replaced: + old.file.delete(save=False) + old.delete() return redirect("expenses:photo", pk=receipt.pk) @@ -100,10 +106,3 @@ def photo_expense(request, pk): "upload_url": reverse("expenses:photo_upload"), }, ) - - -def _int(value) -> int | None: - try: - return int(value) - except (TypeError, ValueError): - return None diff --git a/huismus/templates/base.html b/huismus/templates/base.html index 28703d6..8d33c57 100644 --- a/huismus/templates/base.html +++ b/huismus/templates/base.html @@ -116,16 +116,18 @@
{% translate "Facturen en uitgaven voor zzp'ers, met of zonder KOR" %}{% translate "Sneltoetsen:" %} N {% translate "nieuw" %}{% block shortcut_search %}{% endblock %}
-{% if user.is_authenticated %} +{% if user.is_authenticated and not desktop %} {% comment %}On a phone every "Uitgave" opens the camera, and the photo goes here (#188; app.js, "The photo first"; expenses/photo_views.py). Without JS -this stays hidden and unused: the link goes to the ordinary form.{% endcomment %} +this stays hidden and unused: the link goes to the ordinary form. Never in +the desktop app, even in a narrow window on a touch screen.{% endcomment %} + {% endif %} {% include "core/_toasts.html" %} diff --git a/tests/e2e/test_photo_first.py b/tests/e2e/test_photo_first.py index 8378998..940606a 100644 --- a/tests/e2e/test_photo_first.py +++ b/tests/e2e/test_photo_first.py @@ -11,6 +11,7 @@ from huismus.core.demo_receipts import _photo from huismus.core.models import Attachment from huismus.expenses.models import Expense +from tests.e2e.conftest import IGNORED pytestmark = pytest.mark.django_db(transaction=True) @@ -32,7 +33,11 @@ def phone(app, browser, browser_name): context.add_cookies(app.context.cookies()) page = context.new_page() errors = [] - page.on("pageerror", lambda error: errors.append(str(error))) + # The same JavaScript errors as the app fixture lets pass. + page.on( + "pageerror", + lambda error: None if any(n in str(error) for n in IGNORED) else errors.append(str(error)), + ) page.base = app.base yield page context.close() @@ -108,6 +113,17 @@ def test_without_a_connection_the_photo_stays_to_send_again(phone): assert Attachment.objects.in_tray().count() == 1 +def test_closing_the_camera_opens_the_ordinary_form(phone): + phone.goto(phone.base + "/uitgaven/") + with phone.expect_file_chooser(): + phone.get_by_role("link", name="Nieuwe uitgave").first.tap() + # What the browser does when the camera is closed without a photo. + phone.locator("#camera input[type=file]").dispatch_event("cancel") + expect(phone).to_have_url(phone.base + "/uitgaven/nieuw/") + expect(phone.get_by_text("Sleep een bonnetje hierheen")).to_be_visible() + assert not Attachment.objects.exists() + + def test_on_a_wide_screen_uitgave_is_the_ordinary_form(app): app.set_viewport_size({"width": 1440, "height": 900}) app.goto(app.base + "/uitgaven/") diff --git a/tests/expenses/test_photo.py b/tests/expenses/test_photo.py index 19f5c35..7ca37c1 100644 --- a/tests/expenses/test_photo.py +++ b/tests/expenses/test_photo.py @@ -239,3 +239,23 @@ def test_alleen_de_foto_bewaren_leaves_it_in_the_tray_and_reads_it(logged_in, mo def test_both_need_a_login(client): assert client.post(reverse("expenses:photo_upload")).status_code == 302 assert "/login/" in client.get(reverse("expenses:photo", args=[1])).url + + +def test_a_vervangt_that_is_no_number_replaces_nothing(logged_in): + _take(logged_in) + _take(logged_in, color="blue", vervangt="nee") + assert Attachment.objects.in_tray().count() == 2 + + +def test_opnieuw_never_removes_a_receipt_from_the_receipts_folder(logged_in): + _take(logged_in) + folder = Attachment.objects.get() + Attachment.objects.filter(pk=folder.pk).update(source="bonnetjesmap") + _take(logged_in, color="blue", vervangt=str(folder.pk)) + assert Attachment.objects.in_tray().count() == 2 + + +def test_the_desktop_app_has_no_camera(logged_in, settings): + assert 'id="camera"' in logged_in.get(reverse("expenses:list")).content.decode() + settings.DESKTOP = True + assert 'id="camera"' not in logged_in.get(reverse("expenses:list")).content.decode() From aa766226d6f8156117894e7e9cfd593289a34a10 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 15 Nov 2026 10:24:24 +0100 Subject: [PATCH 4/7] style(expenses): a smaller photo, so the amount shows above the bar (#188) Co-Authored-By: Claude Opus 5.5 --- huismus/core/static/core/huismus.css | 4 ++-- huismus/templates/expenses/photo.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/huismus/core/static/core/huismus.css b/huismus/core/static/core/huismus.css index 64b3665..861b375 100644 --- a/huismus/core/static/core/huismus.css +++ b/huismus/core/static/core/huismus.css @@ -812,12 +812,12 @@ div.hint-banner:hover { border-color: var(--border); } /* A new expense on a phone, the photo first (#188, expenses/photo.html): the photo with "Opnieuw" on it, then the amount, large. */ .photo-shot { position: relative; padding: var(--s-3); } -.photo-shot .process-img { max-height: 40dvh; } +.photo-shot .process-img { max-height: min(30dvh, 260px); } .photo-again { position: absolute; right: var(--s-5); bottom: var(--s-5); } .amount-xl .input { height: 60px; font-size: var(--fs-2xl); font-weight: var(--fw-semibold); } .amount-xl .money::before { font-size: var(--fs-lg); } /* Its bar: "Uitgave opslaan" with "Alleen de foto bewaren" under it. */ -.actionbar.photo-actions { flex-direction: column; align-items: stretch; flex-wrap: nowrap; } +.actionbar.photo-actions { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 2px; } .actionbar.photo-actions .btn { flex: none; } .report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden; } diff --git a/huismus/templates/expenses/photo.html b/huismus/templates/expenses/photo.html index 9eb1095..ae75a1f 100644 --- a/huismus/templates/expenses/photo.html +++ b/huismus/templates/expenses/photo.html @@ -65,7 +65,7 @@

{% translate "Nieuwe uitgave" %}

- +
{% endblock %} From 92405b42b4bfddd2a8fd98252ba020baad3d9b36 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 15 Nov 2026 10:29:49 +0100 Subject: [PATCH 5/7] fix(expenses): a refused photo keeps its reason on the ordinary form (#188) fetch() followed the redirect and used up the message, so the page that opened after it had none. To the camera's upload Huismus now answers with where to go instead of a redirect. Co-Authored-By: Claude Opus 5.5 --- huismus/core/static/core/app.js | 15 +++++++++++---- huismus/expenses/photo_views.py | 20 ++++++++++++++++++-- tests/e2e/test_photo_first.py | 10 ++++++++++ tests/expenses/test_photo.py | 21 ++++++++++++++++++--- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/huismus/core/static/core/app.js b/huismus/core/static/core/app.js index 0198cec..2dd7fda 100644 --- a/huismus/core/static/core/app.js +++ b/huismus/core/static/core/app.js @@ -722,7 +722,14 @@ async function sendPhoto(form, file) { data.set("file", file); let response; try { - response = await fetch(form.action, { method: "POST", body: data }); + // The header asks Huismus to say where to go (X-Huismus-Go) rather than + // to redirect: following a redirect here would use up the next page's + // message, such as why it refused the file (expenses/photo_views.py). + response = await fetch(form.action, { + method: "POST", + body: data, + headers: { "X-Huismus-Camera": "1" }, + }); } catch { // No answer at all: no connection with Huismus. cameraToast("camera-offline"); @@ -734,9 +741,9 @@ async function sendPhoto(form, file) { return; } unsent = null; - // Where Huismus sent it: the photo page, or the ordinary form with the - // reason it refused the file. - window.location.assign(response.url); + // Where Huismus sends it: the photo page, or the ordinary form with the + // reason it refused the file. Signed out meanwhile: the login page. + window.location.assign(response.headers.get("X-Huismus-Go") || response.url); } document.addEventListener("change", (event) => { diff --git a/huismus/expenses/photo_views.py b/huismus/expenses/photo_views.py index d8d5e7f..e282f90 100644 --- a/huismus/expenses/photo_views.py +++ b/huismus/expenses/photo_views.py @@ -16,6 +16,7 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required +from django.http import HttpResponse from django.shortcuts import redirect, render from django.urls import reverse from django.utils import timezone @@ -32,6 +33,9 @@ # Attachment.source of a photo taken here. SOURCE = "telefoon" +# The request header app.js sends the photo with, and the response header +# with the page to open (_go). +CAMERA, GO = "X-Huismus-Camera", "X-Huismus-Go" @login_required @@ -45,7 +49,7 @@ def photo_upload(request): # The form's own reason: "Dit bonnetje is groter dan 10 MB. …". The # ordinary form can take a photo from the library or a PDF. messages.error(request, form.errors["file"][0]) - return redirect("expenses:create") + return _go(request, reverse("expenses:create")) uploaded = form.cleaned_data["file"] receipt = Attachment.objects.create( file=uploaded, kind="receipt", sha256=sha256_of(uploaded), source=SOURCE @@ -60,7 +64,19 @@ def photo_upload(request): for old in replaced: old.file.delete(save=False) old.delete() - return redirect("expenses:photo", pk=receipt.pk) + return _go(request, reverse("expenses:photo", kwargs={"pk": receipt.pk})) + + +def _go(request, url): + """Where the page goes next. To app.js's upload (the header CAMERA) a + 204 with the address: had fetch() followed a redirect, it would have + shown the next page's message to nobody, and the page that opens after + it wouldn't have it any more. To a plain form, a redirect.""" + if CAMERA not in request.headers: + return redirect(url) + response = HttpResponse(status=204) + response[GO] = url + return response @login_required diff --git a/tests/e2e/test_photo_first.py b/tests/e2e/test_photo_first.py index 940606a..0cf1287 100644 --- a/tests/e2e/test_photo_first.py +++ b/tests/e2e/test_photo_first.py @@ -113,6 +113,16 @@ def test_without_a_connection_the_photo_stays_to_send_again(phone): assert Attachment.objects.in_tray().count() == 1 +def test_a_refused_photo_opens_the_ordinary_form_with_the_reason(phone, monkeypatch): + # Found in the screenshots, 2026-11-15: the reason was gone. + monkeypatch.setattr("huismus.expenses.receipts.MAX_RECEIPT_BYTES", 10) + phone.goto(phone.base + "/uitgaven/") + _camera(phone, lambda: phone.get_by_role("link", name="Nieuwe uitgave").first.tap()) + expect(phone).to_have_url(phone.base + "/uitgaven/nieuw/") + expect(phone.locator("#toasts")).to_contain_text("groter dan") + assert not Attachment.objects.exists() + + def test_closing_the_camera_opens_the_ordinary_form(phone): phone.goto(phone.base + "/uitgaven/") with phone.expect_file_chooser(): diff --git a/tests/expenses/test_photo.py b/tests/expenses/test_photo.py index 7ca37c1..91eda43 100644 --- a/tests/expenses/test_photo.py +++ b/tests/expenses/test_photo.py @@ -50,9 +50,11 @@ def _photo(name="IMG_0001.jpg", color="red"): return SimpleUploadedFile(name, buffer.getvalue(), content_type="image/jpeg") -def _take(client, color="red", **extra): - """The photo from the camera, as app.js sends it.""" - return client.post(reverse("expenses:photo_upload"), {"file": _photo(color=color), **extra}) +def _take(client, color="red", headers=None, **extra): + """The photo from the camera, as the form without JS sends it.""" + return client.post( + reverse("expenses:photo_upload"), {"file": _photo(color=color), **extra}, headers=headers + ) def _form(**extra): @@ -259,3 +261,16 @@ def test_the_desktop_app_has_no_camera(logged_in, settings): assert 'id="camera"' in logged_in.get(reverse("expenses:list")).content.decode() settings.DESKTOP = True assert 'id="camera"' not in logged_in.get(reverse("expenses:list")).content.decode() + + +def test_to_app_js_it_says_where_to_go_instead_of_redirecting(logged_in, monkeypatch): + # fetch() would follow a redirect and use up the next page's message. + response = _take(logged_in, headers={"X-Huismus-Camera": "1"}) + receipt = Attachment.objects.get() + assert response.status_code == 204 + assert response["X-Huismus-Go"] == reverse("expenses:photo", args=[receipt.pk]) + + monkeypatch.setattr("huismus.expenses.receipts.MAX_RECEIPT_BYTES", 10) + response = _take(logged_in, color="blue", headers={"X-Huismus-Camera": "1"}) + assert response["X-Huismus-Go"] == reverse("expenses:create") + assert "groter dan" in logged_in.get(response["X-Huismus-Go"]).content.decode() From 7c7828c184c8835377456a338b8ce196478b05ed Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 15 Nov 2026 10:37:49 +0100 Subject: [PATCH 6/7] chore(i18n): the camera's texts in English after the rebase (#188) Co-Authored-By: Claude Opus 5.5 --- huismus/locale/en/LC_MESSAGES/django.po | 56 +++++++++++++++++++++---- huismus/locale/nl/LC_MESSAGES/django.po | 40 +++++++++++++++--- 2 files changed, 82 insertions(+), 14 deletions(-) diff --git a/huismus/locale/en/LC_MESSAGES/django.po b/huismus/locale/en/LC_MESSAGES/django.po index bb47a6e..99c0e8a 100644 --- a/huismus/locale/en/LC_MESSAGES/django.po +++ b/huismus/locale/en/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: huismus\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-15 09:58+0100\n" +"POT-Creation-Date: 2026-11-15 10:36+0100\n" "PO-Revision-Date: 2026-09-25 08:36+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -1705,12 +1705,16 @@ msgstr "Dear {naam}," msgid "" "Van factuur {nummer} staat nog {openstaand} open. De vervaldatum was " "{vervaldatum}. In de bijlage vind je de factuur." -msgstr "Invoice {nummer} still has {openstaand} outstanding. It was due on {vervaldatum}. You'll find the invoice attached." +msgstr "" +"Invoice {nummer} still has {openstaand} outstanding. It was due on " +"{vervaldatum}. You'll find the invoice attached." msgid "" "Wil je het bedrag zo snel mogelijk overmaken? Heb je al betaald, dan kun je " "deze mail vergeten." -msgstr "Could you transfer the amount as soon as possible? If you've already paid, please ignore this email." +msgstr "" +"Could you transfer the amount as soon as possible? If you've already paid, " +"please ignore this email." msgid "Met vriendelijke groet," msgstr "Kind regards," @@ -2206,12 +2210,15 @@ msgstr "expense line" msgid "uitgaveregels" msgstr "expense lines" -msgid "Uitgave nagekeken." -msgstr "Expense checked." +msgid "Bonnetje bewaard. Je vindt het bij Verwerken." +msgstr "Receipt saved. You'll find it under Process." msgid "Uitgave opgeslagen." msgstr "Expense saved." +msgid "Uitgave nagekeken." +msgstr "Expense checked." + msgid "Niet gelezen: dit lijkt geen bonnetje." msgstr "Not read: this doesn't look like a receipt." @@ -2966,6 +2973,18 @@ msgstr "Shortcuts:" msgid "nieuw" msgstr "new" +msgid "Bonnetje uploaden…" +msgstr "Uploading receipt…" + +msgid "Huismus is niet bereikbaar. Probeer het opnieuw als je verbinding hebt." +msgstr "Can't reach Huismus. Try again when you're connected." + +msgid "Opnieuw proberen" +msgstr "Try again" + +msgid "Het uploaden is mislukt. Probeer het nog een keer." +msgstr "The upload failed. Please try once more." + msgid "Niet gekoppeld" msgstr "Not connected" @@ -3549,7 +3568,11 @@ msgid "" "{bedrag}, {naam} en {bedrijf}; bij een factuur en een herinnering ook " "{vervaldatum}, bij een herinnering {openstaand}, bij een offerte " "{geldig_tot}." -msgstr "Every mail starts with this. You can still change it per mail. Leave a field empty and Huismus uses its own text. Placeholders: {nummer}, {bedrag}, {naam} and {bedrijf}; for an invoice and a reminder also {vervaldatum}, for a reminder {openstaand}, for a quote {geldig_tot}." +msgstr "" +"Every mail starts with this. You can still change it per mail. Leave a field " +"empty and Huismus uses its own text. Placeholders: {nummer}, {bedrag}, " +"{naam} and {bedrijf}; for an invoice and a reminder also {vervaldatum}, for " +"a reminder {openstaand}, for a quote {geldig_tot}." #, python-format msgid "%(counter)s veld heeft aandacht nodig" @@ -4039,9 +4062,6 @@ msgid "" msgstr "" "This device can't connect to Huismus. Check your Wi-Fi or VPN and try again." -msgid "Opnieuw proberen" -msgstr "Try again" - #, python-format msgid "Stap %(number)s van %(total)s" msgstr "Step %(number)s of %(total)s" @@ -5104,6 +5124,24 @@ msgstr "No expense matches your search and filters." msgid "betekent dat er een bonnetje bij de uitgave zit." msgstr "means the expense has a receipt." +msgid "Opnieuw" +msgstr "Retake" + +msgid "Foto versturen" +msgstr "Send photo" + +msgid "Bedrag, zoals je het betaalde" +msgstr "Amount, as you paid it" + +msgid "Meer regels of een omschrijving" +msgstr "More lines or a description" + +msgid "Uitgave opslaan" +msgstr "Save expense" + +msgid "Alleen de foto bewaren" +msgstr "Just keep the photo" + msgid "Verwerken" msgstr "Process" diff --git a/huismus/locale/nl/LC_MESSAGES/django.po b/huismus/locale/nl/LC_MESSAGES/django.po index a6dcc2b..e70c3db 100644 --- a/huismus/locale/nl/LC_MESSAGES/django.po +++ b/huismus/locale/nl/LC_MESSAGES/django.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: huismus\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-15 09:58+0100\n" +"POT-Creation-Date: 2026-11-15 10:36+0100\n" "PO-Revision-Date: 2026-09-25 08:36+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -2116,12 +2116,15 @@ msgstr "" msgid "uitgaveregels" msgstr "" -msgid "Uitgave nagekeken." +msgid "Bonnetje bewaard. Je vindt het bij Verwerken." msgstr "" msgid "Uitgave opgeslagen." msgstr "" +msgid "Uitgave nagekeken." +msgstr "" + msgid "Niet gelezen: dit lijkt geen bonnetje." msgstr "" @@ -2796,6 +2799,18 @@ msgstr "" msgid "nieuw" msgstr "" +msgid "Bonnetje uploaden…" +msgstr "" + +msgid "Huismus is niet bereikbaar. Probeer het opnieuw als je verbinding hebt." +msgstr "" + +msgid "Opnieuw proberen" +msgstr "" + +msgid "Het uploaden is mislukt. Probeer het nog een keer." +msgstr "" + msgid "Niet gekoppeld" msgstr "" @@ -3784,9 +3799,6 @@ msgid "" "en probeer het opnieuw." msgstr "" -msgid "Opnieuw proberen" -msgstr "" - #, python-format msgid "Stap %(number)s van %(total)s" msgstr "" @@ -4780,6 +4792,24 @@ msgstr "" msgid "betekent dat er een bonnetje bij de uitgave zit." msgstr "" +msgid "Opnieuw" +msgstr "" + +msgid "Foto versturen" +msgstr "" + +msgid "Bedrag, zoals je het betaalde" +msgstr "" + +msgid "Meer regels of een omschrijving" +msgstr "" + +msgid "Uitgave opslaan" +msgstr "" + +msgid "Alleen de foto bewaren" +msgstr "" + msgid "Verwerken" msgstr "" From 6e637e461d31b4ba08021c6f025a83bc5292f3c4 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 15 Nov 2026 10:41:45 +0100 Subject: [PATCH 7/7] fix(expenses): the receipt on a new expense is no longer called optional A receipt is the proof of an expense. Saving without one still works. Co-Authored-By: Claude Opus 5.5 --- huismus/templates/expenses/form.html | 2 +- tests/expenses/test_views.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/huismus/templates/expenses/form.html b/huismus/templates/expenses/form.html index 8620bf6..042903b 100644 --- a/huismus/templates/expenses/form.html +++ b/huismus/templates/expenses/form.html @@ -93,7 +93,7 @@

{% translate "Dit bonnetje verw Bonnetjes section above the form, with its own upload.{% endcomment %} {% if new_receipt_form %}{% with field=new_receipt_form.file %}
-

{% translate "Bonnetje" %} ({% translate "optioneel" %})

+

{% translate "Bonnetje" %}