|
| 1 | +# german-accounting |
| 2 | + |
| 3 | +Machine-readable SKR03/SKR04 chart of accounts with MCC-to-account mapping for German SME accounting. MIT licensed — code and data. |
| 4 | + |
| 5 | +The only open source dataset combining enriched SKR03/SKR04 metadata with ISO 18245 MCC codes mapped to specific German accounts. Use it from any language: download the JSON files directly or install the npm package for a typed TypeScript API. |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install german-accounting |
| 9 | +``` |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Quick start |
| 14 | + |
| 15 | +```typescript |
| 16 | +import { SKR03, suggestAccount } from "german-accounting"; |
| 17 | + |
| 18 | +// Look up an account |
| 19 | +const konto = SKR03.get("4650"); |
| 20 | +// { konto: "4650", name: "Bewirtungskosten", klasse: 4, typ: "aufwand", |
| 21 | +// ust_relevant: true, steuerschluessel: [9], skr04: "6640", ... } |
| 22 | + |
| 23 | +// Categorize a card transaction by MCC |
| 24 | +const suggestion = suggestAccount("5812"); // restaurant |
| 25 | +// { |
| 26 | +// mcc: "5812", |
| 27 | +// mcc_name: "Eating Places, Restaurants", |
| 28 | +// primary: { konto: "4650", confidence: "high", condition: null }, |
| 29 | +// alternatives: [{ konto: "1800", condition: "If private meal" }], |
| 30 | +// needs_beleg: true, |
| 31 | +// ust_abzug: true |
| 32 | +// } |
| 33 | + |
| 34 | +// SaaS subscriptions (GitHub, Slack, Notion, Figma...) |
| 35 | +suggestAccount("5817").primary.konto; // "4969" — Software-Nutzungsrechte |
| 36 | + |
| 37 | +// Target SKR04 instead of SKR03 |
| 38 | +suggestAccount("5812", "SKR04").primary.konto; // "6640" |
| 39 | + |
| 40 | +// Returns undefined for unknown MCCs — no throws |
| 41 | +suggestAccount("9999"); // undefined |
| 42 | +``` |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## API |
| 47 | + |
| 48 | +### `SKR03` / `SKR04` |
| 49 | + |
| 50 | +Pre-loaded chart-of-accounts singletons. Both are instances of `Kontenrahmen`. |
| 51 | + |
| 52 | +```typescript |
| 53 | +SKR03.get("4650") // → Konto | undefined |
| 54 | +SKR03.search("Reisekosten") // → readonly Konto[] (case-insensitive substring) |
| 55 | +SKR03.klasse(4) // → readonly Konto[] (all Klasse 4 expense accounts) |
| 56 | +SKR03.exists("4650") // → boolean |
| 57 | +SKR03.size // → number |
| 58 | +``` |
| 59 | + |
| 60 | +### `suggestAccount(mcc, skr?)` |
| 61 | + |
| 62 | +```typescript |
| 63 | +suggestAccount(mcc: string, skr?: "SKR03" | "SKR04"): MCCSuggestion | undefined |
| 64 | +``` |
| 65 | + |
| 66 | +MCC range entries (airlines `3000–3350`, hotels `3351–3500`, car rentals `3501–3999`) are expanded at load time. Any code in those ranges resolves correctly. |
| 67 | + |
| 68 | +When `skr = "SKR04"`, the primary account is the `skr04_primary` value. `name` is `null` and `alternatives` is empty (no SKR04 name data in v0.1). |
| 69 | + |
| 70 | +### Types |
| 71 | + |
| 72 | +```typescript |
| 73 | +interface Konto { |
| 74 | + konto: string; // "4650" |
| 75 | + name: string; // "Bewirtungskosten" |
| 76 | + klasse: number; // 4 |
| 77 | + typ: "aufwand" | "ertrag" | "aktiv" | "passiv"; |
| 78 | + gruppe: string; |
| 79 | + untergruppe?: string; |
| 80 | + ust_relevant: boolean; |
| 81 | + steuerschluessel: readonly number[]; |
| 82 | + skr04?: string | null; // cross-ref to SKR04 account (SKR03 only) |
| 83 | + skr03?: string | null; // back-ref to SKR03 account (SKR04 only) |
| 84 | + notes?: string | null; |
| 85 | +} |
| 86 | + |
| 87 | +interface MCCSuggestion { |
| 88 | + mcc: string; |
| 89 | + mcc_name: string; |
| 90 | + category: string; |
| 91 | + primary: AccountSuggestion; |
| 92 | + alternatives: readonly AccountSuggestion[]; |
| 93 | + needs_beleg: boolean; |
| 94 | + ust_abzug: boolean; |
| 95 | + notes: string | null; |
| 96 | +} |
| 97 | + |
| 98 | +interface AccountSuggestion { |
| 99 | + konto: string; |
| 100 | + name: string | null; |
| 101 | + confidence: "high" | "medium" | "low"; |
| 102 | + condition: string | null; |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## Data files |
| 109 | + |
| 110 | +The JSON files are the primary product. Download them from [GitHub Releases](https://github.com/german-accounting/german-accounting/releases) to use without Node. |
| 111 | + |
| 112 | +| File | Contents | |
| 113 | +|------|----------| |
| 114 | +| [`src/data/skr03.json`](src/data/skr03.json) | 289 SKR03 accounts with enriched metadata and SKR04 cross-references | |
| 115 | +| [`src/data/skr04.json`](src/data/skr04.json) | 254 SKR04 accounts derived from SKR03 cross-references | |
| 116 | +| [`src/data/mcc_skr_mapping.json`](src/data/mcc_skr_mapping.json) | 230 MCC mappings with confidence levels and alternatives | |
| 117 | + |
| 118 | +JSON Schemas are in [`schemas/`](schemas/) and validated by CI on every push. |
| 119 | + |
| 120 | +### Data schema — `skr03.json` |
| 121 | + |
| 122 | +```jsonc |
| 123 | +{ |
| 124 | + "meta": { "version": "2026.1", "last_updated": "2026-04-03", ... }, |
| 125 | + "klassen": [{ "klasse": 0, "name": "Anlage- und Kapitalkonten" }, ...], |
| 126 | + "konten": [ |
| 127 | + { |
| 128 | + "konto": "4650", |
| 129 | + "name": "Bewirtungskosten", |
| 130 | + "klasse": 4, |
| 131 | + "typ": "aufwand", |
| 132 | + "gruppe": "Betriebliche Aufwendungen", |
| 133 | + "ust_relevant": true, |
| 134 | + "steuerschluessel": [9, 8], |
| 135 | + "skr04": "6640" |
| 136 | + } |
| 137 | + ] |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +### Data schema — `mcc_skr_mapping.json` |
| 142 | + |
| 143 | +```jsonc |
| 144 | +{ |
| 145 | + "meta": { "version": "2026.1", ... }, |
| 146 | + "mappings": [ |
| 147 | + { |
| 148 | + "mcc": "5812", |
| 149 | + "mcc_name": "Eating Places, Restaurants", |
| 150 | + "category": "Food & Beverage", |
| 151 | + "skr03": { "primary": "4650", "confidence": "high" }, |
| 152 | + "skr04_primary": "6640", |
| 153 | + "alternatives": [ |
| 154 | + { "konto": "1800", "condition": "If private meal" } |
| 155 | + ], |
| 156 | + "needs_beleg": true, |
| 157 | + "ust_abzug": true |
| 158 | + } |
| 159 | + ] |
| 160 | +} |
| 161 | +``` |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +## Contributing |
| 166 | + |
| 167 | +### Add or fix an MCC mapping |
| 168 | + |
| 169 | +1. Edit `mcc_skr_mapping.json`. Required fields: `mcc`, `mcc_name`, `category`, `skr03.primary`, `skr03.confidence`, `skr04_primary`, `needs_beleg`, `ust_abzug`. |
| 170 | +2. Run `npm test` — CI gate verifies that all referenced accounts exist in `skr03.json`. |
| 171 | +3. Open a PR using the [MCC mapping template](.github/PULL_REQUEST_TEMPLATE/mcc_mapping.md). Include the account number, confidence level, your rationale, and your source (DATEV docs, Steuerberater guidance, SKR documentation). |
| 172 | + |
| 173 | +**Confidence guidelines:** |
| 174 | +- `high` — the MCC strongly implies a specific account with no real ambiguity (e.g., fuel stations → Kfz-Betriebskosten) |
| 175 | +- `medium` — likely correct but depends on context (e.g., office supply store → could be Bürobedarf or a larger asset) |
| 176 | +- `low` — genuinely ambiguous; the mapping is a reasonable default but alternatives are common |
| 177 | + |
| 178 | +### Add or fix SKR03 accounts |
| 179 | + |
| 180 | +Edit `skr03.json` directly. All fields from the schema are required. Run `npm test` to verify referential integrity before opening a PR. |
| 181 | + |
| 182 | +--- |
| 183 | + |
| 184 | +## Versioning |
| 185 | + |
| 186 | +Data is versioned independently from the package using a year-based scheme (`2026.1`, `2026.2`, ...). The package version tracks the API. |
| 187 | + |
| 188 | +--- |
| 189 | + |
| 190 | +## License |
| 191 | + |
| 192 | +[MIT](LICENSE) — code and data. |
0 commit comments