Compare commits
2 Commits
Neuhauser-
...
690267c388
Author | SHA1 | Date | |
---|---|---|---|
690267c388 | |||
9c19414e5a |
@@ -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;
|
||||||
|
@@ -157,6 +157,17 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
|
|
||||||
static const bool carryOverNotSet = Utilities::isCarryOverNotSet(cfg, paymentMethodId);
|
static const bool carryOverNotSet = Utilities::isCarryOverNotSet(cfg, paymentMethodId);
|
||||||
static const uint minParkingPrice = Utilities::getMinimalParkingPrice(cfg, paymentMethodId);
|
static const uint minParkingPrice = Utilities::getMinimalParkingPrice(cfg, paymentMethodId);
|
||||||
|
static const uint maxParkingPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
||||||
|
|
||||||
|
if (cost < minParkingPrice) {
|
||||||
|
qCritical() << QString("ERROR: COST < MIN_PARKING_PRICE (%1 < %2)").arg(cost).arg(minParkingPrice);
|
||||||
|
return QDateTime().toString(Qt::ISODate).toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cost > maxParkingPrice) {
|
||||||
|
qCritical() << QString("WARN: COST > MAX_PARKING_PRICE (%1 > %2)").arg(cost).arg(maxParkingPrice);
|
||||||
|
cost = maxParkingPrice;
|
||||||
|
}
|
||||||
|
|
||||||
Q_ASSERT_X(carryOverNotSet, __func__, "CARRYOVER SET (FOR KIRCHDORF)");
|
Q_ASSERT_X(carryOverNotSet, __func__, "CARRYOVER SET (FOR KIRCHDORF)");
|
||||||
Q_ASSERT_X(prepaid, __func__, "PREPAID NOT SET (FOR KIRCHDORF)");
|
Q_ASSERT_X(prepaid, __func__, "PREPAID NOT SET (FOR KIRCHDORF)");
|
||||||
@@ -279,6 +290,10 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
|
|
||||||
price += (uint)rate.pra_price;
|
price += (uint)rate.pra_price;
|
||||||
|
|
||||||
|
if (price >= maxParkingPrice) {
|
||||||
|
price = maxParkingPrice;
|
||||||
|
}
|
||||||
|
|
||||||
durationMinutes -= duration;
|
durationMinutes -= duration;
|
||||||
durationMinutesNetto += duration;
|
durationMinutesNetto += duration;
|
||||||
durationMinutesBrutto += duration;
|
durationMinutesBrutto += duration;
|
||||||
@@ -320,10 +335,16 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
ATBPaymentRate const rate = x.second;
|
ATBPaymentRate const rate = x.second;
|
||||||
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
|
||||||
price += (uint)rate.pra_price;
|
price += (uint)rate.pra_price;
|
||||||
|
|
||||||
|
if (price >= maxParkingPrice) {
|
||||||
|
price = maxParkingPrice;
|
||||||
|
}
|
||||||
|
|
||||||
if (price >= cost) {
|
if (price >= cost) {
|
||||||
end_datetime = current;
|
end_datetime = current;
|
||||||
// return end_datetime.toString(Qt::ISODate).toStdString();
|
// return end_datetime.toString(Qt::ISODate).toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user