get_maximal_parkingprice(): in case of progressive tariff, read maximal parking time

directly form tariff-file as there is not price per hour.
This commit is contained in:
Gerhard Hoffmann 2024-02-20 15:47:02 +01:00
parent 9c19414e5a
commit 690267c388

View File

@ -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 CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) {
int maxPrice = -1; int maxPrice = -1;
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
switch(permitType) { switch(permitType) {
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
int const key = cfg->getPaymentOptions().pop_id; if (paymentMethodId == PaymentMethod::Progressive) {
int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key); } else { // PaymentMethod::Linear -> e.g. szeged
if (pv) { int const key = cfg->getPaymentOptions().pop_id;
QVector<ATBPaymentRate> const &paymentRate = pv.value(); int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes
if (paymentRate.size() > 0) { std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
int const price = paymentRate.at(0).pra_price; // price is given per hour if (pv) {
maxPrice = qRound((maxTime * price) / 60.0f); QVector<ATBPaymentRate> 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; } break;