#889: AbstractRechnungsStatistik.kt

projectforge-business/src/main/kotlin/org/projectforge/business/fibu/AbstractRechnungsStatistik.kt

Type: Abstract generic class (Serializable)

Package: org.projectforge.business.fibu

Full path: projectforge-business/src/main/kotlin/org/projectforge/business/fibu/AbstractRechnungsStatistik.kt

223 lines · 148 code · 53 comments · 22 blank

Abstract statistics calculator for invoices. Aggregates financial metrics across a collection of invoices (outgoing or incoming): gross (brutto), net (netto), with cash discount (bruttoMitSkonto), paid (gezahlt), open (offen), overdue (ueberfaellig), and cash discount amounts (skonto). Also tracks payment term averages and provides Markdown-formatted output for Wicket UI display. Supports multi-currency conversion with warning tracking.

Type Parameter

T : AbstractRechnungDO? — The concrete invoice type (e.g., RechnungDO or EingangsrechnungDO).

Aggregated Properties

PropertyTypeDescription
bruttoBigDecimalTotal gross sum across all invoices
nettoBigDecimalTotal net sum
bruttoMitSkontoBigDecimalTotal gross with discount applied
gezahltBigDecimalTotal amount paid
offenBigDecimalTotal outstanding (not yet paid)
ueberfaelligBigDecimalTotal overdue amount
skontoBigDecimalAccepted shortfall (discounts granted by customer)
counterIntTotal number of invoices counted
counterBezahltIntNumber of fully paid invoices

Core Method: add(rechnung: T)

The primary entry point. For each invoice added:

  1. Retrieves cached invoice info via rechnungCache.getRechnungInfo(rechnung)
  2. Converts all amounts to the system's configured currency using currencyConversionService.convert()
  3. If currency conversion fails for any invoice, a warning message is accumulated in currencyConversionWarnings and the original (unconverted) amount is used as fallback
  4. Accumulates gross, net, gross-with-discount, and paid/open/overdue amounts
  5. Calculates cash discount (skonto) when paid amount is less than gross
  6. Tracks payment term averages: contractual (zahlungsZielSum) and actual (tatsaechlichesZahlungsZiel)
  7. Detects overdue invoices via rechnungInfo.isUeberfaellig

Currency Conversion

The private convertToSystemCurrency() method handles multi-currency scenarios:

Computed Properties

Companion Object Dependencies

The companion object holds lateinit service references that must be set externally before use:

Git History

868d6abb7 2025 -> 2026
472fbc977 WIP: currency conversion with Claude Code.
8c2bf04f0 WIP: currency conversion with Claude Code.
6be9c2b84 WIP: currency conversion with Claude Code.
63081666f Source file headers: 2024-> 2025.
b47c21af6 Refactored caching and calculations with invoices (not yet finished)
ccb7ca64d Migration stuff in progress...
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
09b3f0df7 WIP: Jobmonitor. ListStatisticsSupport -> MarkdownBuilder
0b835b27e Support of statistics or other infos on result set on list page.
a286007ee Mass update of creditor invoices: handling of discount implemented.
832934b14 WIP: mass update
PropertyTypeDescription
zahlungszielAverageIntAverage contractual payment term in days
tatsaechlichesZahlungzielAverageIntWeighted average actual payment duration in days
asMarkdownStringMarkdown table with all financial metrics, colored for open (blue) and overdue (red) amounts
hasCurrencyConversionWarningsBooleanTrue if any currency conversion failures occurred
currencyConversionWarningsListList<String>List of warning messages for Wicket display