@fin.cx/chartdata 2.14.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fin.cx/chartdata",
3
- "version": "2.14.0",
3
+ "version": "2.16.0",
4
4
  "private": false,
5
5
  "description": "Year-versioned German SKR03/SKR04 chart-of-accounts datasets with Automatikkonto functions, BU-key rules, UStVA-Kennzahl and Anlage EÜR mappings",
6
6
  "main": "dist_ts/index.js",
package/readme.md CHANGED
@@ -27,6 +27,18 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
27
27
  not tell it apart from the others of its position: a fixed asset's sale
28
28
  proceeds (`asset_sale_proceeds`) and the book value of a disposed fixed
29
29
  asset (`disposal_book_value`), listed per chart by `getAccountsByRole`
30
+ - Securities accounts (Wertpapiere) with their securities role
31
+ (`securitiesRole`): the holdings of fixed and current assets, their income,
32
+ their sale (net for current assets, gross on a Finanzanlage's disposal
33
+ accounts), the costs of a sale, write-downs and write-ups, the taxes withheld
34
+ from their income and the margin interest, listed per chart by
35
+ `getAccountsBySecuritiesRole` and found one by one with `getSecuritiesAccount`
36
+ - DATEV's mark "HB" (`commercialOnly`): an account posted in the commercial
37
+ balance sheet only
38
+ - The tax rule an income or expense account is kept for (`taxRule`):
39
+ `estg_3_40_kstg_8b` on every account DATEV names "§ 3 Nr. 40 EStG bzw. § 8b …
40
+ KStG", whose income DATEV's corporate-tax interface treats as tax-free and
41
+ whose expenses as non-deductible
30
42
  - Account→Anlage EÜR mappings (`euer`) for the Einnahmenüberschussrechnung
31
43
  (§ 4 Abs. 3 EStG, § 60 Abs. 4 EStDV), with the lines of the 2025 and 2026
32
44
  forms (`ANLAGE_EUER_FORMS`); every account maps or is excluded with its
