EN · DE · RU · FR · ES

#794: BuchungssatzImpl.java

projectforge-business/src/main/java/org/projectforge/reporting/impl/BuchungssatzImpl.java Adapter, projectforge-business/src/main/java/org/projectforge/reporting/impl/BuchungssatzImpl.java 143 lines · 90 code · 27 comments · 26 blank

Adapter Pattern for BuchungssatzDO

Proxy/adapter for BuchungssatzDO — the JPA entity representing an accounting entry in org.projectforge.business.fibu.kost. Implements the Buchungssatz reporting interface from org.projectforge.reporting. Javadoc: "Proxy for BuchungssatzDO".

This is the classic Adapter pattern: a JPA entity cannot directly implement a reporting interface (they live in separate modules with different dependency graphs), so a wrapper delegates all calls to the DO. At 143 lines, it is the largest Impl wrapper in the reporting package.

In its constructor, it accepts a BuchungssatzDO, extracts related objects (Konto, GegenKonto, Kost1, Kost2), and wraps each into its corresponding Impl class: KontoImpl (#795), Kost1Impl, Kost2Impl. All fields are cached as final — created once during construction and never recomputed.

Why not BuchungssatzDO implements Buchungssatz?

The JPA entity lives in the projectforge-business module, while the reporting interface is consumed by the financial reporting module. A direct dependency would create a circular dependency. The Adapter solves this: the DO knows nothing about reporting, and reporting obtains data through the wrapper. Additionally, the Impl can transform data (e.g. getFormattedMonth() calling StringHelper.format2DigitNumber()) without polluting the DO with reporting-specific formatting logic.

Method Delegation

Every getter simply delegates to the underlying BuchungssatzDO:

MethodReturnsSource
getId()LongDirect delegate
getBeleg()Document numberDirect delegate
getBetrag()BigDecimal amountDirect delegate
getComment()StringDirect delegate
getDatum()LocalDateDirect delegate
getGegenKonto()KontoCached Impl proxy
getKonto()KontoCached Impl proxy
getKost1()Kost1Cached Impl proxy
getKost2()Kost2Cached Impl proxy
getMenge()Quantity stringDirect delegate
getMonth()IntegerDirect delegate
getFormattedMonth()2-digit stringFormatted via StringHelper
getSatznr()IntegerDirect delegate
getSh()SHType (debit/credit)Direct delegate
getText()StringDirect delegate
getYear()IntegerDirect delegate

Type Migration History

The ID was migrated from Integer to Long in commit 4c04cfd65. Date fields use java.time.LocalDate (migrated from java.util.Date in 78b436d9e).

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
4c04cfd65 MAJOR-CHANGE! Migration of integer id's to Long id's (including fk's etc.)
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022
ceb63e8a1 Source code header: (C) 2001-2021.
a6a7aece4 Optimize Imports
78b436d9e Replace instances of java.util.date and java.sql.Date with java.time.LocalDate
7c79f1922 Copyright of source header -> 2020.