feat(invoiceintake): send every invoice mail on to DATEV from invoice@ #110

Merged
sharang merged 1 commits from feat/intake-datev-forward into main 2026-11-02 11:59:01 +00:00
Owner

Backlog t60: DATEV Unternehmen Online takes receipts by mail only from registered senders. Strato forwarded invoice@ with the supplier as sender, so DATEV rejected every invoice that came straight from a supplier (Hetzner, OpenAI, Anthropic, …). In October they were uploaded by hand.

What changes. With INTAKE_DATEV_ADDRESS set, the intake sends every invoice mail received on or after INTAKE_DATEV_SINCE on to DATEV Upload Mail, from invoice@ through ERPNext (frappe.core.doctype.communication.email.make):

  • The sent mail replies to the received one (in_reply_to). That is the "already forwarded" marker, so the service stays stateless. It also shows in the mail's timeline, and ERPNext's Email Queue retries a failed send.
  • An XRechnung goes as XML only (DATEV reads it, and the PDF rendering would be a second receipt). Otherwise every PDF goes.
  • DATEV's own mails (*.datev.de) and bounces (mailer-daemon, postmaster) are never forwarded, so nothing loops. They now become ToDos with their own reason instead of "Keine PDF-Anlage".
  • A failed forward doesn't stop the drafts, and the other way round (errors.Join).
  • Off by default: without INTAKE_DATEV_ADDRESS nothing changes. -dry-run reports "N forwarded to DATEV" without sending.

Before switching it on (orca-infra PR to follow, which also bumps the image digest):

  1. In DATEV Unternehmen Online: register invoice@breakpilot.com as an Upload Mail sender.
  2. In ERPNext: turn on outgoing mail (Strato SMTP) for the Email Account "Eingangsrechnung" (invoice@). Without it, Frappe falls back to the default outgoing account.
  3. At Strato: remove the copy of invoice@ to the DATEV address, otherwise every founder-forwarded mail arrives twice.
  4. Set the DATEV address as an orca secret. It never appears in logs or in this repo.

Tests: 7 new (internal/invoiceintake): forward once and stable across processes, XML-only for XRechnung, cut-off date, DATEV/bounce mails, dry run, forward failure keeps drafts and retries, config validation. go test -race and go vet pass, and coverage is 87.4 %.

🤖 Generated with Claude Code

Backlog t60: DATEV Unternehmen Online takes receipts by mail only from registered senders. Strato forwarded invoice@ with the supplier as sender, so DATEV rejected every invoice that came straight from a supplier (Hetzner, OpenAI, Anthropic, …). In October they were uploaded by hand. **What changes.** With `INTAKE_DATEV_ADDRESS` set, the intake sends every invoice mail received on or after `INTAKE_DATEV_SINCE` on to DATEV Upload Mail, **from invoice@ through ERPNext** (`frappe.core.doctype.communication.email.make`): - The sent mail replies to the received one (`in_reply_to`). That is the "already forwarded" marker, so the service stays stateless. It also shows in the mail's timeline, and ERPNext's Email Queue retries a failed send. - An XRechnung goes as XML only (DATEV reads it, and the PDF rendering would be a second receipt). Otherwise every PDF goes. - DATEV's own mails (`*.datev.de`) and bounces (`mailer-daemon`, `postmaster`) are never forwarded, so nothing loops. They now become ToDos with their own reason instead of "Keine PDF-Anlage". - A failed forward doesn't stop the drafts, and the other way round (`errors.Join`). - Off by default: without `INTAKE_DATEV_ADDRESS` nothing changes. `-dry-run` reports "N forwarded to DATEV" without sending. **Before switching it on** (orca-infra PR to follow, which also bumps the image digest): 1. In DATEV Unternehmen Online: register `invoice@breakpilot.com` as an Upload Mail sender. 2. In ERPNext: turn on outgoing mail (Strato SMTP) for the Email Account "Eingangsrechnung" (invoice@). Without it, Frappe falls back to the default outgoing account. 3. At Strato: remove the copy of invoice@ to the DATEV address, otherwise every founder-forwarded mail arrives twice. 4. Set the DATEV address as an orca secret. It never appears in logs or in this repo. **Tests:** 7 new (`internal/invoiceintake`): forward once and stable across processes, XML-only for XRechnung, cut-off date, DATEV/bounce mails, dry run, forward failure keeps drafts and retries, config validation. `go test -race` and `go vet` pass, and coverage is 87.4 %. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-02 11:32:45 +00:00
feat(invoiceintake): send every invoice mail on to DATEV from invoice@
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 26m10s
ci / image (pull_request) Skipped
36a30e206d
DATEV Unternehmen Online takes receipts by mail only from registered
senders. Strato forwarded invoice@ with the supplier as sender, so DATEV
rejected every invoice that came straight from a supplier (backlog t60).

With INTAKE_DATEV_ADDRESS set, the intake sends each invoice mail received
on or after INTAKE_DATEV_SINCE on to that address, from invoice@, through
ERPNext (communication.email.make). The sent mail replies to the received
one (in_reply_to): that is the marker, it shows in the mail's timeline,
and ERPNext's Email Queue retries a failed send. An XRechnung goes as XML
only, so its PDF rendering doesn't become a second receipt. DATEV's own
answers and bounces are never forwarded; they become ToDos with their own
reason instead of "no PDF". A failed forward doesn't stop the drafts, and
the other way round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit 286f50c5fb into main 2026-11-02 11:59:01 +00:00
sharang deleted branch feat/intake-datev-forward 2026-11-02 11:59:01 +00:00
Sign in to join this conversation.