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

@@ -418,6 +418,7 @@ export class Ledger {
accountNumber: account.accountNumber,
debit: Math.abs(balance),
description: `Closing ${account.accountName}`,
postingKey: 40, // Tax-free - internal closing entry
});
totalRevenue += Math.abs(balance);
}
@@ -429,6 +430,7 @@ export class Ledger {
accountNumber: closingAccountNumber,
credit: totalRevenue,
description: 'Revenue closing to P&L',
postingKey: 40, // Tax-free - internal closing entry
});
const revenueClosingEntry = await this.postJournalEntry({
@@ -458,6 +460,7 @@ export class Ledger {
accountNumber: account.accountNumber,
credit: Math.abs(balance),
description: `Closing ${account.accountName}`,
postingKey: 40, // Tax-free - internal closing entry
});
totalExpense += Math.abs(balance);
}
@@ -469,6 +472,7 @@ export class Ledger {
accountNumber: closingAccountNumber,
debit: totalExpense,
description: 'Expense closing to P&L',
postingKey: 40, // Tax-free - internal closing entry
});
const expenseClosingEntry = await this.postJournalEntry({