ComputeDurationFromCost():

If overapid or trunctae has been set, then truncated max. parking time
	to time-limit configured in tariff-file.
This commit is contained in:
Gerhard Hoffmann 2024-09-30 16:51:51 +02:00
parent bcbe95d483
commit acbc27cfb2

View File

@ -347,9 +347,60 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
.arg(free_parking_time_in_minutes); .arg(free_parking_time_in_minutes);
if (std::optional<ATBTariffOutOfService> oos = getOutOfService(cfg, dt)) { if (std::optional<ATBTariffOutOfService> oos = getOutOfService(cfg, dt)) {
if (overPaid || startDateNotOutOfService) { if (overPaid) {
return std::make_pair(CalcState(CalcState::State::OVERPAID, QList <int> keys = nettoParktimePrice.keys();
CalcState::OVERPAID), dt); for (int k = 0; k < keys.size(); ++k) {
if (keys[k] < netto_parking_time_in_minutes) {
continue;
}
int const maxPriceForTimeLimit = nettoParktimePrice[keys[k]];
if (cost > maxPriceForTimeLimit) {
cfg->getPaymentOptions(paymentOptionIndex).pop_max_price = maxPriceForTimeLimit;
CalcState cs(CalcState::State::OVERPAID);
return std::make_pair(cs, dt);
}
if (cost == maxPriceForTimeLimit) {
cfg->getPaymentOptions(paymentOptionIndex).pop_max_price = maxPriceForTimeLimit;
CalcState cs(CalcState::State::SUCCESS_MAXPRICE);
return std::make_pair(cs, dt);
}
}
return std::make_pair(CalcState(CalcState::State::OVERPAID), dt);
}
if (startDateNotOutOfService) {
if (truncate) {
qCritical() << __func__ << ":" << __LINE__ << "set time-limit reached";
qCritical() << __func__ << ":" << __LINE__ << "netto-parking-time" << netto_parking_time_in_minutes;
Calculator::GetInstance().setTimeLimitReached(true);
QList <int> keys = nettoParktimePrice.keys();
for (int k = 0; k < keys.size(); ++k) {
if (keys[k] < netto_parking_time_in_minutes) {
continue;
}
int const maxPriceForTimeLimit = nettoParktimePrice[keys[k]];
qCritical() << __func__ << ":" << __LINE__ << keys[k] << maxPriceForTimeLimit << cost;
// Calculator::GetInstance().setCostAtTimeLimit(nettoParktimePrice[keys[k]]);
if (cost > maxPriceForTimeLimit) {
cfg->getPaymentOptions(paymentOptionIndex).pop_max_price = maxPriceForTimeLimit;
CalcState cs(CalcState::State::OVERPAID);
return std::make_pair(cs, dt);
}
if (cost == maxPriceForTimeLimit) {
cfg->getPaymentOptions(paymentOptionIndex).pop_max_price = maxPriceForTimeLimit;
CalcState cs(CalcState::State::SUCCESS_MAXPRICE);
return std::make_pair(cs, dt);
}
}
qCritical() << __func__ << ":" << __LINE__ << "DT" << dt.toString(Qt::ISODate);
return std::make_pair(CalcState(CalcState::State::SUCCESS), dt);
}
} }
return std::make_pair(CalcState(CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME, return std::make_pair(CalcState(CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME,
CalcState::OUTSIDE_ALLOWED_PARKING_TIME), dt); CalcState::OUTSIDE_ALLOWED_PARKING_TIME), dt);