parseWeekDay():
for the park-time-limit checking take into account that the start-date-time and end-date-time are on different days.
This commit is contained in:
parent
75f1c1bb76
commit
f02521d3c2
@ -112,7 +112,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
for (auto l = o.MemberBegin(); l != o.MemberEnd(); ++l) {
|
||||
if (l->name.IsString()) {
|
||||
QString const &member = QString::fromStdString(l->name.GetString());
|
||||
if (member == "default") {
|
||||
if (member == "prev_day_sunday?") {
|
||||
if (l->value.IsArray()) {
|
||||
auto limits = l->value.GetArray();
|
||||
if (limits.Size() >= 2) {
|
||||
@ -120,23 +120,26 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate);
|
||||
}
|
||||
parkTimeLimitChecker = [&cfg, weekDay, weekDayName](ATBTariffCarryOverSettings const& cs,
|
||||
QDateTime const &endTime,
|
||||
int paymentOptionIndex) {
|
||||
if (endTime.date().dayOfWeek() == (int)weekDay) {
|
||||
if (endTime.time() > cs.m_parking_time_limit) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< QString("ERROR time limit for end-time violated: [%1, %2 end-time=%3], but time-limit=%4")
|
||||
.arg(weekDayName)
|
||||
.arg(endTime.date().toString(Qt::ISODate))
|
||||
.arg(endTime.time().toString(Qt::ISODate))
|
||||
.arg(cs.m_parking_time_limit.toString(Qt::ISODate));
|
||||
return true;
|
||||
}
|
||||
if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
|
||||
} else {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
|
||||
QDateTime const &startTime,
|
||||
QDateTime const &endTime,
|
||||
int paymentOptionIndex) {
|
||||
if (startTime.date() < endTime.date()) { // start end end on different days
|
||||
if (endTime.date().dayOfWeek() == (int)weekDay) {
|
||||
if (endTime.time() > cs.m_parking_time_limit) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< QString("ERROR time limit for end-time violated: [%1, %2 end-time=%3], but time-limit=%4")
|
||||
.arg(weekDayName)
|
||||
.arg(endTime.date().toString(Qt::ISODate))
|
||||
.arg(endTime.time().toString(Qt::ISODate))
|
||||
.arg(cs.m_parking_time_limit.toString(Qt::ISODate));
|
||||
return true;
|
||||
}
|
||||
if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
|
||||
} else {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -151,23 +154,26 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate);
|
||||
}
|
||||
parkTimeLimitChecker = [&cfg, weekDayName](ATBTariffCarryOverSettings const& cs,
|
||||
QDateTime const &endTime,
|
||||
int paymentOptionIndex) {
|
||||
if (previousDayHoliday(cfg, endTime)) {
|
||||
if (endTime.time() > cs.m_parking_time_limit) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< QString("ERROR time limit for end-time violated: [%1, %2, end-time=%3], but time-limit=%4")
|
||||
.arg(weekDayName)
|
||||
.arg(endTime.date().toString(Qt::ISODate))
|
||||
.arg(endTime.time().toString(Qt::ISODate))
|
||||
.arg(cs.m_parking_time_limit.toString(Qt::ISODate));
|
||||
return true;
|
||||
}
|
||||
if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
|
||||
} else {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
|
||||
QDateTime const &startTime,
|
||||
QDateTime const &endTime,
|
||||
int paymentOptionIndex) {
|
||||
if (startTime.date() < endTime.date()) { // start end end on different days
|
||||
if (previousDayHoliday(cfg, endTime)) {
|
||||
if (endTime.time() > cs.m_parking_time_limit) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< QString("ERROR time limit for end-time violated: [%1, %2, end-time=%3], but time-limit=%4")
|
||||
.arg(weekDayName)
|
||||
.arg(endTime.date().toString(Qt::ISODate))
|
||||
.arg(endTime.time().toString(Qt::ISODate))
|
||||
.arg(cs.m_parking_time_limit.toString(Qt::ISODate));
|
||||
return true;
|
||||
}
|
||||
if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
|
||||
} else {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -251,21 +257,24 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
}
|
||||
|
||||
parkTimeLimitChecker = [&cfg, weekDay](ATBTariffCarryOverSettings const& cs,
|
||||
QDateTime const &endTime,
|
||||
int paymentOptionIndex) {
|
||||
if (endTime.date().dayOfWeek() == (int)weekDay) {
|
||||
if (endTime.time() > cs.m_parking_time_limit) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< QString("ERROR time limit for end-time violated: end-time=%1, but time-limit=%2")
|
||||
.arg(endTime.time().toString(Qt::ISODate))
|
||||
.arg(cs.m_parking_time_limit.toString(Qt::ISODate));
|
||||
return true;
|
||||
}
|
||||
if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
|
||||
} else {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
|
||||
QDateTime const &startTime,
|
||||
QDateTime const &endTime,
|
||||
int paymentOptionIndex) {
|
||||
if (startTime.date() < endTime.date()) { // start end end on different days
|
||||
if (endTime.date().dayOfWeek() == (int)weekDay) {
|
||||
if (endTime.time() > cs.m_parking_time_limit) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< QString("ERROR time limit for end-time violated: end-time=%1, but time-limit=%2")
|
||||
.arg(endTime.time().toString(Qt::ISODate))
|
||||
.arg(cs.m_parking_time_limit.toString(Qt::ISODate));
|
||||
return true;
|
||||
}
|
||||
if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
|
||||
} else {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -280,21 +289,24 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
}
|
||||
}
|
||||
parkTimeLimitChecker = [&cfg](ATBTariffCarryOverSettings const& cs,
|
||||
QDateTime const &endTime,
|
||||
int paymentOptionIndex) {
|
||||
if (previousDayHoliday(cfg, endTime)) {
|
||||
if (endTime.time() > cs.m_parking_time_limit) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< QString("ERROR time limit for end-time violated: end-time=%1, but time-limit=%2")
|
||||
.arg(endTime.time().toString(Qt::ISODate))
|
||||
.arg(cs.m_parking_time_limit.toString(Qt::ISODate));
|
||||
return true;
|
||||
}
|
||||
if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
|
||||
} else {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
|
||||
QDateTime const &startTime,
|
||||
QDateTime const &endTime,
|
||||
int paymentOptionIndex) {
|
||||
if (startTime.date() < endTime.date()) { // start end end on different days
|
||||
if (previousDayHoliday(cfg, endTime)) {
|
||||
if (endTime.time() > cs.m_parking_time_limit) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< QString("ERROR time limit for end-time violated: end-time=%1, but time-limit=%2")
|
||||
.arg(endTime.time().toString(Qt::ISODate))
|
||||
.arg(cs.m_parking_time_limit.toString(Qt::ISODate));
|
||||
return true;
|
||||
}
|
||||
if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
|
||||
} else {
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
|
||||
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -1523,7 +1535,6 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
|
||||
|
||||
int getPaymentOptionIndex(Configuration const &cfg) {
|
||||
|
||||
|
||||
int const numOptions = cfg.getAllPaymentOptions().size();
|
||||
|
||||
for (int opt=0; opt < numOptions; ++opt) {
|
||||
|
Loading…
Reference in New Issue
Block a user