diff --git a/zorm/src/test/kotlin/com/zenmo/orm/companysurvey/ElectricityTest.kt b/zorm/src/test/kotlin/com/zenmo/orm/companysurvey/ElectricityTest.kt index 9a772e29..2f9d09ab 100644 --- a/zorm/src/test/kotlin/com/zenmo/orm/companysurvey/ElectricityTest.kt +++ b/zorm/src/test/kotlin/com/zenmo/orm/companysurvey/ElectricityTest.kt @@ -16,7 +16,7 @@ class ElectricityTest { ) ) - assertEquals(electricity.getContractedConnectionCapacityKw(), 3 * 80.0 * 230.0 * 0.001) + assertEquals(electricity.getContractedDeliveryCapacityKw(), 3 * 80.0 * 230.0 * 0.001) } @Test @@ -27,6 +27,6 @@ class ElectricityTest { ) ) - assertEquals(electricity.getContractedConnectionCapacityKw(), 400.0) + assertEquals(electricity.getContractedDeliveryCapacityKw(), 400.0) } } diff --git a/zummon/src/commonMain/kotlin/companysurvey/Electricity.kt b/zummon/src/commonMain/kotlin/companysurvey/Electricity.kt index ba51dbda..ab27cdd4 100644 --- a/zummon/src/commonMain/kotlin/companysurvey/Electricity.kt +++ b/zummon/src/commonMain/kotlin/companysurvey/Electricity.kt @@ -34,7 +34,7 @@ data class Electricity ( fun getHasConnection(): Boolean { return hasConnection ?: false } - + /** * Contracted capacity for delivery of electricity from grid to company. */ @@ -54,14 +54,22 @@ data class Electricity ( } } + fun getContractedDeliveryCapacityKw(): Double? { + return when (kleinverbruikOrGrootverbruik) { + KleinverbruikOrGrootverbruik.GROOTVERBRUIK -> grootverbruik?.contractedConnectionDeliveryCapacity_kW?.toDouble() + KleinverbruikOrGrootverbruik.KLEINVERBRUIK -> kleinverbruik?.connectionCapacity?.toKw() + else -> kleinverbruik?.connectionCapacity?.toKw() ?: grootverbruik?.contractedConnectionDeliveryCapacity_kW?.toDouble() + } + } + /** * Contracted capacity for feed-in of electricity from company to grid. */ fun getContractedFeedInCapacityKw(): Double? { - when (kleinverbruikOrGrootverbruik) { - KleinverbruikOrGrootverbruik.GROOTVERBRUIK -> return grootverbruik?.contractedConnectionFeedInCapacity_kW?.toDouble() - KleinverbruikOrGrootverbruik.KLEINVERBRUIK -> return kleinverbruik?.connectionCapacity?.toKw() - else -> return kleinverbruik?.connectionCapacity?.toKw() ?: grootverbruik?.contractedConnectionFeedInCapacity_kW?.toDouble() + return when (kleinverbruikOrGrootverbruik) { + KleinverbruikOrGrootverbruik.GROOTVERBRUIK -> grootverbruik?.contractedConnectionFeedInCapacity_kW?.toDouble() + KleinverbruikOrGrootverbruik.KLEINVERBRUIK -> kleinverbruik?.connectionCapacity?.toKw() + else -> kleinverbruik?.connectionCapacity?.toKw() ?: grootverbruik?.contractedConnectionFeedInCapacity_kW?.toDouble() } } } diff --git a/zummon/src/commonMain/kotlin/companysurvey/TimeSeries.kt b/zummon/src/commonMain/kotlin/companysurvey/TimeSeries.kt index e7af2856..13068fbb 100644 --- a/zummon/src/commonMain/kotlin/companysurvey/TimeSeries.kt +++ b/zummon/src/commonMain/kotlin/companysurvey/TimeSeries.kt @@ -77,6 +77,7 @@ data class TimeSeries ( return maxNullSequence } + fun getPeak(): DataPoint = DataPoint(values.max(), unit, timeStep) /** * Get a full calendar year of data if it is present. diff --git a/zummon/src/commonMain/kotlin/companysurvey/Validation.kt b/zummon/src/commonMain/kotlin/companysurvey/Validation.kt index 82059922..47621c6f 100644 --- a/zummon/src/commonMain/kotlin/companysurvey/Validation.kt +++ b/zummon/src/commonMain/kotlin/companysurvey/Validation.kt @@ -57,11 +57,11 @@ class GridConnectionValidator : Validator { gridConnection.transport.vans.powerPerChargePointKw ).map { (it ?: 0).toFloat() }.sum() - val contractedCapacity = (gridConnection.electricity.getContractedConnectionCapacityKw() ?: 0.0).toFloat() + val contractedCapacity = (gridConnection.electricity.getContractedDeliveryCapacityKw() ?: 0.0).toFloat() val batteryPower = (gridConnection.storage.batteryPowerKw ?: 0.0).toFloat() return if (totalPowerChargePoints < (contractedCapacity + batteryPower)) { - listOf(ValidationResult(Status.VALID, translate("gridConnection.totalPowerChargePoints"))) + listOf(ValidationResult(Status.VALID, translate("gridConnection.totalPowerChargePointsValid"))) } else { listOf(ValidationResult(Status.INVALID, translate("gridConnection.totalPowerChargePointsInvalid", totalPowerChargePoints, contractedCapacity + batteryPower))) } @@ -235,7 +235,7 @@ class ElectricityValidator : Validator { // Validator for contracted delivery capacity <= physical capacity fun validateContractedCapacity(electricity: Electricity): ValidationResult { - val contractedCapacity = electricity.getContractedConnectionCapacityKw() + val contractedCapacity = electricity.getContractedDeliveryCapacityKw() val physicalCapacity = electricity.getPhysicalConnectionCapacityKw() return when { @@ -289,7 +289,12 @@ class ElectricityValidator : Validator { } ?: false if (isCloseEnough) { - ValidationResult(Status.VALID, translate("electricity.annualFeedInValid", electricity.annualElectricityFeedIn_kWh, totalQuarterHourlyFeedIn)) + ValidationResult( + Status.VALID, message( + nl = "Jaarwaarde teruglevering ${electricity.annualElectricityFeedIn_kWh} kWh komt overeen met het totaal van de kwartierwaarden ${totalQuarterHourlyFeedIn} kWh", + en = "Annual feed-in of ${electricity.annualElectricityFeedIn_kWh} kWh matches total of quarter-hourly feed-in ${totalQuarterHourlyFeedIn} kWh", + ) + ) } else { ValidationResult(Status.INVALID, translate("electricity.annualFeedInMismatch", electricity.annualElectricityFeedIn_kWh, totalQuarterHourlyFeedIn)) } @@ -366,7 +371,10 @@ class ElectricityValidator : Validator { nl = "Peak of quarter-hourly delivery ${peakDelivery.kWh()} kWh does not exceed contracted capacity ${contractedCapacity_kW} kW", )) } else { - ValidationResult(Status.INVALID, translate("electricity.quarterHourlyDeliveryHighContractedCapacityKw", contractedCapacity)) + ValidationResult(Status.INVALID, message( + nl = "Piek van kwartierwaarden levering ${peakDelivery.kWh()} kWh mag niet hoger zijn dan gecontracteerd vermogen levering ${contractedCapacity_kW} kW", + en = "Peak of quarter-hourly ${peakDelivery.kWh()} kWh delivery should be below contracted capacity ${contractedCapacity_kW} Kw", + )) } } @@ -569,7 +577,12 @@ class TransportValidator { fun validateTotalElectricVans(transport: Transport): ValidationResult { return when { ((transport.vans.numElectricVans ?: 0) > (transport.vans.numVans ?: 0)) -> ValidationResult(Status.INVALID, translate("transport.electricVansInvalid", transport.vans.numElectricVans, transport.vans.numVans)) - else -> ValidationResult(Status.VALID, translate("transport.electricVansValid")) + else -> ValidationResult( + Status.VALID, message( + en = "Number of electric vans does not exceed the total number of Vans", + nl = "Aantal elektrische bestelwagens valt binnen het totale aantal bestelwagens" + ) + ) } } } @@ -698,11 +711,7 @@ val translations: Map>> = mapOf( "electricTrucksValid" to "Number of Electric Trucks is lower than the total of Trucks", "electricTrucksInvalid" to "Number of electric trucks %d exceeds the total number of trucks %d", - "electricVansValid" to "Number of Electric Vans is lower than the total of Vans", "electricVansInvalid" to "Number of electric vans %d exceeds the total number of vans %d", - - "quarterHourlyDeliveryLowContractedCapacityKw" to "Kwartuur levering blijft lager dan de Contractuele CapaciteitKw (%d)", - "quarterHourlyDeliveryHighContractedCapacityKw" to "Kwartuur levering mag niet hoger zijn dan de Contractuele CapaciteitKw (%d)", ), ), Language.nl to mapOf(