@fin.cx/skr 1.1.0 β†’ 1.2.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 (46) hide show
  1. package/dist_ts/index.d.ts +6 -0
  2. package/dist_ts/index.js +7 -1
  3. package/dist_ts/plugins.d.ts +8 -1
  4. package/dist_ts/plugins.js +10 -2
  5. package/dist_ts/skr.api.d.ts +70 -0
  6. package/dist_ts/skr.api.js +348 -1
  7. package/dist_ts/skr.export.accounts.d.ts +53 -0
  8. package/dist_ts/skr.export.accounts.js +111 -0
  9. package/dist_ts/skr.export.balances.d.ts +59 -0
  10. package/dist_ts/skr.export.balances.js +205 -0
  11. package/dist_ts/skr.export.d.ts +110 -0
  12. package/dist_ts/skr.export.js +315 -0
  13. package/dist_ts/skr.export.ledger.d.ts +95 -0
  14. package/dist_ts/skr.export.ledger.js +164 -0
  15. package/dist_ts/skr.export.pdf.d.ts +82 -0
  16. package/dist_ts/skr.export.pdf.js +548 -0
  17. package/dist_ts/skr.invoice.adapter.d.ts +98 -0
  18. package/dist_ts/skr.invoice.adapter.js +476 -0
  19. package/dist_ts/skr.invoice.booking.d.ts +102 -0
  20. package/dist_ts/skr.invoice.booking.js +556 -0
  21. package/dist_ts/skr.invoice.entity.d.ts +287 -0
  22. package/dist_ts/skr.invoice.entity.js +2 -0
  23. package/dist_ts/skr.invoice.mapper.d.ts +69 -0
  24. package/dist_ts/skr.invoice.mapper.js +401 -0
  25. package/dist_ts/skr.invoice.storage.d.ts +140 -0
  26. package/dist_ts/skr.invoice.storage.js +529 -0
  27. package/dist_ts/skr.security.d.ts +65 -0
  28. package/dist_ts/skr.security.js +319 -0
  29. package/dist_ts/skr.types.d.ts +1 -0
  30. package/package.json +17 -12
  31. package/readme.md +207 -16
  32. package/ts/index.ts +6 -0
  33. package/ts/plugins.ts +22 -1
  34. package/ts/skr.api.ts +485 -0
  35. package/ts/skr.export.accounts.ts +154 -0
  36. package/ts/skr.export.balances.ts +270 -0
  37. package/ts/skr.export.ledger.ts +249 -0
  38. package/ts/skr.export.pdf.ts +601 -0
  39. package/ts/skr.export.ts +443 -0
  40. package/ts/skr.invoice.adapter.ts +581 -0
  41. package/ts/skr.invoice.booking.ts +738 -0
  42. package/ts/skr.invoice.entity.ts +351 -0
  43. package/ts/skr.invoice.mapper.ts +486 -0
  44. package/ts/skr.invoice.storage.ts +710 -0
  45. package/ts/skr.security.ts +405 -0
  46. package/ts/skr.types.ts +1 -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 financial statements
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
- // 3. Export for tax advisor
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
- // 4. Close the period
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('=== Jahresabschluss 2024 ===');
449
- console.log(`Umsatz: €${incomeStatement.totalRevenue}`);
450
- console.log(`Aufwendungen: €${incomeStatement.totalExpenses}`);
451
- console.log(`Jahresergebnis: €${incomeStatement.netIncome}`);
452
- console.log(`Bilanzsumme: €${balanceSheet.assets.totalAssets}`);
453
- console.log(`Cash Flow: €${cashFlow.netCashFlow}`);
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
- export { smartdata, smartunique, smarttime, smartlog };
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
+ };