Files
tenant-registry/internal/erpsetup/reisekosten.go
sharangandClaude Opus 5.5 6a640d553f
ci / shared (push) Successful in 13s
ci / test (push) Successful in 25m57s
ci / image (push) Successful in 37s
feat(erpsetup): Reisekosten expense claim types with SKR04 accounts (#87)
The 22 Expense Claim Types of the Reisekosten app, each with its standard SKR04 Arbeitnehmer account for Breakpilot GmbH (decided 2026-10-20), and breakpilot_report_id (unique) on Expense Claim as the relay's idempotency key. Backlog #39 (a)+(b).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 11:07:48 +00:00

88 lines
3.4 KiB
Go

package erpsetup
// Travel expenses (backlog #39): the Reisekosten app hands an approved
// report to ERPNext as an Expense Claim (HRMS). Each line names an Expense
// Claim Type, exactly as in the app's src/config/erpnext-mapping.json, and
// the type carries the expense account per company. The accounts are our
// own choice of the standard SKR04 accounts (decided 2026-10-20), changed
// only if the tax advisor books differently. Managing directors of a GmbH
// are employees, hence the "Reisekosten Arbeitnehmer" accounts.
//
// The report id on the claim (breakpilot_report_id, unique) makes the relay
// idempotent (#40). The company's HR accounts (payable for expense claims,
// employee advances) wait for the tax advisor's expense account.
import (
"context"
"fmt"
)
type expenseType struct{ Name, Account string }
// expenseTypes: the 22 types of the app with their SKR04 account.
func expenseTypes() []expenseType {
return []expenseType{
{"Reisekosten Bahn", "6663"},
{"Reisekosten Flug", "6663"},
{"Reisekosten ÖPNV", "6663"},
{"Reisekosten Taxi", "6663"},
{"Reisekosten Mietwagen", "6663"},
{"Reisekosten Carsharing", "6663"},
{"Reisekosten Kraftstoff", "6663"}, // rental car or car sharing; a private car is covered by the Kilometerpauschale
{"Reisekosten Ladestrom", "6663"},
{"Reisekosten Fähre", "6663"},
{"Reisekosten Übernachtung", "6660"},
{"Reisekosten Verpflegung", "6650"}, // own meals on top of the per diem: wage-tax check (app flag "Sachbezug prüfen")
{"Reisenebenkosten Parken", "6650"},
{"Reisenebenkosten Maut", "6650"},
{"Reisenebenkosten Gebühren", "6650"},
{"Reisenebenkosten Sonstige", "6650"},
{"Bewirtung", "6640"}, // 30 % not deductible (6644), split by the tax advisor
{"Messe / Konferenz", "6600"}, // trade fairs; pure training would be 6821
{"Telekommunikation", "6805"},
{"Bürobedarf", "6815"},
{"Sonderausgabe (Prüfung)", "6300"}, // always checked by hand
{"Kilometerpauschale", "6668"},
{"Verpflegungsmehraufwand (steuerfrei)", "6664"},
}
}
func reportIDField() map[string]any {
f := customField("Expense Claim", "breakpilot_report_id", "Reisekostenabrechnung", "Data", "employee_name", true)
f["read_only"] = 1
f["description"] = "Von der Reisekosten-App gesetzt: die Abrechnung, aus der diese Spesenabrechnung stammt. Nicht ändern."
return f
}
func (r *runner) reisekosten(ctx context.Context) error {
f := reportIDField()
if err := r.ensure(ctx, "Custom Field", f["name"].(string), fmt.Sprintf("custom field %s.%s", f["dt"], f["fieldname"]), f); err != nil {
return err
}
accounts := map[string]string{} // SKR04 number → account name, "" when missing
for _, t := range expenseTypes() {
if err := r.ensure(ctx, "Expense Claim Type", t.Name, "expense claim type "+t.Name,
map[string]any{"doctype": "Expense Claim Type", "name": t.Name, "expense_type": t.Name}); err != nil {
return err
}
account, seen := accounts[t.Account]
if !seen {
a, err := r.findAccount(ctx, t.Account)
if err != nil {
return err
}
account, accounts[t.Account] = a, a
}
what := "expense claim type " + t.Name + " account " + t.Account
if account == "" {
r.record(what, "missing (not created)")
continue
}
if err := r.ensureChildRow(ctx, "Expense Claim Type", t.Name, "accounts", what,
map[string]any{"company": companyName}, map[string]any{"default_account": account}); err != nil {
return err
}
}
return nil
}