Use helper functions GetTimeStep() and GetPriceForTimeStep() inside of

GetCostFromDuration().
This commit is contained in:
Gerhard Hoffmann 2023-10-11 15:41:02 +02:00
parent 7508cb6c45
commit 6ea2ea7df7

View File

@ -341,6 +341,15 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
/// <inheritdoc/>
double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_option, const QDateTime start_datetime, QDateTime & end_datetime, double durationMin, bool nextDay, bool prepaid)
{
if (cfg->project.project == "Schoenau" || cfg->project.project == "schoenau") {
static QList<int> const timeSteps = GetTimeSteps(cfg, payment_option);
if (!timeSteps.contains(durationMin)) {
return 0.0f; // error: timestep not valid
}
return GetPriceForTimeStep(cfg, payment_option, durationMin);
}
// Get input date
QDateTime inputDate = start_datetime;