From 98555d5d8de7f457c83e805c4f99bfee35eb3ebe Mon Sep 17 00:00:00 2001 From: Kai Reinhard Date: Mon, 16 Dec 2024 16:45:13 +0100 Subject: [PATCH] Bugfix: search for numbers (e. g. invoices), monthlyEmployeeReportPage -> Timesheets. --- .../kotlin/org/projectforge/business/fibu/KostFormatter.kt | 4 ++-- .../kotlin/org/projectforge/business/fibu/kost/Kost2DO.kt | 2 +- .../framework/persistence/api/impl/DBPredicate.kt | 5 +++-- .../org/projectforge/web/fibu/MonthlyEmployeeReportPage.java | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/KostFormatter.kt b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/KostFormatter.kt index 5c05d0b65f..66d2601132 100644 --- a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/KostFormatter.kt +++ b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/KostFormatter.kt @@ -159,7 +159,7 @@ class KostFormatter { formatType: FormatType = FormatType.FORMATTED_NUMBER, abbreviationLength: Int = ABBREVIATION_LENGTH, ): String { - var useKost2 = kostCache.getKost2IfNotInitialized(kost2) + val useKost2 = kostCache.getKost2IfNotInitialized(kost2) ?: return if (formatType == FormatType.NUMBER) "????????" else "?.???.??.??" val delimiter = if ((formatType == FormatType.NUMBER)) "" else "." val sb = StringBuilder() @@ -171,7 +171,7 @@ class KostFormatter { } else { sb.append("--") } - var useProjekt = projektCache.getProjektIfNotInitialized(useKost2.projekt) + val useProjekt = projektCache.getProjektIfNotInitialized(useKost2.projekt) if (formatType == FormatType.LONG || formatType == FormatType.TEXT) { sb.append(": ") useProjekt.let { projekt -> diff --git a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/kost/Kost2DO.kt b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/kost/Kost2DO.kt index 775ab8afc9..659f9d4b08 100644 --- a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/kost/Kost2DO.kt +++ b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/kost/Kost2DO.kt @@ -155,7 +155,7 @@ open class Kost2DO : DefaultBaseDO(), Comparable, DisplayNameCapable { */ @get:PropertyInfo(i18nKey = "fibu.kost2") @get:Transient - @get:GenericField + @get:GenericField(name = "nummer") @get:IndexingDependency(derivedFrom = [ObjectPath(PropertyValue(propertyName = "id"))]) val formattedNumber: String get() = KostFormatter.instance.formatKost2(this, KostFormatter.FormatType.FORMATTED_NUMBER) diff --git a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/api/impl/DBPredicate.kt b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/api/impl/DBPredicate.kt index 8c3b994f11..8ba7bfb6a0 100644 --- a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/api/impl/DBPredicate.kt +++ b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/api/impl/DBPredicate.kt @@ -521,9 +521,10 @@ abstract class DBPredicate( logDebugFunCall(log) { it.mtd("FullSearch.handledByFullTextQuery(...)") } val useSearchFields = if (fulltextSearchFields.isNullOrEmpty()) searchClassInfo.stringFieldNames else fulltextSearchFields - if (fulltextSearchFields.isNullOrEmpty() && NumberUtils.isCreatable(queryString)) { + val plainQueryString = queryString.removeSuffix("*").removeSuffix("%") + if (fulltextSearchFields.isNullOrEmpty() && NumberUtils.isCreatable(plainQueryString)) { // query string is number, so search in number search fields as well as in text search fields. - val number = NumberUtils.createNumber(queryString) + val number = NumberUtils.createNumber(plainQueryString) search( searchPredicateFactory, boolCollector, diff --git a/projectforge-wicket/src/main/java/org/projectforge/web/fibu/MonthlyEmployeeReportPage.java b/projectforge-wicket/src/main/java/org/projectforge/web/fibu/MonthlyEmployeeReportPage.java index e83a3afeef..be8e387a53 100644 --- a/projectforge-wicket/src/main/java/org/projectforge/web/fibu/MonthlyEmployeeReportPage.java +++ b/projectforge-wicket/src/main/java/org/projectforge/web/fibu/MonthlyEmployeeReportPage.java @@ -287,7 +287,7 @@ private void addReport() { } final Kost2Row kost2Row = rowEntry.getValue(); final Kost2DO cost2 = kost2Row.getKost2(); - addLabelCols(row, cost2, null, "kost2.nummer:" + cost2.getFormattedNumber(), report.getUser(), + addLabelCols(row, cost2, null, "kost2.nummer:" + cost2.getFormattedNumber() + "*", report.getUser(), report.getFromDate().getTime(), report .getToDate().getTime()); final RepeatingView colWeekRepeater = new RepeatingView("colWeekRepeater");