GetTimeSteps() for payment-method degressive. introduced for Valser Alm (location: Fane).

This commit is contained in:
Gerhard Hoffmann 2024-07-30 15:39:55 +02:00
parent cdeb625a15
commit e4cb992aae

View File

@ -2335,7 +2335,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
if (w.has_value()) {
QVector<ATBWeekDaysWorktime> const &vec = w.value();
if (pop_carry_over == false) {
//if (pop_carry_over == false) {
for (int i = 1; i <= vec.size(); ++i) {
QTime const &from = QTime::fromString(QString::fromStdString(vec[i-1].pwd_time_from), Qt::ISODate);
QString const &toStr = QString::fromStdString(vec[i-1].pwd_time_to);
@ -2343,20 +2343,24 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
int weekDayId = vec[i-1].pwd_period_day_in_week_id;
if (start.date().dayOfWeek() == weekDayId) {
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << weekDayId;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") to" << to.toString(Qt::ISODate);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate);
}
if (start.time() >= from && start.time() < to) {
int runtimeInMinutes = (start.time().secsTo(to) / 60);
if (to.hour() == 23 && to.minute() == 59) {
runtimeInMinutes += 1;
}
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") index" << paymentOptionIndex;
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
}
// m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
@ -2364,7 +2368,9 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
// int pwd_id = vec[i-1].pwd_id;
// int pwd_next_id = vec[i-1].pwd_next_id;
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
}
int price = -1;
int durationId = -1;
@ -2384,13 +2390,17 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
}
if (price >= 0 && durationId >= 0) {
if (DBG_LEVEL >= DBG_DEBUG) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
}
pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
if (durationId == itr->second.pra_payment_unit_id) {
itr->second.pra_price = price;
cfg->getPaymentOptions(paymentOptionIndex).pop_min_price = price;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") park min price" << price;
break;
}
}
@ -2401,15 +2411,16 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
} // if (start.date().dayOfWeek() == weekDayId) {
} // for (int i = 1; i <= vec.size(); ++i) {
// show content:
m_timeSteps[paymentOptionIndex].clear();
int runtimeInMinutes = 0;
for (Configuration::TariffDurationType::const_iterator it = cfg->Duration.cbegin();
it != cfg->Duration.cend();
++it) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
<< (*it).first << " => " << (*it).second;
runtimeInMinutes += it->second.pun_duration;
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
}
} // if (pop_carry_over == false) {
//} // if (pop_carry_over == false) {
} // if (w.has_value()) {
} else {
uint16_t timeStepCompensation = 0;