feat: Enhance journal entry and transaction handling with posting keys

- Added posting key support to SKR03 and SKR04 journal entries and transactions to ensure DATEV compliance.
- Implemented validation for posting keys in journal entries, ensuring all lines have a posting key and that they are consistent across the entry.
- Introduced automatic account checks to prevent posting to accounts that cannot be directly posted to (e.g., 1400, 1600).
- Updated account validation to include checks for debtor and creditor ranges.
- Enhanced invoice booking logic to include appropriate posting keys based on VAT rates and scenarios.
- Created a new module for posting key definitions and validation rules, including functions for validating posting keys and suggesting appropriate keys based on transaction parameters.
- Updated tests to cover new posting key functionality and ensure compliance with accounting rules.
This commit is contained in:
2025-10-27 08:34:28 +00:00
parent 73b46f7857
commit 4f1066da2e
13 changed files with 758 additions and 229 deletions

View File

@@ -7,7 +7,7 @@ let testConfig: Awaited<ReturnType<typeof getTestConfig>>;
tap.test('should demonstrate complete Jahresabschluss (Annual Financial Statement) for SKR03', async () => {
testConfig = await getTestConfig();
// Use timestamp to ensure unique database for each test run
const timestamp = Date.now();
api = new skr.SkrApi({
@@ -17,13 +17,34 @@ tap.test('should demonstrate complete Jahresabschluss (Annual Financial Statemen
await api.initialize('SKR03');
expect(api.getSKRType()).toEqual('SKR03');
// Create debtor account (customer) - replaces automatic account 1400
await api.createAccount({
accountNumber: '10001',
accountName: 'Kunde Mustermann GmbH',
accountClass: 1,
accountType: 'asset',
skrType: 'SKR03',
});
// Create creditor account (supplier) - replaces automatic account 1600
await api.createAccount({
accountNumber: '70001',
accountName: 'Lieferant Test GmbH',
accountClass: 7,
accountType: 'liability',
skrType: 'SKR03',
});
});
tap.test('should set up opening balances (Eröffnungsbilanz)', async () => {
// Opening balances from previous year's closing
// This represents a small GmbH (limited liability company)
// Using only accounts that exist in SKR03
// Note: Opening balance entries use posting key 40 (tax-free) as they are internal closing entries
// Using personal accounts (10001 for debtor, 70001 for creditor) instead of automatic accounts
// Post opening journal entry (Eröffnungsbuchung)
const openingEntry = await api.postJournalEntry({
date: new Date('2024-01-01'),
@@ -31,20 +52,20 @@ tap.test('should set up opening balances (Eröffnungsbilanz)', async () => {
reference: 'EB-2024',
lines: [
// Debit all asset accounts
{ accountNumber: '0200', debit: 45000, description: 'Grundstücke' },
{ accountNumber: '0210', debit: 120000, description: 'Gebäude' },
{ accountNumber: '0500', debit: 35000, description: 'Betriebs- und Geschäftsausstattung' },
{ accountNumber: '0400', debit: 8000, description: 'Fuhrpark' },
{ accountNumber: '1200', debit: 25000, description: 'Bank' },
{ accountNumber: '1000', debit: 2500, description: 'Kasse' },
{ accountNumber: '1400', debit: 18000, description: 'Forderungen' },
{ accountNumber: '3100', debit: 12000, description: 'Warenvorräte' },
{ accountNumber: '0200', debit: 45000, description: 'Grundstücke', postingKey: 40 },
{ accountNumber: '0210', debit: 120000, description: 'Gebäude', postingKey: 40 },
{ accountNumber: '0500', debit: 35000, description: 'Betriebs- und Geschäftsausstattung', postingKey: 40 },
{ accountNumber: '0400', debit: 8000, description: 'Fuhrpark', postingKey: 40 },
{ accountNumber: '1200', debit: 25000, description: 'Bank', postingKey: 40 },
{ accountNumber: '1000', debit: 2500, description: 'Kasse', postingKey: 40 },
{ accountNumber: '10001', debit: 18000, description: 'Forderungen Kunde', postingKey: 40 },
{ accountNumber: '3100', debit: 12000, description: 'Warenvorräte', postingKey: 40 },
// Credit all liability and equity accounts
{ accountNumber: '2000', credit: 150000, description: 'Eigenkapital' },
{ accountNumber: '2900', credit: 35000, description: 'Gewinnrücklagen' },
{ accountNumber: '1600', credit: 52500, description: 'Verbindlichkeiten L+L' },
{ accountNumber: '3300', credit: 28000, description: 'Verbindlichkeiten Kreditinstitute' },
{ accountNumber: '2000', credit: 150000, description: 'Eigenkapital', postingKey: 40 },
{ accountNumber: '2900', credit: 35000, description: 'Gewinnrücklagen', postingKey: 40 },
{ accountNumber: '70001', credit: 52500, description: 'Verbindlichkeiten Lieferant', postingKey: 40 },
{ accountNumber: '3300', credit: 28000, description: 'Verbindlichkeiten Kreditinstitute', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -57,28 +78,28 @@ tap.test('should set up opening balances (Eröffnungsbilanz)', async () => {
tap.test('should record Q1 business transactions', async () => {
// January - March transactions
// Sale of goods with 19% VAT
// Sale of goods with 19% VAT - using debtor account 10001 instead of automatic 1400
await api.postJournalEntry({
date: new Date('2024-01-15'),
description: 'Verkauf Waren auf Rechnung',
reference: 'RE-2024-001',
lines: [
{ accountNumber: '1400', debit: 11900, description: 'Forderungen inkl. USt' },
{ accountNumber: '8400', credit: 10000, description: 'Erlöse 19% USt' },
{ accountNumber: '1771', credit: 1900, description: 'Umsatzsteuer 19%' },
{ accountNumber: '10001', debit: 11900, description: 'Forderungen inkl. USt', postingKey: 9 },
{ accountNumber: '8400', credit: 10000, description: 'Erlöse 19% USt', postingKey: 40 },
{ accountNumber: '1771', credit: 1900, description: 'Umsatzsteuer 19%', postingKey: 40 },
],
skrType: 'SKR03',
});
// Purchase of materials with 19% VAT
// Purchase of materials with 19% VAT - using creditor account 70001 instead of automatic 1600
await api.postJournalEntry({
date: new Date('2024-01-20'),
description: 'Einkauf Material auf Rechnung',
reference: 'ER-2024-001',
lines: [
{ accountNumber: '5400', debit: 5000, description: 'Wareneingang 19% Vorsteuer' },
{ accountNumber: '1571', debit: 950, description: 'Vorsteuer 19%' },
{ accountNumber: '1600', credit: 5950, description: 'Verbindlichkeiten' },
{ accountNumber: '5400', debit: 5000, description: 'Wareneingang 19% Vorsteuer', postingKey: 40 },
{ accountNumber: '1571', debit: 950, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '70001', credit: 5950, description: 'Verbindlichkeiten', postingKey: 9 },
],
skrType: 'SKR03',
});
@@ -89,21 +110,21 @@ tap.test('should record Q1 business transactions', async () => {
description: 'Gehaltszahlung Januar',
reference: 'GH-2024-01',
lines: [
{ accountNumber: '6000', debit: 8000, description: 'Löhne und Gehälter' },
{ accountNumber: '6100', debit: 1600, description: 'Sozialversicherung AG-Anteil' },
{ accountNumber: '1200', credit: 9600, description: 'Banküberweisung' },
{ accountNumber: '6000', debit: 8000, description: 'Löhne und Gehälter', postingKey: 40 },
{ accountNumber: '6100', debit: 1600, description: 'Sozialversicherung AG-Anteil', postingKey: 40 },
{ accountNumber: '1200', credit: 9600, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR03',
});
// Customer payment received
// Customer payment received - using debtor account 10001 instead of automatic 1400
await api.postJournalEntry({
date: new Date('2024-02-10'),
description: 'Zahlungseingang Kunde',
reference: 'ZE-2024-001',
lines: [
{ accountNumber: '1200', debit: 11900, description: 'Bankgutschrift' },
{ accountNumber: '1400', credit: 11900, description: 'Forderungsausgleich' },
{ accountNumber: '1200', debit: 11900, description: 'Bankgutschrift', postingKey: 40 },
{ accountNumber: '10001', credit: 11900, description: 'Forderungsausgleich', postingKey: 3 },
],
skrType: 'SKR03',
});
@@ -114,8 +135,8 @@ tap.test('should record Q1 business transactions', async () => {
description: 'Miete Februar',
reference: 'MI-2024-02',
lines: [
{ accountNumber: '7100', debit: 2000, description: 'Miete' },
{ accountNumber: '1200', credit: 2000, description: 'Banküberweisung' },
{ accountNumber: '7100', debit: 2000, description: 'Miete', postingKey: 40 },
{ accountNumber: '1200', credit: 2000, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -126,9 +147,9 @@ tap.test('should record Q1 business transactions', async () => {
description: 'Büromaterial',
reference: 'BM-2024-001',
lines: [
{ accountNumber: '6800', debit: 200, description: 'Bürobedarf' },
{ accountNumber: '1571', debit: 38, description: 'Vorsteuer 19%' },
{ accountNumber: '1200', credit: 238, description: 'Bankzahlung' },
{ accountNumber: '6800', debit: 200, description: 'Bürobedarf', postingKey: 40 },
{ accountNumber: '1571', debit: 38, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '1200', credit: 238, description: 'Bankzahlung', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -139,22 +160,22 @@ tap.test('should record Q1 business transactions', async () => {
description: 'Tankrechnung Firmenfahrzeug',
reference: 'KFZ-2024-001',
lines: [
{ accountNumber: '7400', debit: 150, description: 'Kfz-Kosten' },
{ accountNumber: '1571', debit: 28.50, description: 'Vorsteuer 19%' },
{ accountNumber: '1200', credit: 178.50, description: 'Bankzahlung' },
{ accountNumber: '7400', debit: 150, description: 'Kfz-Kosten', postingKey: 40 },
{ accountNumber: '1571', debit: 28.50, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '1200', credit: 178.50, description: 'Bankzahlung', postingKey: 40 },
],
skrType: 'SKR03',
});
// Another sale
// Another sale - using debtor account 10001 instead of automatic 1400
await api.postJournalEntry({
date: new Date('2024-03-20'),
description: 'Verkauf Dienstleistung',
reference: 'RE-2024-002',
lines: [
{ accountNumber: '1400', debit: 7140, description: 'Forderungen inkl. USt' },
{ accountNumber: '8400', credit: 6000, description: 'Erlöse 19% USt' },
{ accountNumber: '1771', credit: 1140, description: 'Umsatzsteuer 19%' },
{ accountNumber: '10001', debit: 7140, description: 'Forderungen inkl. USt', postingKey: 9 },
{ accountNumber: '8400', credit: 6000, description: 'Erlöse 19% USt', postingKey: 40 },
{ accountNumber: '1771', credit: 1140, description: 'Umsatzsteuer 19%', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -169,35 +190,35 @@ tap.test('should record Q2-Q4 business transactions', async () => {
description: 'Kauf neue Produktionsmaschine',
reference: 'INV-2024-001',
lines: [
{ accountNumber: '0500', debit: 25000, description: 'Neue Maschine' },
{ accountNumber: '1571', debit: 4750, description: 'Vorsteuer 19%' },
{ accountNumber: '1200', credit: 29750, description: 'Banküberweisung' },
{ accountNumber: '0500', debit: 25000, description: 'Neue Maschine', postingKey: 40 },
{ accountNumber: '1571', debit: 4750, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '1200', credit: 29750, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR03',
});
// Q2: Large sale
// Q2: Large sale - using debtor account 10001
await api.postJournalEntry({
date: new Date('2024-05-10'),
description: 'Großauftrag Kunde ABC',
reference: 'RE-2024-003',
lines: [
{ accountNumber: '1400', debit: 35700, description: 'Forderungen inkl. USt' },
{ accountNumber: '8400', credit: 30000, description: 'Erlöse 19% USt' },
{ accountNumber: '1771', credit: 5700, description: 'Umsatzsteuer 19%' },
{ accountNumber: '10001', debit: 35700, description: 'Forderungen inkl. USt', postingKey: 9 },
{ accountNumber: '8400', credit: 30000, description: 'Erlöse 19% USt', postingKey: 40 },
{ accountNumber: '1771', credit: 5700, description: 'Umsatzsteuer 19%', postingKey: 40 },
],
skrType: 'SKR03',
});
// Q3: Marketing expenses
// Q3: Marketing expenses - using creditor account 70001
await api.postJournalEntry({
date: new Date('2024-07-10'),
description: 'Werbekampagne',
reference: 'WK-2024-001',
lines: [
{ accountNumber: '6600', debit: 5000, description: 'Werbekosten' },
{ accountNumber: '1571', debit: 950, description: 'Vorsteuer 19%' },
{ accountNumber: '1600', credit: 5950, description: 'Verbindlichkeiten' },
{ accountNumber: '6600', debit: 5000, description: 'Werbekosten', postingKey: 40 },
{ accountNumber: '1571', debit: 950, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '70001', credit: 5950, description: 'Verbindlichkeiten', postingKey: 9 },
],
skrType: 'SKR03',
});
@@ -208,9 +229,9 @@ tap.test('should record Q2-Q4 business transactions', async () => {
description: 'Steuerberatung',
reference: 'STB-2024-001',
lines: [
{ accountNumber: '6700', debit: 2500, description: 'Steuerberatungskosten' },
{ accountNumber: '1571', debit: 475, description: 'Vorsteuer 19%' },
{ accountNumber: '1200', credit: 2975, description: 'Banküberweisung' },
{ accountNumber: '6700', debit: 2500, description: 'Steuerberatungskosten', postingKey: 40 },
{ accountNumber: '1571', debit: 475, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '1200', credit: 2975, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -221,35 +242,35 @@ tap.test('should record Q2-Q4 business transactions', async () => {
description: 'Jahresbonus Mitarbeiter',
reference: 'BON-2024',
lines: [
{ accountNumber: '6000', debit: 10000, description: 'Tantieme' },
{ accountNumber: '6100', debit: 2000, description: 'Sozialversicherung AG-Anteil' },
{ accountNumber: '1200', credit: 12000, description: 'Banküberweisung' },
{ accountNumber: '6000', debit: 10000, description: 'Tantieme', postingKey: 40 },
{ accountNumber: '6100', debit: 2000, description: 'Sozialversicherung AG-Anteil', postingKey: 40 },
{ accountNumber: '1200', credit: 12000, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR03',
});
// Q4: Collection of outstanding receivables
// Q4: Collection of outstanding receivables - using debtor account 10001
await api.postJournalEntry({
date: new Date('2024-12-15'),
description: 'Zahlungseingang Großauftrag',
reference: 'ZE-2024-003',
lines: [
{ accountNumber: '1200', debit: 35700, description: 'Bankgutschrift' },
{ accountNumber: '1400', credit: 35700, description: 'Forderungsausgleich' },
{ accountNumber: '1200', debit: 35700, description: 'Bankgutschrift', postingKey: 40 },
{ accountNumber: '10001', credit: 35700, description: 'Forderungsausgleich', postingKey: 3 },
],
skrType: 'SKR03',
});
});
tap.test('should perform year-end adjustments (Jahresabschlussbuchungen)', async () => {
// 1. Depreciation (Abschreibungen)
// 1. Depreciation (Abschreibungen) - internal adjustments use posting key 40
await api.postJournalEntry({
date: new Date('2024-12-31'),
description: 'Abschreibung Gebäude (linear 2%)',
reference: 'AFA-2024-001',
lines: [
{ accountNumber: '7000', debit: 2400, description: 'AfA auf Gebäude' },
{ accountNumber: '0210', credit: 2400, description: 'Wertberichtigung Gebäude' },
{ accountNumber: '7000', debit: 2400, description: 'AfA auf Gebäude', postingKey: 40 },
{ accountNumber: '0210', credit: 2400, description: 'Wertberichtigung Gebäude', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -259,8 +280,8 @@ tap.test('should perform year-end adjustments (Jahresabschlussbuchungen)', async
description: 'Abschreibung BGA (linear 10%)',
reference: 'AFA-2024-002',
lines: [
{ accountNumber: '7000', debit: 6000, description: 'AfA auf BGA' }, // (35000 + 25000) * 10%
{ accountNumber: '0500', credit: 6000, description: 'Wertberichtigung BGA' },
{ accountNumber: '7000', debit: 6000, description: 'AfA auf BGA', postingKey: 40 }, // (35000 + 25000) * 10%
{ accountNumber: '0500', credit: 6000, description: 'Wertberichtigung BGA', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -270,57 +291,57 @@ tap.test('should perform year-end adjustments (Jahresabschlussbuchungen)', async
description: 'Abschreibung Fuhrpark (linear 20%)',
reference: 'AFA-2024-003',
lines: [
{ accountNumber: '7000', debit: 1600, description: 'AfA auf Fuhrpark' },
{ accountNumber: '0400', credit: 1600, description: 'Wertberichtigung Fuhrpark' },
{ accountNumber: '7000', debit: 1600, description: 'AfA auf Fuhrpark', postingKey: 40 },
{ accountNumber: '0400', credit: 1600, description: 'Wertberichtigung Fuhrpark', postingKey: 40 },
],
skrType: 'SKR03',
});
// 2. Accruals (Rechnungsabgrenzung)
// 2. Accruals (Rechnungsabgrenzung) - internal adjustments use posting key 40
await api.postJournalEntry({
date: new Date('2024-12-31'),
description: 'Aktive Rechnungsabgrenzung - Vorausbezahlte Versicherung',
reference: 'ARA-2024-001',
lines: [
{ accountNumber: '1900', debit: 1000, description: 'Aktive Rechnungsabgrenzung' },
{ accountNumber: '7300', credit: 1000, description: 'Versicherungen' },
{ accountNumber: '1900', debit: 1000, description: 'Aktive Rechnungsabgrenzung', postingKey: 40 },
{ accountNumber: '7300', credit: 1000, description: 'Versicherungen', postingKey: 40 },
],
skrType: 'SKR03',
});
// 3. Provisions (Rückstellungen)
// 3. Provisions (Rückstellungen) - internal adjustments use posting key 40
await api.postJournalEntry({
date: new Date('2024-12-31'),
description: 'Rückstellung für Jahresabschlusskosten',
reference: 'RS-2024-001',
lines: [
{ accountNumber: '6700', debit: 3000, description: 'Rechts- und Beratungskosten' },
{ accountNumber: '3000', credit: 3000, description: 'Rückstellungen' },
{ accountNumber: '6700', debit: 3000, description: 'Rechts- und Beratungskosten', postingKey: 40 },
{ accountNumber: '3000', credit: 3000, description: 'Rückstellungen', postingKey: 40 },
],
skrType: 'SKR03',
});
// 4. Inventory adjustment
// 4. Inventory adjustment - internal adjustments use posting key 40
await api.postJournalEntry({
date: new Date('2024-12-31'),
description: 'Bestandsveränderung Waren',
reference: 'BV-2024-001',
lines: [
{ accountNumber: '3100', debit: 3000, description: 'Warenbestand Zugang' },
{ accountNumber: '5900', credit: 3000, description: 'Bestandsveränderungen' },
{ accountNumber: '3100', debit: 3000, description: 'Warenbestand Zugang', postingKey: 40 },
{ accountNumber: '5900', credit: 3000, description: 'Bestandsveränderungen', postingKey: 40 },
],
skrType: 'SKR03',
});
// 5. VAT clearing (Umsatzsteuer-Vorauszahlung)
// 5. VAT clearing (Umsatzsteuer-Vorauszahlung) - internal adjustments use posting key 40
await api.postJournalEntry({
date: new Date('2024-12-31'),
description: 'USt-Abschluss Q4',
reference: 'UST-2024-Q4',
lines: [
{ accountNumber: '1771', debit: 8740, description: 'USt-Saldo' }, // Total collected VAT
{ accountNumber: '1571', credit: 7191.50, description: 'Vorsteuer-Saldo' }, // Total input VAT
{ accountNumber: '1800', credit: 1548.50, description: 'USt-Zahllast' },
{ accountNumber: '1771', debit: 8740, description: 'USt-Saldo', postingKey: 40 }, // Total collected VAT
{ accountNumber: '1571', credit: 7191.50, description: 'Vorsteuer-Saldo', postingKey: 40 }, // Total input VAT
{ accountNumber: '1800', credit: 1548.50, description: 'USt-Zahllast', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -366,41 +387,41 @@ tap.test('should calculate income statement (GuV) before closing', async () => {
tap.test('should perform closing entries (Abschlussbuchungen)', async () => {
// Close all income and expense accounts to the profit/loss account
// Close revenue accounts
// Close revenue accounts - year-end closing uses posting key 40
await api.postJournalEntry({
date: new Date('2024-12-31'),
description: 'Abschluss Ertragskonten',
reference: 'AB-2024-001',
lines: [
{ accountNumber: '8400', debit: 46000, description: 'Erlöse abschließen' },
{ accountNumber: '9400', credit: 46000, description: 'GuV-Konto' },
{ accountNumber: '8400', debit: 46000, description: 'Erlöse abschließen', postingKey: 40 },
{ accountNumber: '9400', credit: 46000, description: 'GuV-Konto', postingKey: 40 },
],
skrType: 'SKR03',
});
// Close expense accounts
// Close expense accounts - year-end closing uses posting key 40
await api.postJournalEntry({
date: new Date('2024-12-31'),
description: 'Abschluss Aufwandskonten',
reference: 'AB-2024-002',
lines: [
{ accountNumber: '9400', debit: 45450, description: 'GuV-Konto' },
{ accountNumber: '7300', debit: 1000, description: 'Versicherung abschließen (credit balance)' },
{ accountNumber: '5900', debit: 3000, description: 'Bestandsveränderungen abschließen (credit balance)' },
{ accountNumber: '5400', credit: 5000, description: 'Wareneingang abschließen' },
{ accountNumber: '6000', credit: 18000, description: 'Löhne und Gehälter abschließen' },
{ accountNumber: '6100', credit: 3600, description: 'SV AG-Anteil abschließen' },
{ accountNumber: '7000', credit: 10000, description: 'AfA abschließen' },
{ accountNumber: '7100', credit: 2000, description: 'Miete abschließen' },
{ accountNumber: '7400', credit: 150, description: 'Kfz abschließen' },
{ accountNumber: '6600', credit: 5000, description: 'Werbung abschließen' },
{ accountNumber: '6700', credit: 5500, description: 'Beratung abschließen' },
{ accountNumber: '6800', credit: 200, description: 'Bürobedarf abschließen' },
{ accountNumber: '9400', debit: 45450, description: 'GuV-Konto', postingKey: 40 },
{ accountNumber: '7300', debit: 1000, description: 'Versicherung abschließen (credit balance)', postingKey: 40 },
{ accountNumber: '5900', debit: 3000, description: 'Bestandsveränderungen abschließen (credit balance)', postingKey: 40 },
{ accountNumber: '5400', credit: 5000, description: 'Wareneingang abschließen', postingKey: 40 },
{ accountNumber: '6000', credit: 18000, description: 'Löhne und Gehälter abschließen', postingKey: 40 },
{ accountNumber: '6100', credit: 3600, description: 'SV AG-Anteil abschließen', postingKey: 40 },
{ accountNumber: '7000', credit: 10000, description: 'AfA abschließen', postingKey: 40 },
{ accountNumber: '7100', credit: 2000, description: 'Miete abschließen', postingKey: 40 },
{ accountNumber: '7400', credit: 150, description: 'Kfz abschließen', postingKey: 40 },
{ accountNumber: '6600', credit: 5000, description: 'Werbung abschließen', postingKey: 40 },
{ accountNumber: '6700', credit: 5500, description: 'Beratung abschließen', postingKey: 40 },
{ accountNumber: '6800', credit: 200, description: 'Bürobedarf abschließen', postingKey: 40 },
],
skrType: 'SKR03',
});
// Transfer profit/loss to equity
// Transfer profit/loss to equity - year-end closing uses posting key 40
const guv_result = 46000 - 45450; // Profit of 550
if (guv_result > 0) {
await api.postJournalEntry({
@@ -408,8 +429,8 @@ tap.test('should perform closing entries (Abschlussbuchungen)', async () => {
description: 'Jahresgewinn auf Eigenkapital',
reference: 'AB-2024-003',
lines: [
{ accountNumber: '9400', debit: guv_result, description: 'GuV-Konto ausgleichen' },
{ accountNumber: '2900', credit: guv_result, description: 'Gewinnrücklagen' },
{ accountNumber: '9400', debit: guv_result, description: 'GuV-Konto ausgleichen', postingKey: 40 },
{ accountNumber: '2900', credit: guv_result, description: 'Gewinnrücklagen', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -419,8 +440,8 @@ tap.test('should perform closing entries (Abschlussbuchungen)', async () => {
description: 'Jahresverlust auf Eigenkapital',
reference: 'AB-2024-003',
lines: [
{ accountNumber: '2500', debit: Math.abs(guv_result), description: 'Verlustvortrag' },
{ accountNumber: '9400', credit: Math.abs(guv_result), description: 'GuV-Konto ausgleichen' },
{ accountNumber: '2500', debit: Math.abs(guv_result), description: 'Verlustvortrag', postingKey: 40 },
{ accountNumber: '9400', credit: Math.abs(guv_result), description: 'GuV-Konto ausgleichen', postingKey: 40 },
],
skrType: 'SKR03',
});

View File

@@ -7,7 +7,7 @@ let testConfig: Awaited<ReturnType<typeof getTestConfig>>;
tap.test('should demonstrate complete Jahresabschluss (Annual Financial Statement) for SKR04', async () => {
testConfig = await getTestConfig();
// Use timestamp to ensure unique database for each test run
const timestamp = Date.now();
api = new skr.SkrApi({
@@ -17,12 +17,31 @@ tap.test('should demonstrate complete Jahresabschluss (Annual Financial Statemen
await api.initialize('SKR04');
expect(api.getSKRType()).toEqual('SKR04');
// Create debtor account (customer) - replaces automatic account 1400
await api.createAccount({
accountNumber: '10001',
accountName: 'Kunde Mustermann GmbH',
accountClass: 1,
accountType: 'asset',
skrType: 'SKR04',
});
// Create creditor account (supplier) - replaces automatic account 1600
await api.createAccount({
accountNumber: '70001',
accountName: 'Lieferant Test GmbH',
accountClass: 7,
accountType: 'liability',
skrType: 'SKR04',
});
});
tap.test('should set up opening balances (Eröffnungsbilanz) for SKR04', async () => {
// Opening balances from previous year's closing
// SKR04 uses different account structure than SKR03
// Using personal accounts (10001 for debtor, 70001 for creditor) instead of automatic accounts
// Post opening journal entry (Eröffnungsbuchung)
const openingEntry = await api.postJournalEntry({
date: new Date('2024-01-01'),
@@ -30,19 +49,19 @@ tap.test('should set up opening balances (Eröffnungsbilanz) for SKR04', async (
reference: 'EB-2024',
lines: [
// Debit all asset accounts
{ accountNumber: '0200', debit: 45000, description: 'Grundstücke' },
{ accountNumber: '0210', debit: 120000, description: 'Gebäude' },
{ accountNumber: '0500', debit: 35000, description: 'BGA' },
{ accountNumber: '0400', debit: 8000, description: 'Fuhrpark' },
{ accountNumber: '1200', debit: 25000, description: 'Bank' },
{ accountNumber: '1000', debit: 2500, description: 'Kasse' },
{ accountNumber: '1400', debit: 18000, description: 'Forderungen' },
{ accountNumber: '0200', debit: 45000, description: 'Grundstücke', postingKey: 40 },
{ accountNumber: '0210', debit: 120000, description: 'Gebäude', postingKey: 40 },
{ accountNumber: '0500', debit: 35000, description: 'BGA', postingKey: 40 },
{ accountNumber: '0400', debit: 8000, description: 'Fuhrpark', postingKey: 40 },
{ accountNumber: '1200', debit: 25000, description: 'Bank', postingKey: 40 },
{ accountNumber: '1000', debit: 2500, description: 'Kasse', postingKey: 40 },
{ accountNumber: '10001', debit: 18000, description: 'Forderungen Kunde', postingKey: 40 },
// Credit all liability and equity accounts
{ accountNumber: '9000', credit: 150000, description: 'Eigenkapital' },
{ accountNumber: '9300', credit: 35000, description: 'Gewinnrücklagen' },
{ accountNumber: '1600', credit: 40500, description: 'Verbindlichkeiten L+L' },
{ accountNumber: '1700', credit: 28000, description: 'Sonstige Verbindlichkeiten' },
{ accountNumber: '9000', credit: 150000, description: 'Eigenkapital', postingKey: 40 },
{ accountNumber: '9300', credit: 35000, description: 'Gewinnrücklagen', postingKey: 40 },
{ accountNumber: '70001', credit: 40500, description: 'Verbindlichkeiten Lieferant', postingKey: 40 },
{ accountNumber: '1700', credit: 28000, description: 'Sonstige Verbindlichkeiten', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -61,9 +80,9 @@ tap.test('should record Q1 business transactions for SKR04', async () => {
description: 'Verkauf Waren auf Rechnung',
reference: 'RE-2024-001',
lines: [
{ accountNumber: '1400', debit: 11900, description: 'Forderungen inkl. USt' },
{ accountNumber: '4300', credit: 10000, description: 'Erlöse 19% USt' },
{ accountNumber: '1771', credit: 1900, description: 'Umsatzsteuer 19%' },
{ accountNumber: '10001', debit: 11900, description: 'Forderungen inkl. USt', postingKey: 9 },
{ accountNumber: '4300', credit: 10000, description: 'Erlöse 19% USt', postingKey: 40 },
{ accountNumber: '1771', credit: 1900, description: 'Umsatzsteuer 19%', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -74,9 +93,9 @@ tap.test('should record Q1 business transactions for SKR04', async () => {
description: 'Einkauf Material auf Rechnung',
reference: 'ER-2024-001',
lines: [
{ accountNumber: '2100', debit: 5000, description: 'Bezogene Waren' },
{ accountNumber: '1571', debit: 950, description: 'Vorsteuer 19%' },
{ accountNumber: '1600', credit: 5950, description: 'Verbindlichkeiten' },
{ accountNumber: '2100', debit: 5000, description: 'Bezogene Waren', postingKey: 40 },
{ accountNumber: '1571', debit: 950, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '70001', credit: 5950, description: 'Verbindlichkeiten', postingKey: 9 },
],
skrType: 'SKR04',
});
@@ -87,9 +106,9 @@ tap.test('should record Q1 business transactions for SKR04', async () => {
description: 'Gehaltszahlung Januar',
reference: 'GH-2024-01',
lines: [
{ accountNumber: '2300', debit: 8000, description: 'Löhne' },
{ accountNumber: '2400', debit: 1600, description: 'Gehälter' },
{ accountNumber: '1200', credit: 9600, description: 'Banküberweisung' },
{ accountNumber: '2300', debit: 8000, description: 'Löhne', postingKey: 40 },
{ accountNumber: '2400', debit: 1600, description: 'Gehälter', postingKey: 40 },
{ accountNumber: '1200', credit: 9600, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -100,8 +119,8 @@ tap.test('should record Q1 business transactions for SKR04', async () => {
description: 'Zahlungseingang Kunde',
reference: 'ZE-2024-001',
lines: [
{ accountNumber: '1200', debit: 11900, description: 'Bankgutschrift' },
{ accountNumber: '1400', credit: 11900, description: 'Forderungsausgleich' },
{ accountNumber: '1200', debit: 11900, description: 'Bankgutschrift', postingKey: 40 },
{ accountNumber: '10001', credit: 11900, description: 'Forderungsausgleich', postingKey: 3 },
],
skrType: 'SKR04',
});
@@ -112,8 +131,8 @@ tap.test('should record Q1 business transactions for SKR04', async () => {
description: 'Miete Februar',
reference: 'MI-2024-02',
lines: [
{ accountNumber: '3000', debit: 2000, description: 'Miete' },
{ accountNumber: '1200', credit: 2000, description: 'Banküberweisung' },
{ accountNumber: '3000', debit: 2000, description: 'Miete', postingKey: 40 },
{ accountNumber: '1200', credit: 2000, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -124,9 +143,9 @@ tap.test('should record Q1 business transactions for SKR04', async () => {
description: 'Büromaterial',
reference: 'BM-2024-001',
lines: [
{ accountNumber: '3100', debit: 200, description: 'Bürobedarf' },
{ accountNumber: '1571', debit: 38, description: 'Vorsteuer 19%' },
{ accountNumber: '1200', credit: 238, description: 'Bankzahlung' },
{ accountNumber: '3100', debit: 200, description: 'Bürobedarf', postingKey: 40 },
{ accountNumber: '1571', debit: 38, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '1200', credit: 238, description: 'Bankzahlung', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -137,9 +156,9 @@ tap.test('should record Q1 business transactions for SKR04', async () => {
description: 'Tankrechnung Firmenfahrzeug',
reference: 'KFZ-2024-001',
lines: [
{ accountNumber: '3300', debit: 150, description: 'Kfz-Kosten' },
{ accountNumber: '1571', debit: 28.50, description: 'Vorsteuer 19%' },
{ accountNumber: '1200', credit: 178.50, description: 'Bankzahlung' },
{ accountNumber: '3300', debit: 150, description: 'Kfz-Kosten', postingKey: 40 },
{ accountNumber: '1571', debit: 28.50, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '1200', credit: 178.50, description: 'Bankzahlung', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -150,9 +169,9 @@ tap.test('should record Q1 business transactions for SKR04', async () => {
description: 'Verkauf Dienstleistung',
reference: 'RE-2024-002',
lines: [
{ accountNumber: '1400', debit: 7140, description: 'Forderungen inkl. USt' },
{ accountNumber: '4300', credit: 6000, description: 'Erlöse 19% USt' },
{ accountNumber: '1771', credit: 1140, description: 'Umsatzsteuer 19%' },
{ accountNumber: '10001', debit: 7140, description: 'Forderungen inkl. USt', postingKey: 9 },
{ accountNumber: '4300', credit: 6000, description: 'Erlöse 19% USt', postingKey: 40 },
{ accountNumber: '1771', credit: 1140, description: 'Umsatzsteuer 19%', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -167,9 +186,9 @@ tap.test('should record Q2-Q4 business transactions for SKR04', async () => {
description: 'Kauf neue Produktionsmaschine',
reference: 'INV-2024-001',
lines: [
{ accountNumber: '0500', debit: 25000, description: 'Neue Maschine' },
{ accountNumber: '1571', debit: 4750, description: 'Vorsteuer 19%' },
{ accountNumber: '1200', credit: 29750, description: 'Banküberweisung' },
{ accountNumber: '0500', debit: 25000, description: 'Neue Maschine', postingKey: 40 },
{ accountNumber: '1571', debit: 4750, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '1200', credit: 29750, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -180,9 +199,9 @@ tap.test('should record Q2-Q4 business transactions for SKR04', async () => {
description: 'Großauftrag Kunde ABC',
reference: 'RE-2024-003',
lines: [
{ accountNumber: '1400', debit: 35700, description: 'Forderungen inkl. USt' },
{ accountNumber: '4300', credit: 30000, description: 'Erlöse 19% USt' },
{ accountNumber: '1771', credit: 5700, description: 'Umsatzsteuer 19%' },
{ accountNumber: '10001', debit: 35700, description: 'Forderungen inkl. USt', postingKey: 9 },
{ accountNumber: '4300', credit: 30000, description: 'Erlöse 19% USt', postingKey: 40 },
{ accountNumber: '1771', credit: 5700, description: 'Umsatzsteuer 19%', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -193,9 +212,9 @@ tap.test('should record Q2-Q4 business transactions for SKR04', async () => {
description: 'Werbekampagne',
reference: 'WK-2024-001',
lines: [
{ accountNumber: '3400', debit: 5000, description: 'Werbekosten' },
{ accountNumber: '1571', debit: 950, description: 'Vorsteuer 19%' },
{ accountNumber: '1600', credit: 5950, description: 'Verbindlichkeiten' },
{ accountNumber: '3400', debit: 5000, description: 'Werbekosten', postingKey: 40 },
{ accountNumber: '1571', debit: 950, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '70001', credit: 5950, description: 'Verbindlichkeiten', postingKey: 9 },
],
skrType: 'SKR04',
});
@@ -206,9 +225,9 @@ tap.test('should record Q2-Q4 business transactions for SKR04', async () => {
description: 'Steuerberatung',
reference: 'STB-2024-001',
lines: [
{ accountNumber: '3500', debit: 2500, description: 'Steuerberatungskosten' },
{ accountNumber: '1571', debit: 475, description: 'Vorsteuer 19%' },
{ accountNumber: '1200', credit: 2975, description: 'Banküberweisung' },
{ accountNumber: '3500', debit: 2500, description: 'Steuerberatungskosten', postingKey: 40 },
{ accountNumber: '1571', debit: 475, description: 'Vorsteuer 19%', postingKey: 9 },
{ accountNumber: '1200', credit: 2975, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -219,9 +238,9 @@ tap.test('should record Q2-Q4 business transactions for SKR04', async () => {
description: 'Jahresbonus Mitarbeiter',
reference: 'BON-2024',
lines: [
{ accountNumber: '2300', debit: 10000, description: 'Tantieme' },
{ accountNumber: '2400', debit: 2000, description: 'Gehälter Bonus' },
{ accountNumber: '1200', credit: 12000, description: 'Banküberweisung' },
{ accountNumber: '2300', debit: 10000, description: 'Tantieme', postingKey: 40 },
{ accountNumber: '2400', debit: 2000, description: 'Gehälter Bonus', postingKey: 40 },
{ accountNumber: '1200', credit: 12000, description: 'Banküberweisung', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -232,8 +251,8 @@ tap.test('should record Q2-Q4 business transactions for SKR04', async () => {
description: 'Zahlungseingang Großauftrag',
reference: 'ZE-2024-003',
lines: [
{ accountNumber: '1200', debit: 35700, description: 'Bankgutschrift' },
{ accountNumber: '1400', credit: 35700, description: 'Forderungsausgleich' },
{ accountNumber: '1200', debit: 35700, description: 'Bankgutschrift', postingKey: 40 },
{ accountNumber: '10001', credit: 35700, description: 'Forderungsausgleich', postingKey: 3 },
],
skrType: 'SKR04',
});
@@ -246,8 +265,8 @@ tap.test('should perform year-end adjustments (Jahresabschlussbuchungen) for SKR
description: 'Abschreibung Gebäude (linear 2%)',
reference: 'AFA-2024-001',
lines: [
{ accountNumber: '3700', debit: 2400, description: 'AfA auf Gebäude' },
{ accountNumber: '0210', credit: 2400, description: 'Wertberichtigung Gebäude' },
{ accountNumber: '3700', debit: 2400, description: 'AfA auf Gebäude', postingKey: 40 },
{ accountNumber: '0210', credit: 2400, description: 'Wertberichtigung Gebäude', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -257,8 +276,8 @@ tap.test('should perform year-end adjustments (Jahresabschlussbuchungen) for SKR
description: 'Abschreibung BGA (linear 10%)',
reference: 'AFA-2024-002',
lines: [
{ accountNumber: '3700', debit: 6000, description: 'AfA auf BGA' }, // (35000 + 25000) * 10%
{ accountNumber: '0500', credit: 6000, description: 'Wertberichtigung BGA' },
{ accountNumber: '3700', debit: 6000, description: 'AfA auf BGA', postingKey: 40 }, // (35000 + 25000) * 10%
{ accountNumber: '0500', credit: 6000, description: 'Wertberichtigung BGA', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -268,8 +287,8 @@ tap.test('should perform year-end adjustments (Jahresabschlussbuchungen) for SKR
description: 'Abschreibung Fuhrpark (linear 20%)',
reference: 'AFA-2024-003',
lines: [
{ accountNumber: '3700', debit: 1600, description: 'AfA auf Fuhrpark' },
{ accountNumber: '0400', credit: 1600, description: 'Wertberichtigung Fuhrpark' },
{ accountNumber: '3700', debit: 1600, description: 'AfA auf Fuhrpark', postingKey: 40 },
{ accountNumber: '0400', credit: 1600, description: 'Wertberichtigung Fuhrpark', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -280,8 +299,8 @@ tap.test('should perform year-end adjustments (Jahresabschlussbuchungen) for SKR
description: 'Aktive Rechnungsabgrenzung - Vorausbezahlte Versicherung',
reference: 'ARA-2024-001',
lines: [
{ accountNumber: '1900', debit: 1000, description: 'Aktive Rechnungsabgrenzung' },
{ accountNumber: '3200', credit: 1000, description: 'Versicherungen' },
{ accountNumber: '1900', debit: 1000, description: 'Aktive Rechnungsabgrenzung', postingKey: 40 },
{ accountNumber: '3200', credit: 1000, description: 'Versicherungen', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -292,8 +311,8 @@ tap.test('should perform year-end adjustments (Jahresabschlussbuchungen) for SKR
description: 'Rückstellung für Jahresabschlusskosten',
reference: 'RS-2024-001',
lines: [
{ accountNumber: '3500', debit: 3000, description: 'Rechts- und Beratungskosten' },
{ accountNumber: '0800', credit: 3000, description: 'Rückstellungen' },
{ accountNumber: '3500', debit: 3000, description: 'Rechts- und Beratungskosten', postingKey: 40 },
{ accountNumber: '0800', credit: 3000, description: 'Rückstellungen', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -304,9 +323,9 @@ tap.test('should perform year-end adjustments (Jahresabschlussbuchungen) for SKR
description: 'USt-Abschluss Q4',
reference: 'UST-2024-Q4',
lines: [
{ accountNumber: '1771', debit: 8740, description: 'USt-Saldo' }, // Total collected VAT
{ accountNumber: '1571', credit: 7191.50, description: 'Vorsteuer-Saldo' }, // Total input VAT
{ accountNumber: '1700', credit: 1548.50, description: 'USt-Zahllast' },
{ accountNumber: '1771', debit: 8740, description: 'USt-Saldo', postingKey: 40 }, // Total collected VAT
{ accountNumber: '1571', credit: 7191.50, description: 'Vorsteuer-Saldo', postingKey: 40 }, // Total input VAT
{ accountNumber: '1700', credit: 1548.50, description: 'USt-Zahllast', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -360,8 +379,8 @@ tap.test('should perform closing entries (Abschlussbuchungen) for SKR04', async
description: 'Abschluss Ertragskonten',
reference: 'AB-2024-001',
lines: [
{ accountNumber: '4300', debit: 46000, description: 'Erlöse abschließen' },
{ accountNumber: '9500', credit: 46000, description: 'GuV-Konto' },
{ accountNumber: '4300', debit: 46000, description: 'Erlöse abschließen', postingKey: 40 },
{ accountNumber: '9500', credit: 46000, description: 'GuV-Konto', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -372,17 +391,17 @@ tap.test('should perform closing entries (Abschlussbuchungen) for SKR04', async
description: 'Abschluss Aufwandskonten',
reference: 'AB-2024-002',
lines: [
{ accountNumber: '9500', debit: 48450, description: 'GuV-Konto' },
{ accountNumber: '3200', debit: 1000, description: 'Versicherung abschließen (credit balance)' },
{ accountNumber: '2100', credit: 5000, description: 'Bezogene Waren abschließen' },
{ accountNumber: '2300', credit: 18000, description: 'Löhne abschließen' },
{ accountNumber: '2400', credit: 3600, description: 'Gehälter abschließen' },
{ accountNumber: '3700', credit: 10000, description: 'AfA abschließen' },
{ accountNumber: '3000', credit: 2000, description: 'Miete abschließen' },
{ accountNumber: '3300', credit: 150, description: 'Kfz abschließen' },
{ accountNumber: '3400', credit: 5000, description: 'Werbung abschließen' },
{ accountNumber: '3500', credit: 5500, description: 'Beratung abschließen' },
{ accountNumber: '3100', credit: 200, description: 'Bürobedarf abschließen' },
{ accountNumber: '9500', debit: 48450, description: 'GuV-Konto', postingKey: 40 },
{ accountNumber: '3200', debit: 1000, description: 'Versicherung abschließen (credit balance)', postingKey: 40 },
{ accountNumber: '2100', credit: 5000, description: 'Bezogene Waren abschließen', postingKey: 40 },
{ accountNumber: '2300', credit: 18000, description: 'Löhne abschließen', postingKey: 40 },
{ accountNumber: '2400', credit: 3600, description: 'Gehälter abschließen', postingKey: 40 },
{ accountNumber: '3700', credit: 10000, description: 'AfA abschließen', postingKey: 40 },
{ accountNumber: '3000', credit: 2000, description: 'Miete abschließen', postingKey: 40 },
{ accountNumber: '3300', credit: 150, description: 'Kfz abschließen', postingKey: 40 },
{ accountNumber: '3400', credit: 5000, description: 'Werbung abschließen', postingKey: 40 },
{ accountNumber: '3500', credit: 5500, description: 'Beratung abschließen', postingKey: 40 },
{ accountNumber: '3100', credit: 200, description: 'Bürobedarf abschließen', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -395,8 +414,8 @@ tap.test('should perform closing entries (Abschlussbuchungen) for SKR04', async
description: 'Jahresgewinn auf Eigenkapital',
reference: 'AB-2024-003',
lines: [
{ accountNumber: '9500', debit: guv_result, description: 'GuV-Konto ausgleichen' },
{ accountNumber: '9300', credit: guv_result, description: 'Gewinnrücklagen' },
{ accountNumber: '9500', debit: guv_result, description: 'GuV-Konto ausgleichen', postingKey: 40 },
{ accountNumber: '9300', credit: guv_result, description: 'Gewinnrücklagen', postingKey: 40 },
],
skrType: 'SKR04',
});
@@ -406,8 +425,8 @@ tap.test('should perform closing entries (Abschlussbuchungen) for SKR04', async
description: 'Jahresverlust auf Eigenkapital',
reference: 'AB-2024-003',
lines: [
{ accountNumber: '9400', debit: Math.abs(guv_result), description: 'Verlustvortrag' },
{ accountNumber: '9500', credit: Math.abs(guv_result), description: 'GuV-Konto ausgleichen' },
{ accountNumber: '9400', debit: Math.abs(guv_result), description: 'Verlustvortrag', postingKey: 40 },
{ accountNumber: '9500', credit: Math.abs(guv_result), description: 'GuV-Konto ausgleichen', postingKey: 40 },
],
skrType: 'SKR04',
});

View File

@@ -91,9 +91,9 @@ tap.test('should post journal entry in SKR03', async () => {
description: 'Test journal entry',
reference: 'JE-001',
lines: [
{ accountNumber: '1000', debit: 500 }, // Cash
{ accountNumber: '1200', debit: 500 }, // Bank
{ accountNumber: '4000', credit: 1000 }, // Revenue
{ accountNumber: '1000', debit: 500, postingKey: 40 }, // Cash
{ accountNumber: '1200', debit: 500, postingKey: 40 }, // Bank
{ accountNumber: '4000', credit: 1000, postingKey: 40 }, // Revenue
],
skrType: 'SKR03',
});

View File

@@ -68,10 +68,19 @@ tap.test('should handle Class 8 as free for use in SKR04', async () => {
});
tap.test('should post complex transaction in SKR04', async () => {
// Create creditor account for supplier
await api.createAccount({
accountNumber: '70001',
accountName: 'Lieferant Test GmbH',
accountClass: 7,
accountType: 'liability',
skrType: 'SKR04',
});
const transaction = await api.postTransaction({
date: new Date(),
debitAccount: '5400', // Goods with 19% VAT
creditAccount: '1600', // Trade payables
creditAccount: '70001', // Creditor account (supplier)
amount: 119,
description: 'Purchase with VAT',
reference: 'BILL-001',

View File

@@ -29,8 +29,8 @@ tap.test('should enforce double-entry bookkeeping rules', async () => {
description: 'Unbalanced entry',
reference: 'TEST-001',
lines: [
{ accountNumber: '1000', debit: 100 },
{ accountNumber: '4000', credit: 50 }, // Unbalanced!
{ accountNumber: '1000', debit: 100, postingKey: 40 },
{ accountNumber: '4000', credit: 50, postingKey: 40 }, // Unbalanced!
],
skrType: 'SKR03',
});
@@ -99,10 +99,10 @@ tap.test(
description: 'Complex distribution',
reference: 'COMPLEX-001',
lines: [
{ accountNumber: '5000', debit: 500, description: 'Materials' },
{ accountNumber: '6000', debit: 300, description: 'Wages' },
{ accountNumber: '7100', debit: 200, description: 'Rent' },
{ accountNumber: '1200', credit: 1000, description: 'Bank payment' },
{ accountNumber: '5000', debit: 500, description: 'Materials', postingKey: 40 },
{ accountNumber: '6000', debit: 300, description: 'Wages', postingKey: 40 },
{ accountNumber: '7100', debit: 200, description: 'Rent', postingKey: 40 },
{ accountNumber: '1200', credit: 1000, description: 'Bank payment', postingKey: 40 },
],
skrType: 'SKR03',
});
@@ -220,10 +220,19 @@ tap.test('should handle batch transaction posting', async () => {
});
tap.test('should handle transaction with VAT', async () => {
// Create creditor account for supplier
await api.createAccount({
accountNumber: '70001',
accountName: 'Lieferant Test GmbH',
accountClass: 7,
accountType: 'liability',
skrType: 'SKR03',
});
const transaction = await api.postTransaction({
date: new Date(),
debitAccount: '5400', // Goods with 19% VAT
creditAccount: '1600', // Trade payables
creditAccount: '70001', // Creditor account (supplier)
amount: 119,
description: 'Purchase including VAT',
skrType: 'SKR03',