diff --git a/library/src/calculator_functions.cpp b/library/src/calculator_functions.cpp index 80731de..edff2ed 100644 --- a/library/src/calculator_functions.cpp +++ b/library/src/calculator_functions.cpp @@ -133,7 +133,13 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg, QDateTime inputDate = QDateTime::fromString(startDatetimePassed, Qt::ISODate); inputDate.setTime(QTime(inputDate.time().hour(), inputDate.time().minute(), 0)); static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg); - int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get()); + + int paymentOptionIndex = getPaymentOptionIndex(*cfg); + if (paymentOptionIndex == -1) { + paymentOptionIndex = cfg->getPaymentOptionIndex(QDateTime::fromString(startDatetimePassed, Qt::ISODate)); + } + + qCritical() << DBG_HEADER << " option index:" << paymentOptionIndex; if (DBG_LEVEL >= DBG_DEBUG) { qCritical() << DBG_HEADER << " start:" << inputDate.toString(Qt::ISODate); @@ -1420,7 +1426,10 @@ double Calculator::GetCostFromDuration(Configuration* cfg, Q_UNUSED(payment_option); Q_UNUSED(nextDay); - int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get()); + int paymentOptionIndex = getPaymentOptionIndex(*cfg); + if (paymentOptionIndex == -1) { + paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get()); + } static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg); if (paymentMethodId == PaymentMethod::Steps) { if (tariffIs24_7(cfg)) {