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