Check if computed ticket-end-time violates a carry-over-limit defined in
tariff-file.
This commit is contained in:
parent
52ebbf7bc9
commit
8cdeef26fc
@ -554,7 +554,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// max. tolerance set to 3 minutes
|
// max. tolerance set to 3 minutes
|
||||||
unsigned const tolerance = std::min(minimalDistance, (unsigned)(3));
|
// unsigned const tolerance = std::min(minimalDistance, (unsigned)(3));
|
||||||
if (j != -1) {
|
if (j != -1) {
|
||||||
stepList[j] = currentTimeMinutes;
|
stepList[j] = currentTimeMinutes;
|
||||||
}
|
}
|
||||||
@ -842,6 +842,24 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
|
end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
end_parking_time.setTime(QTime(end_parking_time.time().hour(),
|
||||||
|
end_parking_time.time().minute(), 0));
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
weekDay = end_parking_time.date().dayOfWeek();
|
||||||
|
|
||||||
|
for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)weekDay); itr != rangeEnd; ++itr) {
|
||||||
|
ATBWeekDay const &wd = itr->second;
|
||||||
|
bool const parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(end_parking_time, paymentOptionIndex);
|
||||||
|
if (parkTimeLimitViolated) {
|
||||||
|
calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
|
||||||
|
.arg(end_parking_time.time().toString(Qt::ISODate)));
|
||||||
|
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cost = Calculator::GetInstance().GetCostFromDuration(
|
cost = Calculator::GetInstance().GetCostFromDuration(
|
||||||
tariff,
|
tariff,
|
||||||
@ -1085,25 +1103,43 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (carryOverStart.isValid() && carryOverEnd.isValid()) {
|
if (carryOverStart.isValid() && carryOverEnd.isValid()) {
|
||||||
qCritical() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
qCritical() << __func__ << ":" << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||||
qCritical() << __func__ << __LINE__ << "carryOverEnd" << carryOverEnd.toString(Qt::ISODate);
|
qCritical() << __func__ << ":" << __LINE__ << "carryOverEnd" << carryOverEnd.toString(Qt::ISODate);
|
||||||
qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
|
qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration" << carryOverDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) {
|
if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) {
|
||||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
if (ticketEndTime.time() > carryOverStart) {
|
if (ticketEndTime.time() > carryOverStart) {
|
||||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||||
} else {
|
} else {
|
||||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
if (ticketEndTime.time() < carryOverEnd) {
|
if (ticketEndTime.time() < carryOverEnd) {
|
||||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << __func__ << __LINE__ << "WARNING: wrong carry-over-settings";
|
qCritical() << __func__ << ":" << __LINE__ << "WARNING: wrong carry-over-settings";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ticketEndTime.setTime(QTime(ticketEndTime.time().hour(),
|
||||||
|
ticketEndTime.time().minute(), 0));
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)(ticketEndTime.date().dayOfWeek()));
|
||||||
|
itr != rangeEnd;
|
||||||
|
++itr) {
|
||||||
|
ATBWeekDay const &wd = itr->second;
|
||||||
|
bool const parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(ticketEndTime, paymentOptionIndex);
|
||||||
|
if (parkTimeLimitViolated) {
|
||||||
|
calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
|
||||||
|
.arg(ticketEndTime.time().toString(Qt::ISODate)));
|
||||||
|
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user