From ff32fd474574145b633988a1709372f1c21a3926 Mon Sep 17 00:00:00 2001 From: Kai Reinhard Date: Tue, 14 Jan 2025 00:00:32 +0100 Subject: [PATCH] Test fixed. --- .../business/fibu/ForecastOrderPosInfo.kt | 9 +++------ .../business/fibu/ForecastOrderPosInfoTest.kt | 12 ++++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/ForecastOrderPosInfo.kt b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/ForecastOrderPosInfo.kt index 41cc7dab3a..d0695bc3be 100644 --- a/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/ForecastOrderPosInfo.kt +++ b/projectforge-business/src/main/kotlin/org/projectforge/business/fibu/ForecastOrderPosInfo.kt @@ -25,7 +25,6 @@ package org.projectforge.business.fibu import com.fasterxml.jackson.annotation.JsonIgnore import mu.KotlinLogging -import org.projectforge.common.extensions.isZeroOrNull import org.projectforge.framework.ToStringUtil import org.projectforge.framework.time.PFDay import org.projectforge.framework.utils.NumberHelper @@ -240,7 +239,6 @@ class ForecastOrderPosInfo( if (isUnderBudgetWarning(budget = probabilityNetSum, unused = monthEntry.lostBudget)) { monthEntry.lostBudgetWarning = true } - difference = monthEntry.lostBudget.negate() } } if (value.abs() > BigDecimal.ONE) { // values < 0 are possible for Abrufaufträge (Sarah fragen, 4273) @@ -254,9 +252,7 @@ class ForecastOrderPosInfo( if (futureInvoicesAmountRest.abs() <= BigDecimal.ONE) { // Only differences greater than 1 Euro futureInvoicesAmountRest = BigDecimal.ZERO } - if (difference.isZeroOrNull()) { - difference = futureInvoicesAmountRest.negate() - } + difference = futureInvoicesAmountRest.negate() } /** @@ -299,7 +295,8 @@ class ForecastOrderPosInfo( companion object { const val PERCENTAGE_OF_LOST_BUDGET_WARNING = 10 - private val PERCENTAGE_OF_LOST_BUDGET_WARNING_BD = BigDecimal(PERCENTAGE_OF_LOST_BUDGET_WARNING).divide(NumberHelper.HUNDRED) + private val PERCENTAGE_OF_LOST_BUDGET_WARNING_BD = + BigDecimal(PERCENTAGE_OF_LOST_BUDGET_WARNING).divide(NumberHelper.HUNDRED) /** * If true, unused budget will be added to the last distributed month. diff --git a/projectforge-business/src/test/kotlin/org/projectforge/business/fibu/ForecastOrderPosInfoTest.kt b/projectforge-business/src/test/kotlin/org/projectforge/business/fibu/ForecastOrderPosInfoTest.kt index aafdf4cd3e..d2397fdcaa 100644 --- a/projectforge-business/src/test/kotlin/org/projectforge/business/fibu/ForecastOrderPosInfoTest.kt +++ b/projectforge-business/src/test/kotlin/org/projectforge/business/fibu/ForecastOrderPosInfoTest.kt @@ -42,8 +42,8 @@ class ForecastOrderPosInfoTest { PeriodOfPerformanceType.OWN, periodOfPerformanceBegin = LocalDate.of(2024, Month.NOVEMBER, 13), periodOfPerformanceEnd = LocalDate.of(2025, Month.MARCH, 31), - netSum = BigDecimal("69456.24"), - invoicedSum = BigDecimal("6924.95") + netSum = BigDecimal("50000"), // 5 month + invoicedSum = BigDecimal("5000") ).also { pos -> ForecastOrderPosInfo(orderInfo, pos, baseDate = baseDate).also { fcPosInfo -> fcPosInfo.calculate() @@ -53,15 +53,15 @@ class ForecastOrderPosInfoTest { } if (ForecastOrderPosInfo.DISTRIBUTE_UNUSED_BUDGET) { for (i in 2..4) { - assertSame("13891.25", fcPosInfo.months[i].toBeInvoicedSum) + assertSame("10000", fcPosInfo.months[i].toBeInvoicedSum) } - assertSame("20857.54", fcPosInfo.months[5].toBeInvoicedSum) + assertSame("15000", fcPosInfo.months[5].toBeInvoicedSum) Assertions.assertEquals(BigDecimal.ZERO, fcPosInfo.difference) } else { for (i in 2..5) { - assertSame("13891.25", fcPosInfo.months[i].toBeInvoicedSum) + assertSame("10000", fcPosInfo.months[i].toBeInvoicedSum) } - assertSame("-6966.29", fcPosInfo.difference) + assertSame("-5000", fcPosInfo.difference) } } }