#918: EingangsrechnungsPositionDO.kt

projectforge-business/src/main/kotlin/org/projectforge/business/fibu/EingangsrechnungsPositionDO.kt Type: JPA Entity (Data Object) · Purpose: Represents a line item position within an incoming invoice (Eingangsrechnung) · Path: projectforge-business/src/main/kotlin/org/projectforge/business/fibu/EingangsrechnungsPositionDO.kt 96 lines · 56 code · 31 comments · 9 blank
Core domain entity representing a single position/line item in an incoming invoice. Extends AbstractRechnungsPositionDO and establishes the link to the parent EingangsrechnungDO plus the cost assignments (KostZuweisungDO). Hibernate-search indexed for full-text search.

Architecture / Design

Inheritance & JPA Mapping

Extends AbstractRechnungsPositionDO (the common base class for both incoming and outgoing invoice positions). Declared open (required by Kotlin + Hibernate for lazy-loading proxies). The @Table annotation maps to t_fibu_eingangsrechnung_position with a composite unique constraint on (eingangsrechnung_fk, number) — ensuring position numbers are unique within a single invoice.

FieldTypeJPA / Notes
eingangsrechnungEingangsrechnungDO?@ManyToOne(LAZY) — parent invoice reference. Uses @JsonBackReference to break serialization cycle. Serialized as ID-only via @JsonSerialize(IdOnlySerializer).
rechnungIdLong?@Transient — convenience getter that delegates to eingangsrechnung?.id. Overrides abstract property from AbstractRechnungsPositionDO.
kostZuweisungenMutableList<KostZuweisungDO>?@OneToMany(mappedBy="eingangsrechnungsPosition") with @OrderColumn(name="index"). @JsonManagedReference (the "owning" side of the JSON pair). Annotated with @PersistenceBehavior(autoUpdateCollectionEntries=true).

Key Methods

JSON Serialization Strategy

Uses @JsonBackReference on eingangsrechnung and @JsonManagedReference on kostZuweisungen to handle bidirectional relationships without infinite recursion. The parent invoice is serialized as ID-only, keeping JSON responses compact.

Git History

868d6abb7 2025 -> 2026
aa20b7708 NewGroupSelectPanel fixed (used in wizard). (Eingangs)RechnungsPositionDO: @get:JoinColumn -> mappedBy.
63081666f Source file headers: 2024-> 2025.
0237d5eba Json serialization refactored: IdOnlySerializer and IdsOnlySerializer introduced.
db2599ab8 History in orderbook, incming/outgoing invoices and projects.
4bc37b3a1 Migration stuff in progress...
fa194d7f8 Migration stuff in progress...
4c04cfd65 MAJOR-CHANGE! Migration of integer id's to Long id's (including fk's etc.)
c04fb0d51 Migration stuff in progress...
06828f490 Migration stuff in progress...
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
f984352a0 (Eingangs)Rechnung(sposition): @JsonBackReference/@JsonManagedReference: KostZuweisungDO
a9cf30719 (Eingangs)Rechnung(sposition): @JsonBackReference/@JsonManagedReference.
5f7ef41b8 Copyright 2021 -> 2022
c0f2b9de0 Tenants functionality removed everywhere (untested).
ceb63e8a1 Source code header: (C) 2001-2021.
b79632fa2 Add annotation to EingangsrechnungsPositionDO
7c79f1922 Copyright of source header -> 2020.
1cf12f943 Rechnungsposition->Kostzuweisung: Infinitive loop in json serialization fixed.
55d9ef9ce Nothing, code format
e3a1188d6 EingangsrechnungPositionDO: performance issue: lazy loading of parent Eingangsrechnung.
bc7b1761c Eingangsrechnungen: Kostzuweisungen fixed.
e92b3afd0 Jackson: JsonBackReference/JsonManagedReference -> JsonIdentityInfo
8675a1dbe Found big performance issue: Declared all Kotlin JPA entities and their properties as open. Lazy loading wasn't supported by Hibernate and results in thousands of JPA queries...
a55ef0c14 Heavy WIP: refactoring of (Eingangs)Rechnung*. Found a big performance killer!!!!!
812b5b751 Heavy WIP: refactoring of (Eingangs)Rechnung*. Found a big performance killer!!!!!
2c92507bc {Eingangs}RechnungsPositionDO.rechnungId is now val (not needed as var) and should be JPA transient.
f2b55f6aa RechnungsPositionDO.java - RechnungsPositionDO.kt EingangsrechnungsPositionDO.java -> EingangsrechnungsPositionDO.kt AbstractRechnungsPositionDO.java -> AbstractRechnungsPositionDO.kt