diff --git a/SPEC.md b/SPEC.md index b47ef50..22dd076 100644 --- a/SPEC.md +++ b/SPEC.md @@ -174,7 +174,15 @@ Added after first real use (2026-10-07): Added 2026-10-21: - any invoice or quote, in any status, can be copied into a new draft of the same kind: same customer, language, intro and footer text, and the lines as they are (VAT rate included). The copy gets no number, dates (including a quote's expiry date), notes or snapshots until it is issued or sent itself, and no `related_document` (it is not a correction; that stays a credit note). The original is not touched. Credit notes have no copy. - the PDF button opens a page with the PDF, a way back to the document, and Download (named after the document's number, `.pdf`, ready to attach to an e-mail); where the browser can share files there is also Share, and in the installed app only Share; for an imported invoice with an original PDF the page switches between the original and the regenerated one; the editor's preview PDF still opens in a new tab; in the installed app it opens over the editor, which keeps what was typed; -- on a phone every action stays reachable: the editor's secondary actions (delete, cancel, copy, PDF, preview PDF, mail) sit behind a "Meer" button in its action bar, the tab bar's + opens the same four choices as the sidebar's "Nieuw" (factuur, offerte, klant, uitgave), and with its "Meer" menu the tab bar offers everything else the sidebar does. `tests/e2e/test_every_page.py` checks both on every page. +- on a phone every action stays reachable: the editor's secondary actions (delete, cancel, copy, PDF, preview PDF, mail) sit behind a "Meer" button in its action bar, the tab bar's + opens four choices (factuur, offerte, klant, uitgave), and with its "Meer" menu the tab bar offers everything else the sidebar does. `tests/e2e/test_every_page.py` checks both on every page. +Added with the layout of direction "Vandaag" (issue #186, 2026-11-15; product-owner agent, `huismus-intern/besluiten.md`): +- on a wide screen the menu is a deep violet panel: the sparrow, "Je krijgt nog" (what customers still owe, and how much of it is overdue; `core.dashboard.outstanding_invoices`, the overview's figure, nothing before the first issued invoice), a button "Nieuwe factuur" straight to a new invoice, then Overzicht, Facturen, Offertes, Uitgaven, Klanten, Rapporten, Importeren, Instellingen; Hulp and Uitloggen at the foot. Cards have no border and round corners on a lilac background, buttons are pills, the font is the rounded system font where there is one (no web font); +- one violet button per screen: the panel's "Nieuwe factuur" and the phone's + only on the overview and the invoice list (not when they are empty); elsewhere the screen's own main action; +- the invoice list shows its rows in groups: Te laat, Wacht op betaling (with the days until due), Nog niet verstuurd, Betaald (fully credited ones too), Creditnota's; tabs, search, year and "Meer laden" stay. "Geïmporteerd" is quiet text, and only overdue has a colour; +- an overview without any invoice or credit note shows one card to make the first instead of the invoice figures; +- in the invoice editor on a phone the total stays in sight in the bar above the tab bar; +- notices are quiet blocks: their kind shows in a round icon, only a real problem is red; +- the cost bars in the year overview are yellow without an edge, like the other yellow bars; their amounts are in the table below (the owner, 2026-11-15). Out of scope: command palette with global search, live preview in settings. *Done when:* every screen matches the design reference on desktop and at 360px wide, in both themes; existing tests stay green; the PDF smoke test passes with the restyled template. @@ -315,7 +323,7 @@ Asked by the owner on 2026-11-06: with the KOR off, Huismus records exactly the - **Part 1, invoices: VAT per rate, stored.** A line keeps its rate and whether it is reverse charged, as before (M18). On issuing, an invoice or credit note stores per rate, reverse charge apart, its revenue and VAT exactly as on its PDF (`DocumentVatRow`, `huismus/documents/vat_snapshot.py`, amounts from `documents.totals.vat_rows`): computed per rate group, never per line (invariant 3), and never changed afterwards, also not when Huismus's code changes. "Toch bewerken" and issuing again stores them anew; "Annuleren" keeps the stored ones (a document reopened before they existed gets them from what it was issued with). A Moneybird import stores them when its stated totals are those of its lines, else none: Huismus doesn't guess a split (hard rule 6), and the VAT return names such documents apart. Documents issued before this got their rows once (migration `documents.0016`, approved by the owner); the documents themselves did not change. Nothing changes on screen or on the PDF. - **Part 2, expenses: a VAT rate per line** (`ExpenseLine.vat_rate`, `huismus/expenses/models.py` `VatRate`). "Btw-tarief": 21%, 9%, "0% of geen btw", "Btw verlegd: Nederland", "Btw verlegd: ander EU-land", "Btw verlegd: buiten de EU". Required without the KOR, with no preset choice ("Kies…", error "Kies het btw-tarief."); not on the form under the KOR, where a stored one stays. The VAT amount is always what the user enters, never computed; "0% of geen btw" with VAT above € 0 is refused ("Bij 0% of geen btw is het btw-bedrag € 0,00."), no other check. Without the KOR the field "btw ter info" is called "Btw", and the note under the lines says "Btw: zoals op het bonnetje. Staat er geen btw op, vul dan 0 in en kies 0% of geen btw." instead of "ter informatie" (once, not under every line). The AI connection (`add_expense`, `vat_rate`) and Bonnetjes lezen take the rate as on the receipt; without the KOR a missing or unknown one leaves the receipt in the tray ("Niet gelezen: het btw-tarief staat er niet bij."). Under the KOR they go through the same form, which has no rate: a rate they give is not kept, as when the user types. The Moneybird import takes 21, 9 and 0 when Moneybird's rate name says exactly that, and its "Binnen EU 21% (btw verlegd)" and "Buiten EU 21% (btw verlegd)" as reverse charge in another EU country and outside the EU; any other rate (an old 6%, or a rate without a name) stays empty and the dry run names it ("Btw-tarief onbekend"); an export without rate columns gives no message. Existing expenses keep no rate: none is guessed. A line without a rate never counts as input VAT. - **Part 3, input VAT** (product-owner agent 2026-11-07, `huismus-intern/besluiten.md`, "Voorbelasting op uitgaven: wanneer, verlegd, weergave en label"). With the KOR off, the year overview reads the costs per expense line (`huismus/reports/year_overview.py`): at 21, 9 or 0% costs = gross − VAT and the VAT is input VAT; reverse charged or without a rate, costs = gross. Its card "Kosten zonder btw" with "Voorbelasting € …" under it, a column "Voorbelasting" per quarter, "Kosten zonder btw per categorie", the CSV (columns "kosten zonder btw" and "voorbelasting"), the overview's "Kosten zonder btw" and the AI connection's `list_expenses` (`total`, `total_without_vat`, `input_vat`) follow; profit = revenue − costs without VAT. With the KOR on everything stays gross, as before, also for past years. Nothing stored changes (hard rule 7). The export's `uitgaveregels.csv` gets "btw-tarief" (the name as on the page) and calls the VAT column "btw" without the KOR, "btw ter info" with it; `uitgaven.csv` stays gross. Later: after turning the KOR off, past KOR years show input VAT for imported lines that have a rate; such a rate can be emptied on the expense. -- **Part 4, the VAT return** (product-owner agent 2026-11-07, `huismus-intern/besluiten.md`, "Btw-aangifterapport: plek, periode, opbouw en wat niet meetelt"; which box holds what: the owner, escalation list 1). Rapporten → Btw-aangifte (`/rapporten/btw-aangifte/`, `huismus/reports/vat_return.py`), with tabs "Jaaroverzicht | Btw-aangifte" above both reports; the menu still opens the year overview. A period is a quarter, month or year (`?periode=2026-Q3`, `2026-07`, `2026`, `huismus/reports/periods.py`); by default and for anything unknown or not yet begun, the last finished quarter; no step beyond the current one. It only reads. Sales: the stored rows (part 1) of invoices and credit notes with status issued and an invoice date in the period, a credit note negative: 21% → 1a, 9% → 1b, 0% → 1e, reverse charged by the country in the customer snapshot: Netherlands → 1e, another EU country → 3b, which counts in the period of the delivery date when the document has one and else of the invoice date, so it can come from a document invoiced in another period (issue #113) (EU list and box titles in `docs/belastingregels.md`, "Rubrieken in detail"). Purchases: expense lines by their expense's date: "Btw verlegd: Nederland" → 2a, "buiten de EU" → 4a, "ander EU-land" → 4b, each with the amount as value and the VAT the user entered; 5b is the VAT of lines at 21, 9 or 0% plus that reverse charged VAT ("waarvan verlegd"). 5a is the VAT of boxes 1 to 4; then "Te betalen" or "Terug te krijgen". Amounts in cents, not rounded. Box titles word for word from the Belastingdienst's explanation. Under "Niet meegeteld", with a warning at the top and a link per item: issued documents without rows (Moneybird's amounts), rows at another rate (6% before 2019), reverse charged to a customer outside the EU or without a country, documents with the KOR text, documents back in draft through "Toch bewerken", and expense lines without a rate or VAT. With the KOR on, the page shows only a notice with a link to the KOR settings and no figures (the owner, 2026-11-07): under the KOR the VAT on expenses counts nowhere (hard rule 7), and no expense line is read. The CSV and the AI connection: part 5. +- **Part 4, the VAT return** (product-owner agent 2026-11-07, `huismus-intern/besluiten.md`, "Btw-aangifterapport: plek, periode, opbouw en wat niet meetelt"; which box holds what: the owner, escalation list 1). Rapporten → Btw-aangifte (`/rapporten/btw-aangifte/`, `huismus/reports/vat_return.py`), with tabs "Jaaroverzicht | Btw-aangifte" above both reports; the menu still opens the year overview. A period is a quarter, month or year (`?periode=2026-Q3`, `2026-07`, `2026`, `huismus/reports/periods.py`); by default and for anything unknown or not yet begun, the last finished quarter; no step beyond the current one. It only reads. Sales: the stored rows (part 1) of invoices and credit notes with status issued and an invoice date in the period, a credit note negative: 21% → 1a, 9% → 1b, 0% → 1e, reverse charged by the country in the customer snapshot: Netherlands → 1e, another EU country → 3b, which counts in the period of the delivery date when the document has one and else of the invoice date, so it can come from a document invoiced in another period (issue #113) (EU list and box titles in `docs/belastingregels.md`, "Rubrieken in detail"). Purchases: expense lines by their expense's date: "Btw verlegd: Nederland" → 2a, "buiten de EU" → 4a, "ander EU-land" → 4b, each with the amount as value and the VAT the user entered; 5b is the VAT of lines at 21, 9 or 0% plus that reverse charged VAT ("waarvan verlegd"). 5a is the VAT of boxes 1 to 4; then "Te betalen" or "Terug te krijgen". Amounts in cents, not rounded. Box titles word for word from the Belastingdienst's explanation. Under "Niet meegeteld", with a warning at the top and a link per item: issued documents without rows (Moneybird's amounts), rows at another rate (6% before 2019), reverse charged to a customer outside the EU or without a country, documents with the KOR text, documents back in draft through "Toch bewerken", and expense lines without a rate or VAT. With the KOR on there is no return to fill in: the page shows the notice with a link to the KOR settings, and this calendar year's revenue per quarter ("—" for a quarter still to come) with the KOR limit and its bar, the year overview's figures (`compute_year_overview`, `kor_limit_status`); no period choice, no CSV button (the owner in #186, 2026-11-15, replacing "only a notice" of 2026-11-07). Under the KOR the VAT on expenses counts nowhere (hard rule 7), and no expense line is read. The CSV and the AI connection: part 5. - **Part 5, the VAT return as CSV and for the AI connection** (issue #112; product-owner agent 2026-11-07, `huismus-intern/besluiten.md`, "Btw-aangifterapport: CSV en AI-koppeling"). Both give the same boxes and the same "Niet meegeteld" as the page, from `compute_vat_return()`, and fall back to the same period. **CSV:** a button "CSV downloaden" on the page as on the year overview, `/rapporten/btw-aangifte/csv/?periode=…`, file `btw-aangifte-.csv` in the CSV form of M19 (`huismus/reports/vat_return_csv.py`). Columns `periode;rubriek;omschrijving;nummer;datum;omzet;btw;bedrag`, headings and texts in the user's language: the period on every row; the seven boxes with their titles, also at 0,00; 5a and 5b with the amount under `btw`; "waarvan verlegd" on a row of its own without a box code when it isn't zero; one row "Te betalen" or "Terug te krijgen" without a sign. Then a row per item under "Niet meegeteld" with `rubriek` "niet meegeteld" and the heading of its card on the page, the rate or country after it ("…: 6%", "…: US", "…: land onbekend"); documents with number, invoice date, revenue and VAT as on the page (no VAT for the KOR text, no amounts for "Terug in concept"); an expense line with its expense's date, supplier and line description in `omschrijving` and its gross under `bedrag`. With the KOR on there is no button and the address leads back to the page. **AI connection:** a read tool `get_vat_return` ("Btw-aangifte bekijken", argument `period`), with the period used, per box code, title, revenue and VAT, `5a`, `5b`, `5b_reverse_charged` when not zero, `to_pay` or `to_get_back`, the first and last day of the period, and `not_counted` per kind with its heading and items (documents with their `id` for `get_document`, expense lines with `expense_id`). Its description tells the assistant to pass the boxes on as they are, always to name `not_counted`, and that Huismus files nothing. With the KOR on only `kor` and the page's notice, no figures. No PDF: the page can be printed. ## 7. Moneybird import (M5) diff --git a/docs/design/componenten.html b/docs/design/componenten.html index af399a7..abaf684 100644 --- a/docs/design/componenten.html +++ b/docs/design/componenten.html @@ -56,6 +56,13 @@

Accent: snavelgeel (nooit
--accent-soft
hints, import
--accent-ink
tekst op snavelgeel
--mark-wing
vleugel van de mus
+
--panel
het menu op een breed scherm
+
--panel-text
tekst en mus op het menu
+
--panel-muted
gedempte tekst op het menu
+
--panel-wing
vleugel van de mus op het menu
+
--panel-hover
menu-item onder de muis
+
--panel-current
gekozen menu-item
+
--panel-line
lijn op het menu

Status

@@ -88,7 +95,7 @@

Letters, ruimte, vormen

--fs-sm
13, labels en bijtekst
Vervaldatum
--fs-xs
12
Verloopt over 3 dagen
--lh, --lh-tight
1,5 en 1,2
-
--fw-medium, --fw-semibold, --fw-bold
550, 620, 700
Aa Aa Aa
+
--fw-medium, --fw-semibold, --fw-bold, --fw-heavy
550, 620, 700, 800
Aa Aa Aa Aa
--s-1 … --s-16
4, 8, 12, 16, 20, 24, 32, 40, 48, 64 (--s-2 --s-3 --s-4 --s-5 --s-6 --s-8 --s-10 --s-12)
--r-sm --r-md --r-lg --r-xl --r-pill
6, 10, 14, 20, rond
--sh-1 --sh-2 --sh-paper --sh-pop
kaart, zwevend, vel papier, dialoog
diff --git a/huismus/config/settings.py b/huismus/config/settings.py index 0c102dc..9a6cdf4 100644 --- a/huismus/config/settings.py +++ b/huismus/config/settings.py @@ -108,6 +108,7 @@ "huismus.core.context_processors.desktop", "huismus.core.context_processors.sample_data", "huismus.core.context_processors.theme", + "huismus.core.context_processors.panel", ], }, }, diff --git a/huismus/core/context_processors.py b/huismus/core/context_processors.py index d0ee525..0b61264 100644 --- a/huismus/core/context_processors.py +++ b/huismus/core/context_processors.py @@ -4,9 +4,11 @@ and whether the desktop app signed the window in without a password.""" from django.conf import settings +from django.utils.functional import SimpleLazyObject from huismus.core import auto_backups from huismus.core.appearance import theme_of +from huismus.core.dashboard import outstanding_invoices from huismus.core.desktop import has_no_password # Expense routes that have their own item in the sidebar's sub-navigation. @@ -58,3 +60,12 @@ def theme(request): if user is None or not user.is_authenticated: return {"theme": ""} return {"theme": theme_of(user)} + + +def panel(request): + """panel_outstanding: what the menu panel shows under "Je krijgt nog" + (huismus/core/dashboard.py). Lazy, so a response that doesn't draw the + menu (an HTMX fragment, a PDF) runs no query for it.""" + if not getattr(request, "user", None) or not request.user.is_authenticated: + return {} + return {"panel_outstanding": SimpleLazyObject(outstanding_invoices)} diff --git a/huismus/core/dashboard.py b/huismus/core/dashboard.py index 6ed2e31..3f9217f 100644 --- a/huismus/core/dashboard.py +++ b/huismus/core/dashboard.py @@ -4,6 +4,7 @@ payment state and outstanding amounts come from Document's own with_payment_totals(), revenue and costs from huismus.reports.year_overview.""" +from django.db.models import F, Q from django.urls import reverse from django.utils.translation import gettext_lazy as _ @@ -15,13 +16,28 @@ def outstanding_invoices(): """Issued invoices the customer still owes money on: how many, the - total still open, and how many of them are overdue.""" - invoices = Document.objects.filter(kind="invoice", status="issued").with_payment_totals() + total still open, how many of them are overdue and how much of the + total that is. has_issued: whether there is any issued invoice at all. + + The menu shows this on every page, so the query leaves out invoices + that are settled (payments plus credit notes reach the total). The + second clause keeps an invoice of € 0 with nothing paid, which + payment_state calls "unpaid". The query only narrows: which invoices + are open is still decided by Document.payment_state, and a test checks + that the filter leaves out none of them.""" + issued = Document.objects.filter(kind="invoice", status="issued") + invoices = issued.with_payment_totals().filter( + Q(total_cents__gt=F("paid_cents") + F("credited_cents")) + | Q(paid_cents__lte=0, credited_cents__lte=0) + ) open_invoices = [d for d in invoices if d.payment_state in ("unpaid", "partial")] + overdue = [d for d in open_invoices if d.is_overdue] return { "count": len(open_invoices), "total_cents": sum(d.outstanding_cents for d in open_invoices), - "overdue_count": sum(1 for d in open_invoices if d.is_overdue), + "overdue_count": len(overdue), + "overdue_cents": sum(d.outstanding_cents for d in overdue), + "has_issued": bool(open_invoices) or issued.exists(), } diff --git a/huismus/core/static/core/app.js b/huismus/core/static/core/app.js index 4e7c14c..b721535 100644 --- a/huismus/core/static/core/app.js +++ b/huismus/core/static/core/app.js @@ -271,7 +271,8 @@ document.addEventListener("keydown", (event) => { if (url) { window.location.assign(url); } else { - document.getElementById("nieuw-menu")?.showPopover?.(); + // The four choices of the phone's +: the menu panel itself has only "Nieuwe factuur". + document.getElementById("plus-menu")?.showPopover?.(); } } }); diff --git a/huismus/core/static/core/huismus.css b/huismus/core/static/core/huismus.css index 36167a0..ae9029a 100644 --- a/huismus/core/static/core/huismus.css +++ b/huismus/core/static/core/huismus.css @@ -10,21 +10,23 @@ :root { color-scheme: light dark; - /* Typografie: systeemfontstack (offline, geen hosting nodig) */ - --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif; + /* Typografie: de ronde systeemletter waar die er is, anders de gewone + (offline, geen webfont) */ + --font-sans: ui-rounded, "SF Pro Rounded", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif; --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace; --fs-xs: 0.75rem; /* 12 */ --fs-sm: 0.8125rem; /* 13 */ - --fs-md: 0.9375rem; /* 15: basis */ + --fs-md: 1rem; /* 16: basis */ --fs-lg: 1.0625rem; /* 17 */ --fs-xl: 1.375rem; /* 22 */ - --fs-2xl: 1.75rem; /* 28 */ + --fs-2xl: 1.875rem; /* 30 */ --fs-3xl: 2.25rem; /* 36 */ --lh-tight: 1.2; --lh: 1.5; --fw-medium: 550; --fw-semibold: 620; --fw-bold: 700; + --fw-heavy: 800; /* Spacing (4px-raster) */ --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; @@ -58,6 +60,15 @@ --accent-ink: light-dark(#855000, #FFC766); --mark-wing: light-dark(#A98BF5, #CBB8FA); /* vleugel van de mus: lichter dan het lijf */ + /* Het diepviolette menu op een breed scherm */ + --panel: light-dark(#2A1670, #2F1D80); + --panel-text: light-dark(#FFFFFF, #FFFFFF); + --panel-muted: light-dark(#CFC4F2, #CFC4F2); + --panel-wing: light-dark(#CBB8FA, #CBB8FA); + --panel-hover: rgb(255 255 255 / .10); + --panel-current: rgb(255 255 255 / .16); + --panel-line: rgb(255 255 255 / .18); + /* Status */ --ok: light-dark(#1E7A45, #7AD6A0); --ok-bg: light-dark(#E2F3E8, #1D3326); --warn: light-dark(#855000, #FFC766); --warn-bg: light-dark(#FDF0D5, #33270F); @@ -76,11 +87,13 @@ --overlay: rgb(15 11 30 / .42); /* Maten */ - --sidebar-w: 248px; + --sidebar-w: 288px; --content-max: 1120px; --control-h: 40px; --ease: cubic-bezier(.2, .7, .2, 1); } +/* Op een middelbreed scherm (een laptop van 1024) houdt de inhoud genoeg ruimte. */ +@media (max-width: 1200px) { :root { --sidebar-w: 248px; } } :root[data-theme="dark"] { color-scheme: dark; } :root[data-theme="light"] { color-scheme: light; } @@ -93,7 +106,7 @@ body { -webkit-font-smoothing: antialiased; } h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-semibold); letter-spacing: -0.015em; text-wrap: balance; } -h1 { font-size: var(--fs-2xl); letter-spacing: -0.022em; } +h1 { font-size: var(--fs-2xl); font-weight: var(--fw-heavy); letter-spacing: -0.022em; } h2 { font-size: var(--fs-lg); } h3 { font-size: var(--fs-md); } p { margin: 0; text-wrap: pretty; } @@ -148,34 +161,48 @@ a:hover { color: var(--primary-hover); } .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-4); - padding: var(--s-5) var(--s-3); background: var(--surface); border-right: 1px solid var(--border); + padding: var(--s-6) var(--s-5); background: var(--panel); color: var(--panel-text); + /* De mus in wit op het vlak, met een lichte vleugel en het oog in de kleur van het vlak */ + --mark-body: var(--panel-text); --mark-wing-fill: var(--panel-wing); --mark-eye: var(--panel); } +.sidebar :focus-visible { outline-color: var(--panel-text); } .sidebar > * { flex-shrink: 0; } -.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px; color: var(--text); text-decoration: none; font-weight: var(--fw-bold); font-size: 1.1875rem; letter-spacing: -0.02em; } -.brand:hover { color: var(--text); } +.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px; color: inherit; text-decoration: none; font-weight: var(--fw-bold); font-size: 1.1875rem; letter-spacing: -0.02em; } +.brand:hover { color: inherit; } .nav { display: flex; flex-direction: column; gap: 2px; } .nav a { - display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 10px; border-radius: var(--r-md); - color: var(--text-muted); text-decoration: none; font-weight: var(--fw-medium); font-size: 0.90625rem; + display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill); + color: var(--panel-text); text-decoration: none; font-weight: var(--fw-medium); font-size: 0.90625rem; transition: background .15s, color .15s; } -.nav a:hover { background: var(--surface-2); color: var(--text); } -.nav a[aria-current="page"], .nav a.is-active { background: var(--primary-soft); color: var(--primary-ink); font-weight: var(--fw-semibold); } +.nav a:hover { background: var(--panel-hover); color: var(--panel-text); } +.nav a[aria-current="page"], .nav a.is-active { background: var(--panel-current); color: var(--panel-text); font-weight: var(--fw-semibold); } .nav .sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px; } .nav .sub a { min-height: 32px; padding-left: 39px; font-size: var(--fs-sm); } -.nav .sub a[aria-current="page"] { background: none; color: var(--primary-ink); } +.nav .sub a { padding-left: 43px; } +.nav .sub a[aria-current="page"] { background: none; color: var(--panel-text); text-decoration: underline; text-underline-offset: 4px; } .sidebar-search { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--bg); color: var(--text-muted); font: inherit; font-size: var(--fs-sm); cursor: pointer; width: 100%; } .sidebar-search .kbd { margin-left: auto; } -.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: var(--s-3); border-top: 1px solid var(--border); } +.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: var(--s-3); border-top: 1px solid var(--panel-line); } .sidebar-foot .nav a { min-height: 34px; font-size: var(--fs-sm); } .lang { display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); } .lang button { height: 26px; min-width: 34px; padding: 0 8px; border: 0; border-radius: 6px; background: none; font: 600 12px/1 var(--font-sans); color: var(--text-muted); cursor: pointer; } .lang button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); } .btn-new { anchor-name: --nieuw; } -#nieuw-menu { position-anchor: --nieuw; inset: auto; top: anchor(bottom); left: anchor(left); width: anchor-size(width); margin-top: 6px; } +/* Op het vlak: wit als het de hoofdactie van de pagina is, anders alleen een omlijning */ +.sidebar .btn-primary { --btn-bg: var(--panel-text); --btn-fg: var(--panel); } +.sidebar .btn-primary:hover { background: color-mix(in oklab, var(--panel-text) 88%, var(--panel)); } +.sidebar .btn-quiet { --btn-bg: transparent; --btn-fg: var(--panel-text); --btn-bd: var(--panel-line); } +.sidebar .btn-quiet:hover { background: var(--panel-hover); } +/* "Je krijgt nog" bovenin het vlak */ +.panel-owed { display: flex; flex-direction: column; gap: 2px; padding: var(--s-3) 10px var(--s-2); color: inherit; text-decoration: none; border-radius: var(--r-lg); } +.panel-owed:hover { color: inherit; background: var(--panel-hover); } +.panel-owed-label, .panel-owed-sub { color: var(--panel-muted); font-size: var(--fs-sm); } +.panel-owed-amount { font-size: 2rem; font-weight: var(--fw-heavy); letter-spacing: -0.025em; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; } +.panel-owed-sub:empty { display: none; } #plus-menu { inset: auto 0 calc(72px + env(safe-area-inset-bottom)); margin: 0 auto; } #meer-menu { inset: auto 12px calc(72px + env(safe-area-inset-bottom)) auto; max-height: calc(100dvh - 140px); overflow-y: auto; } @@ -200,12 +227,12 @@ a:hover { color: var(--primary-hover); } .sidebar { display: none; } .content { padding: var(--s-5) var(--s-4) 112px; } .app-footer { padding: var(--s-4) var(--s-4) 96px; } - h1 { font-size: var(--fs-xl); } + h1 { font-size: 1.625rem; } .main { padding-top: 56px; } .mtop { display: flex; align-items: center; gap: 10px; position: fixed; top: 0; left: 0; right: 0; z-index: 20; - height: 56px; padding: 0 var(--s-4); background: color-mix(in oklab, var(--surface) 90%, transparent); - backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); + height: 56px; padding: 0 var(--s-4); background: color-mix(in oklab, var(--bg) 90%, transparent); + backdrop-filter: blur(10px); } .mtop .brand { padding: 0; font-size: var(--fs-lg); } .mtop .spacer { flex: 1; } @@ -219,7 +246,9 @@ a:hover { color: var(--primary-hover); } font-size: 11px; font-weight: var(--fw-medium); color: var(--text-muted); text-decoration: none; border-radius: var(--r-md); } .tabbar a[aria-current="page"], .tabbar button[aria-current="page"] { color: var(--primary-ink); } - .tabbar .fab { justify-self: center; align-self: center; width: 48px; height: 48px; min-height: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); box-shadow: var(--sh-2); } + .tabbar .fab { justify-self: center; align-self: center; width: 52px; height: 52px; min-height: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); box-shadow: var(--sh-2); } + /* Alleen violet waar een factuur maken de hoofdactie is; anders wit met een omlijning */ + .tabbar .fab-quiet { background: var(--surface); color: var(--primary-ink); box-shadow: inset 0 0 0 1px var(--border-strong); } .page-head { align-items: flex-start; } .page-head .actions { width: 100%; } .page-head .actions .btn-primary { flex: 1 1 100%; order: -1; } @@ -235,9 +264,9 @@ a:hover { color: var(--primary-hover); } .btn { --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; - height: var(--control-h); padding: 0 16px; border-radius: var(--r-md); + height: var(--control-h); padding: 0 18px; border-radius: var(--r-pill); background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd); - font: var(--fw-semibold) var(--fs-sm)/1 var(--font-sans); letter-spacing: .005em; white-space: nowrap; + font: var(--fw-semibold) 0.9375rem/1 var(--font-sans); letter-spacing: .005em; white-space: nowrap; text-decoration: none; cursor: pointer; user-select: none; transition: background .15s, border-color .15s, transform .08s, box-shadow .15s; } @@ -254,8 +283,8 @@ a:hover { color: var(--primary-hover); } .btn-danger:focus-visible { box-shadow: 0 0 0 3px var(--danger-ring); } .btn-danger-quiet { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--danger); } .btn-danger-quiet:hover { background: var(--bad-bg); } -.btn-sm { height: 32px; padding: 0 12px; border-radius: 8px; } -.btn-lg { height: 48px; padding: 0 22px; font-size: var(--fs-md); border-radius: 12px; } +.btn-sm { height: 32px; padding: 0 14px; } +.btn-lg { height: 48px; padding: 0 24px; font-size: var(--fs-md); } .btn-icon { width: var(--control-h); padding: 0; } .btn-sm.btn-icon { width: 32px; } .btn-block { width: 100%; } @@ -290,7 +319,7 @@ a:hover { color: var(--primary-hover); } .input, .select, .textarea { width: 100%; height: var(--control-h); padding: 0 12px; font: inherit; font-size: var(--fs-md); color: var(--text); - background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); + background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); transition: border-color .15s, box-shadow .15s, background .15s; } /* Pseudo-elementen lossen light-dark() niet overal op. currentColor is hier de tekstkleur van het veld, @@ -307,7 +336,7 @@ a:hover { color: var(--primary-hover); } background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8075' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; } -.input-sm { height: 34px; font-size: var(--fs-sm); padding: 0 10px; border-radius: 8px; } +.input-sm { height: 34px; font-size: var(--fs-sm); padding: 0 12px; border-radius: var(--r-md); } .select.input-sm { padding-right: 30px; background-position: right 8px center; } .money { position: relative; } .money::before { content: "€"; position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--text-muted); pointer-events: none; font-size: var(--fs-sm); } @@ -365,11 +394,15 @@ a:hover { color: var(--primary-hover); } .combo-list .muted { font-size: var(--fs-sm); } /* ---------- 6. Kaarten, tabellen, lijsten ---------- */ -.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); min-width: 0; } +/* Blokken zonder rand, met ronde hoeken, op de lila achtergrond */ +.card { background: var(--surface); border: 0; border-radius: var(--r-xl); min-width: 0; } .card-pad { padding: var(--s-5) var(--s-6); } .card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); } .card-head h2 { font-size: var(--fs-md); } .card-foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); font-size: var(--fs-sm); } +/* Een kopje per groep in een lijst (Te laat, Wacht op betaling, ...) */ +.list-group-title { padding: var(--s-5) var(--s-5) var(--s-2); font-size: var(--fs-md); font-weight: var(--fw-bold); } +.imported { display: block; } .section-title { font-size: var(--fs-lg); margin-bottom: var(--s-3); } .divider { height: 1px; background: var(--border); border: 0; margin: var(--s-6) 0; } @@ -379,6 +412,11 @@ a:hover { color: var(--primary-hover); } .table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); } .table th { text-align: left; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; } .table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; } +/* Op de telefoon: een tabel met bedragen naast elkaar (zoals het jaaroverzicht) krijgt + kleinere letters en minder ruimte, zodat er meer kolommen in beeld passen. */ +@media (max-width: 760px) { + .table:not(.stackable) th, .table:not(.stackable) td { padding: 10px 8px; font-size: var(--fs-sm); } +} .table tbody tr:last-child td { border-bottom: 0; } .table .r { text-align: right; } .table .amount, .table .num { font-variant-numeric: tabular-nums; } @@ -453,7 +491,8 @@ a:hover { color: var(--primary-hover); } /* Alleen wat om actie vraagt krijgt een vlak: te laat, deels betaald, nakijken. De rest is rustig (huismus-intern/besluiten.md, 2026-10-30 en 2026-11-15). */ .pill-overdue { --pill-bg: var(--bad-bg); --pill-fg: var(--bad); } -.pill-partial, .pill-check { --pill-bg: var(--warn-bg); --pill-fg: var(--warn); } +.pill-check { --pill-bg: var(--warn-bg); --pill-fg: var(--warn); } +.pill-partial { --pill-bg: transparent; --pill-fg: var(--text); padding-inline: 0; font-weight: var(--fw-medium); } /* loopt nog: alleen "te laat" krijgt kleur */ .pill-partial::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px currentColor; } .pill-import { --pill-bg: var(--accent-soft); --pill-fg: var(--accent-ink); } .pill-credit { --pill-bg: var(--surface-2); --pill-fg: var(--text); box-shadow: inset 0 0 0 1px var(--border); } @@ -634,11 +673,19 @@ a:hover { color: var(--primary-hover); } } .actionbar .status { display: flex; align-items: center; gap: 8px; margin-right: auto; font-size: var(--fs-sm); color: var(--text-muted); } .actionbar .dot-unsaved { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); } +/* Het totaal in de balk: alleen op de telefoon, daar staat het rijtje totalen vaak buiten beeld. */ +.actionbar-total { display: none; } @media (max-width: 760px) { - .actionbar { bottom: calc(62px + env(safe-area-inset-bottom)); padding: 10px var(--s-4); } + .actionbar { bottom: calc(65px + env(safe-area-inset-bottom)); padding: 10px var(--s-4); } .actionbar { flex-wrap: nowrap; } .actionbar .status { display: none; } .actionbar .btn { flex: 1; padding: 0 10px; } + /* Factuur maken: het totaal boven de knoppen, de balk boven de tabbalk. */ + .actionbar-editor { flex-wrap: wrap; } + /* Wat de focus krijgt (ook met Tab), schuift boven de balk en de tabbalk. */ + html:has(.actionbar-editor) { scroll-padding-bottom: 190px; } + .actionbar-total { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); flex-basis: 100%; } + .actionbar-total strong { font-size: var(--fs-lg); font-weight: var(--fw-heavy); } } /* Extra actions in the editor's bar. On a wide screen the popover's own box is dissolved (display: contents), so its buttons sit in the bar; on a @@ -701,30 +748,29 @@ a:hover { color: var(--primary-hover); } /* ---------- 13. Dashboard & jaaroverzicht ---------- */ .kpi { padding: var(--s-5) var(--s-6); display: flex; flex-direction: column; gap: 6px; } .kpi-label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-medium); display: flex; align-items: center; gap: 8px; } -.kpi-value { white-space: nowrap; font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1.15; } +.kpi-value { white-space: nowrap; font-size: var(--fs-2xl); font-weight: var(--fw-heavy); letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1.15; } .kpi-sub { font-size: var(--fs-sm); color: var(--text-muted); } .kpi-hero { background: var(--primary); color: var(--on-primary); border-color: transparent; } .kpi-hero .kpi-label, .kpi-hero .kpi-sub { color: color-mix(in oklab, var(--on-primary) 82%, var(--primary)); } .kpi-hero a { color: var(--on-primary); } -/* A notice is a quiet card: colour only in the stripe, the icon and the link on the - right, so a reminder doesn't shout like a problem (huismus-intern/besluiten.md, 2026-10-30). */ +/* A notice is a quiet block like the other cards: no border, no stripe. Its kind + shows only in the round icon; the link is violet, and red only for a real + problem (huismus-intern/besluiten.md, 2026-10-30; the owner, 2026-11-15). */ .hint-banner { - --hb-line: var(--accent); --hb-ink: var(--accent-ink); - display: flex; align-items: center; gap: var(--s-3); padding: 12px var(--s-4); - border-radius: var(--r-md); background: var(--surface); color: var(--text); - border: 1px solid var(--border); box-shadow: inset 3px 0 0 var(--hb-line), var(--sh-1); - font-weight: var(--fw-medium); text-decoration: none; + --hb-ink: var(--accent-ink); --hb-chip: var(--accent-soft); --hb-link: var(--primary-ink); + display: flex; align-items: center; gap: var(--s-3); padding: 12px var(--s-5) 12px var(--s-3); + border-radius: var(--r-xl); background: var(--surface); color: var(--text); + border: 0; font-weight: var(--fw-medium); text-decoration: none; + transition: background .15s; } -.hint-banner:hover { color: var(--text); border-color: var(--border-strong); } -.hint-banner > .i { color: var(--hb-ink); flex: none; } +a.hint-banner:hover { color: var(--text); background: color-mix(in oklab, var(--surface) 92%, var(--primary)); } +.hint-banner > .i { box-sizing: content-box; width: 18px; height: 18px; padding: 8px; border-radius: 50%; color: var(--hb-ink); background: var(--hb-chip); flex: none; } .hint-banner .spacer { flex: 1; } -.hint-banner .spacer + span, .hint-banner a { color: var(--hb-ink); font-weight: var(--fw-semibold); } -.hint-banner.is-warn { --hb-line: var(--warn); --hb-ink: var(--warn); } -.hint-banner.is-bad { --hb-line: var(--bad); --hb-ink: var(--bad); } +.hint-banner .spacer + span, .hint-banner a { color: var(--hb-link); font-weight: var(--fw-semibold); } +.hint-banner.is-warn { --hb-ink: var(--warn); --hb-chip: var(--warn-bg); } +.hint-banner.is-bad { --hb-ink: var(--bad); --hb-chip: var(--bad-bg); --hb-link: var(--bad); } /* Information that isn't a task, like a new version (desktop app). */ -.hint-banner.is-info { --hb-line: var(--primary); --hb-ink: var(--primary-ink); } -/* A notice with a close button ("Huismus is bijgewerkt") is a div, not a link. */ -div.hint-banner:hover { border-color: var(--border); } +.hint-banner.is-info { --hb-ink: var(--primary-ink); --hb-chip: var(--primary-soft); } .hint-banner > form { display: flex; margin: -6px calc(-1 * var(--s-2)) -6px 0; } .checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; } @@ -741,6 +787,7 @@ div.hint-banner:hover { border-color: var(--border); } .chart-col { display: grid; grid-template-rows: 1fr 28px; background-image: linear-gradient(var(--border) 1px, transparent 1px); background-size: 100% calc((100% - 28px) / 4); } .chart-bars { display: flex; align-items: flex-end; justify-content: center; gap: 6px; border-bottom: 1.5px solid var(--border-strong); } .chart-bar { width: min(34%, 38px); height: calc(var(--v) * 1%); border-radius: 6px 6px 2px 2px; background: var(--primary); position: relative; transition: height .4s var(--ease); } +/* Geel zonder rand, zoals de andere gele balken; de bedragen staan in de tabel eronder (de eigenaar, 2026-11-15). */ .chart-bar.is-cost { background: var(--accent); } .chart-bar.is-empty { height: 2px; background: var(--border-strong); } .chart-label { display: grid; place-items: center; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); } @@ -932,12 +979,12 @@ div.hint-banner:hover { border-color: var(--border); } /* Uitloggen is een POST-formulier (Django's LogoutView), geen link: de knop krijgt dezelfde vorm als de navigatielinks. */ .nav .nav-button { - display: flex; align-items: center; gap: 11px; width: 100%; min-height: 34px; padding: 0 10px; - border: 0; border-radius: var(--r-md); background: none; cursor: pointer; - color: var(--text-muted); font: inherit; font-weight: var(--fw-medium); font-size: var(--fs-sm); text-align: left; + display: flex; align-items: center; gap: 11px; width: 100%; min-height: 34px; padding: 0 14px; + border: 0; border-radius: var(--r-pill); background: none; cursor: pointer; + color: var(--panel-text); font: inherit; font-weight: var(--fw-medium); font-size: var(--fs-sm); text-align: left; transition: background .15s, color .15s; } -.nav .nav-button:hover { background: var(--surface-2); color: var(--text); } +.nav .nav-button:hover { background: var(--panel-hover); color: var(--panel-text); } /* Taalwissel onder de inlogkaart: .login is een grid met place-items:center, dus de kaart en de wissel staan onder elkaar gecentreerd. */ @@ -945,7 +992,7 @@ div.hint-banner:hover { border-color: var(--border); } /* Betaalstatus "Gecrediteerd": creditnota's dekken het hele factuurbedrag. Zelfde uiterlijk als de creditnota-pil, zonder stip. */ -.pill-credited { --pill-bg: var(--surface-2); --pill-fg: var(--text); box-shadow: inset 0 0 0 1px var(--border); } +.pill-credited { --pill-bg: transparent; --pill-fg: var(--text-muted); padding-inline: 0; font-weight: var(--fw-medium); } .pill-credited::before { display: none; } /* {% field ... suffix="dagen" %}: eenheid rechts in het invoerveld @@ -1012,10 +1059,10 @@ div.hint-banner:hover { border-color: var(--border); } @media (max-width: 760px) { .hint-banner { flex-wrap: wrap; align-items: flex-start; } .hint-banner .spacer { display: none; } - .hint-banner > .spacer ~ span:not(.spacer) { flex-basis: 100%; padding-left: calc(18px + var(--s-3)); } + .hint-banner > .spacer ~ span:not(.spacer) { flex-basis: 100%; padding-left: calc(34px + var(--s-3)); } .hint-banner > .i + span { flex: 1 1 0; min-width: 0; } /* The close button stays beside the first line, the link goes below. */ - .hint-banner > .spacer ~ a { order: 1; flex-basis: 100%; padding-left: calc(18px + var(--s-3)); } + .hint-banner > .spacer ~ a { order: 1; flex-basis: 100%; padding-left: calc(34px + var(--s-3)); } } /* Grote schermen: het ontwerp is gemaakt voor een laptop (± 1440 px). Daarboven diff --git a/huismus/core/views.py b/huismus/core/views.py index 6f65c69..7b41889 100644 --- a/huismus/core/views.py +++ b/huismus/core/views.py @@ -105,6 +105,9 @@ def home(request): "core/home.html", { "first_time": False, + # No invoice or credit note in any status yet: one card to make the + # first, in place of the invoice figures (#186). + "has_invoices": Document.objects.filter(kind__in=["invoice", "credit_note"]).exists(), "greeting": _greeting(now), "today": today, "outstanding": outstanding_invoices(), diff --git a/huismus/documents/listing.py b/huismus/documents/listing.py index dd0aa8b..e242f2c 100644 --- a/huismus/documents/listing.py +++ b/huismus/documents/listing.py @@ -8,7 +8,9 @@ of a second, SQL version of the same rule. """ +from django.utils.text import capfirst, format_lazy from django.utils.translation import gettext_lazy as _ +from django.utils.translation import ngettext # (slug in the URL, label). The first one is the default. INVOICE_TABS = [ @@ -20,6 +22,58 @@ ] +# The groups of the invoice list, in the order they show (#186). +INVOICE_GROUPS = { + "te-laat": _("Te laat"), + "wacht": _("Wacht op betaling"), + "concept": _("Nog niet verstuurd"), + "betaald": _("Betaald"), + "creditnotas": _("Creditnota's"), +} + + +def invoice_group(document): + """Which group of the invoice list a document belongs to. Drafts of + either kind are "not sent yet"; fully credited invoices count as paid, + like the tab Betaald.""" + if document.status == "draft": + return "concept" + if document.kind == "credit_note": + return "creditnotas" + if document.is_overdue: + return "te-laat" + if document.payment_state in ("unpaid", "partial"): + return "wacht" + return "betaald" + + +def grouped(documents): + """The documents with .group set, sorted by group in INVOICE_GROUPS + order. Within a group they keep the order they came in, so "Meer + laden" continues a group instead of starting its heading again.""" + order = list(INVOICE_GROUPS) + for document in documents: + document.group = invoice_group(document) + return sorted(documents, key=lambda d: order.index(d.group)) + + +def waiting_label(document, today): + """The status of an invoice in the group "Wacht op betaling": how long + until it is due, "Deels betaald" in front if part is paid. Without a due + date only the payment state.""" + partial = document.payment_state == "partial" + if document.due_date is None: + return _("Deels betaald") if partial else _("Onbetaald") + days = (document.due_date - today).days + if days == 0: + when = _("vandaag te betalen") + else: + when = ngettext("nog %(days)s dag", "nog %(days)s dagen", days) % {"days": days} + if partial: + return format_lazy("{}, {}", _("Deels betaald"), when) + return capfirst(when) + + def in_tab(document, tab): if tab == "concepten": return document.status == "draft" diff --git a/huismus/documents/templatetags/documents_tags.py b/huismus/documents/templatetags/documents_tags.py index f74a9cb..3204bc8 100644 --- a/huismus/documents/templatetags/documents_tags.py +++ b/huismus/documents/templatetags/documents_tags.py @@ -1,6 +1,7 @@ # SPDX-FileCopyrightText: 2026 Huismus contributors # SPDX-License-Identifier: AGPL-3.0-or-later from django import template +from django.utils import timezone from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ @@ -115,3 +116,9 @@ def subtract(cents, other_cents): """cents − other_cents, for amounts that are a plain difference of two stored values ("Nog te crediteren" = invoice total − credited).""" return (cents or 0) - (other_cents or 0) + + +@register.filter +def waiting_label(document): + """listing.waiting_label for today.""" + return listing.waiting_label(document, timezone.localdate()) diff --git a/huismus/documents/views.py b/huismus/documents/views.py index e3fb3b9..691609e 100644 --- a/huismus/documents/views.py +++ b/huismus/documents/views.py @@ -36,9 +36,11 @@ ) from .issuing import IssueError, issue from .listing import ( + INVOICE_GROUPS, INVOICE_TABS, QUOTE_TABS, expiry_hint, + grouped, in_quote_tab, in_tab, matches_search, @@ -101,7 +103,7 @@ def document_list(request): ) found = [d for d in invoices if matches_search(d, query)] - rows = [d for d in found if in_tab(d, tab)] + rows = grouped([d for d in found if in_tab(d, tab)]) def list_url(**changes): params = {"tab": tab, "q": query, "jaar": year or "alle", **changes} @@ -129,6 +131,7 @@ def list_url(**changes): "year": year, "years": years, "has_any": Document.objects.filter(kind__in=["invoice", "credit_note"]).exists(), + "group_titles": INVOICE_GROUPS, }, ) diff --git a/huismus/locale/en/LC_MESSAGES/django.po b/huismus/locale/en/LC_MESSAGES/django.po index ba96264..f64fde9 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:39+0100\n" +"POT-Creation-Date: 2026-11-15 10:33+0100\n" "PO-Revision-Date: 2026-09-25 08:36+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -1652,6 +1652,30 @@ msgstr "Paid" msgid "Creditnota's" msgstr "Credit notes" +msgid "Te laat" +msgstr "Overdue" + +msgid "Wacht op betaling" +msgstr "Waiting for payment" + +msgid "Nog niet verstuurd" +msgstr "Not sent yet" + +msgid "Deels betaald" +msgstr "Partly paid" + +msgid "Onbetaald" +msgstr "Unpaid" + +msgid "vandaag te betalen" +msgstr "due today" + +#, python-format +msgid "nog %(days)s dag" +msgid_plural "nog %(days)s dagen" +msgstr[0] "%(days)s day left" +msgstr[1] "%(days)s days left" + msgid "Wachten op antwoord" msgstr "Awaiting reply" @@ -2849,6 +2873,18 @@ msgstr "costs" msgid "%(quarter)se kwartaal %(year)s" msgstr "Q%(quarter)s %(year)s" +msgid "jan–mrt" +msgstr "Jan–Mar" + +msgid "apr–jun" +msgstr "Apr–Jun" + +msgid "jul–sep" +msgstr "Jul–Sep" + +msgid "okt–dec" +msgstr "Oct–Dec" + msgid "Kwartaal" msgstr "Quarter" @@ -2870,8 +2906,18 @@ msgstr "No category" msgid "Navigatie" msgstr "Navigation" -msgid "Nieuw" -msgstr "New" +msgid "Je krijgt nog" +msgstr "Still to receive" + +#, python-format +msgid "%(amount)s is te laat" +msgstr "%(amount)s is overdue" + +msgid "Niets openstaand" +msgstr "Nothing outstanding" + +msgid "Nieuwe factuur" +msgstr "New invoice" msgid "Hoofdmenu" msgstr "Main menu" @@ -2897,6 +2943,9 @@ msgstr "Help" msgid "Uitloggen" msgstr "Log out" +msgid "Nieuw" +msgstr "New" + msgid "Meer" msgstr "More" @@ -3862,9 +3911,6 @@ msgstr "%(done)s of %(total)s done" msgid "Doen" msgstr "Start" -msgid "Nieuwe factuur" -msgstr "New invoice" - #, python-format msgid "" "Je omzet in %(year)s (%(revenue)s) is hoger dan je KOR-grens van %(limit)s." @@ -3986,6 +4032,15 @@ msgstr "" msgid "Geen offertes die op antwoord wachten." msgstr "No quotes waiting for a reply." +msgid "Nog geen facturen" +msgstr "No invoices yet" + +msgid "Maak je eerste factuur. Of zet je administratie over uit Moneybird." +msgstr "Make your first invoice. Or move your records over from Moneybird." + +msgid "Naar je uitgaven" +msgstr "To your expenses" + msgid "Huismus is niet bereikbaar" msgstr "Huismus can't be reached" @@ -4656,9 +4711,6 @@ msgstr "" "Invoices and credit notes. An issued invoice is final. To correct it, make a " "credit note." -msgid "Nog geen facturen" -msgstr "No invoices yet" - msgid "Maak je eerste factuur. Hij blijft een concept tot je hem uitgeeft." msgstr "Create your first invoice. It stays a draft until you issue it." @@ -4674,12 +4726,12 @@ msgstr "Search by number or customer" msgid "Alle jaren" msgstr "All years" -msgid "Soort" -msgstr "Kind" - msgid "Status" msgstr "Status" +msgid "Bedrag" +msgstr "Amount" + msgid "Nog geen klant" msgstr "No customer yet" @@ -5010,9 +5062,6 @@ msgstr "All expenses" msgid "Leverancier" msgstr "Supplier" -msgid "Bedrag" -msgstr "Amount" - msgid "Met bonnetje" msgstr "With receipt" @@ -5636,6 +5685,21 @@ msgstr "Download CSV" msgid "KOR-instellingen" msgstr "KOR settings" +#, python-format +msgid "Omzet in %(year)s" +msgstr "Revenue in %(year)s" + +#, python-format +msgid "van %(limit)s, je KOR-grens" +msgstr "of %(limit)s, your KOR limit" + +msgid "Per kwartaal" +msgstr "Per quarter" + +#, python-format +msgid "Omzet per kwartaal in %(year)s" +msgstr "Revenue per quarter in %(year)s" + msgid "De omzet en btw uit je facturen en uitgaven, per rubriek." msgstr "Revenue and VAT from your invoices and expenses, per box." @@ -5726,9 +5790,6 @@ msgstr "%(revenue)s of %(limit)s" msgid "Gemeten met je huidige KOR-grens van %(limit)s." msgstr "Measured against your current KOR limit of %(limit)s." -msgid "Per kwartaal" -msgstr "Per quarter" - msgid "Staafgrafiek omzet en kosten per kwartaal" msgstr "Bar chart of revenue and costs per quarter" @@ -5740,18 +5801,6 @@ msgstr "Revenue Q%(q)s: %(amount)s" msgid "Kosten Q%(q)s: %(amount)s" msgstr "Costs Q%(q)s: %(amount)s" -msgid "jan–mrt" -msgstr "Jan–Mar" - -msgid "apr–jun" -msgstr "Apr–Jun" - -msgid "jul–sep" -msgstr "Jul–Sep" - -msgid "okt–dec" -msgstr "Oct–Dec" - msgid "Kosten zonder btw per categorie" msgstr "Costs excluding VAT by category" @@ -6578,6 +6627,18 @@ msgstr "" "If you have a Raspberry Pi, a NAS, your own server or a VPS, you can also " "run Huismus in Docker. That is for people who are handy with that." +#~ msgid "Vandaag te betalen" +#~ msgstr "Due today" + +#, python-format +#~ msgid "Nog %(days)s dag" +#~ msgid_plural "Nog %(days)s dagen" +#~ msgstr[0] "%(days)s day left" +#~ msgstr[1] "%(days)s days left" + +#~ msgid "Soort" +#~ msgstr "Kind" + #~ msgid "Wat Huismus (nog) niet doet" #~ msgstr "What Huismus doesn't do (yet)" diff --git a/huismus/locale/nl/LC_MESSAGES/django.po b/huismus/locale/nl/LC_MESSAGES/django.po index b140ad5..49eb90c 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:39+0100\n" +"POT-Creation-Date: 2026-11-15 10:33+0100\n" "PO-Revision-Date: 2026-09-25 08:36+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -1580,6 +1580,30 @@ msgstr "" msgid "Creditnota's" msgstr "" +msgid "Te laat" +msgstr "" + +msgid "Wacht op betaling" +msgstr "" + +msgid "Nog niet verstuurd" +msgstr "" + +msgid "Deels betaald" +msgstr "" + +msgid "Onbetaald" +msgstr "" + +msgid "vandaag te betalen" +msgstr "" + +#, python-format +msgid "nog %(days)s dag" +msgid_plural "nog %(days)s dagen" +msgstr[0] "" +msgstr[1] "" + msgid "Wachten op antwoord" msgstr "" @@ -2687,6 +2711,18 @@ msgstr "" msgid "%(quarter)se kwartaal %(year)s" msgstr "" +msgid "jan–mrt" +msgstr "" + +msgid "apr–jun" +msgstr "" + +msgid "jul–sep" +msgstr "" + +msgid "okt–dec" +msgstr "" + msgid "Kwartaal" msgstr "" @@ -2708,7 +2744,17 @@ msgstr "" msgid "Navigatie" msgstr "" -msgid "Nieuw" +msgid "Je krijgt nog" +msgstr "" + +#, python-format +msgid "%(amount)s is te laat" +msgstr "" + +msgid "Niets openstaand" +msgstr "" + +msgid "Nieuwe factuur" msgstr "" msgid "Hoofdmenu" @@ -2735,6 +2781,9 @@ msgstr "" msgid "Uitloggen" msgstr "" +msgid "Nieuw" +msgstr "" + msgid "Meer" msgstr "" @@ -3617,9 +3666,6 @@ msgstr "" msgid "Doen" msgstr "" -msgid "Nieuwe factuur" -msgstr "" - #, python-format msgid "" "Je omzet in %(year)s (%(revenue)s) is hoger dan je KOR-grens van %(limit)s." @@ -3734,6 +3780,15 @@ msgstr "" msgid "Geen offertes die op antwoord wachten." msgstr "" +msgid "Nog geen facturen" +msgstr "" + +msgid "Maak je eerste factuur. Of zet je administratie over uit Moneybird." +msgstr "" + +msgid "Naar je uitgaven" +msgstr "" + msgid "Huismus is niet bereikbaar" msgstr "" @@ -4352,9 +4407,6 @@ msgid "" "je met een creditnota." msgstr "" -msgid "Nog geen facturen" -msgstr "" - msgid "Maak je eerste factuur. Hij blijft een concept tot je hem uitgeeft." msgstr "" @@ -4370,10 +4422,10 @@ msgstr "" msgid "Alle jaren" msgstr "" -msgid "Soort" +msgid "Status" msgstr "" -msgid "Status" +msgid "Bedrag" msgstr "" msgid "Nog geen klant" @@ -4689,9 +4741,6 @@ msgstr "" msgid "Leverancier" msgstr "" -msgid "Bedrag" -msgstr "" - msgid "Met bonnetje" msgstr "" @@ -5259,6 +5308,21 @@ msgstr "" msgid "KOR-instellingen" msgstr "" +#, python-format +msgid "Omzet in %(year)s" +msgstr "" + +#, python-format +msgid "van %(limit)s, je KOR-grens" +msgstr "" + +msgid "Per kwartaal" +msgstr "" + +#, python-format +msgid "Omzet per kwartaal in %(year)s" +msgstr "" + msgid "De omzet en btw uit je facturen en uitgaven, per rubriek." msgstr "" @@ -5342,9 +5406,6 @@ msgstr "" msgid "Gemeten met je huidige KOR-grens van %(limit)s." msgstr "" -msgid "Per kwartaal" -msgstr "" - msgid "Staafgrafiek omzet en kosten per kwartaal" msgstr "" @@ -5356,18 +5417,6 @@ msgstr "" msgid "Kosten Q%(q)s: %(amount)s" msgstr "" -msgid "jan–mrt" -msgstr "" - -msgid "apr–jun" -msgstr "" - -msgid "jul–sep" -msgstr "" - -msgid "okt–dec" -msgstr "" - msgid "Kosten zonder btw per categorie" msgstr "" diff --git a/huismus/reports/views.py b/huismus/reports/views.py index b1bcca1..28b6356 100644 --- a/huismus/reports/views.py +++ b/huismus/reports/views.py @@ -122,14 +122,43 @@ def _period_name(period: Period) -> str: return str(period.year) +# The quarters as the VAT return under the KOR names them. +QUARTER_MONTHS = [_("jan–mrt"), _("apr–jun"), _("jul–sep"), _("okt–dec")] + + +def _kor_year(today) -> dict: + """With the KOR on there is no return to fill in: the page shows this + year's revenue per quarter and how close it is to the KOR limit, the + same figures as the year overview (one function for both). A quarter + still to come has no figure (None).""" + year = today.year + current_quarter = (today.month - 1) // 3 + 1 + overview = compute_year_overview(year) + return { + "year": year, + "quarters": [ + { + "months": months, + "revenue_cents": ( + None if quarter.quarter > current_quarter else quarter.revenue_cents + ), + } + for months, quarter in zip(QUARTER_MONTHS, overview.quarters, strict=True) + ], + "limit": kor_limit_status(year), + } + + @login_required def vat_return(request): - period = Period.parse(request.GET.get("periode"), today=timezone.localdate()) + today = timezone.localdate() + period = Period.parse(request.GET.get("periode"), today=today) report = compute_vat_return(period) return render( request, "reports/vat_return.html", { + "kor_year": _kor_year(today) if report.kor_on else None, "report": report, "period": period, "period_name": _period_name(period), diff --git a/huismus/templates/base.html b/huismus/templates/base.html index 2c211a1..cfe81e7 100644 --- a/huismus/templates/base.html +++ b/huismus/templates/base.html @@ -1,4 +1,4 @@ -{% load i18n static %} +{% load i18n static money %} {% get_current_language as LANGUAGE_CODE %} @@ -31,24 +31,27 @@
@@ -100,6 +102,7 @@

{{ greeting }}{% if user.first_name %}, {{ user.first_name }}{% endif %}

{% translate "Openstaand" %} @@ -121,7 +124,6 @@

{{ greeting }}{% if user.first_name %}, {{ user.first_name }}{% endif %}

{% translate "Naar het jaaroverzicht" %} →
-

{% translate "Laatste facturen" %}

{% translate "Alle facturen" %}
@@ -165,6 +167,46 @@

{{ greeting }}{% if user.first_name %}, {{ user.first_name }}{% endif %}

+{% else %} +
+
+
+

{% translate "Nog geen facturen" %}

+

{% translate "Maak je eerste factuur. Of zet je administratie over uit Moneybird." %}

+ {% translate "Eerste factuur maken" %} + {% translate "Importeren uit Moneybird" %} +
+
+{% comment %}Expenses stay: only the invoice figures make way for the card above.{% endcomment %} + +{% if waiting_quotes %} +
+

{% translate "Wachten op antwoord" %}

{% translate "Offertes" %}
+ {% if waiting_quotes %} +
    + {% for quote, hint in waiting_quotes %} +
  • +
    + {{ quote|contact_name }} +
    {{ quote.number }}{% if hint.0 == "soon" %} · {% if hint.1 == 0 %}{% translate "verloopt vandaag" %}{% else %}{% blocktranslate count days=hint.1 %}verloopt over {{ days }} dag{% plural %}verloopt over {{ days }} dagen{% endblocktranslate %}{% endif %}{% elif hint.0 == "past" %} · {% translate "geldigheid voorbij" %}{% elif quote.expiry_date %} · {% blocktranslate with date=quote.expiry_date|date:"SHORT_DATE_FORMAT" %}geldig tot {{ date }}{% endblocktranslate %}{% endif %}
    +
    + {{ quote.total_cents|money }} +
  • + {% endfor %} +
+
{% translate "Verzonden offertes zonder antwoord. Na de geldigheidsdatum kun je ze als verlopen markeren." %}
+ {% else %} +
{% translate "Geen offertes die op antwoord wachten." %}
+ {% endif %} +
+{% endif %} +{% endif %} {% if last_backup %}

{% blocktranslate with moment=last_backup|moment %}Laatste back-up: {{ moment }}{% endblocktranslate %}

{% endif %} diff --git a/huismus/templates/documents/_bar_total.html b/huismus/templates/documents/_bar_total.html new file mode 100644 index 0000000..e903530 --- /dev/null +++ b/huismus/templates/documents/_bar_total.html @@ -0,0 +1,3 @@ +{% load i18n documents_tags %} +{% comment %}The total in the editor's bar, so it stays in sight on a phone while you scroll through the lines. The same totals as #totalen (one totals function, invariant 4); documents:preview swaps it with them.{% endcomment %} +{% translate "Totaal" %} {{ totals.total_cents|money_for:document }} diff --git a/huismus/templates/documents/_editor_live.html b/huismus/templates/documents/_editor_live.html index 560d7b9..990abec 100644 --- a/huismus/templates/documents/_editor_live.html +++ b/huismus/templates/documents/_editor_live.html @@ -2,6 +2,7 @@ {% comment %}Response of documents:preview. Only out-of-band swaps: the live parts of the editor, recomputed on the server for the unsaved form.{% endcomment %} {% include "documents/_totals.html" with oob=True %} +{% include "documents/_bar_total.html" with oob=True %} {% include "documents/_address.html" with oob=True %} {% include "documents/_attention.html" with oob=True %} {% include "documents/_issue_summary.html" with oob=True %} diff --git a/huismus/templates/documents/edit.html b/huismus/templates/documents/edit.html index 1e380d0..9caaf7c 100644 --- a/huismus/templates/documents/edit.html +++ b/huismus/templates/documents/edit.html @@ -135,8 +135,9 @@

{% if is_quote %}{% if document.number %}{% translate "Offerte" %} {{ docume {% endblock %} {% block actionbar %} -
+
+ {% include "documents/_bar_total.html" %} {% comment %}The extra actions: in the bar on a wide screen, behind "Meer" on a phone (see .actionbar-more in huismus.css).{% endcomment %}
diff --git a/huismus/templates/documents/list.html b/huismus/templates/documents/list.html index b74dff5..f36fa26 100644 --- a/huismus/templates/documents/list.html +++ b/huismus/templates/documents/list.html @@ -3,6 +3,9 @@ {% block title %}{% translate "Facturen" %} — Huismus{% endblock %} +{% comment %}Making an invoice is this page's main action: the panel's button and the phone's + are violet, unless the list is empty (then "Maak je eerste factuur" is).{% endcomment %} +{% block panel_new_class %}{% if has_any %}btn-primary{% else %}btn-quiet{% endif %}{% endblock %} +{% block tab_plus_class %}{% if not has_any %}fab-quiet{% endif %}{% endblock %} {% block main_attrs %} data-shortcut-new="{% url 'documents:create' %}"{% endblock %} {% block shortcut_search %}{% include "core/_shortcut_search.html" %}{% endblock %} @@ -12,9 +15,6 @@

{% translate "Facturen" %}

{% translate "Facturen en creditnota's. Een uitgegeven factuur staat vast. Corrigeren doe je met een creditnota." %}

-
{% if not has_any %} @@ -57,43 +57,43 @@

{% translate "Nog geen facturen" %}

{% if documents %} + {% regroup documents by group as groups %} + {% for group in groups %} +

{{ group_titles|get:group.grouper }}

- +
- - + + - - + - {% for document in documents %} + {% for document in group.list %} - - - + + - {% endfor %}
{% translate "Nummer" %}{% translate "Soort" %} {% translate "Klant" %}{% translate "Nummer" %}{% translate "Datum" %} {% translate "Status" %}{% translate "Totaal" %}{% translate "Betaalstatus" %}{% translate "Bedrag" %}
+ {% endfor %}
{% blocktranslate count total=total with shown=documents|length %}{{ shown }} van {{ total }} factuur{% plural %}{{ shown }} van {{ total }} facturen{% endblocktranslate %} diff --git a/huismus/templates/reports/vat_return.html b/huismus/templates/reports/vat_return.html index 6dc20c1..3b633e5 100644 --- a/huismus/templates/reports/vat_return.html +++ b/huismus/templates/reports/vat_return.html @@ -23,7 +23,24 @@ {% include "reports/_tabs.html" with current="vat_return" %} {% if report.kor_on %} -

{{ kor_note }} {% translate "KOR-instellingen" %} →

+

{{ kor_note }} {% translate "KOR-instellingen" %} →

+
+ {% if kor_year.limit %} +
+ {% blocktranslate with year=kor_year.year %}Omzet in {{ year }}{% endblocktranslate %} + {{ kor_year.limit.revenue_cents|money }} + {% blocktranslate with limit=kor_year.limit.limit_cents|money %}van {{ limit }}, je KOR-grens{% endblocktranslate %} + +
+ {% endif %} +
+

{% translate "Per kwartaal" %}

+ + + {% for quarter in kor_year.quarters %}{% endfor %} +
{% blocktranslate with year=kor_year.year %}Omzet per kwartaal in {{ year }}{% endblocktranslate %}
{{ quarter.months }}{% if quarter.revenue_cents is None %}—{% else %}{{ quarter.revenue_cents|money }}{% endif %}
+
+
{% else %}

{% translate "De omzet en btw uit je facturen en uitgaven, per rubriek." %}

diff --git a/tests/core/test_contrast.py b/tests/core/test_contrast.py index 3c7f69a..6a1be7d 100644 --- a/tests/core/test_contrast.py +++ b/tests/core/test_contrast.py @@ -34,8 +34,18 @@ ("accent-ink", "accent-soft"), ("draft", "draft-bg"), ("draft", "surface"), + ("panel-text", "panel"), + ("panel-muted", "panel"), + ("text", "warn-bg"), ] +# (graphic, surface it stands on): bars and edges need 3 : 1 (WCAG 1.4.11). +GRAPHIC_PAIRS = [ + ("primary", "surface"), # the revenue bar +] +# The yellow cost bar has no edge (the owner, 2026-11-15): its amounts are in +# the table right below the chart. + def _tokens(): """name -> (light, dark) for every token written as light-dark(#hex, #hex).""" @@ -63,3 +73,12 @@ def test_text_reaches_aa_on_its_surface(text, surface, theme): index = 0 if theme == "light" else 1 ratio = _contrast(tokens[text][index], tokens[surface][index]) assert ratio >= 4.5, f"--{text} on --{surface} ({theme}): {ratio:.2f} : 1" + + +@pytest.mark.parametrize("theme", ["light", "dark"]) +@pytest.mark.parametrize(("graphic", "surface"), GRAPHIC_PAIRS) +def test_bars_reach_3_to_1_on_their_surface(graphic, surface, theme): + tokens = _tokens() + index = 0 if theme == "light" else 1 + ratio = _contrast(tokens[graphic][index], tokens[surface][index]) + assert ratio >= 3, f"--{graphic} on --{surface} ({theme}): {ratio:.2f} : 1" diff --git a/tests/core/test_dashboard.py b/tests/core/test_dashboard.py index b2c03a1..616ebb4 100644 --- a/tests/core/test_dashboard.py +++ b/tests/core/test_dashboard.py @@ -63,6 +63,30 @@ def test_outstanding_sums_what_is_still_owed_and_counts_overdue(settings_filled) assert summary["overdue_count"] == 1 +def test_outstanding_says_how_much_of_it_is_overdue(settings_filled): + _issued(100000) + _issued(30000, due_date=TODAY - timedelta(days=3)) + _issued(50000, due_date=TODAY - timedelta(days=1), paid=20000) # partly paid, overdue + _issued(80000, due_date=TODAY - timedelta(days=9), paid=80000) # paid: not overdue + + summary = outstanding_invoices() + + assert summary["overdue_cents"] == 30000 + 30000 + assert summary["total_cents"] == 100000 + 30000 + 30000 + assert summary["has_issued"] is True + + +def test_outstanding_before_the_first_invoice_is_empty(settings_filled): + summary = outstanding_invoices() + assert summary == { + "count": 0, + "total_cents": 0, + "overdue_count": 0, + "overdue_cents": 0, + "has_issued": False, + } + + def test_onboarding_steps_follow_what_exists(settings_filled): steps = {step["key"]: step["done"] for step in onboarding_steps()} assert steps == { @@ -156,3 +180,59 @@ def test_the_kor_or_vat_step_is_done_without_the_kor_and_with_a_vat_number(setti settings_filled.vat_number = "NL000099998B57" settings_filled.save() assert next(s for s in onboarding_steps() if s["key"] == "kor")["done"] is True + + +def test_the_query_filter_leaves_out_no_open_invoice(settings_filled): + """outstanding_invoices() narrows the query for speed; payment_state + still decides. Every invoice it decides is open must be counted.""" + _issued(100000) + _issued(50000, paid=20000) + _issued(40000, paid=40000) + credited = _issued(25000) + _issued(25000, kind="credit_note", related=credited) + _issued(0) # € 0, nothing paid: "unpaid" + + every = Document.objects.filter(kind="invoice", status="issued").with_payment_totals() + open_count = sum(1 for d in every if d.payment_state in ("unpaid", "partial")) + + assert outstanding_invoices()["count"] == open_count == 3 + + +def _home(client): + user = get_user_model().objects.create_user(username="sam", password="s3cret-pass") + client.force_login(user) + return client.get(reverse("home")).content.decode().replace("\xa0", " ") + + +def test_the_menu_panel_says_what_you_still_receive_and_what_is_overdue(client, settings_filled): + _issued(100000) + _issued(30000, due_date=TODAY - timedelta(days=3)) + + html = _home(client) + + assert 'id="je-krijgt-nog"' in html + assert "Je krijgt nog" in html + assert "€ 1.300,00" in html + assert "€ 300,00 is te laat" in html + + +def test_the_menu_panel_says_nothing_is_outstanding_when_all_is_paid(client, settings_filled): + _issued(40000, paid=40000) + assert "Niets openstaand" in _home(client) + + +def test_the_menu_panel_is_empty_before_the_first_issued_invoice(client, settings_filled): + Contact.objects.create(company_name="Klant BV") # past the welcome + assert 'id="je-krijgt-nog"' not in _home(client) + + +def test_an_overview_without_invoices_shows_one_card_to_make_the_first(client, settings_filled): + Contact.objects.create(company_name="Klant BV") # past the welcome + + html = _home(client) + + assert 'id="nog-geen-facturen"' in html + assert "Eerste factuur maken" in html + assert "Importeren uit Moneybird" in html + assert "Openstaand" not in html + assert "Laatste facturen" not in html diff --git a/tests/core/test_design_system.py b/tests/core/test_design_system.py index 6f609c9..712cdea 100644 --- a/tests/core/test_design_system.py +++ b/tests/core/test_design_system.py @@ -17,6 +17,7 @@ # Variants that only make sense inside the app shell, not on a page of their own. NOT_ON_PAGE = { "btn-new", # the sidebar's "Nieuwe factuur", styled by .sidebar + "btn-quiet", # that button where it isn't the page's main action, also by .sidebar "flash-body", # the text inside a .flash or .toast, not a variant of its own } diff --git a/tests/documents/test_list_view.py b/tests/documents/test_list_view.py index 10c71d0..fa7ee8d 100644 --- a/tests/documents/test_list_view.py +++ b/tests/documents/test_list_view.py @@ -171,3 +171,26 @@ def test_query_count_does_not_grow_with_the_number_of_invoices( _invoice(f"Klant {number}", paid=5000) with django_assert_max_num_queries(8): _get(client_in) + + +def test_the_list_shows_invoices_in_groups_with_how_long_until_due(client_in): + """#186: Te laat, Wacht op betaling, Nog niet verstuurd, Betaald, each + with its own heading, in that order.""" + _invoice("Studio Noordwind", due_date=TODAY + timedelta(days=4)) + _invoice("Atelier De Vries", paid=10000) + _invoice("Bouwbedrijf Van Dijk", due_date=TODAY - timedelta(days=12)) + _invoice("Vandaag BV", due_date=TODAY) + _draft("Bakkerij Jansen BV") + + html = client_in.get(reverse("documents:list")).content.decode().replace("\xa0", " ") + + headings = ["groep-te-laat", "groep-wacht", "groep-concept", "groep-betaald"] + positions = [html.index(f'id="{heading}"') for heading in headings] + assert positions == sorted(positions) + assert 'id="groep-creditnotas"' not in html # only groups with rows + assert html.index("Bouwbedrijf Van Dijk") < positions[1] + assert "12 dagen te laat" in html + assert "Nog 4 dagen" in html + assert "Vandaag te betalen" in html + assert html.index("Bakkerij Jansen BV") > positions[2] + assert html.index("Atelier De Vries") > positions[3] diff --git a/tests/documents/test_listing.py b/tests/documents/test_listing.py index a28a4ff..dcddb1b 100644 --- a/tests/documents/test_listing.py +++ b/tests/documents/test_listing.py @@ -6,7 +6,14 @@ import pytest -from huismus.documents.listing import contact_name, in_tab, matches_search +from huismus.documents.listing import ( + contact_name, + grouped, + in_tab, + invoice_group, + matches_search, + waiting_label, +) def _doc(**fields): @@ -109,3 +116,55 @@ def test_in_quote_tab(status, tab, expected): def test_expiry_hint(status, expiry, expected): quote = _doc(kind="quote", status=status, expiry_date=expiry) assert expiry_hint(quote, today=TODAY) == expected + + +@pytest.mark.parametrize( + ("document", "group"), + [ + (_doc(is_overdue=True), "te-laat"), + (_doc(payment_state="partial", is_overdue=True), "te-laat"), + (_doc(is_overdue=False), "wacht"), + (_doc(payment_state="partial", is_overdue=False), "wacht"), + (_doc(status="draft", payment_state=None, is_overdue=False), "concept"), + (_doc(payment_state="paid", is_overdue=False), "betaald"), + (_doc(payment_state="credited", is_overdue=False), "betaald"), + (_doc(kind="credit_note", payment_state=None, is_overdue=False), "creditnotas"), + (_doc(kind="credit_note", status="draft", payment_state=None, is_overdue=False), "concept"), + ], +) +def test_invoice_group(document, group): + assert invoice_group(document) == group + + +def test_grouped_keeps_the_order_within_a_group_and_puts_groups_in_order(): + paid_new = _doc(payment_state="paid", is_overdue=False, number="5") + late = _doc(is_overdue=True, number="4") + waiting = _doc(is_overdue=False, number="3") + paid_old = _doc(payment_state="paid", is_overdue=False, number="2") + draft = _doc(status="draft", payment_state=None, is_overdue=False, number="") + + rows = grouped([paid_new, late, waiting, paid_old, draft]) + + assert [d.number for d in rows] == ["4", "3", "", "5", "2"] + assert [d.group for d in rows] == ["te-laat", "wacht", "concept", "betaald", "betaald"] + + +LABEL_TODAY = date(2026, 11, 15) + + +@pytest.mark.parametrize( + ("state", "due_in", "label"), + [ + ("unpaid", 4, "Nog 4 dagen"), + ("unpaid", 1, "Nog 1 dag"), + ("unpaid", 0, "Vandaag te betalen"), + ("unpaid", None, "Onbetaald"), + ("partial", 4, "Deels betaald, nog 4 dagen"), + ("partial", 0, "Deels betaald, vandaag te betalen"), + ("partial", None, "Deels betaald"), + ], +) +def test_waiting_label(state, due_in, label): + due = None if due_in is None else LABEL_TODAY + timedelta(days=due_in) + document = _doc(payment_state=state, due_date=due) + assert str(waiting_label(document, LABEL_TODAY)) == label diff --git a/tests/e2e/test_browser.py b/tests/e2e/test_browser.py index 170c457..882b3b4 100644 --- a/tests/e2e/test_browser.py +++ b/tests/e2e/test_browser.py @@ -1574,3 +1574,33 @@ def test_a_new_expense_gets_its_receipt_in_one_go(app, tmp_path): expect(app.get_by_text("Uitgave opgeslagen.")).to_be_visible() expect(app.locator(".receipt .r-name")).to_have_text("bon-hosting.png") assert Expense.objects.get().attachments.count() == 1 + + +def test_on_a_phone_the_editor_bar_keeps_the_total_in_sight(app, contact): + """#186: on a phone the total stays in the bar at the bottom, above the + tab bar, and follows what you type (the server's figure, like #totalen).""" + app.set_viewport_size({"width": 360, "height": 740}) + app.goto(app.base + "/facturen/nieuw/") + picker = app.locator("input[role=combobox]") + picker.fill("korrel") + picker.press("Enter") + line = app.locator("[data-formset-forms=lines] .line").first + line.locator("textarea[name$=-description]").fill("Uren") + line.locator("input[name$=-quantity]").fill("2,5") + line.locator("input[name$=-unit_price_cents]").fill("85") + + bar_total = app.locator("#actiebalk-totaal") + expect(bar_total).to_be_visible() + expect(bar_total).to_contain_text("257,13") + bar = app.locator(".actionbar").bounding_box() + tabs = app.locator(".tabbar").bounding_box() + assert bar["y"] + bar["height"] <= tabs["y"] + 1 + # A field low on the page that gets the focus (Tab, or the browser) + # scrolls into sight above the bar, not under it. + footer = app.locator("[name=footer_text]") + footer.focus() + box = footer.bounding_box() + assert box["y"] + box["height"] <= app.locator(".actionbar").bounding_box()["y"] + 1 + # On a wide screen the totals beside the lines are enough. + app.set_viewport_size({"width": 1280, "height": 800}) + expect(bar_total).to_be_hidden() diff --git a/tests/e2e/test_every_page.py b/tests/e2e/test_every_page.py index 900c494..9829a34 100644 --- a/tests/e2e/test_every_page.py +++ b/tests/e2e/test_every_page.py @@ -602,7 +602,10 @@ def test_every_action_on_a_wide_screen_can_be_reached_on_a_narrow_one(app, histo ); const phoneNav = ".mtop, .tabbar, #plus-menu, #meer-menu"; const phone = new Set(actions(phoneNav).filter(reachable).map(key)); + // "Je krijgt nog" is a shortcut to Facturen › Openstaand, which the phone + // reaches through Facturen; on the phone the amount itself is the overview's (#186). return actions(".sidebar") + .filter((el) => !el.matches(".panel-owed")) .filter((el) => !phone.has(key(el))) .map((el) => `${(el.innerText || "").trim()} ${key(el)}`); } diff --git a/tests/reports/test_views.py b/tests/reports/test_views.py index a319ad4..282dde8 100644 --- a/tests/reports/test_views.py +++ b/tests/reports/test_views.py @@ -178,3 +178,45 @@ def test_the_old_year_overview_address_still_arrives(client, old, new): response = client.get(old) assert response.status_code == 301 assert response.url == new + + +def test_the_vat_return_under_the_kor_shows_this_years_revenue_per_quarter(client): + """With the KOR on there is no return to fill in (#186): the page shows + this year's revenue per quarter and the KOR limit, the year overview's + figures.""" + _login(client) + _kor_on() + year = timezone.localdate().year + _issued_invoice(f"{year}-02-01", 298_000) + _issued_invoice(f"{year}-03-01", 364_000) + _issued_invoice(f"{year - 1}-05-01", 999_999) # last year: doesn't count + + response = client.get(reverse("reports:vat_return")) + + kor_year = response.context["kor_year"] + assert kor_year["limit"].revenue_cents == 662_000 + # The four quarters add up to the figure in the card. + shown = [q["revenue_cents"] for q in kor_year["quarters"] if q["revenue_cents"] is not None] + assert sum(shown) == kor_year["limit"].revenue_cents + page = response.content.decode().replace("\xa0", " ") + assert 'id="kor-omzet"' in page + assert f"Omzet in {year}" in page + assert "€ 6.620,00" in page + assert "van € 10.000,00, je KOR-grens" in page + assert 'jan–mrt€ 6.620,00' in page + + +def test_quarters_still_to_come_show_a_dash(client): + _login(client) + _kor_on() + today = timezone.localdate() + quarters = client.get(reverse("reports:vat_return")).context["kor_year"]["quarters"] + current = (today.month - 1) // 3 + assert all(q["revenue_cents"] is None for q in quarters[current + 1 :]) + assert all(q["revenue_cents"] is not None for q in quarters[: current + 1]) + + +def test_the_vat_return_without_the_kor_has_no_kor_revenue(client): + _login(client) + page = client.get(reverse("reports:vat_return")).content.decode() + assert 'id="kor-omzet"' not in page