fix(invoices): Ej skickade view and a prompt before downloading a draft-stamped PDF (#2401)
* fix(invoices): show finalized-but-unsent invoices as their own view and ask before downloading a draft-stamped PDF
Two user reports, one hidden state: an invoice that went through Granska
& skapa has an F-number but its DB status is still 'draft' until it is
marked as sent (and booked). The list lumped those rows under Utkast, and
"Ladda ner PDF" handed out the UTKAST-stamped render with no warning, which
users then mailed to customers.
Why it occurred: the status column carries two meanings for 'draft'
(unnumbered draft vs numbered, unsent invoice) and every surface decided on
its own how to read it. The list badge knew the difference ("Ej skickad"),
the tab predicate and the PDF download did not.
What was simplified: the tab predicate moved out of the page into
lib/invoices/invoice-list-tabs.ts as one function used by the rows, the
per-view counts, the status sections and the row badge, so the four cannot
drift. The ?status= alias parsing collapsed into the same module.
Why this and not the proposed shapes: a real 'issued' status in the DB
would touch MCP, the v1 API, reports and SIE for a distinction that
invoice_number already carries. Removing the UTKAST stamp from numbered
drafts would be wrong: an unbooked invoice is not issued. So the UI splits
the state (Ej skickade view, ?status=unsent, ?status=godkanda alias) and the
download asks first: "Bokför och ladda ner" (or "Markera som skickad och
ladda ner" for cash-method companies and offerter) runs the existing manual
mark-sent dialog and then downloads the issued document; "Ladda ner utkast"
still works. The manual mark-sent toast now offers "Ladda ner PDF" too.
Fixes #2399
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RZiqSg2v6XrtaFZyyRK88b
* fix(invoices): skeptic round on the draft-download prompt
Four refutations on 352d4bafc, all confirmed in code:
- Proformas (and any non-faktura) in an accrual company were told "Fakturan
är inte bokförd" and offered "Bokför och ladda ner"; mark-sent never books
a proforma. The label predicate is now issuesByBooking = booksOnIssue &&
isRealInvoice, shared with the existing primary button, which carried the
same "och bokför" promise on proformas.
- A partial mark-sent success (PDF archive, periodisering or delivery history
failed) still ran the chained download, and its toast evicted the warning
(one toast at a time). onSuccess now carries `partial`; the chained
download is dropped on a partial result, matching the toast action.
- Numbered följesedlar are stamped UTKAST too (pdf-template does not exclude
them) but the decision skipped the prompt. They now get the prompt; the
issue action is their own status flip, so updateStatus reports success and
the download is queued only after it.
- The download queue was a boolean bound to "whatever invoice is mounted";
the detail pager keeps the page mounted across ArrowLeft/ArrowRight, so a
step could download the neighbour or leave the queue armed. The queue now
holds the invoice id and is dropped when a different invoice is shown.
Refs #2399
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RZiqSg2v6XrtaFZyyRK88b
* fix(invoices): review pass on PR #2401
CodeRabbit, all confirmed against the code:
- The PDF preview (Visa PDF) bypassed the draft prompt; the browser viewer
has a save button, so an unwarned preview is an unwarned download. The
preview now runs the same decision; the prompt's draft button honours the
original intent ("Visa utkast" opens the viewer, "Ladda ner utkast" saves).
- updateStatus lost its isUpdating reset when both branches started
returning; moved to finally so a failed refetch after mark-sent does not
leave the page's buttons disabled.
- A cancelled credit note matched both the Kreditfakturor and Makulerade
views; the credit view now excludes cancelled rows like every other view.
Declined: the DECISIONS.md date (2026-09-08 is the local date the decision
was recorded; the bot compared against UTC) and the docstring-coverage
warning (not a repo gate).
Refs #2399
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RZiqSg2v6XrtaFZyyRK88b
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
477b59453f
commit
4e8d649b2f
@@ -4266,6 +4266,16 @@
|
||||
"pdf_downloaded_title": "PDF downloaded",
|
||||
"pdf_downloaded_with_number": "Invoice {number} has been downloaded",
|
||||
"pdf_downloaded_draft": "The draft has been downloaded",
|
||||
"draft_download_book_title": "The invoice is not posted",
|
||||
"draft_download_book_desc": "The PDF is stamped UTKAST (draft) until the invoice is marked as sent and posted. Post it first if the file is going to the customer.",
|
||||
"draft_download_send_title": "The document is not marked as sent",
|
||||
"draft_download_send_desc": "The PDF is stamped UTKAST (draft) until the document is marked as sent. Mark it as sent first if the file is going to the customer.",
|
||||
"draft_download_unnumbered_title": "The draft has no invoice number",
|
||||
"draft_download_unnumbered_desc": "The PDF is stamped UTKAST and is not a valid invoice. Use Review & create before sending it to the customer.",
|
||||
"draft_download_draft_action": "Download draft",
|
||||
"draft_download_preview_action": "Preview draft",
|
||||
"draft_download_book_action": "Post and download",
|
||||
"draft_download_send_action": "Mark as sent and download",
|
||||
"pdf_download_failed_title": "Could not download PDF",
|
||||
"peppol_downloaded_title": "Peppol XML downloaded",
|
||||
"peppol_downloaded_description": "The XML file passed Accounted's local checks. It has not been sent to Peppol.",
|
||||
@@ -6721,6 +6731,7 @@
|
||||
"tab_all": "All",
|
||||
"tab_unpaid": "Unpaid",
|
||||
"tab_paid": "Paid",
|
||||
"tab_unsent": "Not sent",
|
||||
"tab_draft": "Draft",
|
||||
"tab_proforma": "Proforma",
|
||||
"tab_quote": "Quotes",
|
||||
@@ -6731,6 +6742,8 @@
|
||||
"no_search_results_description": "No invoices match \"{term}\".",
|
||||
"no_category_title": "No invoices in this category",
|
||||
"no_category_description": "Try switching tabs to see more invoices.",
|
||||
"no_unsent_title": "No unsent invoices",
|
||||
"no_unsent_description": "Invoices that have a number but have not been sent or posted yet end up here.",
|
||||
"badge_credit": "Credit",
|
||||
"badge_proforma": "Proforma",
|
||||
"badge_quote": "Quote",
|
||||
@@ -6795,6 +6808,7 @@
|
||||
"group_none": "No grouping",
|
||||
"group_unknown": "Missing",
|
||||
"section_drafts": "Drafts ({count})",
|
||||
"section_unsent": "Not sent ({count})",
|
||||
"section_awaiting": "Awaiting payment ({count})",
|
||||
"section_settled": "Paid and settled ({count})",
|
||||
"coverage_notice": "Invoices before {date} may exist only as posted journal entries and are not shown in this list."
|
||||
|
||||
@@ -4266,6 +4266,16 @@
|
||||
"pdf_downloaded_title": "PDF nedladdad",
|
||||
"pdf_downloaded_with_number": "Faktura {number} har laddats ner",
|
||||
"pdf_downloaded_draft": "Utkastet har laddats ner",
|
||||
"draft_download_book_title": "Fakturan är inte bokförd",
|
||||
"draft_download_book_desc": "PDF:en stämplas UTKAST tills fakturan är markerad som skickad och bokförd. Bokför den först om filen ska skickas till kunden.",
|
||||
"draft_download_send_title": "Dokumentet är inte markerat som skickat",
|
||||
"draft_download_send_desc": "PDF:en stämplas UTKAST tills dokumentet är markerat som skickat. Markera det som skickat först om filen ska skickas till kunden.",
|
||||
"draft_download_unnumbered_title": "Utkastet har inget fakturanummer",
|
||||
"draft_download_unnumbered_desc": "PDF:en stämplas UTKAST och är inte en giltig faktura. Använd Granska & skapa innan den skickas till kunden.",
|
||||
"draft_download_draft_action": "Ladda ner utkast",
|
||||
"draft_download_preview_action": "Visa utkast",
|
||||
"draft_download_book_action": "Bokför och ladda ner",
|
||||
"draft_download_send_action": "Markera som skickad och ladda ner",
|
||||
"pdf_download_failed_title": "Kunde inte ladda ner PDF",
|
||||
"peppol_downloaded_title": "Peppol XML nedladdad",
|
||||
"peppol_downloaded_description": "XML-filen har klarat Accounteds lokala kontroll. Den har inte skickats till Peppol.",
|
||||
@@ -6721,6 +6731,7 @@
|
||||
"tab_all": "Alla",
|
||||
"tab_unpaid": "Obetalda",
|
||||
"tab_paid": "Betalda",
|
||||
"tab_unsent": "Ej skickade",
|
||||
"tab_draft": "Utkast",
|
||||
"tab_proforma": "Proforma",
|
||||
"tab_quote": "Offerter",
|
||||
@@ -6731,6 +6742,8 @@
|
||||
"no_search_results_description": "Inga fakturor matchar \"{term}\".",
|
||||
"no_category_title": "Inga fakturor i denna kategori",
|
||||
"no_category_description": "Prova att byta flik för att se fler fakturor.",
|
||||
"no_unsent_title": "Inga ej skickade fakturor",
|
||||
"no_unsent_description": "Fakturor som har fått nummer men ännu inte skickats eller bokförts hamnar här.",
|
||||
"badge_credit": "Kredit",
|
||||
"badge_proforma": "Proforma",
|
||||
"badge_quote": "Offert",
|
||||
@@ -6795,6 +6808,7 @@
|
||||
"group_none": "Ingen gruppering",
|
||||
"group_unknown": "Saknas",
|
||||
"section_drafts": "Utkast ({count})",
|
||||
"section_unsent": "Ej skickade ({count})",
|
||||
"section_awaiting": "Väntar på betalning ({count})",
|
||||
"section_settled": "Betalda och avslutade ({count})",
|
||||
"coverage_notice": "Fakturor före {date} kan ligga som bokförda verifikat och visas inte i den här listan."
|
||||
|
||||
Reference in New Issue
Block a user