GetTimeSteps(): use new parameter paymentOptionIndex
This commit is contained in:
parent
4e7fa83507
commit
7e3347b043
@ -1569,24 +1569,26 @@ QList<int> Calculator::GetPriceSteps(Configuration * /*cfg*/) const {
|
|||||||
return QList<int>();
|
return QList<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
QList<int> Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const {
|
||||||
if (m_timeSteps.size() > 0) {
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "paymentOptionIndex:" << paymentOptionIndex;
|
||||||
|
|
||||||
|
if (m_timeSteps.size() > paymentOptionIndex) {
|
||||||
//qCritical() << __PRETTY_FUNCTION__ << "timeSteps:" << m_timeSteps;
|
//qCritical() << __PRETTY_FUNCTION__ << "timeSteps:" << m_timeSteps;
|
||||||
return m_timeSteps;
|
return m_timeSteps[paymentOptionIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime start = QDateTime::currentDateTime();
|
QDateTime start = QDateTime::currentDateTime();
|
||||||
start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
|
start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
|
||||||
|
|
||||||
int const pop_id = cfg->getPaymentOptions().pop_id;
|
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||||
int const pop_carry_over = cfg->getPaymentOptions().pop_carry_over;
|
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||||
int const pop_time_step_config = cfg->getPaymentOptions().pop_time_step_config;
|
int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
|
||||||
|
|
||||||
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << " start parking time:" << start.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
|
||||||
qCritical() << __func__ << ":" << __LINE__ << " payment option id:" << pop_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "payment option carry over:" << pop_carry_over;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over;
|
||||||
|
|
||||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
|
||||||
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
//qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC";
|
||||||
@ -1595,13 +1597,13 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
|||||||
std::size_t const s = cfg->TimeRange.size();
|
std::size_t const s = cfg->TimeRange.size();
|
||||||
for (std::size_t id = 1; id <= s; ++id) {
|
for (std::size_t id = 1; id <= s; ++id) {
|
||||||
int const step = Utilities::getTimeRangeStep(cfg, id, paymentMethodId);
|
int const step = Utilities::getTimeRangeStep(cfg, id, paymentMethodId);
|
||||||
m_timeSteps.append(step);
|
m_timeSteps[paymentOptionIndex].append(step);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint16_t timeStepCompensation = 0;
|
uint16_t timeStepCompensation = 0;
|
||||||
|
|
||||||
if (pop_carry_over) {
|
if (pop_carry_over) {
|
||||||
int const pop_carry_over_time_range_id = cfg->getPaymentOptions().pop_carry_over_time_range_id;
|
int const pop_carry_over_time_range_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_time_range_id;
|
||||||
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
QTime const carryOverTimeRangeFrom = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_from;
|
||||||
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
QTime const carryOverTimeRangeTo = cfg->TimeRange.find(pop_carry_over_time_range_id)->second.time_range_to;
|
||||||
|
|
||||||
@ -1625,19 +1627,19 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
|||||||
.arg(timeStep).arg(duration.pun_duration_max);
|
.arg(timeStep).arg(duration.pun_duration_max);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
qCritical() << __PRETTY_FUNCTION__ << "configured minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") configured minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
|
||||||
// set dynamic minimal parking time
|
// set dynamic minimal parking time
|
||||||
cfg->getPaymentOptions().pop_min_time = timeStep;
|
cfg->getPaymentOptions().pop_min_time = timeStep;
|
||||||
|
|
||||||
qCritical() << __PRETTY_FUNCTION__ << " computed minimal parking time:" << cfg->getPaymentOptions().pop_min_time;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
|
||||||
duration.pun_duration = timeStep;
|
duration.pun_duration = timeStep;
|
||||||
timeStepCompensation = duration.pun_duration_max - duration.pun_duration;
|
timeStepCompensation = duration.pun_duration_max - duration.pun_duration;
|
||||||
m_timeSteps << duration.pun_duration;
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
} else {
|
} else {
|
||||||
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
duration.pun_duration = duration.pun_duration_max - timeStepCompensation;
|
||||||
m_timeSteps << duration.pun_duration;;
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg->Duration.erase(search);
|
cfg->Duration.erase(search);
|
||||||
@ -1658,19 +1660,26 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::STATIC";
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
int const durationId = itr->second.pra_payment_unit_id;
|
int const durationId = itr->second.pra_payment_unit_id;
|
||||||
int const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
int const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||||
m_timeSteps << durationUnit;
|
int size = m_timeSteps.size();
|
||||||
|
|
||||||
|
while (size <= paymentOptionIndex) {
|
||||||
|
m_timeSteps.push_back(QList<int>());
|
||||||
|
size = m_timeSteps.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_timeSteps[paymentOptionIndex] << durationUnit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << __PRETTY_FUNCTION__ << "NEW timeSteps:" << m_timeSteps;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "NEW timeSteps:" << m_timeSteps;
|
||||||
|
|
||||||
return m_timeSteps;
|
return m_timeSteps[paymentOptionIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep) const {
|
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user