@@ -75,6 +87,61 @@ getAccountsByRole('SKR04', 2026, 'disposal_book_value').map((account) => account
75
87
  // ['4855', '4856', '4857', '4858', '6895', '6896', '6897', '6898']
76
88
  ```
77
89
 
90
+ ### Securities
91
+
92
+ A booking of securities finds its account by the securities role and the tax
93
+ rule; within a chart no two accounts share both. DATEV keeps an account under
94
+ § 3 Nr. 40 EStG / § 8b KStG beside most ordinary ones (`taxRule:
95
+ 'estg_3_40_kstg_8b'`); whether a dividend or a gain belongs there is the
96
+ booking's decision, not the account's: a holding of less than 10 % at the start
97
+ of the calendar year receives taxable dividends (§ 8b Abs. 4 KStG), while a
98
+ share's sale gain falls under § 8b Abs. 2 KStG whatever the holding.
99
+
100
+ ```ts
101
+ import { getSecuritiesAccount, getAccountsBySecuritiesRole } from '@fin.cx/chartdata';
102
+
103
+ getSecuritiesAccount('SKR04', 2026, 'holding_current')?.accountNumber; // '1510' Sonstige Wertpapiere
104
+ getSecuritiesAccount('SKR04', 2026, 'sale_gain_current', 'estg_3_40_kstg_8b')?.accountNumber; // '4906'
105
+ getSecuritiesAccount('SKR03', 2026, 'income_current')?.accountNumber; // '2654'
106
+ getSecuritiesAccount('SKR03', 2026, 'income_current', 'estg_3_40_kstg_8b')?.accountNumber; // '2655'
107
+ getSecuritiesAccount('SKR03', 2026, 'sale_costs_gain'); // null: DATEV keeps the costs of a sale only under § 8b
108
+ getAccountsBySecuritiesRole('SKR03', 2026, 'sale_proceeds_fixed_gain').map((account) => account.accountNumber);
109
+ // ['8838', '8839']: a Finanzanlage's sale stated gross, on the accounts of a fixed asset's disposal
110
+ ```
111
+
112
+ | Role | What it books | SKR03 | SKR04 |
113
+ | --- | --- | --- | --- |
114
+ | `holding_fixed`, `holding_fixed_shares`, `holding_fixed_bonds` | Wertpapiere des Anlagevermögens (A.III.5) | 0525, 0530, 0535 | 0900, 0910, 0920 |
115
+ | `holding_current` | Sonstige Wertpapiere (B.III.2) | 1348 | 1510 |
116
+ | `income_fixed` / `income_current` | dividends, distributions, coupons (GuV 10 / 11) | 2620 (§ 8b 2625) / 2654 (§ 8b 2655) | 7010 (§ 8b 7014) / 7115 (§ 8b 7103) |
117
+ | `sale_gain_current` / `sale_loss_current` | a current asset's sale, net (GuV 4 / 8) | 2725 (§ 8b 2726) / 2325 (§ 8b 2326) | 4905 (§ 8b 4906) / 6905 (§ 8b 6906) |
118
+ | `sale_proceeds_fixed_*`, `book_value_fixed_*` | a Finanzanlage's sale, gross | 8838/8818, 2317/2312 (§ 8b 8839/8819, 2318/2313) | 4851/6891, 4857/6897 (§ 8b 4852/6892, 4858/6898) |
119
+ | `sale_costs_gain` / `sale_costs_loss` | the costs of a sale under § 8b KStG | 4976 / 4977 | 6857 / 6858 |
120
+ | `writedown_fixed_lasting`, `writedown_fixed_temporary`, `writedown_current` | write-downs (GuV 12) | 4870 (§ 8b 4871), 4866, 4875 (§ 8b 4876) | 7200 (§ 8b 7204), 7201, 7210 (§ 8b 7214) |
121
+ | `writeup_fixed`, `writeup_current`, `writeup` | write-ups (GuV 4) | 2712, 2715, § 8b 2714 | 4912, 4915, § 8b 4914 |
122
+ | `capital_gains_tax`, `capital_gains_tax_soli` | Kapitalertragsteuer and its Solidaritätszuschlag (GuV 14) | 2213, 2216 | 7630, 7633 |
123
+ | `foreign_withholding_tax`, `foreign_tax_exempt_income` | foreign tax to credit or deduct; on income exempt at home (GuV 14) | 2219, 2218 | 7639, 7638 |
124
+ | `foreign_tax_refund` | a foreign tax to be refunded (B.II.4) | 1542 | 1440 |
125
+ | `margin_interest` | interest on a short-term debt (GuV 13) | 2110 | 7310 |
126
+ | `borrow_fees` | interest-like expenses such as the fees of securities borrowed (GuV 13) | 2140 | 7330 |
127
+ | `writedown_other_current` | a write-down of a current asset that is no security, usual amount: an option bought, a margin paid (GuV 8) | 4886 | 6910 |
128
+ | `expected_loss_provision` | the provision for an expected loss from a pending transaction, a written option (B.3; HB) | 0976 | 3092 |
129
+ | `provision_release` | the income of a provision released (GuV 4) | 2735 | 4930 |
130
+
131
+ None of them carries a tax function or a UStVA figure. DATEV marks the provision
132
+ for an expected loss "HB" (`commercialOnly`): it is posted in the commercial
133
+ balance sheet only, as § 5 Abs. 4a EStG allows none in the tax balance sheet;
134
+ so do the write-downs of a Finanzanlage for a decline that does not last (SKR03
135
+ 4866, SKR04 7201), which tax law allows only for a lasting one. In the Anlage EÜR the
136
+ holdings are no part of the form (fixed assets reach it by their residual book
137
+ value, current ones of § 4 Abs. 3 Satz 4 EStG by their cost when sold:
138
+ `deferred_current_asset`); income and gains on sale are receipts free of VAT or
139
+ not taxable for VAT (Kz 103), a loss on sale is cost at the sale (Kz 100), the costs of a
140
+ sale other expenses (Kz 183), write-downs and write-ups values at a closing date
141
+ (`valuation`), so are a provision and its release, the margin interest and
142
+ interest-like expenses other debt interest (Kz 234), and the taxes on income a
143
+ withdrawal (Kz 122, § 12 Nr. 3 EStG).
144
+
78
145
  ### Anlage EÜR
79
146
 
80
147
  Every account of a chart either maps to the Anlage EÜR or is excluded from it
@@ -112,7 +179,9 @@ getMappingCoverage('SKR04', 2026, usedAccountNumbers, 'euer').missing; // []
112
179
  `pass_through` (§ 4 Abs. 3 Satz 2 EStG), `reverse_charge` (the tax of an
113
180
  intra-Community acquisition or under § 13b UStG: such invoices contain no
114
181
  input tax, Anleitung zur Anlage EÜR, Zeile 58, and the tax is no receipt;
115
- what a return leaves to pay counts as paid VAT, Kz 186) and `closing`.
182
+ what a return leaves to pay counts as paid VAT, Kz 186), `closing` and
183
+ `deferred_current_asset` (shares, securities, land and buildings held as
184
+ current assets, whose cost counts at their sale, § 4 Abs. 3 Satz 4 EStG).
116
185
  - A line's `sign` says how it enters its section's sum: 1 adds, -1 subtracts
117
186
  (Zeilen 73 and 75), 0 not at all (a "davon" line, the column "nicht
118
187
  abziehbar", the Entnahmen and Einlagen).
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@fin.cx/chartdata',
6
- version: '2.14.0',
6
+ version: '2.16.0',
7
7
  description: 'Year-versioned German SKR03/SKR04 chart-of-accounts datasets with Automatikkonto functions, BU-key rules, UStVA-Kennzahl and Anlage EÜR mappings'
8
8
  }
@@ -7,6 +7,8 @@ import type {
7
7
  TChartName,
8
8
  TEuerAccountLines,
9
9
  TMappingDimension,
10
+ TSecuritiesRole,
11
+ TTaxRule,
10
12
  } from './chartdata.types.js';
11
13
  import { euerLinesOf, type IEuerLinesOptions } from './chartdata.euer.js';
12
14
  import { SKR03_2026 } from './data/skr03.2026.js';
@@ -83,6 +85,34 @@ export function getAccountsByRole(
83
85
  return getChart(chart, year).accounts.filter((account) => account.accountRole === role);
84
86
  }
85
87
 
88
+ /**
89
+ * The accounts of a chart with the securities role (`IChartAccount.securitiesRole`),
90
+ * in the chart's order: one without a tax rule and, where DATEV keeps one apart,
91
+ * one under § 3 Nr. 40 EStG / § 8b KStG. Throws for unknown chart/year
92
+ * combinations, as `getChart`.
93
+ */
94
+ export function getAccountsBySecuritiesRole(
95
+ chart: TChartName,
96
+ year: number,
97
+ role: TSecuritiesRole,
98
+ ): IChartAccount[] {
99
+ return getChart(chart, year).accounts.filter((account) => account.securitiesRole === role);
100
+ }
101
+
102
+ /**
103
+ * The one account of a chart that books the securities role under the tax rule
104
+ * (`taxRule`; none: the account without one), or `null` where the chart keeps
105
+ * none for it. Throws for unknown chart/year combinations, as `getChart`.
106
+ */
107
+ export function getSecuritiesAccount(
108
+ chart: TChartName,
109
+ year: number,
110
+ role: TSecuritiesRole,
111
+ taxRule?: TTaxRule,
112
+ ): IChartAccount | null {
113
+ return getAccountsBySecuritiesRole(chart, year, role).find((account) => account.taxRule === taxRule) ?? null;
114
+ }
115
+
86
116
  function hasMapping(account: IChartAccount, dimension: TMappingDimension): boolean {
87
117
  switch (dimension) {
88
118
  case 'ustva':
@@ -16,6 +16,96 @@ export type TAccountType = 'asset' | 'liability' | 'equity' | 'revenue' | 'expen
16
16
  */
17
17
  export type TAccountRole = 'asset_sale_proceeds' | 'disposal_book_value';
18
18
 
19
+ /**
20
+ * What an account books of a business's securities (Wertpapiere): holding
21
+ * them, their income, their sale, their valuation at a closing date and the
22
+ * taxes withheld from their income. A booking of securities finds its
23
+ * account by this role together with the account's `taxRule`: within a
24
+ * chart, no two accounts share both.
25
+ * - holdings, by the balance-sheet item (§ 266 Abs. 2 HGB):
26
+ * 'holding_fixed' (Wertpapiere des Anlagevermögens, A.III.5),
27
+ * 'holding_fixed_shares' (those whose income falls under the
28
+ * Teileinkünfteverfahren, A.III.5), 'holding_fixed_bonds' (fixed-interest
29
+ * ones, A.III.5), 'holding_current' (sonstige Wertpapiere, B.III.2);
30
+ * - their income (dividends, distributions, coupons) by whether the
31
+ * securities are fixed or current assets: 'income_fixed', 'income_current';
32
+ * - the sale of current assets, stated net: 'sale_gain_current',
33
+ * 'sale_loss_current';
34
+ * - the sale of fixed assets, stated gross on the accounts of a fixed asset's
35
+ * disposal (`accountRole`): what it fetched, 'sale_proceeds_fixed_gain' and
36
+ * 'sale_proceeds_fixed_loss', and the book value it leaves the books with,
37
+ * 'book_value_fixed_gain' and 'book_value_fixed_loss', by whether the sale
38
+ * makes a book gain or a book loss;
39
+ * - the costs of a sale DATEV states apart, 'sale_costs_gain' and
40
+ * 'sale_costs_loss' (§ 8b Abs. 2 Satz 2 KStG);
41
+ * - the valuation at a closing date (§ 253 Abs. 3 to 5 HGB): a fixed asset's
42
+ * write-down for a lasting or a temporary decline,
43
+ * 'writedown_fixed_lasting' and 'writedown_fixed_temporary', a current
44
+ * asset's, 'writedown_current', and the write-ups, 'writeup_fixed',
45
+ * 'writeup_current', and 'writeup' where one account takes either;
46
+ * - the taxes withheld from their income: 'capital_gains_tax'
47
+ * (Kapitalertragsteuer) and 'capital_gains_tax_soli' (the Solidaritätszuschlag
48
+ * on it), 'foreign_withholding_tax' (a foreign tax to be credited or
49
+ * deducted), 'foreign_tax_exempt_income' (a foreign tax on income exempt at
50
+ * home), and 'foreign_tax_refund' (a foreign tax to be refunded);
51
+ * - 'margin_interest': the interest on a short-term debt, such as a broker's
52
+ * margin loan;
53
+ * - 'borrow_fees': interest-like expenses (zinsähnliche Aufwendungen), such as
54
+ * the fees of securities borrowed for a short sale;
55
+ * - 'writedown_other_current': the write-down of a current asset that is
56
+ * neither inventory nor a security, at the usual amount (an option bought,
57
+ * a variation margin paid);
58
+ * - 'expected_loss_provision': the provision for an expected loss from a
59
+ * pending transaction (§ 249 Abs. 1 HGB: a written option worth more than
60
+ * its premium), which tax law does not allow (§ 5 Abs. 4a EStG);
61
+ * - 'provision_release': the income of a provision released.
62
+ */
63
+ export type TSecuritiesRole =
64
+ | 'holding_fixed'
65
+ | 'holding_fixed_shares'
66
+ | 'holding_fixed_bonds'
67
+ | 'holding_current'
68
+ | 'income_fixed'
69
+ | 'income_current'
70
+ | 'sale_gain_current'
71
+ | 'sale_loss_current'
72
+ | 'sale_proceeds_fixed_gain'
73
+ | 'sale_proceeds_fixed_loss'
74
+ | 'book_value_fixed_gain'
75
+ | 'book_value_fixed_loss'
76
+ | 'sale_costs_gain'
77
+ | 'sale_costs_loss'
78
+ | 'writedown_fixed_lasting'
79
+ | 'writedown_fixed_temporary'
80
+ | 'writedown_current'
81
+ | 'writeup_fixed'
82
+ | 'writeup_current'
83
+ | 'writeup'
84
+ | 'capital_gains_tax'
85
+ | 'capital_gains_tax_soli'
86
+ | 'foreign_withholding_tax'
87
+ | 'foreign_tax_exempt_income'
88
+ | 'foreign_tax_refund'
89
+ | 'margin_interest'
90
+ | 'borrow_fees'
91
+ | 'writedown_other_current'
92
+ | 'expected_loss_provision'
93
+ | 'provision_release';
94
+
95
+ /**
96
+ * A rule of the income tax law an income or expense account is kept for, as
97
+ * its DATEV name states it:
98
+ * - 'estg_3_40_kstg_8b': income from shares and the expenses of it under the
99
+ * Teileinkünfteverfahren (§ 3 Nr. 40, § 3c Abs. 2 EStG) or, for a
100
+ * corporation, § 8b KStG — DATEV names these accounts "§ 3 Nr. 40 EStG bzw.
101
+ * § 8b … KStG". DATEV's interface to the corporate income tax treats their
102
+ * income as 100 % tax-free and their expenses as 100 % non-deductible, its
103
+ * interface to the trade tax 40 % each (Kontenrahmen SKR 03 and SKR 04,
104
+ * gültig für 2026, footnote 9); the corrections are made in the return, not
105
+ * in the books.
106
+ */
107
+ export type TTaxRule = 'estg_3_40_kstg_8b';
108
+
19
109
  /**
20
110
  * Built-in DATEV tax automatism of an account. Lines on automatik accounts
21
111
  * must carry no BU key (automatism applies) or key 40 (automatism cancelled).
@@ -69,7 +159,12 @@ export type TEuerMapping = { kennzahl: number } | { debitKennzahl: number; credi
69
159
  * return: no receipt and no payment of its own (Anleitung zur Anlage EÜR,
70
160
  * Zeile 58); what a return leaves to pay counts as paid VAT (Kz 186);
71
161
  * - 'closing': a carry-forward, closing or statistical account, which records
72
- * no business transaction.
162
+ * no business transaction;
163
+ * - 'deferred_current_asset': a current asset named in § 4 Abs. 3 Satz 4
164
+ * EStG — shares, securities, land and buildings —, whose cost counts only
165
+ * when its sale's proceeds are received or it is withdrawn, as goods
166
+ * (Zeile 29, Kz 100), through the list of such assets in the Anlage AVEÜR
167
+ * (Zeilen 93 bis 96), not when it is paid.
73
168
  */
74
169
  export type TEuerExclusion =
75
170
  | 'balance_sheet'
@@ -78,7 +173,8 @@ export type TEuerExclusion =
78
173
  | 'valuation'
79
174
  | 'pass_through'
80
175
  | 'reverse_charge'
81
- | 'closing';
176
+ | 'closing'
177
+ | 'deferred_current_asset';
82
178
 
83
179
  /**
84
180
  * The part of the Anlage EÜR a line belongs to: Betriebseinnahmen (Zeilen
@@ -137,6 +233,15 @@ export interface IChartAccount {
137
233
  accountType: TAccountType;
138
234
  /** what the account is for beyond its type and HGB position; unset = they say it all */
139
235
  accountRole?: TAccountRole;
236
+ /** what the account books of a business's securities; unset = nothing of its own */
237
+ securitiesRole?: TSecuritiesRole;
238
+ /** the income tax rule the account is kept for, as its DATEV name states it; unset = none of its own */
239
+ taxRule?: TTaxRule;
240
+ /**
241
+ * DATEV's mark "HB": the account is posted in the commercial balance sheet only (Handelsbilanz), its amounts
242
+ * are no part of the tax balance sheet; unset = both
243
+ */
244
+ commercialOnly?: true;
140
245
  description?: string;
141
246
  automatikFunction?: TAutomatikFunction;
142
247
  /** BU keys allowed on lines of this account ('' = none). Unset = all. */