#986: DatevImportService.kt

projectforge-business/src/main/kotlin/org/projectforge/business/fibu/datev/DatevImportService.kt Type: Spring Service
Package: org.projectforge.business.fibu.datev
Actual Path: projectforge-business/src/main/kotlin/org/projectforge/business/fibu/datev/DatevImportService.kt
Note: The file does not exist at the requested path (.../excelimport/...). It resides in the datev sub-package. The documentation below reflects the actual source. 273 lines · 180 code · 69 comments · 24 blank

The orchestration service for DATEV-style Excel imports. Coordinates the import pipeline for both Kontenplan (chart of accounts) and Buchungssätze (accounting records). Manages the import lifecycle: parse (import), validate (reconcile), and persist (commit). All operations require the FIBU_DATEV_IMPORT user right.

Architecture

Dependencies

DependencyRole
PfPersistenceServicePersistence context management
AccessCheckerUser right verification
KontoDaoCommit kontenplan entries; resolve account numbers
Kost1DaoPassed to BuchungssatzExcelImporter
Kost2DaoPassed to BuchungssatzExcelImporter
BuchungssatzDaoCommit buchungssatz entries; lookup existing records

Import Lifecycle

Phase 1: Import (Parse Excel)

MethodInputOutput
importKontenplan(inputStream, filename)Excel InputStreamImportStorage<KontoDO>
importBuchungsdaten(inputStream, filename)Excel InputStreamImportStorage<BuchungssatzDO>

Both methods open an ExcelWorkbook from the input stream, create an ImportStorage with logging configuration, delegate to the respective importer class (KontenplanExcelImporter / BuchungssatzExcelImporter), and return the populated storage.

Phase 2: Reconcile (Validate & Diff)

MethodDescription
reconcile(storage, sheetName)Dispatches to reconcileKontenplan() or reconcileBuchungsdaten() based on storage type. Sets numberOfCommittedElements to -1.

Reconciliation matches imported elements with existing database entries:

Phase 3: Commit (Persist)

MethodDescription
commit(storage, sheetName)Requires RECONCILED status. Dispatches to commitKontenplan() or commitBuchungsdaten(). Sets status to IMPORTED.

Commit collects selected elements, sets the database id from oldValue if the entry already exists, and bulk-inserts via the DAO in blocks of 50.

Import Type Enum

DatevImportService.Type: KONTENPLAN, BUCHUNGSSAETZE. Used as a discriminator in ImportStorage.

Diff Properties

ConstantProperties
KONTO_DIFF_PROPERTIESnummer, bezeichnung
BUCHUNGSSATZ_DIFF_PROPERTIESsatznr, betrag, sh, konto, kost2, menge, beleg, datum, gegenKonto, text, kost1, comment

Access Control

All public methods call checkLoggedinUserRight() which verifies UserRightId.FIBU_DATEV_IMPORT with value TRUE. The companion object provides static helper methods for use in Wicket pages (pre-service decoupling).

Git History

868d6abb7 2025 -> 2026
312d5e61c Clean-up
63081666f Source file headers: 2024-> 2025.
1012e347a Migration stuff in progress... (all tests of all packages: OK).
bbc198d03 Migration stuff in progress... (all tests of all packages: OK).
4bc37b3a1 Migration stuff in progress...
d67bce18b Migration stuff in progress...
1b50060c3 BaseDao: renamed: get -> find, save -> insert, getList -> select, load -> select
87aaf6a5a Migration stuff in progress... BaseDao refactored (not yet finished)
3aeda5ef5 Big change: all save|update|...InTrans renamed (InTrans removed).