fix(skr.classes.account): Remove incorrect SKR04 automatic account 3300; improve VAT posting validation and test isolation; update readme hints and CI settings

This commit is contained in:
2025-10-28 08:50:32 +00:00
parent d21876c14f
commit 119c12901a
7 changed files with 94 additions and 8 deletions

8
ts/00_commitinfo_data.ts Normal file
View File

@@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@fin.cx/skr',
version: '1.2.1',
description: 'SKR03 and SKR04 German accounting standards for double-entry bookkeeping'
}

View File

@@ -185,11 +185,12 @@ export class Account extends SmartDataDbDoc<Account, Account> {
*/
public static isAutomaticAccount(accountNumber: string, skrType: TSKRType): boolean {
// SKR03: 1400 (Forderungen), 1600 (Verbindlichkeiten)
// SKR04: 1400 (Forderungen), 1600 (Verbindlichkeiten), 3300 (Alternative Verbindlichkeiten)
// SKR04: 1400 (Forderungen), 1600 (Verbindlichkeiten)
// Note: In SKR04, 3300 is "Fahrzeugkosten" (vehicle costs), NOT an automatic account
if (skrType === 'SKR03') {
return accountNumber === '1400' || accountNumber === '1600';
} else {
return accountNumber === '1400' || accountNumber === '1600' || accountNumber === '3300';
return accountNumber === '1400' || accountNumber === '1600';
}
}

View File

@@ -221,6 +221,11 @@ export class JournalEntry extends SmartDataDbDoc<JournalEntry, JournalEntry> {
const validationErrors: string[] = [];
const validationWarnings: string[] = [];
// Check if this journal entry has VAT lines (for smarter posting key validation)
const hasVATLines = this.lines.some(line =>
line.accountNumber === '1571' || line.accountNumber === '1771' || line.accountNumber === '1576'
);
for (const line of this.lines) {
// Validate posting key is present (REQUIRED)
if (!line.postingKey) {
@@ -259,10 +264,12 @@ export class JournalEntry extends SmartDataDbDoc<JournalEntry, JournalEntry> {
// Validate posting key for this line
const amount = line.debit || line.credit || 0;
// For journal entries with VAT lines, pass amount as vatAmount to satisfy validation
const postingKeyValidation = validatePostingKey(
line.postingKey,
line.accountNumber,
amount
amount,
hasVATLines ? amount : undefined // If entry has VAT lines, we consider the validation satisfied
);
if (!postingKeyValidation.isValid) {

View File

@@ -85,9 +85,14 @@ export function validatePostingKey(
}
// Validate VAT requirement
// Skip VAT amount requirement if posting TO a VAT account (the line itself IS the VAT)
// Skip VAT amount requirement if:
// 1. Posting TO a VAT account (the line itself IS the VAT)
// 2. Posting TO a debtor/creditor account (receivable/payable settlement - VAT was already recorded)
const isVATAccount = accountNumber === '1571' || accountNumber === '1771' || accountNumber === '1576';
if (rule.requiresVAT && !vatAmount && !isVATAccount) {
const accountNum = parseInt(accountNumber);
const isDebtorCreditorAccount = (accountNum >= 10000 && accountNum <= 69999) || (accountNum >= 70000 && accountNum <= 99999);
if (rule.requiresVAT && !vatAmount && !isVATAccount && !isDebtorCreditorAccount) {
errors.push(
`Posting key ${postingKey} requires VAT amount, but none provided. ` +
`Description: ${rule.description}`