@fin.cx/skr 1.0.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.
Files changed (44) hide show
  1. package/dist_ts/index.d.ts +10 -0
  2. package/dist_ts/index.js +11 -0
  3. package/dist_ts/plugins.d.ts +5 -0
  4. package/dist_ts/plugins.js +7 -0
  5. package/dist_ts/skr.api.d.ts +181 -0
  6. package/dist_ts/skr.api.js +402 -0
  7. package/dist_ts/skr.classes.account.d.ts +34 -0
  8. package/dist_ts/skr.classes.account.js +224 -0
  9. package/dist_ts/skr.classes.chartofaccounts.d.ts +99 -0
  10. package/dist_ts/skr.classes.chartofaccounts.js +377 -0
  11. package/dist_ts/skr.classes.journalentry.d.ts +33 -0
  12. package/dist_ts/skr.classes.journalentry.js +296 -0
  13. package/dist_ts/skr.classes.ledger.d.ts +61 -0
  14. package/dist_ts/skr.classes.ledger.js +363 -0
  15. package/dist_ts/skr.classes.reports.d.ts +55 -0
  16. package/dist_ts/skr.classes.reports.js +514 -0
  17. package/dist_ts/skr.classes.transaction.d.ts +37 -0
  18. package/dist_ts/skr.classes.transaction.js +263 -0
  19. package/dist_ts/skr.database.d.ts +5 -0
  20. package/dist_ts/skr.database.js +28 -0
  21. package/dist_ts/skr.types.d.ts +126 -0
  22. package/dist_ts/skr.types.js +2 -0
  23. package/dist_ts/skr03.data.d.ts +18 -0
  24. package/dist_ts/skr03.data.js +890 -0
  25. package/dist_ts/skr04.data.d.ts +18 -0
  26. package/dist_ts/skr04.data.js +912 -0
  27. package/npmextra.json +17 -0
  28. package/package.json +61 -0
  29. package/readme.hints.md +3 -0
  30. package/readme.md +409 -0
  31. package/readme.plan.md +243 -0
  32. package/ts/index.ts +10 -0
  33. package/ts/plugins.ts +7 -0
  34. package/ts/skr.api.ts +533 -0
  35. package/ts/skr.classes.account.ts +238 -0
  36. package/ts/skr.classes.chartofaccounts.ts +508 -0
  37. package/ts/skr.classes.journalentry.ts +318 -0
  38. package/ts/skr.classes.ledger.ts +528 -0
  39. package/ts/skr.classes.reports.ts +721 -0
  40. package/ts/skr.classes.transaction.ts +300 -0
  41. package/ts/skr.database.ts +39 -0
  42. package/ts/skr.types.ts +154 -0
  43. package/ts/skr03.data.ts +901 -0
  44. package/ts/skr04.data.ts +923 -0
