Use free function getPaymentOptionIndex() to compute index of valid
payment-option-section in tariff-file based on configured businessHours.
This commit is contained in:
		| @@ -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)) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user