From 690267c388b06ad3fa57c652e35e14c2feedda77 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 20 Feb 2024 15:47:02 +0100 Subject: [PATCH] get_maximal_parkingprice(): in case of progressive tariff, read maximal parking time directly form tariff-file as there is not price per hour. --- library/src/calculate_price.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/library/src/calculate_price.cpp b/library/src/calculate_price.cpp index 0a70495..54f965c 100644 --- a/library/src/calculate_price.cpp +++ b/library/src/calculate_price.cpp @@ -78,17 +78,22 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TY int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) { int maxPrice = -1; + static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg); switch(permitType) { case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) - int const key = cfg->getPaymentOptions().pop_id; - int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes - std::optional> const &pv = cfg->getPaymentRateForKey(key); - if (pv) { - QVector const &paymentRate = pv.value(); - if (paymentRate.size() > 0) { - int const price = paymentRate.at(0).pra_price; // price is given per hour - maxPrice = qRound((maxTime * price) / 60.0f); + if (paymentMethodId == PaymentMethod::Progressive) { + maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId); + } else { // PaymentMethod::Linear -> e.g. szeged + int const key = cfg->getPaymentOptions().pop_id; + int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes + std::optional> const &pv = cfg->getPaymentRateForKey(key); + if (pv) { + QVector const &paymentRate = pv.value(); + if (paymentRate.size() > 0) { + int const price = paymentRate.at(0).pra_price; // price is given per hour + maxPrice = qRound((maxTime * price) / 60.0f); + } } } } break;