Use free function getPaymentOptionIndex() to compute index of valid

payment-option-section in tariff-file based on configured businessHours.
This commit is contained in:
Gerhard Hoffmann 2024-09-02 17:14:20 +02:00
parent f92906f680
commit 5cab0de9fb

View File

@ -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)) {