package/npmextra.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "npmci": {
3
+ "npmGlobalTools": [],
4
+ "npmAccessLevel": "public"
5
+ },
6
+ "gitzone": {
7
+ "projectType": "npm",
8
+ "module": {
9
+ "githost": "code.foss.global",
10
+ "gitscope": "fin.cx",
11
+ "gitrepo": "skr",
12
+ "description": "SKR03 and SKR04 German accounting standards for double-entry bookkeeping",
13
+ "npmPackagename": "@fin.cx/skr",
14
+ "license": "MIT"
15
+ }
16
+ }
17
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@fin.cx/skr",
3
+ "version": "1.0.0",
4
+ "description": "SKR03 and SKR04 German accounting standards for double-entry bookkeeping",
5
+ "main": "dist_ts/index.js",
6
+ "typings": "dist_ts/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "test": "tstest test/ --verbose --logfile --timeout=60",
10
+ "build": "tsbuild --web --node",
11
+ "buildDocs": "tsdoc"
12
+ },
13
+ "keywords": [
14
+ "skr03",
15
+ "skr04",
16
+ "accounting",
17
+ "bookkeeping",
18
+ "double-entry",
19
+ "german",
20
+ "datev",
21
+ "mongodb",
22
+ "typescript"
23
+ ],
24
+ "author": "Fin.cx",
25
+ "license": "MIT",
26
+ "packageManager": "pnpm@10.11.0",
27
+ "dependencies": {
28
+ "@push.rocks/smartdata": "^5.15.1",
29
+ "@push.rocks/smartlog": "^3.1.8",
30
+ "@push.rocks/smarttime": "^4.1.1",
31
+ "@push.rocks/smartunique": "^3.0.9"
32
+ },
33
+ "devDependencies": {
34
+ "@git.zone/tsbuild": "^2.6.4",
35
+ "@git.zone/tsrun": "^1.3.3",
36
+ "@git.zone/tstest": "^2.3.2"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://code.foss.global/fin.cx/skr.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://code.foss.global/fin.cx/skr/issues"
44
+ },
45
+ "homepage": "https://code.foss.global/fin.cx/skr#readme",
46
+ "files": [
47
+ "ts/**/*",
48
+ "ts_web/**/*",
49
+ "dist/**/*",
50
+ "dist_*/**/*",
51
+ "dist_ts/**/*",
52
+ "dist_ts_web/**/*",
53
+ "assets/**/*",
54
+ "cli.js",
55
+ "npmextra.json",
56
+ "readme.md"
57
+ ],
58
+ "pnpm": {
59
+ "overrides": {}
60
+ }
61
+ }
@@ -0,0 +1,3 @@
1
+ # Project Readme Hints
2
+
3
+ This is the initial readme hints file.
package/readme.md ADDED
@@ -0,0 +1,409 @@
1
+ # @fin.cx/skr 📊
2
+
3
+ > **Enterprise-grade German accounting standards implementation for SKR03 and SKR04**
4
+ > Double-entry bookkeeping with MongoDB persistence and full TypeScript support
5
+
6
+ ## 🚀 Why @fin.cx/skr?
7
+
8
+ Building compliant German accounting software? You've come to the right place! This module provides a **complete, type-safe implementation** of the German standard charts of accounts (Standardkontenrahmen) SKR03 and SKR04, the backbone of professional accounting in Germany.
9
+
10
+ ### 🎯 What makes it awesome?
11
+
12
+ - **🏢 Enterprise-Ready**: Production-tested implementation following DATEV standards
13
+ - **⚡ Lightning Fast**: MongoDB-powered with optimized indexing and caching
14
+ - **🔒 Type-Safe**: Full TypeScript support with comprehensive type definitions
15
+ - **🎮 Developer-Friendly**: Intuitive API that makes complex accounting operations simple
16
+ - **📈 Real-time Reporting**: Generate financial statements on-the-fly
17
+ - **🔄 Transaction Safety**: Built-in double-entry validation and reversals
18
+
19
+ ## 📦 Installation
20
+
21
+ ```bash
22
+ # Using npm
23
+ npm install @fin.cx/skr
24
+
25
+ # Using pnpm (recommended)
26
+ pnpm add @fin.cx/skr
27
+
28
+ # Using yarn
29
+ yarn add @fin.cx/skr
30
+ ```
31
+
32
+ ## 🎓 Quick Start
33
+
34
+ ### Basic Setup
35
+
36
+ ```typescript
37
+ import { SkrApi } from '@fin.cx/skr';
38
+
39
+ // Initialize the API
40
+ const api = new SkrApi({
41
+ mongoDbUrl: 'mongodb://localhost:27017',
42
+ dbName: 'accounting' // optional, defaults to 'skr_accounting'
43
+ });
44
+
45
+ // Choose your SKR standard (SKR03 or SKR04)
46
+ await api.initialize('SKR03');
47
+ ```
48
+
49
+ ### 💰 Posting Transactions
50
+
51
+ ```typescript
52
+ // Simple transaction posting
53
+ const transaction = await api.postTransaction({
54
+ date: new Date(),
55
+ debitAccount: '1200', // Bank account
56
+ creditAccount: '8400', // Revenue account
57
+ amount: 1190.00,
58
+ description: 'Invoice #2024-001 payment received',
59
+ reference: 'INV-2024-001',
60
+ vatAmount: 190.00
61
+ });
62
+
63
+ // Complex journal entry with multiple lines
64
+ const journalEntry = await api.postJournalEntry({
65
+ date: new Date(),
66
+ description: 'Monthly salary payments',
67
+ reference: 'SAL-2024-03',
68
+ lines: [
69
+ { accountNumber: '6000', debit: 5000.00, description: 'Gross salary' },
70
+ { accountNumber: '4830', credit: 1000.00, description: 'Social security' },
71
+ { accountNumber: '4840', credit: 500.00, description: 'Tax withholding' },
72
+ { accountNumber: '1200', credit: 3500.00, description: 'Net payment' }
73
+ ]
74
+ });
75
+ ```
76
+
77
+ ### 📊 Generating Reports
78
+
79
+ ```typescript
80
+ // Trial Balance
81
+ const trialBalance = await api.generateTrialBalance({
82
+ dateFrom: new Date('2024-01-01'),
83
+ dateTo: new Date('2024-12-31')
84
+ });
85
+
86
+ // Income Statement (P&L)
87
+ const incomeStatement = await api.generateIncomeStatement({
88
+ dateFrom: new Date('2024-01-01'),
89
+ dateTo: new Date('2024-12-31')
90
+ });
91
+
92
+ // Balance Sheet
93
+ const balanceSheet = await api.generateBalanceSheet({
94
+ date: new Date('2024-12-31')
95
+ });
96
+
97
+ // Export for DATEV
98
+ const datevExport = await api.exportDatev({
99
+ dateFrom: new Date('2024-01-01'),
100
+ dateTo: new Date('2024-12-31'),
101
+ format: 'CSV'
102
+ });
103
+ ```
104
+
105
+ ## 🏗️ Core Architecture
106
+
107
+ ### Account Management
108
+
109
+ ```typescript
110
+ // Create custom accounts
111
+ const account = await api.createAccount({
112
+ accountNumber: '1299',
113
+ accountName: 'PayPal Business',
114
+ accountClass: 1,
115
+ accountType: 'asset',
116
+ description: 'PayPal business account for online payments',
117
+ isActive: true
118
+ });
119
+
120
+ // Search accounts
121
+ const accounts = await api.searchAccounts('bank');
122
+
123
+ // Get account balance
124
+ const balance = await api.getAccountBalance('1200');
125
+ console.log(`Balance: ${balance.balance} EUR`);
126
+ console.log(`Debits: ${balance.debitTotal} EUR`);
127
+ console.log(`Credits: ${balance.creditTotal} EUR`);
128
+ ```
129
+
130
+ ### Transaction Management
131
+
132
+ ```typescript
133
+ // Get transaction history
134
+ const transactions = await api.listTransactions({
135
+ accountNumber: '1200',
136
+ dateFrom: new Date('2024-01-01'),
137
+ dateTo: new Date('2024-12-31'),
138
+ minAmount: 100,
139
+ maxAmount: 10000
140
+ });
141
+
142
+ // Reverse a transaction
143
+ const reversal = await api.reverseTransaction(transactionId);
144
+
145
+ // Batch processing
146
+ const batchResults = await api.postBatchTransactions([
147
+ { date: new Date(), debitAccount: '1200', creditAccount: '8400', amount: 100 },
148
+ { date: new Date(), debitAccount: '1200', creditAccount: '8400', amount: 200 },
149
+ { date: new Date(), debitAccount: '1200', creditAccount: '8400', amount: 300 }
150
+ ]);
151
+ ```
152
+
153
+ ## 📚 SKR03 vs SKR04: Which One to Choose?
154
+
155
+ ### SKR03 - Process Structure Principle (Prozessgliederungsprinzip)
156
+ **Best for:** 🛍️ Trading companies, 💼 Service providers, 🏪 Retail businesses
157
+
158
+ - Accounts organized by **business process flow**
159
+ - Easier mapping to operational workflows
160
+ - Natural progression from purchasing → inventory → sales
161
+ - Popular with small to medium enterprises
162
+
163
+ ### SKR04 - Financial Classification Principle (Abschlussgliederungsprinzip)
164
+ **Best for:** 🏭 Manufacturing companies, 🏗️ Large corporations, 📈 Public companies
165
+
166
+ - Accounts organized by **financial statement structure**
167
+ - Direct mapping to balance sheet and P&L positions
168
+ - Simplified financial reporting and analysis
169
+ - Preferred by auditors and financial institutions
170
+
171
+ ## 🎯 Account Structure
172
+
173
+ Both SKR standards follow the same hierarchical structure:
174
+
175
+ ```
176
+ [0-9] → Account Class (Kontenklasse)
177
+ [0-9] → Account Group (Kontengruppe)
178
+ [0-9] → Account Subgroup (Kontenuntergruppe)
179
+ [0-9] → Individual Account (Einzelkonto)
180
+ ```
181
+
182
+ ### Account Classes Overview
183
+
184
+ | Class | SKR03 Description | SKR04 Description | Type |
185
+ |-------|------------------|-------------------|------|
186
+ | **0** | Fixed Assets | Fixed Assets | Asset |
187
+ | **1** | Current Assets | Current Assets | Asset |
188
+ | **2** | Equity | Equity | Equity |
189
+ | **3** | Liabilities | Liabilities | Liability |
190
+ | **4** | Operating Income | Operating Income | Revenue |
191
+ | **5** | Cost of Materials | Cost of Materials | Expense |
192
+ | **6** | Operating Expenses | Other Operating Costs | Expense |
193
+ | **7** | Other Income/Expenses | Other Income/Expenses | Mixed |
194
+ | **8** | --- | Financial Results | Mixed |
195
+ | **9** | Closing Accounts | Closing Accounts | System |
196
+
197
+ ## 🔧 Advanced Features
198
+
199
+ ### Ledger Operations
200
+
201
+ ```typescript
202
+ import { Ledger } from '@fin.cx/skr';
203
+
204
+ const ledger = new Ledger('SKR03');
205
+
206
+ // Post to general ledger
207
+ await ledger.postToGeneralLedger(transaction);
208
+
209
+ // Get account ledger
210
+ const accountLedger = await ledger.getAccountLedger('1200', {
211
+ dateFrom: new Date('2024-01-01'),
212
+ dateTo: new Date('2024-12-31')
213
+ });
214
+
215
+ // Close accounting period
216
+ await ledger.closePeriod('2024-01');
217
+ ```
218
+
219
+ ### Custom Reporting
220
+
221
+ ```typescript
222
+ import { Reports } from '@fin.cx/skr';
223
+
224
+ const reports = new Reports('SKR03');
225
+
226
+ // Generate custom report
227
+ const customReport = await reports.generateCustomReport({
228
+ accounts: ['1200', '1300', '1400'],
229
+ dateFrom: new Date('2024-01-01'),
230
+ dateTo: new Date('2024-12-31'),
231
+ groupBy: 'month',
232
+ includeSubAccounts: true
233
+ });
234
+
235
+ // Cash flow statement
236
+ const cashFlow = await reports.generateCashFlowStatement({
237
+ year: 2024
238
+ });
239
+ ```
240
+
241
+ ### Data Import/Export
242
+
243
+ ```typescript
244
+ // Import from CSV
245
+ const importedCount = await api.importAccountsFromCSV(csvContent);
246
+
247
+ // Export to CSV
248
+ const csvExport = await api.exportAccountsToCSV();
249
+
250
+ // DATEV-compatible export
251
+ const datevData = await api.exportDatev({
252
+ consultantNumber: '12345',
253
+ clientNumber: '67890',
254
+ dateFrom: new Date('2024-01-01'),
255
+ dateTo: new Date('2024-12-31')
256
+ });
257
+ ```
258
+
259
+ ## 🛡️ Type Safety
260
+
261
+ Full TypeScript support with comprehensive type definitions:
262
+
263
+ ```typescript
264
+ import type {
265
+ TSKRType,
266
+ IAccountData,
267
+ ITransactionData,
268
+ IJournalEntry,
269
+ ITrialBalanceReport,
270
+ IIncomeStatement,
271
+ IBalanceSheet
272
+ } from '@fin.cx/skr';
273
+
274
+ // All operations are fully typed
275
+ const account: IAccountData = {
276
+ accountNumber: '1200',
277
+ accountName: 'Bank Account',
278
+ accountClass: 1,
279
+ accountType: 'asset',
280
+ skrType: 'SKR03',
281
+ vatRate: 0,
282
+ isActive: true
283
+ };
284
+ ```
285
+
286
+ ## 🌟 Real-World Example
287
+
288
+ Here's a complete example of setting up a basic accounting system:
289
+
290
+ ```typescript
291
+ import { SkrApi } from '@fin.cx/skr';
292
+
293
+ async function setupAccounting() {
294
+ // Initialize
295
+ const api = new SkrApi({
296
+ mongoDbUrl: process.env.MONGODB_URL!,
297
+ dbName: 'my_company_accounting'
298
+ });
299
+
300
+ await api.initialize('SKR03');
301
+
302
+ // Create custom accounts for your business
303
+ await api.createAccount({
304
+ accountNumber: '1299',
305
+ accountName: 'Stripe Account',
306
+ accountClass: 1,
307
+ accountType: 'asset',
308
+ description: 'Stripe payment gateway account'
309
+ });
310
+
311
+ // Post daily transactions
312
+ const transactions = [
313
+ {
314
+ date: new Date(),
315
+ debitAccount: '1299', // Stripe
316
+ creditAccount: '8400', // Revenue
317
+ amount: 99.00,
318
+ description: 'SaaS subscription payment',
319
+ reference: 'stripe_pi_abc123'
320
+ },
321
+ {
322
+ date: new Date(),
323
+ debitAccount: '5900', // Hosting costs
324
+ creditAccount: '1200', // Bank
325
+ amount: 29.99,
326
+ description: 'AWS monthly bill',
327
+ reference: 'aws-2024-03'
328
+ }
329
+ ];
330
+
331
+ for (const tx of transactions) {
332
+ await api.postTransaction(tx);
333
+ }
334
+
335
+ // Generate monthly report
336
+ const report = await api.generateIncomeStatement({
337
+ dateFrom: new Date('2024-03-01'),
338
+ dateTo: new Date('2024-03-31')
339
+ });
340
+
341
+ console.log('Revenue:', report.totalRevenue);
342
+ console.log('Expenses:', report.totalExpenses);
343
+ console.log('Net Income:', report.netIncome);
344
+
345
+ // Close the connection when done
346
+ await api.close();
347
+ }
348
+
349
+ setupAccounting().catch(console.error);
350
+ ```
351
+
352
+ ## 🚦 API Reference
353
+
354
+ ### Main Classes
355
+
356
+ - **`SkrApi`** - Main API entry point
357
+ - **`ChartOfAccounts`** - Account management
358
+ - **`Ledger`** - General ledger operations
359
+ - **`Reports`** - Financial reporting
360
+ - **`Account`** - Account model
361
+ - **`Transaction`** - Transaction model
362
+ - **`JournalEntry`** - Journal entry model
363
+
364
+ ### Key Methods
365
+
366
+ | Method | Description |
367
+ |--------|-------------|
368
+ | `initialize(skrType)` | Initialize with SKR03 or SKR04 |
369
+ | `postTransaction(data)` | Post a simple transaction |
370
+ | `postJournalEntry(data)` | Post a complex journal entry |
371
+ | `reverseTransaction(id)` | Reverse a posted transaction |
372
+ | `generateTrialBalance(params)` | Generate trial balance report |
373
+ | `generateIncomeStatement(params)` | Generate P&L statement |
374
+ | `generateBalanceSheet(params)` | Generate balance sheet |
375
+ | `exportDatev(params)` | Export DATEV-compatible data |
376
+
377
+ ## 📋 Requirements
378
+
379
+ - **Node.js** >= 18.0.0
380
+ - **MongoDB** >= 5.0
381
+ - **TypeScript** >= 5.0 (for development)
382
+
383
+ ## 🏆 Why Developers Love It
384
+
385
+ - **🎯 Zero Configuration**: Pre-configured SKR03/SKR04 accounts out of the box
386
+ - **🔄 Automatic Validation**: Never worry about unbalanced entries
387
+ - **📊 Real-time Analytics**: Instant financial insights
388
+ - **🛡️ Production Ready**: Battle-tested in enterprise environments
389
+ - **📚 Great Documentation**: You're reading it!
390
+ - **🤝 Active Community**: Regular updates and support
391
+
392
+ ## License and Legal Information
393
+
394
+ This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
395
+
396
+ **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
397
+
398
+ ### Trademarks
399
+
400
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
401
+
402
+ ### Company Information
403
+
404
+ Task Venture Capital GmbH
405
+ Registered at District court Bremen HRB 35230 HB, Germany
406
+
407
+ For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
408
+
409
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.