#910: CurrencyConversionRateDO.kt

projectforge-business/src/main/kotlin/org/projectforge/business/fibu/CurrencyConversionRateDO.kt Type: JPA Entity (Data Object)
Package: org.projectforge.business.fibu
Path: projectforge-business/src/main/kotlin/org/projectforge/business/fibu/CurrencyConversionRateDO.kt
Author: Kai Reinhard (k.reinhard@micromata.de) 119 lines · 75 code · 33 comments · 11 blank

A time-dependent currency conversion rate record. Each entry belongs to a CurrencyPairDO and has a validFrom date. The rate remains active until a newer rate's validFrom date takes effect. Both forward and inverse rates are stored to simplify querying from either direction. Extends AbstractBaseDO<Long> and implements Serializable.

Database Mapping

Tablet_fibu_currency_conversion_rate
PK Columnpk (sequence-generated)
Unique Constraint(currency_pair_fk, valid_from)
Indexesidx_fk_t_fibu_curr_conv_rate_pair on currency_pair_fk, idx_t_fibu_curr_conv_rate_valid on valid_from

Named Queries

ConstantQueryPurpose
FIND_BY_PAIR_AND_DATEFind rate by pair id and validFromValidation — check if a rate already exists
FIND_OTHER_BY_PAIR_AND_DATEFind rate by pair id, validFrom, excluding a given idValidation during update (exclude self)
FIND_ALL_BY_PAIRAll rates for a pair, sorted by validFrom DESCListing and active-rate lookup

Fields

FieldTypeColumnConstraintsDescription
idLong?pkPK, sequencePrimary key
currencyPairCurrencyPairDO?currency_pair_fkFK, not null, lazy, @JsonIdentityReferenceParent currency pair (serialized as id only)
validFromLocalDate?valid_fromNot nullDate from which this rate becomes active
conversionRateBigDecimal?conversion_rateScale 8, precision 18, not nullForward conversion factor (source → target)
inverseConversionRateBigDecimal?inverse_conversion_rateScale 8, precision 18, not nullInverse factor (target → source), stored redundantly for performance
commentString?commentMax length Constants.LENGTH_TEXTOptional comment

Key Methods

History Tracking

Annotated with @WithHistory, enabling automatic change tracking via the ProjectForge history framework.

Git History

868d6abb7 2025 -> 2026
07edc85de WIP: currency conversion with Claude Code.
0d4a5352a WIP: currency conversion with Claude Code.
bd69407de Initial revision with Claude Code.