From c75d202df02c72dff86a36337c6cc354a3d448fe Mon Sep 17 00:00:00 2001 From: Kai Reinhard Date: Thu, 30 Jan 2025 01:09:35 +0100 Subject: [PATCH] AdminPage refreshes now also AuftragsRechnungCache. Visitorbook: unused field contactPerson removed. ForecastExportInvoices: cache access for order positions changed (fix of missing invoices) --- .../business/fibu/ForecastExportInvoices.kt | 10 +++------- .../org/projectforge/business/fibu/RechnungCache.kt | 8 +++++++- .../org/projectforge/business/system/SystemService.kt | 7 ++++++- .../projectforge/rest/orga/VisitorbookEntryPageRest.kt | 2 +- .../org/projectforge/web/fibu/RechnungListPage.java | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/ForecastExportInvoices.kt b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/ForecastExportInvoices.kt index 06a9492118..a8fcbc7dc2 100644 --- a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/ForecastExportInvoices.kt +++ b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/ForecastExportInvoices.kt @@ -56,14 +56,10 @@ internal class ForecastExportInvoices { // open needed by Wicket. continue // Ignoriere stornierte oder geplante Rechnungen. } rechnungCache.getRechnungInfo(invoice.id)?.positions?.forEach { pos -> - // for (pos in rechnungCache.getRechnungsPositionVOSetByRechnungId(invoice.id) ?: continue) { - val orderPosId = pos.auftragsPositionId + val orderPosInfo = rechnungCache.getOrderPositionInfoOfInvoicePos(pos.id) + val orderPosId = orderPosInfo?.id val orderPositionFound = orderPosId != null && ctx.orderPositionMap.containsKey(orderPosId) - // val invoiceProjektId = invoice.projektId - // val orderProjectId = orderPos?.auftrag?.projektId // may differ from invoiceProjektId - // val projectFound = invoiceProjektId != null && ctx.projectIds.contains(invoiceProjektId) || - // orderProjectId != null && ctx.projectIds.contains(orderProjectId) - if (!ctx.showAll && !orderPositionFound) { // !projectFound && !orderPositionFound) { + if (!ctx.showAll && !orderPositionFound) { return@forEach // Ignore invoices referring an order position or project which isn't part of the order list filtered by the user. } var order = if (orderPosId != null) { diff --git a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/RechnungCache.kt b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/RechnungCache.kt index 3d5a9b31ba..aa711e62df 100644 --- a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/RechnungCache.kt +++ b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/RechnungCache.kt @@ -52,7 +52,7 @@ class RechnungCache(rechnungJdbcService: RechnungJdbcService) : RechnungCalculator.auftragsCache = auftragsCache } - fun getOrderPositionInfos(rechnungId: Long?): Set? { + fun getOrderPositionInfosOfInvoice(rechnungId: Long?): Set? { rechnungId ?: return null val info = getRechnungInfo(rechnungId) ?: return null val set = mutableSetOf() @@ -66,6 +66,12 @@ class RechnungCache(rechnungJdbcService: RechnungJdbcService) : return set } + fun getOrderPositionInfoOfInvoicePos(rechnungPosId: Long?): OrderPositionInfo? { + rechnungPosId ?: return null + val posInfo = getRechnungPosInfo(rechnungPosId) ?: return null + return auftragsCache.getOrderPositionInfo(posInfo.auftragsPositionId) + } + fun getRechnungsPosInfosByAuftragId(auftragId: Long?): List? { auftragId ?: return null return auftragsRechnungCache.getRechnungsPosInfoByAuftragId(auftragId) diff --git a/projectforge-business/src/main/kotlin/org/projectforge/business/system/SystemService.kt b/projectforge-business/src/main/kotlin/org/projectforge/business/system/SystemService.kt index 42fc20e139..391637d891 100644 --- a/projectforge-business/src/main/kotlin/org/projectforge/business/system/SystemService.kt +++ b/projectforge-business/src/main/kotlin/org/projectforge/business/system/SystemService.kt @@ -27,6 +27,7 @@ import mu.KotlinLogging import org.apache.commons.io.FileUtils import org.projectforge.business.address.BirthdayCache.Companion.instance import org.projectforge.business.fibu.AuftragsCache +import org.projectforge.business.fibu.AuftragsRechnungCache import org.projectforge.business.fibu.KontoCache import org.projectforge.business.fibu.RechnungCache import org.projectforge.business.fibu.kost.KostCache @@ -62,6 +63,9 @@ class SystemService { @Autowired private lateinit var auftragsCache: AuftragsCache + @Autowired + private lateinit var auftragsRechnungCache: AuftragsRechnungCache + @Autowired private lateinit var cronSanityCheckJob: CronSanityCheckJob @@ -173,8 +177,9 @@ class SystemService { kostCache.forceReload() rechnungCache.forceReload() auftragsCache.forceReload() + auftragsRechnungCache.forceReload() systemInfoCache.forceReload() instance.forceReload() - return "UserGroupCache, TaskTree, KontoCache, KostCache, RechnungCache, AuftragsCache, SystemInfoCache, BirthdayCache" + return "UserGroupCache, TaskTree, KontoCache, KostCache, RechnungCache, AuftragsCache, AuftragsRechnungCache, SystemInfoCache, BirthdayCache" } } diff --git a/projectforge-rest/src/main/kotlin/org/projectforge/rest/orga/VisitorbookEntryPageRest.kt b/projectforge-rest/src/main/kotlin/org/projectforge/rest/orga/VisitorbookEntryPageRest.kt index 74886e0037..e178f4ef09 100644 --- a/projectforge-rest/src/main/kotlin/org/projectforge/rest/orga/VisitorbookEntryPageRest.kt +++ b/projectforge-rest/src/main/kotlin/org/projectforge/rest/orga/VisitorbookEntryPageRest.kt @@ -74,7 +74,7 @@ class VisitorbookEntryPageRest : AbstractDynamicPageRest() { } val lc = LayoutContext(VisitorbookEntryDO::class.java) val layout = UILayout("orga.visitorbook.timeofvisit") - layout.add(lc, "dateOfVisit", "arrived", "departed", "contactPerson", "comment") + layout.add(lc, "dateOfVisit", "arrived", "departed", "comment") layout.addAction(UIButton.createCancelButton(responseAction = ResponseAction(targetType = TargetType.CLOSE_MODAL))) if (id < 0) { // New entry diff --git a/projectforge-wicket/src/main/java/org/projectforge/web/fibu/RechnungListPage.java b/projectforge-wicket/src/main/java/org/projectforge/web/fibu/RechnungListPage.java index b51de840dd..d827d9e315 100644 --- a/projectforge-wicket/src/main/java/org/projectforge/web/fibu/RechnungListPage.java +++ b/projectforge-wicket/src/main/java/org/projectforge/web/fibu/RechnungListPage.java @@ -210,7 +210,7 @@ public void populateItem(final Item> item, final Stri public void populateItem(final Item> item, final String componentId, final IModel rowModel) { RechnungDO invoice = rowModel.getObject(); - final Set orderPositions = RechnungCache.getInstance().getOrderPositionInfos(invoice.getId()); + final Set orderPositions = RechnungCache.getInstance().getOrderPositionInfosOfInvoice(invoice.getId()); if (CollectionUtils.isEmpty(orderPositions) == true) { item.add(AbstractUnsecureBasePage.createInvisibleDummyComponent(componentId)); } else {