#56: BankAccountRecordPagesRest.kt

plugins/org.projectforge.plugins.banking/src/main/kotlin/org/projectforge/plugins/banking/BankAccountRecordPagesRest.kt

Path: ./plugins/.../BankAccountRecordPagesRest.kt · Source: GitHub

311 lines · 264 code · 30 comments · 17 blank

What it does

REST controller for bank account record list/edit — the most feature-rich PagesRest class in the banking plugin. Adds magic filters (period, accounts multi-select, doublets, checksumErrors), post-processing (doublet detection via checksum, checksum validation, statistics), and AG Grid row coloring (green for positive amounts/incoming).

Magic filters

addMagicFilterElements():
  period:          DATE filter (date range)
  accounts:        Multi-select of bank accounts (loaded from bankAccountDao)
  doublets:        BOOLEAN — show only records with matching checksums
  checksumErrors:  BOOLEAN — show only records with broken checksums

Post-processing

postProcessResultSet():
  if doublets filter → filter list for isDoublet()
  if checksumErrors → filter for isChecksumError()
  add statistics → BankAccountRecordStatistics (sum of amounts as Markdown)

isDoublet(): records with same buildCheckSum() but different IDs
isChecksumError(): checksum != buildCheckSum()

Doublet detection and checksum verification are post-query in-memory filters — they can't be expressed as SQL/JPA. Doublets use BankAccountRecordDO.buildCheckSum() (#52) to detect identical bank statement entries that were imported twice. Statistics display total amounts as Markdown (rendered in the UI).