Skip to content

Commit

Permalink
WIP test validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikvv committed Dec 3, 2024
1 parent ff94758 commit d46b549
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
18 changes: 13 additions & 5 deletions zummon/src/commonMain/kotlin/companysurvey/Electricity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class Electricity (
fun getHasConnection(): Boolean {
return hasConnection ?: false
}

/**
* Contracted capacity for delivery of electricity from grid to company.
*/
Expand All @@ -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()
}
}
}
Expand Down
20 changes: 13 additions & 7 deletions zummon/src/commonMain/kotlin/companysurvey/Validation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class GridConnectionValidator : Validator<GridConnection> {
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)))
}
Expand Down Expand Up @@ -289,7 +289,12 @@ class ElectricityValidator : Validator<Electricity> {
} ?: 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))
}
Expand Down Expand Up @@ -572,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"
)
)
}
}
}
Expand Down Expand Up @@ -701,11 +711,7 @@ val translations: Map<Language, Map<String, Map<String, String>>> = 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(
Expand Down

0 comments on commit d46b549

Please sign in to comment.