From b7facb9d603eee48e00ef0580adf65ebaea9bd01 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 26 Jul 2024 10:59:45 +0200 Subject: [PATCH] checkin for tariff02.json --- library/include/mobilisis/configuration.h | 2 + library/include/mobilisis/payment_opt.h | 4 + library/include/mobilisis/weekdays_worktime.h | 6 +- library/src/calculate_price.cpp | 45 ++++- library/src/calculator_functions.cpp | 185 +++++++++++++++++- library/src/configuration.cpp | 44 ++++- 6 files changed, 267 insertions(+), 19 deletions(-) diff --git a/library/include/mobilisis/configuration.h b/library/include/mobilisis/configuration.h index e33e79d..b0ecc81 100644 --- a/library/include/mobilisis/configuration.h +++ b/library/include/mobilisis/configuration.h @@ -93,6 +93,7 @@ public: bool isDayIncludedAsSpecialDay(uint64_t businessHours, int specialDayId) const; std::optional> getPaymentRateForAllKeys() const; std::optional> getPaymentOptionsForAllKeys() const; + std::optional getPaymentOptionForId(int key) const; std::optional> getPaymentRateForKey(int key) const; std::optional getPaymentOptionForKey(PERMIT_TYPE permitType) const; std::optional getPaymentOptionForKey(int permitType) const; @@ -108,6 +109,7 @@ public: std::optional> getTariffProductForProductTypeName(QString const &permitTypeName) const; std::optional getCustomerForType(ATBCustomer::CustomerType customerType); std::optional getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek); + std::optional> getAllWeekDayWorkTimes(); std::optional prepaidStart(QDateTime const &start, int prepaid_option_id); int getPaymentOptionIndex(PERMIT_TYPE permitType); diff --git a/library/include/mobilisis/payment_opt.h b/library/include/mobilisis/payment_opt.h index 190c786..6bb51c0 100644 --- a/library/include/mobilisis/payment_opt.h +++ b/library/include/mobilisis/payment_opt.h @@ -38,6 +38,8 @@ public: pop_daily_card_price = -1; pop_business_hours = -1; pop_time_step_config = -1; + pop_use_only_upto_datetime = ""; + pop_use_only_for_duration = 0; } int pop_id; @@ -45,6 +47,8 @@ public: int pop_product_id; QString pop_product_name; int pop_payment_method_id; + QString pop_use_only_upto_datetime; + int pop_use_only_for_duration; std::string pop_day_end_time; std::string pop_day_night_end_time; double pop_price_night; diff --git a/library/include/mobilisis/weekdays_worktime.h b/library/include/mobilisis/weekdays_worktime.h index ceaf61c..3a21797 100644 --- a/library/include/mobilisis/weekdays_worktime.h +++ b/library/include/mobilisis/weekdays_worktime.h @@ -4,8 +4,10 @@ class ATBWeekDaysWorktime { public: - int pwd_id; - int pwd_period_week_day_id; + int pwd_id; + int pwd_pop_id; + int pwd_next_id; + int pwd_period_week_day_id; int pwd_period_day_in_week_id; std::string pwd_time_from; std::string pwd_time_to; diff --git a/library/src/calculate_price.cpp b/library/src/calculate_price.cpp index a813dc2..d1c9dc6 100644 --- a/library/src/calculate_price.cpp +++ b/library/src/calculate_price.cpp @@ -36,9 +36,14 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg, paymentOptionIndex = cfg->getPaymentOptionIndex(permitType); + qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex; + qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString(); + switch(permitType) { case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) + qCritical() << __LINE__ << Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex); minTime = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time; + qCritical() << __func__ << __LINE__ << minTime; } break; case PERMIT_TYPE::DAY_TICKET_ADULT: { } break; @@ -50,10 +55,11 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg, // for each new sell-procedure, recomute the timesteps. implicitly, set // the minimal parking time. Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex); - Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex); + qCritical() << __LINE__ << Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex); minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time); } + qCritical() << "minTime" << minTime; return minTime; } @@ -384,11 +390,13 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char cons if (! (*tariff)->ParseJson(*tariff, json.toStdString().c_str())) { delete *tariff; *tariff = nullptr; + qCritical() << " ... error parsing tariff"; return calcState.set(CalcState::State::ERROR_PARSING_TARIFF); } } else { delete *tariff; *tariff = nullptr; + qCritical() << " ... error loading tariff"; return calcState.set(CalcState::State::ERROR_LOADING_TARIFF); } @@ -427,19 +435,19 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg); switch (paymentMethodId) { case PaymentMethod::Progressive: - qCritical() << " compute_next_timestep() paymentMethodId: Progressive"; + qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Progressive"; break; case PaymentMethod::Degressive: - qCritical() << " compute_next_timestep() paymentMethodId: Degressive"; + qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Degressive"; break; case PaymentMethod::Linear: - qCritical() << " compute_next_timestep() paymentMethodId: Linear"; + qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Linear"; break; case PaymentMethod::Steps: - qCritical() << " compute_next_timestep() paymentMethodId: Steps"; + qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Steps"; break; case PaymentMethod::Undefined: - qCritical() << " compute_next_timestep() paymentMethodId: Undefined"; + qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Undefined"; break; } @@ -607,7 +615,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( int netto_parking_time, QDateTime &end_parking_time, struct price_t *price, - PermitType /* permitType */, + PermitType permitType, bool prepaid) { CalcState calcState; @@ -647,15 +655,30 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( double cost = -1; if (start_parking_time.isValid()) { - if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps) { + + // qCritical() << __func__ << __LINE__; + + if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps || + tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Degressive) { + // qCritical() << __func__ << __LINE__; // hier muesste man unterscheiden: uebertrag oder nicht? calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time, netto_parking_time, paymentOptionIndex); if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) { - // qCritical() << "(" << __func__ << ":" << __LINE__ << ")" - // << calcState.toString(); + qCritical() << "(" << __func__ << ":" << __LINE__ << ")" + << calcState.toString(); + // qCritical() << __func__ << __LINE__; return calcState; } + // qCritical() << __func__ << __LINE__; + + QList lll = Calculator::GetInstance().GetTimeSteps(tariff); + + // netto_parking_time = compute_next_timestep(tariff, netto_parking_time, 1, permitType); + + qCritical() << "LINE" << __LINE__ << "netto" << netto_parking_time << lll; + + // qCritical() << __func__ << __LINE__; cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex); end_parking_time = start_parking_time.addSecs(netto_parking_time*60); @@ -663,6 +686,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( // << "end_parking_time" << end_parking_time.toString(Qt::ISODate); } else { + // qCritical() << __func__ << __LINE__; cost = Calculator::GetInstance().GetCostFromDuration( tariff, tariff->getPaymentOptions().pop_payment_method_id, @@ -671,6 +695,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( netto_parking_time, // minutes, netto false, prepaid); } + // qCritical() << __func__ << __LINE__; double minCost = tariff->getPaymentOptions(paymentOptionIndex).pop_min_price; if (cost < minCost) { calcState.setDesc(QString("line=%1 minCost=%2, cost=%3").arg(__LINE__).arg(minCost).arg(cost)); diff --git a/library/src/calculator_functions.cpp b/library/src/calculator_functions.cpp index f6d570b..af11708 100644 --- a/library/src/calculator_functions.cpp +++ b/library/src/calculator_functions.cpp @@ -843,8 +843,11 @@ uint32_t Calculator::GetCostFromDuration(Configuration *cfg, int paymentOptionIndex) const { // for instance, a tariff as used in Schoenau, Koenigssee: only steps, no // special days, nonstop. + qCritical() << __func__ << __LINE__; + static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg); - if (paymentMethodId == PaymentMethod::Steps) { + if (paymentMethodId == PaymentMethod::Steps || + paymentMethodId == PaymentMethod::Degressive) { QDateTime const end = start.addSecs(timeStepInMinutes*60); return GetCostFromDuration(cfg, start, end, paymentOptionIndex); } @@ -856,8 +859,15 @@ uint32_t Calculator::GetCostFromDuration(Configuration * cfg, QDateTime const &end, int paymentOptionIndex) const { static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg); - if (paymentMethodId == PaymentMethod::Steps) { + + qCritical() << __func__ << __LINE__; + + if (paymentMethodId == PaymentMethod::Steps || + paymentMethodId == PaymentMethod::Degressive) { int const timeStepInMinutes = start.secsTo(end) / 60; + + qCritical() << DBG_HEADER << "timeStepInMinutes" << timeStepInMinutes << start.toString(Qt::ISODate); + return GetPriceForTimeStep(cfg, timeStepInMinutes, paymentOptionIndex); } return 0; @@ -2186,6 +2196,135 @@ QList &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex, int const step = Utilities::getTimeRangeStep(cfg, id, paymentMethodId); m_timeSteps[paymentOptionIndex].append(step); } + } else + if (paymentMethodId == PaymentMethod::Degressive) { // e.g. fuchs, valser alm (fane) (502) + // with growing time, the price goes down + // for instance: until 13.59: price 8, from 14:00: price 5, then for the next day: 8 + // for the following days: 8 euros + + qCritical() << "(" << __func__ << ":" << __LINE__ << ") degressive"; + m_timeSteps[paymentOptionIndex].clear(); + + // lookup pop_next_id in worktimes; + std::optional> const &w = cfg->getAllWeekDayWorkTimes(); + if (w.has_value()) { + QVector const &vec = w.value(); + + if (pop_carry_over) { + for (int i = 0; i < vec.size(); ++i) { + QTime const &from = QTime::fromString(QString::fromStdString(vec[i].pwd_time_from), Qt::ISODate); + QString const &toStr = QString::fromStdString(vec[i].pwd_time_to); + QTime const &to = QTime::fromString(toStr, Qt::ISODate); + + int weekDayId = vec[i].pwd_period_day_in_week_id; + if (start.date().dayOfWeek() == weekDayId) { + //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) { + qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate); + if (start.time() < to) { + qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate); + + int runtimeInMinutes = (start.time().secsTo(to) / 60); + qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes" << runtimeInMinutes; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") index" << paymentOptionIndex; + + m_timeSteps[paymentOptionIndex] << runtimeInMinutes; + + cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes; + + int pop_id = vec[i].pwd_pop_id; + int pwd_id = vec[i].pwd_id; + int pop_next_id = vec[i].pwd_next_id; + + 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); + if (search != cfg->Duration.end()) { + ATBDuration duration = search->second; + duration.pun_duration = runtimeInMinutes; + search->second = duration; + } + } + + if (weekDayId == vec[pop_next_id].pwd_period_day_in_week_id) { + // on the same day + start.setTime(to); + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate); + } else { + // on the next day + start.setTime(QTime::fromString(QString::fromStdString(vec[pop_next_id].pwd_time_from), Qt::ISODate)); + start = start.addDays(1); + + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate); + } + + + while ((s.secsTo(start) / 60) < 5000) { + qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate); + + pop_id = vec[i].pwd_pop_id; + pwd_id = vec[i].pwd_id; + pop_next_id = vec[i].pwd_next_id; + + runtimeInMinutes += (start.time().secsTo(to) / 60); + + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pwd_id " << pwd_id; + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id " << pop_id; + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_next_id " << pop_next_id; + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep" << nextTimeStep; + + // ATBPaymentOption o = cfg->getPaymentOptionForId(); + + m_timeSteps[paymentOptionIndex] << runtimeInMinutes; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX pop" << pop_id; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX index" << paymentOptionIndex; + +#if 0 + 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__ << ") XXXXXX durationId" << durationId; + // int const price = itr->second.pra_price; + + auto search = cfg->Duration.find(durationId); + if (search != cfg->Duration.end()) { + ATBDuration duration = search->second; + duration.pun_duration = runtimeInMinutes; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX durationId" << runtimeInMinutes; + search->second = duration; + } + } +#endif + + if (weekDayId == vec[pop_next_id].pwd_period_day_in_week_id) { + // on the same day + start.setTime(to); + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate); + } else { + // on the next day + start.setTime(QTime::fromString(QString::fromStdString(vec[pop_next_id].pwd_time_from), Qt::ISODate)); + start = start.addDays(1); + + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate); + } + //qCritical() << "(" << __func__ << ":" << __LINE__ << ") until" << s.secsTo(start) / 60; + } + break; + } + } + } + } + } + } + } else { uint16_t timeStepCompensation = 0; @@ -2312,10 +2451,12 @@ QList &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex, } } + qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes; + 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; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId; // int const price = itr->second.pra_price; auto search = cfg->Duration.find(durationId); @@ -2332,7 +2473,7 @@ QList &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex, break; } - //qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes; std::optional ipolCheck = cfg->getInterpolationType(duration.pun_interpolation_id); if (ipolCheck) { @@ -2393,6 +2534,11 @@ QList &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex, } else if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) { + 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; + if (paymentOptionIndex == 1) { // testing TODO: muss in die payment options hinein if (runtimeInMinutes == 0) { if (start.time() < carryOverStart) { @@ -2405,6 +2551,21 @@ QList &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex, } } + if (runtimeInMinutes == 0) { + if (start.time() < carryOverStart) { + runtimeInMinutes = start.time().secsTo(carryOverStart) / 60; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id; + duration.pun_duration = runtimeInMinutes; + m_timeSteps[paymentOptionIndex] << duration.pun_duration; + search->second = duration; + cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes; + } + continue; + } + qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes; + + QDateTime s = start.addSecs(runtimeInMinutes * 60); int const minutes = s.time().secsTo(carryOverStart) / 60; @@ -2441,17 +2602,18 @@ QList &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex, nextTimeStep.setTime(carryOverStart); } - if (DBG_LEVEL >= DBG_DEBUG) { + //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; m_timeSteps[paymentOptionIndex] << duration.pun_duration; search->second = duration; } else { + qCritical() << "(" << __func__ << ":" << __LINE__ << ") HIER NICHT"; cfg->Duration.erase(search); } } @@ -2526,7 +2688,16 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p Q_ASSERT(pun_id == payment_unit_id); + qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id; + + + qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(1)->second.pun_duration; + qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(2)->second.pun_duration; + qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg->Duration.find(3)->second.pun_duration; + int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration; + //int const pun_duration = cfg->Duration.find(2)->second.pun_duration; if (pop_accumulate_prices) { price += itr->second.pra_price; } else { @@ -2537,8 +2708,10 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id; qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id; qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep; if (timeStep == pun_duration) { + qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price; return price; } } diff --git a/library/src/configuration.cpp b/library/src/configuration.cpp index bcd3ca1..7812566 100644 --- a/library/src/configuration.cpp +++ b/library/src/configuration.cpp @@ -589,6 +589,15 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json) QString const &s = QString::fromStdString(k->value.GetString()); this->currentPaymentOptions.last().pop_product_name = s; } + } else if (strcmp(inner_obj_name, "pop_use_only_upto_datetime") == 0) { + if (k->value.IsString()) { + QString const &s = QString::fromStdString(k->value.GetString()); + this->currentPaymentOptions.last().pop_use_only_upto_datetime = s; + } + } else if (strcmp(inner_obj_name, "pop_use_only_for_duration") == 0) { + if (k->value.IsInt()) { + this->currentPaymentOptions.last().pop_use_only_for_duration = k->value.GetInt(); + } } else if (strcmp(inner_obj_name, "pop_payment_method_id") == 0) { this->currentPaymentOptions.last().pop_payment_method_id = k->value.GetInt(); } else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) { @@ -719,6 +728,8 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json) break;*/ case MemberType::WeekDaysWorkTimeType: if (strcmp(inner_obj_name, "pwd_id") == 0) WeekDaysWorktime.pwd_id = k->value.GetInt(); + if (strcmp(inner_obj_name, "pwd_pop_id") == 0) WeekDaysWorktime.pwd_pop_id = k->value.GetInt(); + if (strcmp(inner_obj_name, "pwd_next_id") == 0) WeekDaysWorktime.pwd_next_id = k->value.GetInt(); else if (strcmp(inner_obj_name, "pwd_period_week_day_id") == 0) WeekDaysWorktime.pwd_period_week_day_id = k->value.GetInt(); else if (strcmp(inner_obj_name, "pwd_period_day_in_week_id") == 0) WeekDaysWorktime.pwd_period_day_in_week_id = k->value.GetInt(); else if (strcmp(inner_obj_name, "pwd_time_from") == 0) WeekDaysWorktime.pwd_time_from = k->value.GetString(); @@ -871,7 +882,7 @@ std::optional Configuration::getInterpolationEnd(QDateTime const &sta ATBInterpolation interpolation = ipolCheck.value(); switch (duration.pun_interpolation_id) { case static_cast(ATBInterpolation::NO_INTERPOLATION): - //qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO"; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") NO_INTERPOLATION"; break; case static_cast(ATBInterpolation::STATIC_WALLCLOCK_TIME_VALUES): //qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO"; @@ -1271,6 +1282,18 @@ Configuration::getDailyTicketsForKey(int key) const { return value; } +std::optional +Configuration::getPaymentOptionForId(int key) const { + ATBPaymentOption option; + std::optional value; + + for (auto[it, rangeEnd] = this->PaymentOption.equal_range(key); it != rangeEnd; ++it) { + value = value.value_or(it->second); + } + + return value; +} + std::optional> Configuration::getPaymentOptionsForAllKeys() const { QVector paymentOptions; @@ -1363,6 +1386,25 @@ Configuration::getCustomerForType(ATBCustomer::CustomerType customerType) { return std::nullopt; } +std::optional> +Configuration::getAllWeekDayWorkTimes() { + QVector worktimes; + std::optional> value; + + worktimes.clear(); + + for (std::multimap::const_iterator it = this->WeekDaysWorktime.cbegin(); + it != this->WeekDaysWorktime.cend(); ++it) { + worktimes.append(it->second); + } + + if (worktimes.size() > 0) { + value = value.value_or(worktimes); + } + + return value; +} + std::optional Configuration::getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek) { ATBWeekDaysWorktime worktime;