Repository navigation
harvest-invoicer: invoice archive, unique links, deletion and email sending - #190
Merged
Merged
Conversation
…ending serve now archives every generated PDF under --invoices-dir (default: invoices/ next to the database) with its own link, lists them on an Invoices page, deletes them, and emails them to the client through the existing SMTP settings, recording who it was sent to. Missing issuer or client data shows a pointer to Settings instead of a template error. The Host allow-list now applies to reads too, and /healthz is the probe endpoint.
A wildcard bind no longer disables the Host guard when --allowed-host or OIDC is set, and configured hosts are normalised like request hosts; a malformed Host gets 403. The From header is a structured mailbox with an explicit envelope sender, so issuer names with commas work. Every send is kept in a history (schema v5) and a resend, from the editor or the Invoices page, needs confirmation server-side. The subject is checked before anything is archived; deleting removes the file before the row; new PDFs are fsynced and verified against their sha256 before reuse, sending or serving; /pdf serves this session's last generated invoice; an existing invoices directory is warned about, never chmod'ed. Adds tests for the O_EXCL retry and write/DB failure cleanup.
… the header A configured sender with a display name works again: it is parsed once and the bare address is the envelope sender. A resend is detected by content across every earlier sent entry, so a damaged or deleted file can no longer be replaced and resent unconfirmed; the Invoices list shows missing or altered files without links. The v5 migration runs in one transaction and tolerates a NULL sent_to. Host handling: a malformed Host or one with userinfo gets 403 even with a wildcard bind, --allowed-host rejects wildcards, IDN names are IDNA-encoded, and loopback origins must match the server port. A failed delete row gives a toast instead of a 500, the send dialog snapshots settings under the lock, and an unconfirmed resend returns the dialog with the confirmation. The editor header no longer repeats the invoice number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
harvest-invoicer servenow keeps every PDF it generates, links each one, can delete them and can email them to the client. It also replaces the template error you get when issuer or client data is missing.What changes
--invoices-dir/HARVEST_INVOICER_INVOICES_DIR(defaultinvoices/next to the database), recorded in a newinvoicestable (schema v4, added by the usual migration).<number>_<client>_<8 hex>.pdf.GET /invoices/<id>.pdfshows a PDF inline; add?download=1to download it. Ids are 128-bit random. After generating, a panel shows the file name with Open, Download and Send buttons, replacing the small "open" link./invoiceslists date, number, client, total and sent status, with Open, Download, Send and Delete actions. Delete asks for confirmation, with an extra warning if the invoice was already sent.email, and the subject and body from per-language templates (en/es). It attaches the PDF through the existing SMTP settings and recordssent_at/sent_to.'dict object' has no attribute 'name'.Behaviour changes
serveno longer writesinvoice-<number>.pdfto the current directory. It archives, and also writes a copy when--outputis given. The README has an "Upgrading" note./invoicesin local mode. A proxy must forward the public host.GET /healthzis exempt from the Host check and from the login guard, so Kubernetes probes, which use the pod IP as Host, keep working.--demoandgenerateare unchanged.Security
An independent review found nothing critical. Its findings are fixed here:
O_NOFOLLOW, so a symlink is never followed;Login (OIDC) and CSRF cover every new route. Recipients and subjects with line breaks are rejected, and nothing new is logged.
Testing
testextra dependency;uv.lockupdated).nix fmtandnix flake checkpass.