2025-08-09 12:00:40 +00:00
|
|
|
export type TAccountType =
|
|
|
|
|
| 'asset'
|
|
|
|
|
| 'liability'
|
|
|
|
|
| 'equity'
|
|
|
|
|
| 'revenue'
|
|
|
|
|
| 'expense';
|
|
|
|
|
|
|
|
|
|
export type TSKRType = 'SKR03' | 'SKR04';
|
|
|
|
|
|
|
|
|
|
export type TTransactionStatus = 'pending' | 'posted' | 'reversed';
|
|
|
|
|
|
2025-10-27 08:34:28 +00:00
|
|
|
/**
|
|
|
|
|
* DATEV posting keys (Buchungsschlüssel) for German accounting
|
|
|
|
|
* These keys control automatic VAT booking and are checked in tax audits
|
|
|
|
|
*/
|
|
|
|
|
export type TPostingKey =
|
|
|
|
|
| 3 // Payment with 19% VAT
|
|
|
|
|
| 8 // 7% input VAT
|
|
|
|
|
| 9 // 19% input VAT
|
|
|
|
|
| 19 // 19% input VAT (intra-EU)
|
|
|
|
|
| 40 // Tax-free (disables VAT automatism)
|
|
|
|
|
| 94; // 19% input/output VAT (reverse charge)
|
|
|
|
|
|
2025-08-09 12:00:40 +00:00
|
|
|
export type TReportType =
|
|
|
|
|
| 'trial_balance'
|
|
|
|
|
| 'income_statement'
|
|
|
|
|
| 'balance_sheet'
|
|
|
|
|
| 'general_ledger'
|
|
|
|
|
| 'cash_flow';
|
|
|
|
|
|
2025-10-27 08:34:28 +00:00
|
|
|
/**
|
|
|
|
|
* Posting key validation rule
|
|
|
|
|
*/
|
|
|
|
|
export interface IPostingKeyRule {
|
|
|
|
|
key: TPostingKey;
|
|
|
|
|
description: string;
|
|
|
|
|
vatRate?: number; // Expected VAT rate (if applicable)
|
|
|
|
|
requiresVAT: boolean; // Whether VAT entry is required
|
|
|
|
|
disablesVATAutomatism: boolean; // Whether this key disables automatic VAT
|
|
|
|
|
allowedScenarios?: string[]; // Allowed tax scenarios (e.g., 'reverse_charge')
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-09 12:00:40 +00:00
|
|
|
export interface IAccountData {
|
|
|
|
|
accountNumber: string;
|
|
|
|
|
accountName: string;
|
|
|
|
|
accountClass: number;
|
|
|
|
|
accountType: TAccountType;
|
|
|
|
|
skrType: TSKRType;
|
|
|
|
|
description?: string;
|
|
|
|
|
vatRate?: number;
|
|
|
|
|
isActive?: boolean;
|
2025-10-27 08:34:28 +00:00
|
|
|
isAutomaticAccount?: boolean; // Automatikkonto (e.g., 1400, 1600) - cannot be posted to directly
|
2025-08-09 12:00:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ITransactionData {
|
|
|
|
|
date: Date;
|
|
|
|
|
debitAccount: string;
|
|
|
|
|
creditAccount: string;
|
|
|
|
|
amount: number;
|
|
|
|
|
description: string;
|
|
|
|
|
reference?: string;
|
|
|
|
|
skrType: TSKRType;
|
|
|
|
|
vatAmount?: number;
|
|
|
|
|
costCenter?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IJournalEntry {
|
|
|
|
|
date: Date;
|
|
|
|
|
description: string;
|
|
|
|
|
reference?: string;
|
|
|
|
|
lines: IJournalEntryLine[];
|
|
|
|
|
skrType: TSKRType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IJournalEntryLine {
|
|
|
|
|
accountNumber: string;
|
|
|
|
|
debit?: number;
|
|
|
|
|
credit?: number;
|
|
|
|
|
description?: string;
|
|
|
|
|
costCenter?: string;
|
2025-10-27 08:34:28 +00:00
|
|
|
postingKey: TPostingKey; // REQUIRED: DATEV posting key for VAT automation control
|
2025-08-09 12:00:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ITrialBalanceEntry {
|
|
|
|
|
accountNumber: string;
|
|
|
|
|
accountName: string;
|
|
|
|
|
debitBalance: number;
|
|
|
|
|
creditBalance: number;
|
|
|
|
|
netBalance: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ITrialBalanceReport {
|
|
|
|
|
date: Date;
|
|
|
|
|
skrType: TSKRType;
|
|
|
|
|
entries: ITrialBalanceEntry[];
|
|
|
|
|
totalDebits: number;
|
|
|
|
|
totalCredits: number;
|
|
|
|
|
isBalanced: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IIncomeStatementEntry {
|
|
|
|
|
accountNumber: string;
|
|
|
|
|
accountName: string;
|
|
|
|
|
amount: number;
|
|
|
|
|
percentage?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IIncomeStatement {
|
|
|
|
|
date: Date;
|
|
|
|
|
skrType: TSKRType;
|
|
|
|
|
revenue: IIncomeStatementEntry[];
|
|
|
|
|
expenses: IIncomeStatementEntry[];
|
|
|
|
|
totalRevenue: number;
|
|
|
|
|
totalExpenses: number;
|
|
|
|
|
netIncome: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IBalanceSheetEntry {
|
|
|
|
|
accountNumber: string;
|
|
|
|
|
accountName: string;
|
|
|
|
|
amount: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IBalanceSheet {
|
|
|
|
|
date: Date;
|
|
|
|
|
skrType: TSKRType;
|
|
|
|
|
assets: {
|
|
|
|
|
current: IBalanceSheetEntry[];
|
|
|
|
|
fixed: IBalanceSheetEntry[];
|
|
|
|
|
totalAssets: number;
|
|
|
|
|
};
|
|
|
|
|
liabilities: {
|
|
|
|
|
current: IBalanceSheetEntry[];
|
|
|
|
|
longTerm: IBalanceSheetEntry[];
|
|
|
|
|
totalLiabilities: number;
|
|
|
|
|
};
|
|
|
|
|
equity: {
|
|
|
|
|
entries: IBalanceSheetEntry[];
|
|
|
|
|
totalEquity: number;
|
|
|
|
|
};
|
|
|
|
|
isBalanced: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IAccountFilter {
|
|
|
|
|
skrType?: TSKRType;
|
|
|
|
|
accountClass?: number;
|
|
|
|
|
accountType?: TAccountType;
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
searchTerm?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ITransactionFilter {
|
|
|
|
|
skrType?: TSKRType;
|
|
|
|
|
dateFrom?: Date;
|
|
|
|
|
dateTo?: Date;
|
|
|
|
|
accountNumber?: string;
|
|
|
|
|
minAmount?: number;
|
|
|
|
|
maxAmount?: number;
|
|
|
|
|
searchTerm?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IDatabaseConfig {
|
|
|
|
|
mongoDbUrl: string;
|
|
|
|
|
dbName?: string;
|
2025-08-12 12:37:01 +00:00
|
|
|
invoiceExportPath?: string; // Optional path for invoice storage
|
2025-08-09 12:00:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IReportParams {
|
|
|
|
|
dateFrom?: Date;
|
|
|
|
|
dateTo?: Date;
|
|
|
|
|
skrType: TSKRType;
|
|
|
|
|
format?: 'json' | 'csv' | 'datev';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IAccountBalance {
|
|
|
|
|
accountNumber: string;
|
|
|
|
|
debitTotal: number;
|
|
|
|
|
creditTotal: number;
|
|
|
|
|
balance: number;
|
|
|
|
|
lastUpdated: Date;
|
|
|
|
|
}
|