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,9 +78,13 @@ 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)
if (paymentMethodId == PaymentMethod::Progressive) {
maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
} else { // PaymentMethod::Linear -> e.g. szeged
int const key = cfg->getPaymentOptions().pop_id; int const key = cfg->getPaymentOptions().pop_id;
int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes
std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key); std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
@ -91,6 +95,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TY
maxPrice = qRound((maxTime * price) / 60.0f); maxPrice = qRound((maxTime * price) / 60.0f);
} }
} }
}
} break; } break;
case PERMIT_TYPE::DAY_TICKET_ADULT: case PERMIT_TYPE::DAY_TICKET_ADULT:
break; break;