Use of permitType in several places
This commit is contained in:
parent
b0ecef0361
commit
8344b04b15
@ -9,6 +9,7 @@
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <QDateTime>
|
||||
#include <QScopedArrayPointer>
|
||||
#include <QDebug>
|
||||
@ -121,6 +122,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
uint8_t payment_option,
|
||||
char const *startDatetimePassed, // given in local time
|
||||
double cost,
|
||||
PermitType permitType,
|
||||
bool nextDay,
|
||||
bool prepaid)
|
||||
{
|
||||
@ -153,7 +155,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
}
|
||||
|
||||
// TODO: man braucht den richtigen Index
|
||||
int paymentOptionIndex = 0;
|
||||
int paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
||||
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
@ -271,7 +273,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
|
||||
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||
// int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||
int price = 0;
|
||||
int durationInSecs = 0;
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
@ -1239,23 +1241,25 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
QDateTime &start_datetime,
|
||||
QDateTime &end_datetime,
|
||||
int durationMinutes,
|
||||
PermitType permitType,
|
||||
bool nextDay,
|
||||
bool prepaid) {
|
||||
Q_UNUSED(payment_option);
|
||||
Q_UNUSED(nextDay);
|
||||
|
||||
int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
if (paymentMethodId == PaymentMethod::Steps) {
|
||||
if (tariffIs24_7(cfg)) {
|
||||
end_datetime = start_datetime.addSecs(durationMinutes*60);
|
||||
return GetCostFromDuration(cfg, start_datetime, end_datetime);
|
||||
return GetCostFromDuration(cfg, start_datetime, end_datetime, paymentOptionIndex);
|
||||
} else {
|
||||
if (Utilities::IsYearPeriodActive(cfg, start_datetime)) {
|
||||
if (!prepaid) {
|
||||
CalcState cs = isParkingAllowed(cfg, start_datetime);
|
||||
if (cs) {
|
||||
end_datetime = start_datetime.addSecs(durationMinutes*60);
|
||||
double cost = GetCostFromDuration(cfg, start_datetime, end_datetime);
|
||||
double cost = GetCostFromDuration(cfg, start_datetime, end_datetime, paymentOptionIndex);
|
||||
end_datetime = start_datetime;
|
||||
end_datetime.setTime(cs.getAllowedTimeRange().getTimeUntil());
|
||||
return cost;
|
||||
@ -2130,9 +2134,6 @@ QList<int> Calculator::GetPriceSteps(Configuration * /*cfg*/) const {
|
||||
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
QDateTime const &s) const {
|
||||
|
||||
// TEST
|
||||
// paymentOptionIndex = 1;
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||
}
|
||||
@ -2147,14 +2148,20 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
|
||||
} else {
|
||||
// int diff = paymentOp m_timeSteps.size()
|
||||
while (m_timeSteps.size() <= paymentOptionIndex) {
|
||||
m_timeSteps.push_back(QList<int>());
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime start = s;
|
||||
start.setTime(QTime(s.time().hour(), s.time().minute(), 0));
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id:" << pop_id;
|
||||
}
|
||||
|
||||
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||
int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
|
||||
int const pop_prepaid_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
@ -2289,6 +2296,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
QDateTime nextTimeStep = start;
|
||||
int runtimeInMinutes = 0;
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||
|
||||
int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
|
||||
|
||||
// TODO: auslagern
|
||||
@ -2305,6 +2314,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
|
||||
// int const price = itr->second.pra_price;
|
||||
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
@ -2321,11 +2332,14 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
break;
|
||||
}
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||
|
||||
std::optional<ATBInterpolation> ipolCheck = cfg->getInterpolationType(duration.pun_interpolation_id);
|
||||
if (ipolCheck) {
|
||||
ATBInterpolation interpolation = ipolCheck.value();
|
||||
|
||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_PRICE) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") HIER NICHT";
|
||||
|
||||
interpolation.dynamic_start = start.time();
|
||||
interpolation.dynamic_start.setHMS(start.time().hour(), start.time().minute(), 0);
|
||||
@ -2342,6 +2356,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
runtimeInMinutes += duration.pun_duration;
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||
|
||||
if (nextTimeStep.time() > carryOverStart) {
|
||||
int const backTime = carryOverStart.secsTo(nextTimeStep.time()) / 60;
|
||||
runtimeInMinutes -= backTime;
|
||||
@ -2376,15 +2392,23 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
search->second = duration;
|
||||
} else
|
||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
||||
#if 0
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||
|
||||
if (paymentOptionIndex == 1) { // testing TODO: muss in die payment options hinein
|
||||
if (runtimeInMinutes == 0) {
|
||||
if (start.time() < carryOverStart) {
|
||||
runtimeInMinutes = start.time().secsTo(carryOverStart) / 60;
|
||||
duration.pun_duration = runtimeInMinutes;
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
search->second = duration;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime s = start.addSecs(runtimeInMinutes * 60);
|
||||
int const minutes = s.time().secsTo(carryOverStart) / 60;
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes:" << minutes;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") s:" << s.toString(Qt::ISODate);
|
||||
#if 0
|
||||
if (minutes > 0) {
|
||||
runtimeInMinutes += minutes;
|
||||
previous.pun_duration += minutes;
|
||||
@ -2397,17 +2421,12 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
}
|
||||
#endif
|
||||
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (0):" << runtimeInMinutes;
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
runtimeInMinutes += duration.pun_duration;
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start:" << carryOverStart.toString(Qt::ISODate);
|
||||
|
||||
// TOOO: truncate-flag == false
|
||||
if (nextTimeStep.time() > carryOverStart) {
|
||||
int const backTime = carryOverStart.secsTo(nextTimeStep.time());
|
||||
@ -2423,16 +2442,13 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
|
||||
}
|
||||
|
||||
duration.pun_duration = runtimeInMinutes;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
search->second = duration;
|
||||
} else {
|
||||
@ -2492,12 +2508,16 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
|
||||
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const {
|
||||
|
||||
// test
|
||||
// paymentOptionIndex = 1;
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||
|
||||
uint32_t price = 0;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||
{
|
||||
@ -2513,9 +2533,10 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
||||
price = (uint32_t)(itr->second.pra_price);
|
||||
}
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << cfg->Duration.find(payment_unit_id)->second.pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
|
||||
|
||||
if (timeStep == pun_duration) {
|
||||
return price;
|
||||
@ -2657,14 +2678,53 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
|
||||
}
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::DAY_TICKET: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_PKW: {
|
||||
PermitType const permitType(PERMIT_TYPE::DAY_TICKET_PKW);
|
||||
std::optional<ATBPaymentOption> paymentOption = cfg->getPaymentOptionForKey(permitType.get());
|
||||
if (paymentOption) {
|
||||
ATBPaymentOption option = paymentOption.value();
|
||||
int pop_id = option.pop_id;
|
||||
int pop_daily_card_price = option.pop_daily_card_price;
|
||||
qCritical() << "( GetDailyTicketPrice():" << __LINE__ << ")";
|
||||
qCritical() << " PERMIT-TYPE:" << permitType.toString();
|
||||
qCritical() << " option id:" << pop_id;
|
||||
qCritical() << "daily_ticket_card_price:" << pop_daily_card_price;
|
||||
|
||||
price.netto = pop_daily_card_price;
|
||||
value = value.value_or(price);
|
||||
}
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::SZEGED_START:
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::SZEGED_STOP:
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::INVALID:
|
||||
break;
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_BUS: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_CAMPER: {
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
|
||||
PermitType const permitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
std::optional<ATBPaymentOption> paymentOption = cfg->getPaymentOptionForKey(permitType.get());
|
||||
if (paymentOption) {
|
||||
ATBPaymentOption option = paymentOption.value();
|
||||
int pop_id = option.pop_id;
|
||||
int pop_daily_card_price = option.pop_daily_card_price;
|
||||
qCritical() << "( GetDailyTicketPrice():" << __LINE__ << ")";
|
||||
qCritical() << " PERMIT-TYPE:" << permitType.toString();
|
||||
qCritical() << " option id:" << pop_id;
|
||||
qCritical() << "daily_ticket_card_price:" << pop_daily_card_price;
|
||||
|
||||
price.netto = pop_daily_card_price;
|
||||
value = value.value_or(price);
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER: {
|
||||
} break;
|
||||
case PERMIT_TYPE::SZEGED_START: {
|
||||
} break;
|
||||
case PERMIT_TYPE::SZEGED_STOP: {
|
||||
} break;
|
||||
case PERMIT_TYPE::INVALID: {
|
||||
} break;
|
||||
}
|
||||
} else {
|
||||
// for projects which have not defined a daily ticket in their
|
||||
|
Loading…
Reference in New Issue
Block a user