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:
parent
bcbe95d483
commit
acbc27cfb2
@ -347,9 +347,60 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
|
||||
.arg(free_parking_time_in_minutes);
|
||||
|
||||
if (std::optional<ATBTariffOutOfService> oos = getOutOfService(cfg, dt)) {
|
||||
if (overPaid || startDateNotOutOfService) {
|
||||
return std::make_pair(CalcState(CalcState::State::OVERPAID,
|
||||
CalcState::OVERPAID), dt);
|
||||
if (overPaid) {
|
||||
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]];
|
||||
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,
|
||||
CalcState::OUTSIDE_ALLOWED_PARKING_TIME), dt);
|
||||
|
Loading…
Reference in New Issue
Block a user