@fin.cx/skr 1.1.0 โ 1.2.1
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/dist_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/index.d.ts +6 -0
- package/dist_ts/index.js +7 -1
- package/dist_ts/plugins.d.ts +8 -1
- package/dist_ts/plugins.js +10 -2
- package/dist_ts/skr.api.d.ts +70 -0
- package/dist_ts/skr.api.js +348 -1
- package/dist_ts/skr.classes.account.d.ts +28 -0
- package/dist_ts/skr.classes.account.js +87 -4
- package/dist_ts/skr.classes.journalentry.js +56 -4
- package/dist_ts/skr.classes.ledger.js +5 -1
- package/dist_ts/skr.export.accounts.d.ts +53 -0
- package/dist_ts/skr.export.accounts.js +111 -0
- package/dist_ts/skr.export.balances.d.ts +59 -0
- package/dist_ts/skr.export.balances.js +205 -0
- package/dist_ts/skr.export.d.ts +110 -0
- package/dist_ts/skr.export.js +315 -0
- package/dist_ts/skr.export.ledger.d.ts +95 -0
- package/dist_ts/skr.export.ledger.js +164 -0
- package/dist_ts/skr.export.pdf.d.ts +82 -0
- package/dist_ts/skr.export.pdf.js +548 -0
- package/dist_ts/skr.invoice.adapter.d.ts +98 -0
- package/dist_ts/skr.invoice.adapter.js +476 -0
- package/dist_ts/skr.invoice.booking.d.ts +102 -0
- package/dist_ts/skr.invoice.booking.js +578 -0
- package/dist_ts/skr.invoice.entity.d.ts +287 -0
- package/dist_ts/skr.invoice.entity.js +2 -0
- package/dist_ts/skr.invoice.mapper.d.ts +69 -0
- package/dist_ts/skr.invoice.mapper.js +401 -0
- package/dist_ts/skr.invoice.storage.d.ts +140 -0
- package/dist_ts/skr.invoice.storage.js +529 -0
- package/dist_ts/skr.postingkeys.d.ts +56 -0
- package/dist_ts/skr.postingkeys.js +196 -0
- package/dist_ts/skr.security.d.ts +65 -0
- package/dist_ts/skr.security.js +319 -0
- package/dist_ts/skr.types.d.ts +19 -0
- package/dist_ts/skr03.data.js +3 -1
- package/dist_ts/skr04.data.js +3 -1
- package/package.json +17 -12
- package/readme.hints.md +54 -1
- package/readme.md +207 -16
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/index.ts +6 -0
- package/ts/plugins.ts +22 -1
- package/ts/skr.api.ts +485 -0
- package/ts/skr.classes.account.ts +106 -3
- package/ts/skr.classes.journalentry.ts +78 -3
- package/ts/skr.classes.ledger.ts +4 -0
- package/ts/skr.export.accounts.ts +154 -0
- package/ts/skr.export.balances.ts +270 -0
- package/ts/skr.export.ledger.ts +249 -0
- package/ts/skr.export.pdf.ts +601 -0
- package/ts/skr.export.ts +443 -0
- package/ts/skr.invoice.adapter.ts +581 -0
- package/ts/skr.invoice.booking.ts +760 -0
- package/ts/skr.invoice.entity.ts +351 -0
- package/ts/skr.invoice.mapper.ts +486 -0
- package/ts/skr.invoice.storage.ts +710 -0
- package/ts/skr.postingkeys.ts +252 -0
- package/ts/skr.security.ts +405 -0
- package/ts/skr.types.ts +27 -0
- package/ts/skr03.data.ts +2 -0
- package/ts/skr04.data.ts +2 -0
package/readme.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @fin.cx/skr ๐
|
|
2
2
|
|
|
3
3
|
> **Enterprise-grade German accounting standards implementation for SKR03 and SKR04**
|
|
4
|
-
> Rock-solid double-entry bookkeeping with MongoDB persistence and full TypeScript support
|
|
4
|
+
> Rock-solid double-entry bookkeeping with MongoDB persistence, e-invoice integration, and full TypeScript support
|
|
5
5
|
|
|
6
6
|
## ๐ Why @fin.cx/skr?
|
|
7
7
|
|
|
@@ -17,6 +17,9 @@ Building compliant German accounting software? You've come to the right place! T
|
|
|
17
17
|
- **๐ Transaction Safety**: Built-in double-entry validation and automatic reversals
|
|
18
18
|
- **โ
Battle-Tested**: 65+ comprehensive tests covering all edge cases
|
|
19
19
|
- **๐ก๏ธ SKR Validation**: Automatic validation against official SKR standards
|
|
20
|
+
- **๐งพ E-Invoice Support**: Full XRechnung/ZUGFeRD integration for modern invoice processing
|
|
21
|
+
- **๐ Cryptographic Security**: Merkle tree and digital signature support for audit trails
|
|
22
|
+
- **๐ PDF Export**: Professional PDF report generation with customizable templates
|
|
20
23
|
|
|
21
24
|
## ๐ฆ Installation
|
|
22
25
|
|
|
@@ -76,6 +79,47 @@ const journalEntry = await api.postJournalEntry({
|
|
|
76
79
|
});
|
|
77
80
|
```
|
|
78
81
|
|
|
82
|
+
### ๐งพ E-Invoice Integration
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// Import electronic invoices (XRechnung/ZUGFeRD)
|
|
86
|
+
const invoiceData = await api.importInvoice(xmlContent, {
|
|
87
|
+
format: 'xrechnung',
|
|
88
|
+
validateSchema: true,
|
|
89
|
+
checkDuplicates: true
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Automatically book invoice to accounting
|
|
93
|
+
const booking = await api.bookInvoice(invoiceData.invoiceId, {
|
|
94
|
+
autoDetectAccounts: true,
|
|
95
|
+
splitVAT: true,
|
|
96
|
+
createPaymentSchedule: true
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Export invoice in various formats
|
|
100
|
+
const xRechnung = await api.exportInvoice(invoiceId, {
|
|
101
|
+
format: 'xrechnung',
|
|
102
|
+
version: '3.0',
|
|
103
|
+
includeAttachments: true
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Search and filter invoices
|
|
107
|
+
const invoices = await api.searchInvoices({
|
|
108
|
+
dateFrom: new Date('2024-01-01'),
|
|
109
|
+
dateTo: new Date('2024-12-31'),
|
|
110
|
+
status: 'booked',
|
|
111
|
+
minAmount: 100,
|
|
112
|
+
customerVATId: 'DE123456789'
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Generate compliance reports
|
|
116
|
+
const complianceReport = await api.createInvoiceComplianceReport({
|
|
117
|
+
period: '2024-Q1',
|
|
118
|
+
includeValidation: true,
|
|
119
|
+
includeStatistics: true
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
79
123
|
### ๐ Generating Financial Reports
|
|
80
124
|
|
|
81
125
|
```typescript
|
|
@@ -109,6 +153,71 @@ const cashFlow = await api.generateCashFlowStatement({
|
|
|
109
153
|
});
|
|
110
154
|
```
|
|
111
155
|
|
|
156
|
+
### ๐ Advanced Export Features
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
// Export complete annual closing package (Jahresabschluss)
|
|
160
|
+
const jahresabschluss = await api.exportJahresabschluss({
|
|
161
|
+
year: 2024,
|
|
162
|
+
includeReports: ['balance_sheet', 'income_statement', 'cash_flow'],
|
|
163
|
+
format: 'structured', // 'structured' | 'pdf' | 'csv'
|
|
164
|
+
language: 'de',
|
|
165
|
+
signatureRequired: true
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Generate PDF reports with professional formatting
|
|
169
|
+
const pdfReports = await api.generatePdfReports({
|
|
170
|
+
reports: ['trial_balance', 'income_statement', 'balance_sheet'],
|
|
171
|
+
dateFrom: new Date('2024-01-01'),
|
|
172
|
+
dateTo: new Date('2024-12-31'),
|
|
173
|
+
companyInfo: {
|
|
174
|
+
name: 'Mustermann GmbH',
|
|
175
|
+
address: 'Hauptstraรe 1, 10115 Berlin',
|
|
176
|
+
taxNumber: 'DE123456789',
|
|
177
|
+
registrationNumber: 'HRB 12345'
|
|
178
|
+
},
|
|
179
|
+
outputPath: './reports/',
|
|
180
|
+
template: 'professional' // Custom templates available
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Export with cryptographic signatures for audit trail
|
|
184
|
+
const signedExport = await api.signExport({
|
|
185
|
+
data: jahresabschluss,
|
|
186
|
+
privateKey: privateKeyPEM,
|
|
187
|
+
certificate: certificatePEM,
|
|
188
|
+
includeTimestamp: true,
|
|
189
|
+
hashAlgorithm: 'SHA256'
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Detailed account data export
|
|
193
|
+
const accountExport = await api.exportAccountData({
|
|
194
|
+
dateFrom: new Date('2024-01-01'),
|
|
195
|
+
dateTo: new Date('2024-12-31'),
|
|
196
|
+
format: 'detailed', // 'summary' | 'detailed' | 'tree'
|
|
197
|
+
includeTransactions: true,
|
|
198
|
+
includeBalances: true
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// Balance history export for analysis
|
|
202
|
+
const balanceHistory = await api.exportBalanceData({
|
|
203
|
+
accounts: ['1200', '1000', '8400'],
|
|
204
|
+
interval: 'monthly', // 'daily' | 'weekly' | 'monthly' | 'quarterly'
|
|
205
|
+
dateFrom: new Date('2024-01-01'),
|
|
206
|
+
dateTo: new Date('2024-12-31'),
|
|
207
|
+
includeRunningTotals: true
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Ledger export with filtering options
|
|
211
|
+
const ledgerExport = await api.exportLedgerData({
|
|
212
|
+
accounts: ['1000-1999'], // Range support
|
|
213
|
+
dateFrom: new Date('2024-01-01'),
|
|
214
|
+
dateTo: new Date('2024-12-31'),
|
|
215
|
+
includeReversals: false,
|
|
216
|
+
groupByAccount: true,
|
|
217
|
+
format: 'journal' // 'journal' | 'T-account' | 'chronological'
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
112
221
|
## ๐๏ธ Core Features
|
|
113
222
|
|
|
114
223
|
### Account Management
|
|
@@ -316,6 +425,50 @@ try {
|
|
|
316
425
|
}
|
|
317
426
|
```
|
|
318
427
|
|
|
428
|
+
### Invoice Processing & Compliance
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
// Get invoice statistics and analytics
|
|
432
|
+
const stats = await api.getInvoiceStatistics({
|
|
433
|
+
dateFrom: new Date('2024-01-01'),
|
|
434
|
+
dateTo: new Date('2024-12-31'),
|
|
435
|
+
groupBy: 'month',
|
|
436
|
+
includeVATAnalysis: true
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
// Generate invoices programmatically
|
|
440
|
+
const invoice = await api.generateInvoice({
|
|
441
|
+
invoiceNumber: 'INV-2024-001',
|
|
442
|
+
date: new Date(),
|
|
443
|
+
dueDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
|
|
444
|
+
seller: {
|
|
445
|
+
name: 'Your Company GmbH',
|
|
446
|
+
vatId: 'DE123456789',
|
|
447
|
+
address: 'Hauptstraรe 1, 10115 Berlin'
|
|
448
|
+
},
|
|
449
|
+
buyer: {
|
|
450
|
+
name: 'Customer AG',
|
|
451
|
+
vatId: 'DE987654321',
|
|
452
|
+
address: 'Kundenweg 5, 80331 Mรผnchen'
|
|
453
|
+
},
|
|
454
|
+
lines: [
|
|
455
|
+
{
|
|
456
|
+
description: 'Consulting Services',
|
|
457
|
+
quantity: 10,
|
|
458
|
+
unitPrice: 100,
|
|
459
|
+
vatRate: 19
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
// Validate invoice compliance
|
|
465
|
+
const validation = await api.validateInvoice(invoice, {
|
|
466
|
+
standard: 'xrechnung',
|
|
467
|
+
checkBusinessRules: true,
|
|
468
|
+
checkVATRules: true
|
|
469
|
+
});
|
|
470
|
+
```
|
|
471
|
+
|
|
319
472
|
### Utility Functions
|
|
320
473
|
|
|
321
474
|
```typescript
|
|
@@ -346,7 +499,12 @@ import type {
|
|
|
346
499
|
IPaginationParams,
|
|
347
500
|
IAccountBalance,
|
|
348
501
|
ICashFlowStatement,
|
|
349
|
-
IGeneralLedger
|
|
502
|
+
IGeneralLedger,
|
|
503
|
+
IInvoice,
|
|
504
|
+
IInvoiceLine,
|
|
505
|
+
IInvoiceParty,
|
|
506
|
+
IBookingRules,
|
|
507
|
+
IValidationResult
|
|
350
508
|
} from '@fin.cx/skr';
|
|
351
509
|
|
|
352
510
|
// All operations are fully typed
|
|
@@ -413,7 +571,22 @@ async function performJahresabschluss() {
|
|
|
413
571
|
]
|
|
414
572
|
});
|
|
415
573
|
|
|
416
|
-
// 2. Generate
|
|
574
|
+
// 2. Generate comprehensive annual closing package
|
|
575
|
+
const jahresabschluss = await api.exportJahresabschluss({
|
|
576
|
+
year: 2024,
|
|
577
|
+
includeReports: ['balance_sheet', 'income_statement', 'cash_flow', 'trial_balance'],
|
|
578
|
+
format: 'pdf',
|
|
579
|
+
language: 'de',
|
|
580
|
+
signatureRequired: true,
|
|
581
|
+
companyInfo: {
|
|
582
|
+
name: 'Mustermann GmbH',
|
|
583
|
+
address: 'Hauptstraรe 1, 10115 Berlin',
|
|
584
|
+
taxNumber: 'DE123456789',
|
|
585
|
+
registrationNumber: 'HRB 12345'
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
// 3. Generate individual reports for analysis
|
|
417
590
|
const incomeStatement = await api.generateIncomeStatement({
|
|
418
591
|
dateFrom: new Date('2024-01-01'),
|
|
419
592
|
dateTo: new Date('2024-12-31')
|
|
@@ -423,34 +596,37 @@ async function performJahresabschluss() {
|
|
|
423
596
|
date: new Date('2024-12-31')
|
|
424
597
|
});
|
|
425
598
|
|
|
426
|
-
const trialBalance = await api.generateTrialBalance({
|
|
427
|
-
dateFrom: new Date('2024-01-01'),
|
|
428
|
-
dateTo: new Date('2024-12-31')
|
|
429
|
-
});
|
|
430
|
-
|
|
431
599
|
const cashFlow = await api.generateCashFlowStatement({
|
|
432
600
|
dateFrom: new Date('2024-01-01'),
|
|
433
601
|
dateTo: new Date('2024-12-31')
|
|
434
602
|
});
|
|
435
603
|
|
|
436
|
-
//
|
|
604
|
+
// 4. Export for tax advisor in DATEV format
|
|
437
605
|
const datevExport = await api.exportToDATEV({
|
|
438
606
|
dateFrom: new Date('2024-01-01'),
|
|
439
607
|
dateTo: new Date('2024-12-31')
|
|
440
608
|
});
|
|
441
609
|
|
|
442
|
-
//
|
|
610
|
+
// 5. Create signed export for audit trail
|
|
611
|
+
const signedExport = await api.signExport({
|
|
612
|
+
data: jahresabschluss,
|
|
613
|
+
privateKey: process.env.PRIVATE_KEY!,
|
|
614
|
+
certificate: process.env.CERTIFICATE!,
|
|
615
|
+
includeTimestamp: true
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
// 6. Close the period
|
|
443
619
|
await api.closePeriod('2024-12', {
|
|
444
620
|
performYearEndAdjustments: true,
|
|
445
621
|
generateReports: true
|
|
446
622
|
});
|
|
447
623
|
|
|
448
|
-
console.log('
|
|
449
|
-
console.log(
|
|
450
|
-
console.log(
|
|
451
|
-
console.log(
|
|
452
|
-
console.log(
|
|
453
|
-
console.log(
|
|
624
|
+
console.log('๐ Jahresabschluss 2024 Complete!');
|
|
625
|
+
console.log(`๐ Umsatz: โฌ${incomeStatement.totalRevenue.toLocaleString('de-DE')}`);
|
|
626
|
+
console.log(`๐ฐ Aufwendungen: โฌ${incomeStatement.totalExpenses.toLocaleString('de-DE')}`);
|
|
627
|
+
console.log(`๐ Jahresergebnis: โฌ${incomeStatement.netIncome.toLocaleString('de-DE')}`);
|
|
628
|
+
console.log(`๐ผ Bilanzsumme: โฌ${balanceSheet.assets.totalAssets.toLocaleString('de-DE')}`);
|
|
629
|
+
console.log(`๐ต Cash Flow: โฌ${cashFlow.netCashFlow.toLocaleString('de-DE')}`);
|
|
454
630
|
console.log(incomeStatement.netIncome > 0 ? 'โ
Gewinn!' : '๐ Verlust');
|
|
455
631
|
|
|
456
632
|
await api.close();
|
|
@@ -472,6 +648,9 @@ performJahresabschluss().catch(console.error);
|
|
|
472
648
|
| **`Account`** | Account model with balance tracking |
|
|
473
649
|
| **`Transaction`** | Double-entry transaction model |
|
|
474
650
|
| **`JournalEntry`** | Complex multi-line journal entries |
|
|
651
|
+
| **`InvoiceAdapter`** | XRechnung/ZUGFeRD invoice processing |
|
|
652
|
+
| **`InvoiceBookingEngine`** | Automatic invoice to accounting booking |
|
|
653
|
+
| **`InvoiceStorage`** | Invoice persistence and search |
|
|
475
654
|
|
|
476
655
|
### Key Methods
|
|
477
656
|
|
|
@@ -489,6 +668,13 @@ performJahresabschluss().catch(console.error);
|
|
|
489
668
|
| `generateCashFlowStatement(params)` | Generate cash flow statement |
|
|
490
669
|
| `generateGeneralLedger(params)` | Generate complete general ledger |
|
|
491
670
|
| `exportToDATEV(params)` | Export DATEV-compatible data |
|
|
671
|
+
| `exportJahresabschluss(params)` | Export complete annual closing package |
|
|
672
|
+
| `generatePdfReports(params)` | Generate professional PDF reports |
|
|
673
|
+
| `signExport(data)` | Create cryptographically signed exports |
|
|
674
|
+
| `importInvoice(data, options)` | Import XRechnung/ZUGFeRD invoices |
|
|
675
|
+
| `bookInvoice(invoiceId, rules)` | Book invoice to accounting |
|
|
676
|
+
| `exportInvoice(id, options)` | Export invoice in various formats |
|
|
677
|
+
| `searchInvoices(filter)` | Search and filter invoices |
|
|
492
678
|
| `closePeriod(period, options)` | Close accounting period |
|
|
493
679
|
| `recalculateBalances()` | Recalculate all account balances |
|
|
494
680
|
| `validateDoubleEntry(data)` | Validate transaction before posting |
|
|
@@ -505,6 +691,9 @@ performJahresabschluss().catch(console.error);
|
|
|
505
691
|
- **๐ German Compliance**: Full HGB/GoBD compliance built-in
|
|
506
692
|
- **๐ค Type Safety**: Complete TypeScript definitions prevent runtime errors
|
|
507
693
|
- **๐ Smart Validation**: Warns about non-standard accounts and type mismatches
|
|
694
|
+
- **๐งพ E-Invoice Ready**: Native XRechnung/ZUGFeRD support for modern workflows
|
|
695
|
+
- **๐ Audit-Proof**: Cryptographic signatures and Merkle trees for tamper-proof records
|
|
696
|
+
- **๐ Professional Reports**: Generate PDF reports that impress auditors and stakeholders
|
|
508
697
|
|
|
509
698
|
## ๐ Requirements
|
|
510
699
|
|
|
@@ -525,6 +714,8 @@ pnpm test test/test.skr03.ts # SKR03 functionality
|
|
|
525
714
|
pnpm test test/test.skr04.ts # SKR04 functionality
|
|
526
715
|
pnpm test test/test.jahresabschluss.skr03.ts # Annual closing SKR03
|
|
527
716
|
pnpm test test/test.jahresabschluss.skr04.ts # Annual closing SKR04
|
|
717
|
+
pnpm test test/test.invoice.ts # Invoice processing
|
|
718
|
+
pnpm test test/test.export.ts # Export functionality
|
|
528
719
|
```
|
|
529
720
|
|
|
530
721
|
## License and Legal Information
|
package/ts/index.ts
CHANGED
|
@@ -8,3 +8,9 @@ export * from './skr.classes.reports.js';
|
|
|
8
8
|
export * from './skr.api.js';
|
|
9
9
|
export * from './skr03.data.js';
|
|
10
10
|
export * from './skr04.data.js';
|
|
11
|
+
export * from './skr.export.js';
|
|
12
|
+
export * from './skr.export.ledger.js';
|
|
13
|
+
export * from './skr.export.accounts.js';
|
|
14
|
+
export * from './skr.export.balances.js';
|
|
15
|
+
export * from './skr.export.pdf.js';
|
|
16
|
+
export * from './skr.security.js';
|
package/ts/plugins.ts
CHANGED
|
@@ -3,5 +3,26 @@ import * as smartdata from '@push.rocks/smartdata';
|
|
|
3
3
|
import * as smartunique from '@push.rocks/smartunique';
|
|
4
4
|
import * as smarttime from '@push.rocks/smarttime';
|
|
5
5
|
import * as smartlog from '@push.rocks/smartlog';
|
|
6
|
+
import * as smartfile from '@push.rocks/smartfile';
|
|
7
|
+
import * as smarthash from '@push.rocks/smarthash';
|
|
8
|
+
import * as smartpath from '@push.rocks/smartpath';
|
|
9
|
+
import * as smartpdf from '@push.rocks/smartpdf';
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
// third party
|
|
12
|
+
import * as nodeForge from 'node-forge';
|
|
13
|
+
import { MerkleTree } from 'merkletreejs';
|
|
14
|
+
import * as einvoice from '@fin.cx/einvoice';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
smartdata,
|
|
18
|
+
smartunique,
|
|
19
|
+
smarttime,
|
|
20
|
+
smartlog,
|
|
21
|
+
smartfile,
|
|
22
|
+
smarthash,
|
|
23
|
+
smartpath,
|
|
24
|
+
smartpdf,
|
|
25
|
+
nodeForge,
|
|
26
|
+
MerkleTree,
|
|
27
|
+
einvoice
|
|
28
|
+
};
|