feat(erpsetup): outgoing e-invoices, payment by transfer, discount line #84

Merged
sharang merged 1 commits from feat/einvoice-setup into main 2026-10-20 09:32:06 +00:00
Owner

Backlog #16 (VD-04): outgoing e-invoices with eu_einvoice v15.16.2 on ERPNext 15.112, plus the two decisions from 2026-10-20 (discount as a line, transfer with 21 days).

What erpsetup adds

Area Change
Code lists Code List docs named by the URNs eu_einvoice looks up (Rec 20, UNTDID 4461, UNTDID 5305, VATEX), with only the codes we use and their mapping: Monat → MON, Jahr → ANN, Prüfung/Stück → C62; Überweisung (+ template) → 58, SEPA-Lastschrift (+ template) → 59; reverse-charge templates → AE / vatex-eu-ae; non-EU templates → G / vatex-eu-g. Everything else keeps eu_einvoice's fallback (C62, ZZZ, S). ERPNext 15.112 refuses to import a list from a URL, so no full lists
Payment by transfer Mode of Payment Überweisung (type Bank) on the GL account of the company Bank Account (so the e-invoice carries our IBAN, which code 58 requires) and payment terms Überweisung 21 Tage
Discount Item RABATT (sales, non-stock, unit Stück): a discount is a negative line. Income account SKR04 4700 when the chart has it, cost center Verwaltung
Validation E Invoice Settings: validate on save (warning), on submit (block)
Profile New customers default to EN 16931 (eu_einvoice ships EXTENDED); existing customers are not touched
Print Offers/orders: "Zahlungsart: Überweisung, zahlbar innerhalb von 21 Tagen nach Rechnungsdatum." The billing interval ("monatlich") ignores the negative discount line
Invoice mail "Den Betrag ziehen wir … ein" only when the customer has a mandate reference; otherwise "Bitte überweisen …"

Each step reports missing (not created) instead of failing when a company bank account with IBAN or account 4700 does not exist.

Why a discount line

eu_einvoice cannot carry a document-level discount: it warns and folds it into the line prices (net_rate), so the XML would show reduced line prices while the PDF shows list prices and "Rabatt". A negative line reads the same in both. eu_einvoice flips its sign into a negative quantity (BR-27).

Open for the tax advisor

Non-EU B2B services are mapped to G as a stand-in. The precise O forbids the seller VAT ID (BR-O-02), which eu_einvoice always sends. This does not affect K-00001 (domestic). Ask the tax advisor before the first invoice outside the EU.

Not in this PR

  • Ghostscript in the ERP image for PDF/A-3. That is an orca-infra image change for the next ERP window, together with the entrypoint fix from #42.
  • Switching K-00001 to the profile EN 16931 and the terms "Überweisung 21 Tage", and moving the quotation's 119 € onto a RABATT line: customer data and documents, done by hand.

Tests

go test ./internal/erpsetup covers the codes and their links, the transfer account and terms, the discount item's accounts, the settings and profile default, the "missing" reports, the update of codes when tax templates change, and a second run that changes nothing.

🤖 Generated with Claude Code

Backlog #16 (VD-04): outgoing e-invoices with eu_einvoice v15.16.2 on ERPNext 15.112, plus the two decisions from 2026-10-20 (discount as a line, transfer with 21 days). ## What erpsetup adds | Area | Change | |---|---| | Code lists | Code List docs named by the URNs eu_einvoice looks up (Rec 20, UNTDID 4461, UNTDID 5305, VATEX), with only the codes we use and their mapping: Monat → MON, Jahr → ANN, Prüfung/Stück → C62; Überweisung (+ template) → 58, SEPA-Lastschrift (+ template) → 59; reverse-charge templates → AE / vatex-eu-ae; non-EU templates → G / vatex-eu-g. Everything else keeps eu_einvoice's fallback (C62, ZZZ, S). ERPNext 15.112 refuses to import a list from a URL, so no full lists | | Payment by transfer | Mode of Payment **Überweisung** (type Bank) on the GL account of the company Bank Account (so the e-invoice carries our IBAN, which code 58 requires) and payment terms **Überweisung 21 Tage** | | Discount | Item **RABATT** (sales, non-stock, unit Stück): a discount is a negative line. Income account SKR04 **4700** when the chart has it, cost center Verwaltung | | Validation | E Invoice Settings: validate on save (warning), on submit (block) | | Profile | New customers default to **EN 16931** (eu_einvoice ships EXTENDED); existing customers are not touched | | Print | Offers/orders: "Zahlungsart: Überweisung, zahlbar innerhalb von 21 Tagen nach Rechnungsdatum." The billing interval ("monatlich") ignores the negative discount line | | Invoice mail | "Den Betrag ziehen wir … ein" only when the customer has a mandate reference; otherwise "Bitte überweisen …" | Each step reports `missing (not created)` instead of failing when a company bank account with IBAN or account 4700 does not exist. ## Why a discount line eu_einvoice cannot carry a document-level discount: it warns and folds it into the line prices (net_rate), so the XML would show reduced line prices while the PDF shows list prices and "Rabatt". A negative line reads the same in both. eu_einvoice flips its sign into a negative quantity (BR-27). ## Open for the tax advisor Non-EU B2B services are mapped to **G** as a stand-in. The precise **O** forbids the seller VAT ID (BR-O-02), which eu_einvoice always sends. This does not affect K-00001 (domestic). Ask the tax advisor before the first invoice outside the EU. ## Not in this PR - Ghostscript in the ERP image for PDF/A-3. That is an orca-infra image change for the next ERP window, together with the entrypoint fix from #42. - Switching K-00001 to the profile EN 16931 and the terms "Überweisung 21 Tage", and moving the quotation's 119 € onto a RABATT line: customer data and documents, done by hand. ## Tests `go test ./internal/erpsetup` covers the codes and their links, the transfer account and terms, the discount item's accounts, the settings and profile default, the "missing" reports, the update of codes when tax templates change, and a second run that changes nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-10-20 08:58:01 +00:00
feat(erpsetup): outgoing e-invoices, payment by transfer, discount line
ci / shared (pull_request) Successful in 14s
ci / test (pull_request) Successful in 25m31s
ci / image (pull_request) Skipped
bcaa96ff87
Backlog #16 (VD-04) for eu_einvoice v15.16.2 on ERPNext 15.112:

- Code Lists by the URNs eu_einvoice looks up, with only the codes our
  documents use: units (Monat MON, Jahr ANN, Prüfung/Stück C62), payment
  means (Überweisung 58, SEPA-Lastschrift 59, by Mode of Payment and
  Payment Terms Template), tax categories of the reverse-charge (AE) and
  non-EU (G, stand-in, see comment) templates with their VATEX codes.
  ERPNext 15.112 no longer imports a list from a URL.
- Mode of Payment "Überweisung" on the company bank account's GL account
  (so the e-invoice carries our IBAN, required for 58) and the payment
  terms "Überweisung 21 Tage": same 21 days as the direct debit, for
  customers without a signed mandate (decided 2026-10-20).
- Item RABATT for a discount as a negative line; eu_einvoice cannot carry
  a document discount (it folds it into the line prices, so XML and PDF
  disagree). Revenue reduction on SKR04 4700, cost center Verwaltung.
- E Invoice Settings: validate on save (warning) and submit (block).
- New customers default to the profile EN 16931.
- Print: offers and orders name the transfer and its days; the billing
  interval ignores the discount line. Invoice mail: "ziehen wir ein" only
  with a mandate on the customer, otherwise "bitte überweisen".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit c3bb7702dc into main 2026-10-20 09:32:06 +00:00
Sign in to join this conversation.